summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/glslang/src/Test/310.vert
blob: 61998fd8b389731ed6e94334944ad75ab33822e9 (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
#version 310 es

shared vec4 s;   // ERROR
layout(local_size_x = 2) out;  // ERROR
buffer vec4 v;  // ERROR
in int ini;
layout(location = 2) uniform mat4 x;
layout(location = 3) uniform mat4 y;
layout(location = 2) out mat4 xi;
layout(location = 3) out mat4 yi;  // ERROR, locations conflict with xi

void main()
{
    uvec2 u2;
    u2 = uaddCarry(u2, u2, u2);
    uint u1;
    u1 = usubBorrow(u1, u1, u1);
    uvec4 u4;
    umulExtended(u4, u4, u4, u4);
    ivec4 i4;
    imulExtended(i4, i4, i4, i4);
    int i1;
    i1 = bitfieldExtract(i1, 4, 5);
    uvec3 u3;
    u3 = bitfieldExtract(u3, 4, 5);
    ivec3 i3;
    i3 = bitfieldInsert(i3, i3, 4, 5);
    u1 = bitfieldInsert(u1, u1, 4, 5);
    ivec2 i2;
    i2 = bitfieldReverse(i2);
    u4 = bitfieldReverse(u4);
    i1 = bitCount(i1);
    i3 = bitCount(u3);
    i2 = findLSB(i2);
    i4 = findLSB(u4);
    i1 = findMSB(i1);
    i2 = findMSB(u2);

    vec3 v3;
    v3 = frexp(v3, i3);
    vec2 v2;
    v2 = ldexp(v2, i2);

    mediump vec4 v4;
    u1 = packUnorm4x8(v4);
    u1 = packSnorm4x8(v4);
    v4 = unpackUnorm4x8(u1);
    v4 = unpackSnorm4x8(u1);
}

precision highp sampler2DMS;
precision highp isampler2DMS;
precision highp usampler2DMS;

uniform sampler2DMS s2dms;
uniform isampler2DMS is2dms;
uniform usampler2DMS us2dms;
uniform usampler2DMSArray us2dmsa;   // ERROR

void foo()
{
    ivec2 v2;
    v2 = textureSize(s2dms);
    v2 = textureSize(us2dms);
    vec4 v4 = texelFetch(s2dms, v2, 2);
    ivec4 iv4 = texelFetch(is2dms, v2, 2);
    textureSamples(s2dms);   // ERROR
    float f;
    frexp(f, ini);     // ERROR, i not writable
}

out bool outb;         // ERROR
out sampler2D outo;    // ERROR
out float outa[4];
out float outaa[4][2]; // ERROR
struct S { float f; };
out S outs;
out S[4] outasa;       // ERROR
out S outsa[4];        // ERROR
struct SA { float f[4]; };
out SA outSA;          // ERROR
struct SS { float f; S s; };
out SS outSS;          // ERROR

layout(std430) uniform U430 { int a; } U430i;    // ERROR
layout(std430) buffer B430 { int a; } B430i;

#ifndef GL_OES_shader_io_blocks
#error GL_OES_shader_io_blocks not defined
#endif

#extension GL_OES_shader_io_blocks : enable

out outbname {
    int a;
    out vec4 v;
    highp sampler2D s;   // ERROR, opaque type
} outbinst;

out outbname2 {
    layout(location = 12) int aAnon;
    layout(location = 13) vec4 vAnon;
};

layout(location = 12) out highp int aliased;  // ERROR, aliasing location

in inbname { int a; } inbinst;  // ERROR, no in block in vertex shader

out gl_PerVertex {              // ERROR, has extra member
    highp vec4 gl_Position;
    highp vec4 t;
};

void foo_IO()
{
    int sum  = gl_VertexID +
               gl_InstanceID;
    gl_Position = vec4(1.0);
    gl_PointSize = 2.0;         // ERROR, removed by redeclaration
}

out gl_PerVertex {              // ERROR, already used and already redeclared
    highp vec4 gl_Position;
    highp vec4 t;
};

smooth out smo {                // ERROR, no smooth on a block
    int i;
} smon;

flat out fmo {                  // ERROR, no flat on a block
    int i;
} fmon;

centroid out cmo {              // ERROR, no centroid on a block
    int i;
} cmon;

invariant out imo {             // ERROR, no invariant on a block
    int i;
} imon;

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
    sArray[sIndex + 1];      // ERRRO, not supported
    auArray[sIndex + 1];
    ubInst[1];
    bbInst[2];
    ubInst[sIndex + 1];      // ERRRO, not supported
    bbInst[sIndex];          // ERRRO, not supported
    iArray[2];
    iArray[sIndex * 2];      // ERRRO, not supported
    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);
    sArray[sIndex + 1];
    ubInst[sIndex + 1];
    bbInst[sIndex - 2];      // ERROR, still not supported
    iArray[2];
    iArray[sIndex - 2];
    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
}

