5 GL_ARB_shader_atomic_counters
9 #extension GL_ARB_compute_shader: require
10 #extension GL_ARB_shader_atomic_counters: require
12 layout(local_size_x = 32) in;
17 layout(binding = 0) uniform atomic_uint pass;
18 layout(binding = 0) uniform atomic_uint fail;
22 if (gl_LocalInvocationIndex == 0u) {
29 /* Each local invocation should see a unique value. Each value
30 * observed is tracked in "mask." The test automatically fails if a
31 * duplicate value is observed. The test passes once all 32 possible
32 * values have been observed.
37 /* This is an open-coded atomicAdd. */
40 } while ((f = atomicCompSwap(value, f, f + 4)) != a);
42 uint i = uint(f) / 4u;
47 /* If the bit was already set, the test fails. */
48 uint r = atomicOr(mask, m);
50 atomicCounterIncrement(fail);
52 /* Once all 32 bits are set, the test passes. */
53 if ((r | m) == 0xffffffffu)
54 atomicCounterIncrement(pass);
56 atomicCounterIncrement(fail);
63 probe atomic counter 0 == 24
64 probe atomic counter 1 == 0