summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/glslang/src/Test/310.frag
blob: 2290ce17c76ddd69c23fd8039358712afd718c76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
#version 310 es
highp float nodef3(float); // ERROR, no default precision
precision mediump float;
precision highp usampler2D;
precision highp sampler2D;
precision highp isampler2DArray;

layout(origin_upper_left, pixel_center_integer) in vec4 gl_FragCoord;  // ERROR, not supported

layout(location = 2) in vec3 v3;
layout(location = 2) in mat4 yi;  // ERROR, locations conflict with xi

uniform sampler2D arrayedSampler[5];
uniform usampler2D usamp2d;
uniform usampler2DRect samp2dr;      // ERROR, reserved
uniform isampler2DArray isamp2DA;

in vec2 c2D;
uniform int i;

void main()
{
    vec4 v = texture(arrayedSampler[i], c2D);  // ERROR

    ivec2 offsets[4];
    const ivec2 constOffsets[4] = ivec2[4](ivec2(1,2), ivec2(3,4), ivec2(15,16), ivec2(-2,0));
    uvec4 uv4 = textureGatherOffsets(samp2dr, c2D, offsets, 2);  // ERROR, not supported
    vec4 v4 = textureGather(arrayedSampler[0], c2D);
    ivec4 iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), 3);
    iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), i);  // ERROR, last argument not const
    iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), 4);  // ERROR, last argument out of range
    iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(1), 1+2);
    iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(0.5));
    iv4 = textureGatherOffset(isamp2DA, vec3(0.1), ivec2(i));     // ERROR, offset not constant
}

out vec4 outp;
void foo23()
{
    const ivec2[3] offsets = ivec2[3](ivec2(1,2), ivec2(3,4), ivec2(15,16));

    textureProjGradOffset(usamp2d, outp, vec2(0.0), vec2(0.0), ivec2(c2D));     // ERROR, offset not constant
    textureProjGradOffset(usamp2d, outp, vec2(0.0), vec2(0.0), offsets[1]);
    textureProjGradOffset(usamp2d, outp, vec2(0.0), vec2(0.0), offsets[2]);     // ERROR, offset out of range
    textureProjGradOffset(usamp2d, outp, vec2(0.0), vec2(0.0), ivec2(-10, 20)); // ERROR, offset out of range

    if (gl_HelperInvocation)
        ++outp;

    int sum = gl_MaxVertexImageUniforms +
              gl_MaxFragmentImageUniforms +
              gl_MaxComputeImageUniforms +
              gl_MaxCombinedImageUniforms +
              gl_MaxCombinedShaderOutputResources;

    bool b1, b2, b3, b;

    b1 = mix(b2, b3, b);
    uvec3 um3 = mix(uvec3(i), uvec3(i), bvec3(b));
    ivec4 im4 = mix(ivec4(i), ivec4(i), bvec4(b));
}

layout(binding=3) uniform sampler2D s1;
layout(binding=3) uniform sampler2D s2; // ERROR: overlapping bindings?  Don't see that in the 310 spec.
layout(binding=2) uniform writeonly image2D      i2D;
layout(binding=4) uniform readonly  image3D      i3D;
layout(binding=5) uniform           imageCube    iCube;
layout(binding=6) uniform           image2DArray i2DA;
layout(binding=6) uniform coherent volatile restrict image2D i2Dqualified;

layout(binding = 1) uniform bb {
    int foo;
    layout(binding = 2) float f;     // ERROR
} bbi;

in centroid vec4 centroidIn;
layout(location = 200000) uniform vec4 bigl;  // ERROR, location too big

layout(early_fragment_tests) in;

layout(location = 40) out vec4 bigout1;  // ERROR, too big
layout(location = 40) out vec4 bigout2;  // ERROR, overlap
layout(location = -2) out vec4 neg;      // ERROR, negative

layout(std430) buffer b430 {
    int i;
} b430i;

layout(shared) uniform bshar {
    int i;
} bshari;

in smooth vec4 smoothIn;
in flat int flatIn;

uniform sampler2DMS s2dms;

void foots()
{
    highp ivec2 v2 = textureSize(s1, 2);
    highp ivec3 v3 = textureSize(isamp2DA, 3);
    v2 = textureSize(s2dms);
    v2 = imageSize(i2D);
    v3 = imageSize(i3D);
    v2 = imageSize(iCube);
    v3 = imageSize(i2DA);
    v2 = imageSize(i2Dqualified);
}