uniform samplerBuffer  badSamp1;             // ERROR, reserved
uniform isamplerBuffer badSamp2;             // ERROR, reserved
uniform usamplerBuffer badSamp3;             // ERROR, reserved
uniform writeonly imageBuffer    badSamp4;   // ERROR, reserved
uniform writeonly iimageBuffer   badSamp5;   // ERROR, reserved
uniform writeonly uimageBuffer   badSamp6;   // ERROR, reserved

#extension GL_OES_texture_buffer : enable
#extension GL_EXT_texture_buffer : enable

uniform samplerBuffer  noPreSamp1;            // ERROR, no default precision
uniform isamplerBuffer noPreSamp2;            // ERROR, no default precision
uniform usamplerBuffer noPreSamp3;            // ERROR, no default precision
uniform writeonly imageBuffer    noPreSamp4;  // ERROR, no default precision
uniform writeonly iimageBuffer   noPreSamp5;  // ERROR, no default precision
uniform writeonly uimageBuffer   noPreSamp6;  // ERROR, no default precision

precision highp samplerBuffer; 
precision highp isamplerBuffer;
precision highp usamplerBuffer;
precision highp imageBuffer;   
precision highp iimageBuffer;  
precision highp uimageBuffer;  

#ifdef GL_OES_texture_buffer
uniform samplerBuffer  bufSamp1;          
uniform isamplerBuffer bufSamp2;          
uniform usamplerBuffer bufSamp3;          
#endif
#ifdef GL_EXT_texture_buffer
uniform writeonly imageBuffer    bufSamp4;
uniform writeonly iimageBuffer   bufSamp5;
uniform writeonly uimageBuffer   bufSamp6;
#endif

void bufferT()
{
    highp int s1 = textureSize(bufSamp1);
    highp int s2 = textureSize(bufSamp2);
    highp int s3 = textureSize(bufSamp3);

    highp int s4 = imageSize(bufSamp4);
    highp int s5 = imageSize(bufSamp5);
    highp int s6 = imageSize(bufSamp6);
    
    highp vec4 f1 = texelFetch(bufSamp1, s1);
    highp ivec4 f2 = texelFetch(bufSamp2, s2);
    highp uvec4 f3 = texelFetch(bufSamp3, s3);
}

uniform writeonly imageCubeArray  badCA1;  // ERROR, reserved
uniform writeonly iimageCubeArray badCA2;  // ERROR, reserved
uniform writeonly uimageCubeArray badCA3;  // ERROR, reserved

uniform samplerCubeArray          badCA4;  // ERROR, reserved
uniform samplerCubeArrayShadow    badCA5;  // ERROR, reserved
uniform isamplerCubeArray         badCA6;  // ERROR, reserved
uniform usamplerCubeArray         badCA7;  // ERROR, reserved

#extension GL_OES_texture_cube_map_array : enable

uniform writeonly imageCubeArray  noPreCA1;   // ERROR, no default precision
uniform writeonly iimageCubeArray noPreCA2;   // ERROR, no default precision
uniform writeonly uimageCubeArray noPreCA3;   // ERROR, no default precision

uniform samplerCubeArray          noPreCA4;   // ERROR, no default precision
uniform samplerCubeArrayShadow    noPreCA5;   // ERROR, no default precision
uniform isamplerCubeArray         noPreCA6;   // ERROR, no default precision
uniform usamplerCubeArray         noPreCA7;   // ERROR, no default precision

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;

layout(rgba16f) uniform readonly imageCubeArray  rCA1;
layout(rgba32i) uniform readonly iimageCubeArray rCA2;
layout(r32ui) uniform readonly uimageCubeArray rCA3;

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

