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