out bool bout;          // ERROR
out image2D imageOut;   // ERROR
out mat2x3 mout;        // ERROR

in bool inb;         // ERROR
in sampler2D ino;    // ERROR
in float ina[4];
in float inaa[4][2]; // ERROR
struct S { float f; };
in S ins;
in S[4] inasa;       // ERROR
in S insa[4];        // ERROR
struct SA { float f[4]; };
in SA inSA;          // ERROR
struct SS { float f; S s; };
in SS inSS;          // ERROR

#ifndef GL_EXT_shader_io_blocks
#error GL_EXT_shader_io_blocks not defined
#endif

#extension GL_EXT_shader_io_blocks : enable

out outbname { int a; } outbinst;   // ERROR, not out block in fragment shader

in inbname {
    int a;
    vec4 v;
    struct { int b; } s;     // ERROR, nested struct definition
} inbinst;

in inbname2 {
    layout(location = 12) int aAnon;
    layout(location = 13) centroid in vec4 vAnon;
};

in layout(location = 13) vec4 aliased; // ERROR, aliased

in inbname2 {                // ERROR, reuse of block name
    int aAnon;
    centroid in vec4 vAnon;
};

in badmember {               // ERROR, aAnon already in global scope
    int aAnon;
};

int inbname;                 // ERROR, redefinition of block name

vec4 vAnon;                  // ERROR, anon in global scope; redefinition

in arrayed {
    float f;
} arrayedInst[4];

void fooIO()
{
    vec4 v = inbinst.v + vAnon;
    v *= arrayedInst[2].f;
    v *= arrayedInst[i].f;
}

in vec4 gl_FragCoord;
layout(origin_upper_left, pixel_center_integer) in vec4 gl_FragCoord;  // ERROR, non-ES

layout(early_fragment_tests) in;
out float gl_FragDepth;
layout(depth_any) out float gl_FragDepth;  // ERROR, non-ES

void foo_IO()
{
    gl_FragDepth = 0.2;  // ERROR, early_fragment_tests declared
    gl_Layer;            // ERROR, not present
    gl_PrimitiveID;      // ERROR, not present
    bool f = gl_FrontFacing;
}

out float gl_FragDepth;

#extension GL_OES_geometry_shader : enable

void foo_GS()
{
    highp int l = gl_Layer;
    highp int p = gl_PrimitiveID;
}

in vec2 inf, ing;
uniform ivec2 offsets[4];
uniform sampler2D sArray[4];
uniform int sIndex;
layout(binding = 0) uniform atomic_uint auArray[2];
uniform ubName { int i; } ubInst[4];
buffer bbName { int i; } bbInst[4];
uniform writeonly image2D iArray[5];
const ivec2 constOffsets[4] = ivec2[4](ivec2(0.1), ivec2(0.2), ivec2(0.3), ivec2(0.4));

void pfooBad()
{
    precise vec2 h;                                            // ERROR reserved
    h = fma(inf, ing, h);                                      // ERROR, not available
    textureGatherOffset(sArray[0], vec2(0.1), ivec2(inf));     // ERROR, offset not constant
    textureGatherOffsets(sArray[0], vec2(0.1), constOffsets);  // ERROR, not available
}

#extension GL_OES_gpu_shader5 : enable

void pfoo()
{
    precise vec2 h;
    h = fma(inf, ing, h);
    textureGatherOffset(sArray[0], vec2(0.1), ivec2(inf));
    textureGatherOffsets(sArray[0], vec2(0.1), constOffsets);
    textureGatherOffsets(sArray[0], vec2(0.1), offsets);       // ERROR, offset not constant
}

#extension GL_EXT_texture_cube_map_array : enable

precision highp imageCubeArray        ;
precision highp iimageCubeArray       ;
precision highp uimageCubeArray       ;

precision highp samplerCubeArray      ;
precision highp samplerCubeArrayShadow;
precision highp isamplerCubeArray     ;
precision highp usamplerCubeArray     ;

uniform writeonly imageCubeArray  CA1;
uniform writeonly iimageCubeArray CA2;
uniform writeonly uimageCubeArray CA3;

#ifdef GL_EXT_texture_cube_map_array
uniform samplerCubeArray          CA4;
uniform samplerCubeArrayShadow    CA5;
uniform isamplerCubeArray         CA6;
uniform usamplerCubeArray         CA7;
#endif

