blob: 6814e6c5390a6da8438cd2a19cc6e15d3c95f19f [file] [log] [blame]
John Kessenich4d570902014-08-12 22:07:22 +00001#version 310 es
John Kessenichf57aa7b2014-10-06 19:39:13 +00002highp float nodef3(float); // ERROR, no default precision
John Kessenich4d570902014-08-12 22:07:22 +00003precision mediump float;
4precision highp usampler2D;
5precision highp sampler2D;
6precision highp isampler2DArray;
7
8layout(origin_upper_left, pixel_center_integer) in vec4 gl_FragCoord; // ERROR, not supported
9
10layout(location = 2) in vec3 v3;
11layout(location = 2) in mat4 yi; // ERROR, locations conflict with xi
12
13uniform sampler2D arrayedSampler[5];
14uniform usampler2D usamp2d;
15uniform usampler2DRect samp2dr; // ERROR, reserved
16uniform isampler2DArray isamp2DA;
17
18in vec2 c2D;
19uniform int i;
20
21void main()
22{
23 vec4 v = texture(arrayedSampler[i], c2D); // ERROR
24
25 ivec2 offsets[4];
26 const ivec2 constOffsets[4] = ivec2[4](ivec2(1,2), ivec2(3,4), ivec2(15,16), ivec2(-2,0));
27 uvec4 uv4 = textureGatherOffsets(samp2dr, c2D, offsets, 2); // ERROR, not supported
28 vec4 v4 = textureGather(arrayedSampler[0], c2D);
29 ivec4 iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), 3);
30 iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), i); // ERROR, last argument not const
31 iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), 4); // ERROR, last argument out of range
32 iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), 1+2);
John Kesseniche3933d62015-07-15 19:42:59 -060033 iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(0.5));
34 iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(i)); // ERROR, offset not constant
John Kessenich4d570902014-08-12 22:07:22 +000035}
36
37out vec4 outp;
John Kessenich4d570902014-08-12 22:07:22 +000038void foo23()
39{
40 const ivec2[3] offsets = ivec2[3](ivec2(1,2), ivec2(3,4), ivec2(15,16));
41
42 textureProjGradOffset(usamp2d, outp, vec2(0.0), vec2(0.0), ivec2(c2D)); // ERROR, offset not constant
43 textureProjGradOffset(usamp2d, outp, vec2(0.0), vec2(0.0), offsets[1]);
44 textureProjGradOffset(usamp2d, outp, vec2(0.0), vec2(0.0), offsets[2]); // ERROR, offset out of range
45 textureProjGradOffset(usamp2d, outp, vec2(0.0), vec2(0.0), ivec2(-10, 20)); // ERROR, offset out of range
John Kessenichdf1d81a2014-08-13 08:32:15 +000046
47 if (gl_HelperInvocation)
48 ++outp;
49
50 int sum = gl_MaxVertexImageUniforms +
51 gl_MaxFragmentImageUniforms +
52 gl_MaxComputeImageUniforms +
53 gl_MaxCombinedImageUniforms +
54 gl_MaxCombinedShaderOutputResources;
55
56 bool b1, b2, b3, b;
57
58 b1 = mix(b2, b3, b);
59 uvec3 um3 = mix(uvec3(i), uvec3(i), bvec3(b));
60 ivec4 im4 = mix(ivec4(i), ivec4(i), bvec4(b));
John Kessenich4d570902014-08-12 22:07:22 +000061}
John Kessenichbe703392014-08-13 20:04:19 +000062
63layout(binding=3) uniform sampler2D s1;
64layout(binding=3) uniform sampler2D s2; // ERROR: overlapping bindings? Don't see that in the 310 spec.
John Kessenichac666e72016-06-14 22:12:20 -060065highp layout(binding=2) uniform writeonly image2D i2D;
66 layout(binding=4) uniform readonly image3D i3D; // ERROR, no default precision
67 layout(binding=5) uniform imageCube iCube; // ERROR, no default precision
68 layout(binding=6) uniform image2DArray i2DA; // ERROR, no default precision
69 layout(binding=6) uniform coherent volatile restrict image2D i2Dqualified; // ERROR, no default precision
John Kessenichbe703392014-08-13 20:04:19 +000070
71layout(binding = 1) uniform bb {
72 int foo;
73 layout(binding = 2) float f; // ERROR
74} bbi;
John Kessenichb3007512014-08-14 07:07:21 +000075
76in centroid vec4 centroidIn;
77layout(location = 200000) uniform vec4 bigl; // ERROR, location too big
78
79layout(early_fragment_tests) in;
80
81layout(location = 40) out vec4 bigout1; // ERROR, too big
82layout(location = 40) out vec4 bigout2; // ERROR, overlap
83layout(location = -2) out vec4 neg; // ERROR, negative
84
John Kessenich93930d62015-06-12 22:09:25 +000085layout(std430) buffer b430 {
John Kessenichb3007512014-08-14 07:07:21 +000086 int i;
87} b430i;
88
89layout(shared) uniform bshar {
90 int i;
91} bshari;
92
93in smooth vec4 smoothIn;
94in flat int flatIn;
95
John Kessenichac666e72016-06-14 22:12:20 -060096uniform sampler2DMS s2dms; // ERROR, no default precision qualifier
John Kessenichb3007512014-08-14 07:07:21 +000097
98void foots()
99{
100 highp ivec2 v2 = textureSize(s1, 2);
101 highp ivec3 v3 = textureSize(isamp2DA, 3);
102 v2 = textureSize(s2dms);
103 v2 = imageSize(i2D);
John Kessenichc47175c2014-11-17 16:45:10 +0000104 v3 = imageSize(i3D);
105 v2 = imageSize(iCube);
106 v3 = imageSize(i2DA);
107 v2 = imageSize(i2Dqualified);
John Kessenichb3007512014-08-14 07:07:21 +0000108}
109
110out bool bout; // ERROR
John Kessenichac666e72016-06-14 22:12:20 -0600111highp out image2D imageOut; // ERROR
John Kessenichb3007512014-08-14 07:07:21 +0000112out mat2x3 mout; // ERROR
113
John Kessenichb07957c2014-10-28 05:24:14 +0000114in bool inb; // ERROR
115in sampler2D ino; // ERROR
116in float ina[4];
117in float inaa[4][2]; // ERROR
118struct S { float f; };
119in S ins;
120in S[4] inasa; // ERROR
121in S insa[4]; // ERROR
122struct SA { float f[4]; };
123in SA inSA; // ERROR
124struct SS { float f; S s; };
125in SS inSS; // ERROR
John Kessenich9e41f362015-06-15 15:08:41 +0000126
127#ifndef GL_EXT_shader_io_blocks
128#error GL_EXT_shader_io_blocks not defined
129#endif
130
131#extension GL_EXT_shader_io_blocks : enable
132
133out outbname { int a; } outbinst; // ERROR, not out block in fragment shader
134
135in inbname {
136 int a;
137 vec4 v;
138 struct { int b; } s; // ERROR, nested struct definition
139} inbinst;
140
141in inbname2 {
142 layout(location = 12) int aAnon;
143 layout(location = 13) centroid in vec4 vAnon;
144};
145
146in layout(location = 13) vec4 aliased; // ERROR, aliased
147
148in inbname2 { // ERROR, reuse of block name
149 int aAnon;
150 centroid in vec4 vAnon;
151};
152
153in badmember { // ERROR, aAnon already in global scope
154 int aAnon;
155};
156
157int inbname; // ERROR, redefinition of block name
158
159vec4 vAnon; // ERROR, anon in global scope; redefinition
160
161in arrayed {
162 float f;
163} arrayedInst[4];
164
165void fooIO()
166{
167 vec4 v = inbinst.v + vAnon;
168 v *= arrayedInst[2].f;
John Kessenich1be80632015-11-28 15:19:11 -0700169 v *= arrayedInst[i].f;
John Kessenich9e41f362015-06-15 15:08:41 +0000170}
171
172in vec4 gl_FragCoord;
173layout(origin_upper_left, pixel_center_integer) in vec4 gl_FragCoord; // ERROR, non-ES
174
175layout(early_fragment_tests) in;
176out float gl_FragDepth;
177layout(depth_any) out float gl_FragDepth; // ERROR, non-ES
178
179void foo_IO()
180{
181 gl_FragDepth = 0.2; // ERROR, early_fragment_tests declared
John Kessenich105704e2015-06-19 06:28:59 +0000182 gl_Layer; // ERROR, not present
183 gl_PrimitiveID; // ERROR, not present
184 bool f = gl_FrontFacing;
John Kessenich9e41f362015-06-15 15:08:41 +0000185}
186
187out float gl_FragDepth;
John Kessenich105704e2015-06-19 06:28:59 +0000188
189#extension GL_OES_geometry_shader : enable
190
191void foo_GS()
192{
193 highp int l = gl_Layer;
194 highp int p = gl_PrimitiveID;
195}
John Kesseniche3933d62015-07-15 19:42:59 -0600196
197in vec2 inf, ing;
198uniform ivec2 offsets[4];
199uniform sampler2D sArray[4];
200uniform int sIndex;
201layout(binding = 0) uniform atomic_uint auArray[2];
202uniform ubName { int i; } ubInst[4];
203buffer bbName { int i; } bbInst[4];
John Kessenichac666e72016-06-14 22:12:20 -0600204highp uniform writeonly image2D iArray[5];
John Kesseniche3933d62015-07-15 19:42:59 -0600205const ivec2 constOffsets[4] = ivec2[4](ivec2(0.1), ivec2(0.2), ivec2(0.3), ivec2(0.4));
206
207void pfooBad()
208{
209 precise vec2 h; // ERROR reserved
210 h = fma(inf, ing, h); // ERROR, not available
211 textureGatherOffset(sArray[0], vec2(0.1), ivec2(inf)); // ERROR, offset not constant
212 textureGatherOffsets(sArray[0], vec2(0.1), constOffsets); // ERROR, not available
213}
214
215#extension GL_OES_gpu_shader5 : enable
216
217void pfoo()
218{
219 precise vec2 h;
220 h = fma(inf, ing, h);
221 textureGatherOffset(sArray[0], vec2(0.1), ivec2(inf));
222 textureGatherOffsets(sArray[0], vec2(0.1), constOffsets);
223 textureGatherOffsets(sArray[0], vec2(0.1), offsets); // ERROR, offset not constant
224}
John Kessenichdc9eff72015-08-16 14:21:20 -0600225
226#extension GL_EXT_texture_cube_map_array : enable
227
228precision highp imageCubeArray ;
229precision highp iimageCubeArray ;
230precision highp uimageCubeArray ;
231
232precision highp samplerCubeArray ;
233precision highp samplerCubeArrayShadow;
234precision highp isamplerCubeArray ;
235precision highp usamplerCubeArray ;
236
237uniform writeonly imageCubeArray CA1;
238uniform writeonly iimageCubeArray CA2;
239uniform writeonly uimageCubeArray CA3;
240
241#ifdef GL_EXT_texture_cube_map_array
242uniform samplerCubeArray CA4;
243uniform samplerCubeArrayShadow CA5;
244uniform isamplerCubeArray CA6;
245uniform usamplerCubeArray CA7;
246#endif
247
248void CAT()
249{
250 highp vec4 b4 = texture(CA4, vec4(0.5), 0.24);
251 highp ivec4 b6 = texture(CA6, vec4(0.5), 0.26);
252 highp uvec4 b7 = texture(CA7, vec4(0.5), 0.27);
253}
John Kessenich556ab3a2015-08-16 21:55:59 -0600254
255void badSample()
256{
257 lowp int a1 = gl_SampleID; // ERROR, need extension
258 mediump vec2 a2 = gl_SamplePosition; // ERROR, need extension
259 highp int a3 = gl_SampleMaskIn[0]; // ERROR, need extension
260 gl_SampleMask[0] = a3; // ERROR, need extension
261 mediump int n = gl_NumSamples; // ERROR, need extension
262}
263
264#ifdef GL_OES_sample_variables
265#extension GL_OES_sample_variables : enable
266#endif
267
268void goodSample()
269{
270 lowp int a1 = gl_SampleID;
271 mediump vec2 a2 = gl_SamplePosition;
272 highp int a3 = gl_SampleMaskIn[0];
273 gl_SampleMask[0] = a3;
274 mediump int n1 = gl_MaxSamples;
275 mediump int n2 = gl_NumSamples;
276}
John Kessenichfb5ba512015-08-16 23:40:15 -0600277
278uniform layout(r32f) highp image2D im2Df;
279uniform layout(r32ui) highp uimage2D im2Du;
280uniform layout(r32i) highp iimage2D im2Di;
281uniform ivec2 P;
282
283void badImageAtom()
284{
285 float datf;
286 int dati;
287 uint datu;
288
289 imageAtomicAdd( im2Di, P, dati); // ERROR, need extension
290 imageAtomicAdd( im2Du, P, datu); // ERROR, need extension
291 imageAtomicMin( im2Di, P, dati); // ERROR, need extension
292 imageAtomicMin( im2Du, P, datu); // ERROR, need extension
293 imageAtomicMax( im2Di, P, dati); // ERROR, need extension
294 imageAtomicMax( im2Du, P, datu); // ERROR, need extension
295 imageAtomicAnd( im2Di, P, dati); // ERROR, need extension
296 imageAtomicAnd( im2Du, P, datu); // ERROR, need extension
297 imageAtomicOr( im2Di, P, dati); // ERROR, need extension
298 imageAtomicOr( im2Du, P, datu); // ERROR, need extension
299 imageAtomicXor( im2Di, P, dati); // ERROR, need extension
300 imageAtomicXor( im2Du, P, datu); // ERROR, need extension
301 imageAtomicExchange(im2Di, P, dati); // ERROR, need extension
302 imageAtomicExchange(im2Du, P, datu); // ERROR, need extension
303 imageAtomicExchange(im2Df, P, datf); // ERROR, need extension
304 imageAtomicCompSwap(im2Di, P, 3, dati); // ERROR, need extension
305 imageAtomicCompSwap(im2Du, P, 5u, datu); // ERROR, need extension
306}
307
308#ifdef GL_OES_shader_image_atomic
309#extension GL_OES_shader_image_atomic : enable
310#endif
311
312uniform layout(rgba32f) highp image2D badIm2Df; // ERROR, needs readonly or writeonly
313uniform layout(rgba8ui) highp uimage2D badIm2Du; // ERROR, needs readonly or writeonly
314uniform layout(rgba16i) highp iimage2D badIm2Di; // ERROR, needs readonly or writeonly
315
316void goodImageAtom()
317{
318 float datf;
319 int dati;
320 uint datu;
321
322 imageAtomicAdd( im2Di, P, dati);
323 imageAtomicAdd( im2Du, P, datu);
324 imageAtomicMin( im2Di, P, dati);
325 imageAtomicMin( im2Du, P, datu);
326 imageAtomicMax( im2Di, P, dati);
327 imageAtomicMax( im2Du, P, datu);
328 imageAtomicAnd( im2Di, P, dati);
329 imageAtomicAnd( im2Du, P, datu);
330 imageAtomicOr( im2Di, P, dati);
331 imageAtomicOr( im2Du, P, datu);
332 imageAtomicXor( im2Di, P, dati);
333 imageAtomicXor( im2Du, P, datu);
334 imageAtomicExchange(im2Di, P, dati);
335 imageAtomicExchange(im2Du, P, datu);
336 imageAtomicExchange(im2Df, P, datf);
337 imageAtomicCompSwap(im2Di, P, 3, dati);
338 imageAtomicCompSwap(im2Du, P, 5u, datu);
339
340 imageAtomicMax(badIm2Di, P, dati); // ERROR, not an allowed layout() on the image
341 imageAtomicMax(badIm2Du, P, datu); // ERROR, not an allowed layout() on the image
342 imageAtomicExchange(badIm2Df, P, datf); // ERROR, not an allowed layout() on the image
343}
John Kessenich0fc43382015-08-22 01:21:47 -0600344
345sample in vec4 colorSampInBad; // ERROR, reserved
346centroid out vec4 colorCentroidBad; // ERROR
347flat out vec4 colorBadFlat; // ERROR
348smooth out vec4 colorBadSmooth; // ERROR
349noperspective out vec4 colorBadNo; // ERROR
350flat centroid in vec2 colorfc;
351in float scalarIn;
352
353void badInterp()
354{
355 interpolateAtCentroid(colorfc); // ERROR, need extension
356 interpolateAtSample(colorfc, 1); // ERROR, need extension
357 interpolateAtOffset(colorfc, vec2(0.2)); // ERROR, need extension
358}
359
360#if defined GL_OES_shader_multisample_interpolation
361#extension GL_OES_shader_multisample_interpolation : enable
362#endif
363
364sample in vec4 colorSampIn;
365sample out vec4 colorSampleBad; // ERROR
366flat sample in vec4 colorfsi;
367sample in vec3 sampInArray[4];
368
369void interp()
370{
371 float res;
372 vec2 res2;
373 vec3 res3;
374 vec4 res4;
375
376 res2 = interpolateAtCentroid(colorfc);
377 res4 = interpolateAtCentroid(colorSampIn);
378 res4 = interpolateAtCentroid(colorfsi);
379 res = interpolateAtCentroid(scalarIn);
380 res3 = interpolateAtCentroid(sampInArray); // ERROR
381 res3 = interpolateAtCentroid(sampInArray[2]);
382 res2 = interpolateAtCentroid(sampInArray[2].xy); // ERROR
383
384 res3 = interpolateAtSample(sampInArray, 1); // ERROR
385 res3 = interpolateAtSample(sampInArray[i], 0);
386 res2 = interpolateAtSample(sampInArray[2].xy, 2); // ERROR
387 res = interpolateAtSample(scalarIn, 1);
388
389 res3 = interpolateAtOffset(sampInArray, vec2(0.2)); // ERROR
390 res3 = interpolateAtOffset(sampInArray[2], vec2(0.2));
391 res2 = interpolateAtOffset(sampInArray[2].xy, vec2(0.2)); // ERROR, no swizzle
392 res = interpolateAtOffset(scalarIn + scalarIn, vec2(0.2)); // ERROR, no binary ops other than dereference
393 res = interpolateAtOffset(scalarIn, vec2(0.2));
394
395 float f;
396 res = interpolateAtCentroid(f); // ERROR, not interpolant
397 res4 = interpolateAtSample(outp, 0); // ERROR, not interpolant
398}
399
John Kessenichc8b2e362015-08-30 05:43:51 -0600400layout(blend_support_softlight) out; // ERROR, need extension
401
402#ifdef GL_KHR_blend_equation_advanced
403#extension GL_KHR_blend_equation_advanced : enable
404#endif
405
406layout(blend_support_multiply) out;
407layout(blend_support_screen) out;
408layout(blend_support_overlay) out;
409layout(blend_support_darken, blend_support_lighten) out;
410layout(blend_support_colordodge) layout(blend_support_colorburn) out;
411layout(blend_support_hardlight) out;
412layout(blend_support_softlight) out;
413layout(blend_support_difference) out;
414layout(blend_support_exclusion) out;
415layout(blend_support_hsl_hue) out;
416layout(blend_support_hsl_saturation) out;
417layout(blend_support_hsl_color) out;
418layout(blend_support_hsl_luminosity) out;
419layout(blend_support_all_equations) out;
420
421layout(blend_support_hsl_luminosity) out; // okay to repeat
422
423layout(blend_support_hsl_luminosity) in; // ERROR, only on "out"
424layout(blend_support_hsl_luminosity) out vec4; // ERROR, only on standalone
425layout(blend_support_hsl_luminosity) out vec4 badout; // ERROR, only on standalone
426layout(blend_support_hsl_luminosity) struct badS {int i;}; // ERROR, only on standalone
427layout(blend_support_hsl_luminosity) void blendFoo() { } // ERROR, only on standalone
428void blendFoo(layout(blend_support_hsl_luminosity) vec3 v) { } // ERROR, only on standalone
429layout(blend_support_flizbit) out; // ERROR, no flizbit
John Kessenich93122692015-09-11 15:25:38 -0600430
431out vec4 outAA[2][2]; // ERROR
John Kessenichc08fb8a2017-03-14 16:45:30 -0600432
433void devi()
434{
435 gl_DeviceIndex; // ERROR, no extension
436 gl_ViewIndex; // ERROR, no extension
437}
438
439#ifdef GL_EXT_device_group
440#extension GL_EXT_device_group : enable
441#endif
442
443#ifdef GL_EXT_device_group
444#extension GL_EXT_multiview : enable
445#endif
446
447void devie()
448{
449 gl_DeviceIndex;
450 gl_ViewIndex;
451}