This adds a very simple test of atomicAdd on a shared variable.

Signed-off-by: Ilia Mirkin <[email protected]>
---

Note: this fails on my HSW.

 .../execution/shared-atomics.shader_test           | 43 ++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 
tests/spec/arb_compute_shader/execution/shared-atomics.shader_test

diff --git a/tests/spec/arb_compute_shader/execution/shared-atomics.shader_test 
b/tests/spec/arb_compute_shader/execution/shared-atomics.shader_test
new file mode 100644
index 0000000..e2c1fba
--- /dev/null
+++ b/tests/spec/arb_compute_shader/execution/shared-atomics.shader_test
@@ -0,0 +1,43 @@
+# Verify simple usage of atomics and shared variables
+
+[require]
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_compute_shader
+GL_ARB_shader_image_load_store
+
+[compute shader]
+#version 330
+#extension GL_ARB_compute_shader: enable
+#extension GL_ARB_shader_image_load_store: enable
+
+layout(local_size_x = 3, local_size_y = 2) in;
+
+shared uint value;
+writeonly uniform image2D tex;
+
+void main()
+{
+   if (gl_LocalInvocationIndex == 0u)
+     value = 0u;
+   barrier();
+   atomicAdd(value, gl_LocalInvocationIndex);
+   barrier();
+   if (gl_LocalInvocationIndex == 0u) {
+      vec4 color;
+      if (value == 15u) // 0 + 1 + 2 + 3 + 4 + 5
+        color = vec4(0, 1, 0, 1);
+      else
+        color = vec4(1, 0, 0, 0);
+      imageStore(tex, ivec2(gl_WorkGroupID.xy), color);
+   }
+}
+
+[test]
+uniform int tex 0
+texture rgbw 0 (2, 2) GL_RGBA8
+image texture 0 GL_RGBA8
+fb tex 2d 0
+
+compute 2 2 1
+probe all rgba 0.0 1.0 0.0 1.0
-- 
2.4.10

_______________________________________________
Piglit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to