void CAT()
{
    highp ivec3 s4 = textureSize(CA4, 1);
    highp ivec3 s5 = textureSize(CA5, 1);
    highp ivec3 s6 = textureSize(CA6, 1);
    highp ivec3 s7 = textureSize(CA7, 1);
    
    highp vec4 t4 = texture(CA4, vec4(0.5));
    highp float t5 = texture(CA5, vec4(0.5), 3.0);
    highp ivec4 t6 = texture(CA6, vec4(0.5));
    highp uvec4 t7 = texture(CA7, vec4(0.5));

    highp vec4 L4 = textureLod(CA4, vec4(0.5), 0.24);
    highp ivec4 L6 = textureLod(CA6, vec4(0.5), 0.26);
    highp uvec4 L7 = textureLod(CA7, vec4(0.5), 0.27);

    highp vec4 g4 = textureGrad(CA4, vec4(0.5), vec3(0.1), vec3(0.2));
    highp ivec4 g6 = textureGrad(CA6, vec4(0.5), vec3(0.1), vec3(0.2));
    highp uvec4 g7 = textureGrad(CA7, vec4(0.5), vec3(0.1), vec3(0.2));

    highp vec4 gath4 = textureGather(CA4, vec4(0.5));
    highp vec4 gathC4 = textureGather(CA4, vec4(0.5), 2);
    highp ivec4 gath6 = textureGather(CA6, vec4(0.5));
    highp ivec4 gathC6 = textureGather(CA6, vec4(0.5), 1);
    highp uvec4 gath7 = textureGather(CA7, vec4(0.5));
    highp uvec4 gathC7 = textureGather(CA7, vec4(0.5), 0);

    highp vec4 gath5 = textureGather(CA5, vec4(0.5), 2.5);

    highp ivec3 s1 = imageSize(CA1);
    highp ivec3 s2 = imageSize(CA2);
    highp ivec3 s3 = imageSize(CA3);

    imageStore(CA1, s3, vec4(1));
    imageStore(CA2, s3, ivec4(1));
    imageStore(CA3, s3, uvec4(1));

    highp vec4 cl1 = imageLoad(rCA1, s3);
    highp ivec4 cl2 = imageLoad(rCA2, s3);
    highp uvec4 cl3 = imageLoad(rCA3, s3);
}

uniform sampler2DMSArray  bad2DMS;    // ERROR, reserved
uniform isampler2DMSArray bad2DMSi;   // ERROR, reserved
uniform usampler2DMSArray bad2DMSu;   // ERROR, reserved

#extension GL_OES_texture_storage_multisample_2d_array : enable

#ifdef GL_OES_texture_storage_multisample_2d_array

uniform sampler2DMSArray  noPrec2DMS;    // ERROR, no default
uniform isampler2DMSArray noPrec2DMSi;   // ERROR, no default
uniform usampler2DMSArray noPrec2DMSu;   // ERROR, no default

#endif

precision highp sampler2DMSArray;
precision highp isampler2DMSArray;
precision highp usampler2DMSArray;

uniform sampler2DMSArray  samp2DMSA;
uniform isampler2DMSArray samp2DMSAi;
uniform usampler2DMSArray samp2DMSAu;

void MSA()
{
    vec4 tf = texelFetch(samp2DMSA, ivec3(5), 2);
    ivec4 tfi = texelFetch(samp2DMSAi, ivec3(5), 2);
    uvec4 tfu = texelFetch(samp2DMSAu, ivec3(5), 2);
    
    ivec3 tfs = textureSize(samp2DMSA);
    ivec3 tfsi = textureSize(samp2DMSAi);
    ivec3 tfsb = textureSize(samp2DMSAi, 4);  // ERROR, no lod
    ivec3 tfsu = textureSize(samp2DMSAu);
}

#ifdef GL_OES_shader_image_atomic 
#extension GL_OES_shader_image_atomic : enable
#endif

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

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);
}

sample out vec4 colorSampInBad;       // ERROR, reserved

#extension GL_OES_shader_multisample_interpolation : enable

sample out vec4 colorSample;
flat sample out vec4 colorfsi;
sample out vec3 sampInArray[4];
in vec4 inv4;

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