void CAT()
{
    highp vec4 b4 = texture(CA4, vec4(0.5), 0.24);
    highp ivec4 b6 = texture(CA6, vec4(0.5), 0.26);
    highp uvec4 b7 = texture(CA7, vec4(0.5), 0.27);
}

void badSample()
{
    lowp     int  a1 = gl_SampleID;         // ERROR, need extension
    mediump  vec2 a2 = gl_SamplePosition;   // ERROR, need extension
    highp    int  a3 = gl_SampleMaskIn[0];  // ERROR, need extension
    gl_SampleMask[0] = a3;                  // ERROR, need extension
    mediump int n = gl_NumSamples;          // ERROR, need extension
}

#ifdef GL_OES_sample_variables
#extension GL_OES_sample_variables : enable
#endif

void goodSample()
{
    lowp     int  a1 = gl_SampleID;       
    mediump  vec2 a2 = gl_SamplePosition; 
    highp    int  a3 = gl_SampleMaskIn[0];
    gl_SampleMask[0] = a3;
    mediump int n1 = gl_MaxSamples;
    mediump int n2 = gl_NumSamples;
}

uniform layout(r32f)  highp  image2D im2Df;
uniform layout(r32ui) highp uimage2D im2Du;
uniform layout(r32i)  highp iimage2D im2Di;
uniform ivec2 P;

void badImageAtom()
{
    float datf;
    int dati;
    uint datu;

    imageAtomicAdd(     im2Di, P, dati);        // ERROR, need extension
    imageAtomicAdd(     im2Du, P, datu);        // ERROR, need extension
    imageAtomicMin(     im2Di, P, dati);        // ERROR, need extension
    imageAtomicMin(     im2Du, P, datu);        // ERROR, need extension
    imageAtomicMax(     im2Di, P, dati);        // ERROR, need extension
    imageAtomicMax(     im2Du, P, datu);        // ERROR, need extension
    imageAtomicAnd(     im2Di, P, dati);        // ERROR, need extension
    imageAtomicAnd(     im2Du, P, datu);        // ERROR, need extension
    imageAtomicOr(      im2Di, P, dati);        // ERROR, need extension
    imageAtomicOr(      im2Du, P, datu);        // ERROR, need extension
    imageAtomicXor(     im2Di, P, dati);        // ERROR, need extension
    imageAtomicXor(     im2Du, P, datu);        // ERROR, need extension
    imageAtomicExchange(im2Di, P, dati);        // ERROR, need extension
    imageAtomicExchange(im2Du, P, datu);        // ERROR, need extension
    imageAtomicExchange(im2Df, P, datf);        // ERROR, need extension
    imageAtomicCompSwap(im2Di, P,  3, dati);    // ERROR, need extension
    imageAtomicCompSwap(im2Du, P, 5u, datu);    // ERROR, need extension
}

#ifdef GL_OES_shader_image_atomic 
#extension GL_OES_shader_image_atomic : enable
#endif

uniform layout(rgba32f)  highp  image2D badIm2Df;  // ERROR, needs readonly or writeonly
uniform layout(rgba8ui) highp uimage2D badIm2Du;   // ERROR, needs readonly or writeonly
uniform layout(rgba16i)  highp iimage2D badIm2Di;  // ERROR, needs readonly or writeonly

void goodImageAtom()
{
    float datf;
    int dati;
    uint datu;

    imageAtomicAdd(     im2Di, P, dati);
    imageAtomicAdd(     im2Du, P, datu);
    imageAtomicMin(     im2Di, P, dati);
    imageAtomicMin(     im2Du, P, datu);
    imageAtomicMax(     im2Di, P, dati);
    imageAtomicMax(     im2Du, P, datu);
    imageAtomicAnd(     im2Di, P, dati);
    imageAtomicAnd(     im2Du, P, datu);
    imageAtomicOr(      im2Di, P, dati);
    imageAtomicOr(      im2Du, P, datu);
    imageAtomicXor(     im2Di, P, dati);
    imageAtomicXor(     im2Du, P, datu);
    imageAtomicExchange(im2Di, P, dati);
    imageAtomicExchange(im2Du, P, datu);
    imageAtomicExchange(im2Df, P, datf);
    imageAtomicCompSwap(im2Di, P,  3, dati);
    imageAtomicCompSwap(im2Du, P, 5u, datu);

    imageAtomicMax(badIm2Di, P, dati);      // ERROR, not an allowed layout() on the image
    imageAtomicMax(badIm2Du, P, datu);      // ERROR, not an allowed layout() on the image
    imageAtomicExchange(badIm2Df, P, datf); // ERROR, not an allowed layout() on the image
}

