1617a3babSopenharmony_ci#version 310 es
2617a3babSopenharmony_ci
3617a3babSopenharmony_ci#ifdef GL_EXT_geometry_shader
4617a3babSopenharmony_ci#extension GL_EXT_geometry_shader : enable
5617a3babSopenharmony_ci#else
6617a3babSopenharmony_ci#error no GL_EXT_geometry_shader 
7617a3babSopenharmony_ci#endif
8617a3babSopenharmony_ci
9617a3babSopenharmony_ci#ifndef GL_OES_geometry_shader
10617a3babSopenharmony_ci#error no GL_OES_geometry_shader
11617a3babSopenharmony_ci#endif
12617a3babSopenharmony_ci
13617a3babSopenharmony_ciprecision mediump float;
14617a3babSopenharmony_ci
15617a3babSopenharmony_ciin fromVertex {
16617a3babSopenharmony_ci    in vec3 color;
17617a3babSopenharmony_ci} fromV[];
18617a3babSopenharmony_ci
19617a3babSopenharmony_ciin vec4 nonBlockUnsized[];
20617a3babSopenharmony_ci
21617a3babSopenharmony_ciout toFragment {
22617a3babSopenharmony_ci    out vec3 color;
23617a3babSopenharmony_ci} toF;
24617a3babSopenharmony_ci
25617a3babSopenharmony_ciout fromVertex {  // okay to reuse a block name for another block name
26617a3babSopenharmony_ci    vec3 color;
27617a3babSopenharmony_ci};
28617a3babSopenharmony_ci
29617a3babSopenharmony_ciout fooB {        // ERROR, cannot reuse block name as block instance
30617a3babSopenharmony_ci    vec2 color;
31617a3babSopenharmony_ci} fromVertex;
32617a3babSopenharmony_ci
33617a3babSopenharmony_ciint fromVertex;   // ERROR, cannot reuse a block name for something else
34617a3babSopenharmony_ci
35617a3babSopenharmony_ciout fooC {        // ERROR, cannot have same name for block and instance name
36617a3babSopenharmony_ci    vec2 color;
37617a3babSopenharmony_ci} fooC;
38617a3babSopenharmony_ci
39617a3babSopenharmony_civoid main()
40617a3babSopenharmony_ci{
41617a3babSopenharmony_ci    EmitVertex();
42617a3babSopenharmony_ci    EndPrimitive();
43617a3babSopenharmony_ci    EmitStreamVertex(1);    // ERROR
44617a3babSopenharmony_ci    EndStreamPrimitive(0);  // ERROR
45617a3babSopenharmony_ci
46617a3babSopenharmony_ci    color = fromV[0].color;
47617a3babSopenharmony_ci    gl_ClipDistance[3] =              // ERROR, no ClipDistance
48617a3babSopenharmony_ci        gl_in[1].gl_ClipDistance[2];  // ERROR, no ClipDistance
49617a3babSopenharmony_ci    gl_Position = gl_in[0].gl_Position;
50617a3babSopenharmony_ci
51617a3babSopenharmony_ci    gl_PrimitiveID = gl_PrimitiveIDIn;
52617a3babSopenharmony_ci    gl_Layer = 2;
53617a3babSopenharmony_ci}
54617a3babSopenharmony_ci
55617a3babSopenharmony_cilayout(stream = 4) out vec4 ov4; // ERROR, no streams
56617a3babSopenharmony_ci
57617a3babSopenharmony_cilayout(line_strip, points, triangle_strip, points, triangle_strip) out;  // just means triangle_strip"
58617a3babSopenharmony_ci
59617a3babSopenharmony_ciout ooutb { vec4 a; } ouuaa6;
60617a3babSopenharmony_ci
61617a3babSopenharmony_cilayout(max_vertices = 200) out;
62617a3babSopenharmony_cilayout(max_vertices = 300) out;   // ERROR, too big
63617a3babSopenharmony_civoid foo(layout(max_vertices = 4) int a)  // ERROR
64617a3babSopenharmony_ci{
65617a3babSopenharmony_ci    ouuaa6.a = vec4(1.0);
66617a3babSopenharmony_ci}
67617a3babSopenharmony_ci
68617a3babSopenharmony_cilayout(line_strip, points, triangle_strip, points) out;  // ERROR, changing output primitive
69617a3babSopenharmony_cilayout(line_strip, points) out; // ERROR, changing output primitive
70617a3babSopenharmony_cilayout(triangle_strip) in; // ERROR, not an input primitive
71617a3babSopenharmony_cilayout(triangle_strip) uniform; // ERROR
72617a3babSopenharmony_cilayout(triangle_strip) out vec4 badv4;  // ERROR, not on a variable
73617a3babSopenharmony_cilayout(triangle_strip) in vec4 bad2v4[];  // ERROR, not on a variable or input
74617a3babSopenharmony_cilayout(invocations = 3) out outbn { int a; }; // 2 ERROR, not on a block, not until 4.0
75617a3babSopenharmony_ciout outbn2 {
76617a3babSopenharmony_ci    layout(invocations = 3)  int a; // 2 ERRORs, not on a block member, not until 4.0
77617a3babSopenharmony_ci    layout(max_vertices = 3) int b; // ERROR, not on a block member
78617a3babSopenharmony_ci    layout(triangle_strip)   int c; // ERROR, not on a block member
79617a3babSopenharmony_ci} outbi;
80617a3babSopenharmony_ci
81617a3babSopenharmony_cilayout(lines) out;  // ERROR, not on output
82617a3babSopenharmony_cilayout(lines_adjacency) in;
83617a3babSopenharmony_cilayout(triangles) in;             // ERROR, can't change it
84617a3babSopenharmony_cilayout(triangles_adjacency) in;   // ERROR, can't change it
85617a3babSopenharmony_cilayout(invocations = 4) in;
86617a3babSopenharmony_ci
87617a3babSopenharmony_ciin sameName {
88617a3babSopenharmony_ci    int a15;
89617a3babSopenharmony_ci} insn[];
90617a3babSopenharmony_ci
91617a3babSopenharmony_ciout sameName {
92617a3babSopenharmony_ci    float f15;
93617a3babSopenharmony_ci};
94617a3babSopenharmony_ci
95617a3babSopenharmony_ciuniform sameName {
96617a3babSopenharmony_ci    bool b15;
97617a3babSopenharmony_ci};
98617a3babSopenharmony_ci
99617a3babSopenharmony_ciconst int summ = gl_MaxVertexAttribs +
100617a3babSopenharmony_ci             gl_MaxGeometryInputComponents +
101617a3babSopenharmony_ci             gl_MaxGeometryOutputComponents +
102617a3babSopenharmony_ci             gl_MaxGeometryImageUniforms +
103617a3babSopenharmony_ci             gl_MaxGeometryTextureImageUnits +
104617a3babSopenharmony_ci             gl_MaxGeometryOutputVertices +
105617a3babSopenharmony_ci             gl_MaxGeometryTotalOutputComponents +
106617a3babSopenharmony_ci             gl_MaxGeometryUniformComponents +
107617a3babSopenharmony_ci             gl_MaxGeometryAtomicCounters +
108617a3babSopenharmony_ci             gl_MaxGeometryAtomicCounterBuffers +
109617a3babSopenharmony_ci             gl_MaxVertexTextureImageUnits +
110617a3babSopenharmony_ci             gl_MaxCombinedTextureImageUnits +
111617a3babSopenharmony_ci             gl_MaxTextureImageUnits +
112617a3babSopenharmony_ci             gl_MaxDrawBuffers;
113617a3babSopenharmony_ci
114617a3babSopenharmony_civoid fooe1()
115617a3babSopenharmony_ci{
116617a3babSopenharmony_ci    gl_ViewportIndex;  // ERROR, not in ES
117617a3babSopenharmony_ci    gl_MaxViewports;   // ERROR, not in ES
118617a3babSopenharmony_ci    insn.length();     // 4: lines_adjacency
119617a3babSopenharmony_ci    int inv = gl_InvocationID;
120617a3babSopenharmony_ci}
121617a3babSopenharmony_ci
122617a3babSopenharmony_ciin vec4 explArray[4];
123617a3babSopenharmony_ciin vec4 explArrayBad[5];  // ERROR, wrong size
124617a3babSopenharmony_ciin vec4 nonArrayed;       // ERROR, not an array
125617a3babSopenharmony_ciflat out vec3 myColor1;
126617a3babSopenharmony_cicentroid out vec3 myColor2;
127617a3babSopenharmony_cicentroid in vec3 centr[];
128617a3babSopenharmony_cisample out vec4 perSampleColor;  // ERROR without sample extensions
129617a3babSopenharmony_ci
130617a3babSopenharmony_cilayout(max_vertices = 200) out;  // matching redecl
131617a3babSopenharmony_ci
132617a3babSopenharmony_cilayout(location = 7, component = 2) in float comp[];  // ERROR, es has no component
133617a3babSopenharmony_ci
134617a3babSopenharmony_civoid notHere()
135617a3babSopenharmony_ci{
136617a3babSopenharmony_ci    gl_MaxGeometryVaryingComponents;  // ERROR, not in ES
137617a3babSopenharmony_ci    gl_VerticesIn;                    // ERROR, not in ES
138617a3babSopenharmony_ci}
139617a3babSopenharmony_ci
140617a3babSopenharmony_civoid pointSize1()
141617a3babSopenharmony_ci{
142617a3babSopenharmony_ci    highp float ps = gl_in[3].gl_PointSize;  // ERROR, need point_size extension
143617a3babSopenharmony_ci    gl_PointSize = ps;                       // ERROR, need point_size extension
144617a3babSopenharmony_ci}
145617a3babSopenharmony_ci
146617a3babSopenharmony_ci#extension GL_OES_geometry_point_size : enable
147617a3babSopenharmony_ci
148617a3babSopenharmony_civoid pointSize2()
149617a3babSopenharmony_ci{
150617a3babSopenharmony_ci    highp float ps = gl_in[3].gl_PointSize;
151617a3babSopenharmony_ci    gl_PointSize = ps;
152617a3babSopenharmony_ci}
153