4 GL_ARB_shader_storage_buffer_object
5 GL_INTEL_shader_atomic_float_minmax
7 [vertex shader passthrough]
10 #extension GL_ARB_shader_storage_buffer_object: require
11 #extension GL_INTEL_shader_atomic_float_minmax: require
13 layout(binding = 0) buffer bufblock {
17 #define POS_NAN(x) (0x7f800000u | (0x007fffffu & uint(x)))
18 #define NEG_NAN(x) (0xff800000u | (0x007fffffu & uint(x)))
20 uniform uint comparitors[] = uint[](POS_NAN(0x00ffffff),
27 floatBitsToUint(1.0));
33 uint idx = uint(gl_FragCoord.x + gl_FragCoord.y) % uint(value.length());
35 /* This compare-and-swap should never succeed because NaN is never
36 * equal to anything. Either the value in the SSBO or the value being
37 * compared is NaN. If the compare-and-swap succeeds, the SSBO
38 * element will forever be set to float(idx).
40 atomicCompSwap(value[idx],
41 uintBitsToFloat(comparitors[idx]),
44 color = value[idx] == 42.0
45 ? vec4(1.0, 0.0, 0.0, 1.0)
46 : vec4(0.0, 1.0, 0.0, 1.0);
51 ssbo 0 subdata int 0 0x7fffffff
52 ssbo 0 subdata int 4 0xffffffff
53 ssbo 0 subdata int 8 0x7fd55555
54 ssbo 0 subdata int 12 0xffd55555
55 ssbo 0 subdata float 16 0.0
56 ssbo 0 subdata float 20 1.0
57 ssbo 0 subdata int 24 0x7faaaaaa
58 ssbo 0 subdata int 28 0xffaaaaaa
60 clear color 0.5 0.5 0.5 0.5
64 probe all rgba 0.0 1.0 0.0 1.0