From 22c284ec274604cdf2a7db8955e40f5a517fd300 Mon Sep 17 00:00:00 2001 From: Ilia Mirkin Date: Thu, 18 Feb 2016 17:52:19 -0500 Subject: [PATCH v2] compute: add an execution test for shared atomics This adds a very simple test of atomicAdd on a shared variable. Signed-off-by: Ilia Mirkin --- v1 -> v2: - use an atomic - allow the local size to be messed with easily without changing other bits .../execution/shared-atomics.shader_test | 36 ++++++++++++++++++++++ 1 file changed, 36 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..65f150a --- /dev/null +++ b/tests/spec/arb_compute_shader/execution/shared-atomics.shader_test @@ -0,0 +1,36 @@ +# Verify simple usage of atomics and shared variables + +[require] +GL >= 3.3 +GLSL >= 3.30 +GL_ARB_compute_shader +GL_ARB_shader_atomic_counters + +[compute shader] +#version 330 +#extension GL_ARB_compute_shader: enable +#extension GL_ARB_shader_atomic_counters: enable + +layout(local_size_x = 2, local_size_y = 3) in; + +shared uint value; +layout(binding = 0) uniform atomic_uint pass; +const uint size = gl_WorkGroupSize.x * gl_WorkGroupSize.y * gl_WorkGroupSize.z; + +void main() +{ + if (gl_LocalInvocationIndex == 0u) + value = 0u; + barrier(); + atomicAdd(value, gl_LocalInvocationIndex); + barrier(); + if (gl_LocalInvocationIndex == 0u) { + if (value == size * (size - 1u) / 2u) + atomicCounterIncrement(pass); + } +} + +[test] +atomic counters 1 +compute 2 3 4 +probe atomic counter 0 == 24 -- 2.4.10