Merge pull request #2892 from greg-lunarg/mb
[platform/upstream/glslang.git] / Test / 310.comp
1 #version 310 es\r
2 \r
3 layout(local_size_x = 2) in;\r
4 layout(local_size_x = 16) in;     // ERROR, changing\r
5 layout(local_size_z = 4096) in;   // ERROR, too large\r
6 layout(local_size_x = 2) in;\r
7 layout(local_size_y = 0) in;      // ERROR, 0 not allowed\r
8 const int total = gl_MaxComputeWorkGroupCount.y \r
9                 + gl_MaxComputeUniformComponents\r
10                 + gl_MaxComputeTextureImageUnits\r
11                 + gl_MaxComputeImageUniforms\r
12                 + gl_MaxComputeAtomicCounters\r
13                 + gl_MaxComputeAtomicCounterBuffers;\r
14 \r
15 buffer ShaderStorageBlock\r
16 {\r
17     int value;\r
18     float values[];\r
19 };\r
20 \r
21 buffer InvalidShaderStorageBlock\r
22 {\r
23     float values[];  // ERROR\r
24     int value;\r
25 } invalid;\r
26 \r
27 void main()\r
28 {\r
29     barrier();\r
30     memoryBarrier();\r
31     memoryBarrierAtomicCounter();\r
32     memoryBarrierBuffer();\r
33     memoryBarrierShared();\r
34     memoryBarrierImage();\r
35     groupMemoryBarrier();\r
36     value = int(values[gl_LocalInvocationIndex]);\r
37 }\r
38 \r
39 layout(location = 2) in vec3 v3;      // ERROR\r
40 in float f;                           // ERROR\r
41 out float fo;                         // ERROR\r
42 \r
43 shared vec4 s;\r
44 layout(location = 2) shared vec4 sl;  // ERROR\r
45 shared float fs = 4.2;                // ERROR\r
46 \r
47 layout(local_size_x = 2, local_size_y = 3, local_size_z = 4) out;  // ERROR\r
48 \r
49 int arrX[gl_WorkGroupSize.x];\r
50 int arrY[gl_WorkGroupSize.y];\r
51 int arrZ[gl_WorkGroupSize.z];\r
52 \r
53 readonly buffer roblock\r
54 {\r
55     int value;\r
56     float values[];\r
57 } ro;\r
58 \r
59 void foo()\r
60 {\r
61     ro.values[2] = 4.7;        // ERROR, readonly\r
62     ro.values.length();\r
63     ++s;\r
64 }\r
65 \r
66 buffer vec4 v;  // ERROR\r
67 \r
68 uniform usampler2D us2dbad;  // ERROR, default precision\r
69 \r
70 precision highp usampler2D;\r
71 precision highp iimage2DArray;\r
72 precision highp iimage2D;\r
73 \r
74 uniform usampler2D us2d;\r
75 \r
76 uniform iimage2DArray ii2dabad;  // ERROR, not writeonly\r
77 uniform writeonly iimage2DArray ii2da;\r
78 \r
79 layout(r32i) uniform iimage2D iimg2D;\r
80 layout(rgba32i) uniform readonly iimage2D iimg2Drgba;\r
81 layout(rgba32f) uniform readonly image2D img2Drgba;   // ERROR, no default\r
82 layout(r32ui) uniform uimage2D uimg2D;                // ERROR, no default\r
83 \r
84 void qux()\r
85 {\r
86     int i = 4;\r
87     imageAtomicCompSwap(iimg2D, ivec2(i,i), i, i);// ERROR no longer in 310\r
88     imageAtomicAdd(uimg2D, ivec2(i,i), uint(i));  // ERROR no longer in 310\r
89     imageAtomicMin(iimg2Drgba, ivec2(i,i), i);    // ERROR no longer in 310  // ERROR iimg2Drgba does not have r32i layout\r
90     imageAtomicMax(img2Drgba, ivec2(i,i), i);     // ERROR no longer in 310  // ERROR img2Drgba is not integer image\r
91     ivec4 pos = imageLoad(iimg2D, ivec2(i,i));\r
92     imageStore(ii2da, ivec3(i,i,i), ivec4(0));\r
93     imageLoad(img2Drgba, ivec2(i,i));\r
94     imageLoad(ii2da, ivec3(i,i,i));       // ERROR, drops writeonly\r
95 }\r
96 \r
97 volatile float vol; // ERROR, not an image\r
98 readonly int vol2;  // ERROR, not an image\r
99 \r
100 void passr(coherent readonly iimage2D image)\r
101 {\r
102 }\r
103 \r
104 layout(r32i) coherent readonly uniform iimage2D qualim1;\r
105 layout(r32i) coherent restrict readonly uniform iimage2D qualim2;\r
106 \r
107 void passrc()\r
108 {\r
109     passr(qualim1);   // ERROR, changing formats\r
110     passr(qualim2);   // ERROR, drops restrict, ERROR, changing formats\r
111     passr(iimg2D);    // ERROR, changing formats\r
112 }\r
113 \r
114 highp layout(rg8i)     uniform readonly uimage2D i1bad; // ERROR, type mismatch\r
115 highp layout(rgba32i)  uniform readonly image2D i2bad;  // ERROR, type mismatch\r
116 highp layout(rgba32f)  uniform readonly uimage2D i3bad; // ERROR, type mismatch\r
117 layout(r8_snorm) uniform readonly iimage2D i4bad; // ERROR, type mismatch\r
118 layout(rgba32ui) uniform readonly iimage2D i5bad; // ERROR, type mismatch\r
119 layout(r8ui)     uniform readonly iimage2D i6bad; // ERROR, type mismatch\r
120 \r
121 layout(binding = 0) uniform atomic_uint counter;\r
122 \r
123 uint func(atomic_uint c)\r
124 {\r
125     return atomicCounterIncrement(c);\r
126 }\r
127 \r
128 uint func2(out atomic_uint c) // ERROR, output\r
129 {\r
130     return counter;           // ERROR, type mismatch\r
131     return atomicCounter(counter);\r
132 }\r
133 \r
134 void mainAC()\r
135 {\r
136      atomic_uint non_uniform_counter; // ERROR\r
137      uint val = atomicCounter(counter);\r
138      atomicCounterDecrement(counter);\r
139 }\r
140 \r
141 layout(binding = 1) uniform mediump atomic_uint counterBad;  // ERROR, not highp\r
142 \r
143 layout(binding = 2, offset = 4) uniform atomic_uint countArr[4];\r
144 uniform int i;\r
145 \r
146 void opac()\r
147 {\r
148     int a[3];\r
149     a[counter];         // ERROR, non-integer\r
150     countArr[2];\r
151     countArr[i];\r
152 }\r
153 \r
154 shared int atomi;\r
155 shared uint atomu;\r
156 \r
157 void atoms()\r
158 {\r
159     int origi = atomicAdd(atomi, 3);\r
160     uint origu = atomicAnd(atomu, 7u);\r
161     origi = atomicExchange(atomi, 4);\r
162     origu = atomicCompSwap(atomu, 10u, 8u);\r
163 }\r
164 \r
165 precision highp atomic_uint;\r
166 precision lowp atomic_uint;   // ERROR\r
167 \r
168 precise int pfoo;  // ERROR, reserved\r
169 \r
170 dmat2x4 dm;                     // ERROR\r
171 uniform samplerCubeArray sca;   // ERROR\r
172 uniform iimage2DRect i2dr;      // ERROR\r
173 highp uniform image2DMS i2dms;  // ERROR\r
174 uniform uimage2DMSArray u2dmsa; // ERROR\r
175 \r
176 highp layout(r32f)  coherent volatile restrict readonly writeonly uniform  image2D okay1;\r
177       layout(r32i)  coherent volatile restrict readonly           uniform iimage2D okay2;\r
178 highp layout(r32ui) coherent volatile restrict          writeonly uniform uimage2D okay3;\r
179 highp layout(r32f)  coherent volatile restrict                    uniform  image2D okay4;\r
180  \r
181 highp layout(rgba32f)  coherent volatile restrict                 uniform  image2D badQ1;  // ERROR, bad qualifiers\r
182       layout(rgba8i)   coherent volatile restrict                 uniform iimage2D badQ2;  // ERROR, bad qualifiers\r
183 highp layout(rgba16ui) coherent volatile restrict                 uniform uimage2D badQ3;  // ERROR, bad qualifiers\r
184 \r
185 writeonly buffer woblock\r
186 {\r
187     int value;\r
188     float values[];\r
189 } wo;\r
190 \r
191 void foowo()\r
192 {\r
193     float g;\r
194     g = wo.values[2];            // ERROR, writeonly\r
195     float f = wo.values[2];      // ERROR, writeonly\r
196     ++wo.values[2];              // ERROR, writeonly\r
197     wo.values[2]--;              // ERROR, writeonly\r
198     f + wo.values[2];            // ERROR, writeonly\r
199     wo.values[2] - f;            // ERROR, writeonly\r
200     bool b;\r
201     b ? f : wo.values[2];        // ERROR, writeonly\r
202     b ? wo.values[2] : f;        // ERROR, writeonly\r
203     if (f == wo.values[2])       // ERROR, writeonly\r
204         ++f;\r
205     if (f >= wo.values[2])       // ERROR, writeonly\r
206         ++f;\r
207     f = vec3(wo.values[2]).x;    // ERROR, writeonly\r
208     ~wo.value;                   // ERROR, writeonly\r
209     wo.values[2] = 3.4;\r
210 }\r
211 \r
212 buffer multioblock\r
213 {\r
214     readonly int value;\r
215     writeonly float values[];\r
216 } multio;\r
217 \r
218 void foomultio()\r
219 {\r
220     float g;\r
221     g = wo.values[2];            // ERROR, writeonly\r
222     ~wo.value;\r
223     wo.values[2] = 3.4;\r
224     wo.value = 2;                // ERROR, readonly\r
225 }\r
226 \r
227 in inb {     // ERROR\r
228     int a;\r
229 } inbi;\r
230 \r
231 out outb {     // ERROR\r
232     int a;\r
233 } outbi;\r
234 \r
235 float t__;  // ERROR, no __ until revision 310
236
237     // ERROR, no __ until revision 310
238 #define __D
239
240 shared vec4 arr[2][3][4];
241
242 void devi()
243 {
244     gl_DeviceIndex; // ERROR, no extension
245     gl_ViewIndex;   // ERROR, never this stage
246 }
247
248 #ifdef GL_EXT_device_group
249 #extension GL_EXT_device_group : enable
250 #endif
251
252 void devie()
253 {
254     gl_DeviceIndex;
255     gl_ViewIndex;   // ERROR, never this stage
256 }