sample in vec4 colorSampInBad;       // ERROR, reserved
centroid out vec4 colorCentroidBad;  // ERROR
flat out vec4 colorBadFlat;          // ERROR
smooth out vec4 colorBadSmooth;      // ERROR
noperspective out vec4 colorBadNo;   // ERROR
flat centroid in vec2 colorfc;
in float scalarIn;

void badInterp()
{
    interpolateAtCentroid(colorfc);             // ERROR, need extension
    interpolateAtSample(colorfc, 1);            // ERROR, need extension
    interpolateAtOffset(colorfc, vec2(0.2));    // ERROR, need extension
}

#if defined GL_OES_shader_multisample_interpolation
#extension GL_OES_shader_multisample_interpolation : enable
#endif

sample in vec4 colorSampIn;
sample out vec4 colorSampleBad;     // ERROR
flat sample in vec4 colorfsi;
sample in vec3 sampInArray[4];

void interp()
{
    float res;
    vec2 res2;
    vec3 res3;
    vec4 res4;

    res2 = interpolateAtCentroid(colorfc);
    res4 = interpolateAtCentroid(colorSampIn);
    res4 = interpolateAtCentroid(colorfsi);
    res  = interpolateAtCentroid(scalarIn);
    res3 = interpolateAtCentroid(sampInArray);         // ERROR
    res3 = interpolateAtCentroid(sampInArray[2]);
    res2 = interpolateAtCentroid(sampInArray[2].xy);   // ERROR

    res3 = interpolateAtSample(sampInArray, 1);        // ERROR
    res3 = interpolateAtSample(sampInArray[i], 0);
    res2 = interpolateAtSample(sampInArray[2].xy, 2);  // ERROR
    res  = interpolateAtSample(scalarIn, 1);

    res3 = interpolateAtOffset(sampInArray, vec2(0.2));         // ERROR
    res3 = interpolateAtOffset(sampInArray[2], vec2(0.2));
    res2 = interpolateAtOffset(sampInArray[2].xy, vec2(0.2));   // ERROR, no swizzle
    res  = interpolateAtOffset(scalarIn + scalarIn, vec2(0.2)); // ERROR, no binary ops other than dereference
    res  = interpolateAtOffset(scalarIn, vec2(0.2));

    float f;
    res  = interpolateAtCentroid(f);           // ERROR, not interpolant
    res4 = interpolateAtSample(outp, 0);       // ERROR, not interpolant
}

layout(blend_support_softlight) out;           // ERROR, need extension

#ifdef GL_KHR_blend_equation_advanced
#extension GL_KHR_blend_equation_advanced : enable
#endif

layout(blend_support_multiply) out;
layout(blend_support_screen) out;
layout(blend_support_overlay) out;
layout(blend_support_darken, blend_support_lighten) out;
layout(blend_support_colordodge) layout(blend_support_colorburn) out;
layout(blend_support_hardlight) out;
layout(blend_support_softlight) out;
layout(blend_support_difference) out;
layout(blend_support_exclusion) out;
layout(blend_support_hsl_hue) out;
layout(blend_support_hsl_saturation) out;
layout(blend_support_hsl_color) out;
layout(blend_support_hsl_luminosity) out;
layout(blend_support_all_equations) out;

layout(blend_support_hsl_luminosity) out;              // okay to repeat

layout(blend_support_hsl_luminosity) in;                       // ERROR, only on "out"
layout(blend_support_hsl_luminosity) out vec4;                 // ERROR, only on standalone
layout(blend_support_hsl_luminosity) out vec4 badout;          // ERROR, only on standalone
layout(blend_support_hsl_luminosity) struct badS {int i;};     // ERROR, only on standalone
layout(blend_support_hsl_luminosity) void blendFoo() { }       // ERROR, only on standalone
void blendFoo(layout(blend_support_hsl_luminosity) vec3 v) { } // ERROR, only on standalone
layout(blend_support_flizbit) out;                             // ERROR, no flizbit

out vec4 outAA[2][2];  // ERROR