From: Ian Romanick <ian.d.roman...@intel.com>

This is identical to
tests/spec/arb_shader_storage_buffer_object/execution/ssbo-atomicCompSwap-int.shader_test,
but this test uses gl_HelperInvocation instead of gl_SampleMaskIn.

Signed-off-by: Ian Romanick <ian.d.roman...@intel.com>
---
 .../execution/ssbo-atomicCompSwap-int.shader_test  | 78 ++++++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 
tests/spec/glsl-4.50/execution/ssbo-atomicCompSwap-int.shader_test

diff --git a/tests/spec/glsl-4.50/execution/ssbo-atomicCompSwap-int.shader_test 
b/tests/spec/glsl-4.50/execution/ssbo-atomicCompSwap-int.shader_test
new file mode 100644
index 000000000..25bc42a6c
--- /dev/null
+++ b/tests/spec/glsl-4.50/execution/ssbo-atomicCompSwap-int.shader_test
@@ -0,0 +1,78 @@
+[require]
+GL >= 4.5
+GLSL >= 4.50
+GL_ARB_shader_atomic_counter_ops
+
+[vertex shader passthrough]
+
+[fragment shader]
+#extension GL_ARB_shader_atomic_counter_ops: require
+
+layout(binding = 0) buffer bufblock {
+       int value;
+};
+
+/* GL_ARB_shader_atomic_counters requires at least 8 total counters. */
+layout(binding = 0) uniform atomic_uint mask[7];
+layout(binding = 0) uniform atomic_uint fail;
+
+out vec4 color;
+
+void main()
+{
+       /* According to issue #22 of the GL_ARB_shader_image_load_store, the
+        * return result of atomic operations in helper invocations is
+        * undefined.  To avoid a possible infinite loop (below) in a helper
+        * invocation, bail out now.
+        */
+       if (gl_HelperInvocation)
+               return;
+
+       /* Each of 32 * N fragments should see a unique value.  Each value
+        * observed is tracked in "mask."  The test automatically fails if a
+        * duplicate value is observed.  After the shaders are done running,
+        * the mask values will be probed to ensure that all possible values
+        * were observed.
+        */
+       int f;
+
+       /* This is an open-coded atomicAdd. */
+       do {
+               f = value;
+       } while (f != atomicCompSwap(value, f, f + 4));
+
+       uint i = uint(f) / 4u;
+       uint bit = i % 32u;
+       int c = int(i / 32u);
+       uint m = 1u << bit;
+
+       if (c < mask.length()) {
+               /* If the bit was already set, the test fails. */
+               if ((atomicCounterOrARB(mask[c], m) & m) != 0u)
+                       atomicCounterIncrement(fail);
+
+               color = vec4(0.0, 1.0, 0.0, 1.0);
+       } else {
+               color = vec4(0.0, 0.0, 1.0, 1.0);
+       }
+}
+
+[test]
+atomic counters 8
+
+ssbo 0 32
+ssbo 0 subdata float 0 0.0
+
+clear color 0.5 0.5 0.5 0.5
+clear
+
+draw rect -1 -1 2 2
+
+probe atomic counter 0 == 4294967295
+probe atomic counter 1 == 4294967295
+probe atomic counter 2 == 4294967295
+probe atomic counter 3 == 4294967295
+probe atomic counter 4 == 4294967295
+probe atomic counter 5 == 4294967295
+probe atomic counter 6 == 4294967295
+probe atomic counter 7 == 0
-- 
2.14.4

_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to