5 GL_ARB_shader_atomic_counters
6 GL_INTEL_shader_atomic_float_minmax
10 #extension GL_ARB_compute_shader: require
11 #extension GL_ARB_shader_atomic_counters: require
12 #extension GL_INTEL_shader_atomic_float_minmax: require
14 layout(local_size_x = 32) in;
19 layout(binding = 0) uniform atomic_uint pass;
20 layout(binding = 0) uniform atomic_uint fail;
24 if (gl_LocalInvocationIndex == 0u) {
25 /* Bootstrapping this with zero is unavoidable, but it
26 * also causes problems later. Namely it means that
27 * bit 0 will get set twice and invocation 0 can see a
28 * zero value. Note the explicit checks for bit != 0
29 * and gl_LocalInvocationIndex != 0 below.
37 float f = atomicExchange(value, .5 * float(gl_LocalInvocationIndex));
38 uint i = uint(f * 2.);
43 /* If the bit was already set, the test fails. */
44 uint r = atomicOr(mask, m);
45 if (bit != 0u && (r & m) != 0u)
46 atomicCounterIncrement(fail);
48 /* Invocation index 0 can read it's own index (due to
49 * bootstrapping with zero), but no other invocation should.
51 if (gl_LocalInvocationIndex != 0u &&
52 bit == gl_LocalInvocationIndex)
53 atomicCounterIncrement(fail);
55 atomicCounterIncrement(fail);
60 if (gl_LocalInvocationIndex == 0u) {
61 uint i = uint(value * 2.);
65 uint final = m | mask;
67 /* If all 32 bits are set, the test passes. */
68 if (final == 0xffffffffu)
69 atomicCounterIncrement(pass);
76 probe atomic counter 0 == 24
77 probe atomic counter 1 == 0