Merge pull request #2892 from greg-lunarg/mb
[platform/upstream/glslang.git] / Test / 310.geom
1 #version 310 es\r
2 \r
3 #ifdef GL_EXT_geometry_shader\r
4 #extension GL_EXT_geometry_shader : enable\r
5 #else\r
6 #error no GL_EXT_geometry_shader \r
7 #endif\r
8 \r
9 #ifndef GL_OES_geometry_shader\r
10 #error no GL_OES_geometry_shader\r
11 #endif\r
12 \r
13 precision mediump float;\r
14 \r
15 in fromVertex {\r
16     in vec3 color;\r
17 } fromV[];\r
18 \r
19 in vec4 nonBlockUnsized[];\r
20 \r
21 out toFragment {\r
22     out vec3 color;\r
23 } toF;\r
24 \r
25 out fromVertex {  // okay to reuse a block name for another block name\r
26     vec3 color;\r
27 };\r
28 \r
29 out fooB {        // ERROR, cannot reuse block name as block instance\r
30     vec2 color;\r
31 } fromVertex;\r
32 \r
33 int fromVertex;   // ERROR, cannot reuse a block name for something else\r
34 \r
35 out fooC {        // ERROR, cannot have same name for block and instance name\r
36     vec2 color;\r
37 } fooC;\r
38 \r
39 void main()\r
40 {\r
41     EmitVertex();\r
42     EndPrimitive();\r
43     EmitStreamVertex(1);    // ERROR\r
44     EndStreamPrimitive(0);  // ERROR\r
45 \r
46     color = fromV[0].color;\r
47     gl_ClipDistance[3] =              // ERROR, no ClipDistance\r
48         gl_in[1].gl_ClipDistance[2];  // ERROR, no ClipDistance\r
49     gl_Position = gl_in[0].gl_Position;\r
50 \r
51     gl_PrimitiveID = gl_PrimitiveIDIn;\r
52     gl_Layer = 2;\r
53 }\r
54 \r
55 layout(stream = 4) out vec4 ov4; // ERROR, no streams\r
56 \r
57 layout(line_strip, points, triangle_strip, points, triangle_strip) out;  // just means triangle_strip"\r
58 \r
59 out ooutb { vec4 a; } ouuaa6;\r
60 \r
61 layout(max_vertices = 200) out;\r
62 layout(max_vertices = 300) out;   // ERROR, too big\r
63 void foo(layout(max_vertices = 4) int a)  // ERROR\r
64 {\r
65     ouuaa6.a = vec4(1.0);\r
66 }\r
67 \r
68 layout(line_strip, points, triangle_strip, points) out;  // ERROR, changing output primitive\r
69 layout(line_strip, points) out; // ERROR, changing output primitive\r
70 layout(triangle_strip) in; // ERROR, not an input primitive\r
71 layout(triangle_strip) uniform; // ERROR\r
72 layout(triangle_strip) out vec4 badv4;  // ERROR, not on a variable\r
73 layout(triangle_strip) in vec4 bad2v4[];  // ERROR, not on a variable or input\r
74 layout(invocations = 3) out outbn { int a; }; // 2 ERROR, not on a block, not until 4.0\r
75 out outbn2 {\r
76     layout(invocations = 3)  int a; // 2 ERRORs, not on a block member, not until 4.0\r
77     layout(max_vertices = 3) int b; // ERROR, not on a block member\r
78     layout(triangle_strip)   int c; // ERROR, not on a block member\r
79 } outbi;\r
80 \r
81 layout(lines) out;  // ERROR, not on output\r
82 layout(lines_adjacency) in;\r
83 layout(triangles) in;             // ERROR, can't change it\r
84 layout(triangles_adjacency) in;   // ERROR, can't change it\r
85 layout(invocations = 4) in;\r
86 \r
87 in sameName {\r
88     int a15;\r
89 } insn[];\r
90 \r
91 out sameName {\r
92     float f15;\r
93 };\r
94 \r
95 uniform sameName {\r
96     bool b15;\r
97 };\r
98 \r
99 const int summ = gl_MaxVertexAttribs +\r
100              gl_MaxGeometryInputComponents +\r
101              gl_MaxGeometryOutputComponents +\r
102              gl_MaxGeometryImageUniforms +\r
103              gl_MaxGeometryTextureImageUnits +\r
104              gl_MaxGeometryOutputVertices +\r
105              gl_MaxGeometryTotalOutputComponents +\r
106              gl_MaxGeometryUniformComponents +\r
107              gl_MaxGeometryAtomicCounters +\r
108              gl_MaxGeometryAtomicCounterBuffers +\r
109              gl_MaxVertexTextureImageUnits +\r
110              gl_MaxCombinedTextureImageUnits +\r
111              gl_MaxTextureImageUnits +\r
112              gl_MaxDrawBuffers;\r
113 \r
114 void fooe1()\r
115 {\r
116     gl_ViewportIndex;  // ERROR, not in ES\r
117     gl_MaxViewports;   // ERROR, not in ES\r
118     insn.length();     // 4: lines_adjacency\r
119     int inv = gl_InvocationID;\r
120 }\r
121 \r
122 in vec4 explArray[4];\r
123 in vec4 explArrayBad[5];  // ERROR, wrong size\r
124 in vec4 nonArrayed;       // ERROR, not an array\r
125 flat out vec3 myColor1;\r
126 centroid out vec3 myColor2;\r
127 centroid in vec3 centr[];\r
128 sample out vec4 perSampleColor;  // ERROR without sample extensions\r
129 \r
130 layout(max_vertices = 200) out;  // matching redecl\r
131 \r
132 layout(location = 7, component = 2) in float comp[];  // ERROR, es has no component\r
133 \r
134 void notHere()\r
135 {\r
136     gl_MaxGeometryVaryingComponents;  // ERROR, not in ES\r
137     gl_VerticesIn;                    // ERROR, not in ES\r
138 }\r
139 \r
140 void pointSize1()\r
141 {\r
142     highp float ps = gl_in[3].gl_PointSize;  // ERROR, need point_size extension\r
143     gl_PointSize = ps;                       // ERROR, need point_size extension\r
144 }\r
145 \r
146 #extension GL_OES_geometry_point_size : enable\r
147 \r
148 void pointSize2()\r
149 {\r
150     highp float ps = gl_in[3].gl_PointSize;\r
151     gl_PointSize = ps;\r
152 }\r