4 GL_ARB_shader_atomic_counter_ops
6 [vertex shader passthrough]
9 #extension GL_ARB_shader_atomic_counter_ops: require
11 layout(binding = 0) buffer bufblock {
15 /* GL_ARB_shader_atomic_counters requires at least 8 total counters. */
16 layout(binding = 0) uniform atomic_uint mask[7];
17 layout(binding = 0) uniform atomic_uint fail;
23 /* According to issue #22 of the GL_ARB_shader_image_load_store, the
24 * return result of atomic operations in helper invocations is
25 * undefined. To avoid a possible infinite loop (below) in a helper
26 * invocation, bail out now.
28 if (gl_HelperInvocation)
31 /* Each of 32 * N fragments should see a unique value. Each value
32 * observed is tracked in "mask." The test automatically fails if a
33 * duplicate value is observed. After the shaders are done running,
34 * the mask values will be probed to ensure that all possible values
39 /* This is an open-coded atomicAdd. */
42 } while (f != atomicCompSwap(value, f, f + 4));
44 uint i = uint(f) / 4u;
49 if (c < mask.length()) {
50 /* If the bit was already set, the test fails. */
51 if ((atomicCounterOrARB(mask[c], m) & m) != 0u)
52 atomicCounterIncrement(fail);
54 color = vec4(0.0, 1.0, 0.0, 1.0);
56 color = vec4(0.0, 0.0, 1.0, 1.0);
64 ssbo 0 subdata float 0 0.0
66 clear color 0.5 0.5 0.5 0.5
71 probe atomic counter 0 == 4294967295
72 probe atomic counter 1 == 4294967295
73 probe atomic counter 2 == 4294967295
74 probe atomic counter 3 == 4294967295
75 probe atomic counter 4 == 4294967295
76 probe atomic counter 5 == 4294967295
77 probe atomic counter 6 == 4294967295
78 probe atomic counter 7 == 0