4 GL_ARB_shader_storage_buffer_object
5 GL_ARB_shader_atomic_counters
6 GL_ARB_shader_atomic_counter_ops
9 [vertex shader passthrough]
12 #extension GL_ARB_shader_storage_buffer_object: require
13 #extension GL_ARB_shader_atomic_counters: require
14 #extension GL_ARB_shader_atomic_counter_ops: require
15 #extension GL_ARB_gpu_shader5: require
17 layout(binding = 0) buffer bufblock {
21 /* GL_ARB_shader_atomic_counters requires at least 8 total counters. */
22 layout(binding = 0) uniform atomic_uint mask[7];
23 layout(binding = 0) uniform atomic_uint fail;
29 /* According to issue #22 of the GL_ARB_shader_image_load_store, the
30 * return result of atomic operations in helper invocations is
31 * undefined. To avoid a possible infinite loop (below) in a helper
32 * invocation, bail out now.
34 if (gl_SampleMaskIn[0] == 0)
37 /* Each of 32 * N fragments should see a unique value. Each value
38 * observed is tracked in "mask." The test automatically fails if a
39 * duplicate value is observed. After the shaders are done running,
40 * the mask values will be probed to ensure that all possible values
45 /* This is an open-coded atomicAdd. */
48 } while (f != atomicCompSwap(value, f, f + 4));
50 uint i = uint(f) / 4u;
55 if (c < mask.length()) {
56 /* If the bit was already set, the test fails. */
57 if ((atomicCounterOrARB(mask[c], m) & m) != 0u)
58 atomicCounterIncrement(fail);
60 color = vec4(0.0, 1.0, 0.0, 1.0);
62 color = vec4(0.0, 0.0, 1.0, 1.0);
70 ssbo 0 subdata float 0 0.0
72 clear color 0.5 0.5 0.5 0.5
77 probe atomic counter 0 == 4294967295
78 probe atomic counter 1 == 4294967295
79 probe atomic counter 2 == 4294967295
80 probe atomic counter 3 == 4294967295
81 probe atomic counter 4 == 4294967295
82 probe atomic counter 5 == 4294967295
83 probe atomic counter 6 == 4294967295
84 probe atomic counter 7 == 0