Merge pull request #2976 from jeremy-lunarg/hayes-fix-2975
[platform/upstream/glslang.git] / Test / vk.relaxed.frag
1 #version 460\r
2 \r
3 out vec4 o;\r
4 \r
5 // default uniforms will be gathered into a uniform block\r
6 uniform vec4 a;\r
7 uniform vec2 b = vec2(0, 0);            // initializer will be ignored\r
8 layout(location = 0) uniform vec2 c;    // location qualifier will be ignored\r
9 uniform vec4 d[10];\r
10 uniform struct e {                      \r
11     vec2 x;\r
12     float y;\r
13     uint z;\r
14 } structUniform; \r
15 \r
16 // opaque types will not be grouped into uniform block\r
17 uniform sampler2D t1;\r
18 \r
19 // shared and packed layout qualifier are silently ignored\r
20 layout(shared) uniform UniformBlock {\r
21     float j;\r
22     vec4 k;\r
23 };\r
24 \r
25 layout(packed) buffer BufferBlock {\r
26     float j;\r
27     vec4 k;\r
28 } bufferInstance;\r
29 \r
30 // atomic_uint will be converted to uint and gathered in a buffer block\r
31 layout(binding = 0) uniform atomic_uint counter1; // offset not used\r
32 layout(binding = 0) uniform atomic_uint counter2; // offset not used\r
33 layout(binding = 1) uniform atomic_uint counter3; // offset not used\r
34 \r
35 // atomic counter functions will be converted to equivalent integer atomic operations\r
36 uint bar() {\r
37     uint j = 0;\r
38     j = atomicCounterIncrement(counter1);\r
39     j = atomicCounterDecrement(counter1);\r
40     j = atomicCounter(counter1);\r
41 \r
42     j = atomicCounterAdd(counter1, 1);\r
43     j = atomicCounterAdd(counter1, -1);\r
44     j = atomicCounterSubtract(counter1, 1);\r
45 \r
46     j = atomicCounterMin(counter1, j);\r
47     j = atomicCounterMax(counter1, j);\r
48     j = atomicCounterAnd(counter1, j);\r
49 \r
50     j = atomicCounterOr(counter1, j);\r
51     j = atomicCounterXor(counter1, j);\r
52     \r
53     j = atomicCounterExchange(counter1, j);\r
54     j = atomicCounterCompSwap(counter1, 0, j);\r
55 \r
56     atomicCounterIncrement(counter2);\r
57     atomicCounterIncrement(counter3);\r
58 \r
59     memoryBarrierAtomicCounter();\r
60     \r
61     return j;\r
62 }\r
63 \r
64 vec4 foo() {\r
65     float f = j + bufferInstance.j + structUniform.y + structUniform.z;\r
66     vec2 v2 = b + c + structUniform.x;\r
67     vec4 v4 = a + d[0] + d[1] + d[2] + k + bufferInstance.k + texture(t1, vec2(0, 0));\r
68     return vec4(f) * vec4(v2, 1, 1) * v4;\r
69 }\r
70 \r
71 void main() {\r
72     float j = float(bar());\r
73     o = j * foo();\r
74 }