Reviewed-by: Samuel Pitoiset <samuel.pitoi...@gmail.com>

On 10/23/2017 02:20 AM, Ilia Mirkin wrote:
In this case, the derived values are used in a shader that doesn't
contain the main function.

Signed-off-by: Ilia Mirkin <imir...@alum.mit.edu>
---
  .../execution/separate-global-id-2.shader_test     | 77 ++++++++++++++++++++++
  .../execution/separate-global-id-2.shader_test     | 55 ++++++++++++++++
  2 files changed, 132 insertions(+)
  create mode 100644 
tests/spec/arb_compute_shader/execution/separate-global-id-2.shader_test
  create mode 100644 
tests/spec/arb_compute_variable_group_size/execution/separate-global-id-2.shader_test

diff --git 
a/tests/spec/arb_compute_shader/execution/separate-global-id-2.shader_test 
b/tests/spec/arb_compute_shader/execution/separate-global-id-2.shader_test
new file mode 100644
index 000000000..14231e405
--- /dev/null
+++ b/tests/spec/arb_compute_shader/execution/separate-global-id-2.shader_test
@@ -0,0 +1,77 @@
+# Simple test that verifies gl_GlobalInvocationID values are
+# functioning. Atomic counters are used as outputs.
+#
+# The additional twist is that the work is done in a different shader,
+# which also has the layout declaration.
+
+[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
+
+void go();
+
+// When the go() function gets moved here, the gl_WorkGroupSize can stay
+// behind in the other shader.
+
+void main() {
+  go();
+}
+
+[compute shader]
+#version 330
+#extension GL_ARB_compute_shader: enable
+#extension GL_ARB_shader_atomic_counters: require
+
+layout(local_size_x = 4, local_size_y = 2, local_size_z = 4) in;
+
+layout(binding = 0) uniform atomic_uint a0;
+layout(binding = 0) uniform atomic_uint a1;
+layout(binding = 0) uniform atomic_uint a2;
+layout(binding = 0) uniform atomic_uint a3;
+layout(binding = 0) uniform atomic_uint a4;
+layout(binding = 0) uniform atomic_uint a5;
+layout(binding = 0) uniform atomic_uint a6;
+layout(binding = 0) uniform atomic_uint a7;
+
+void go()
+{
+    uint x = gl_GlobalInvocationID.x;
+    uint y = gl_GlobalInvocationID.y;
+    uint z = gl_GlobalInvocationID.z;
+
+    if (((x & y) & z) == 0u)
+        atomicCounterIncrement(a0);
+    if (((x | y) | z) == 7u)
+        atomicCounterIncrement(a1);
+    if (x == y && y == z)
+        atomicCounterIncrement(a2);
+    if (x != y && y != z && x != z)
+        atomicCounterIncrement(a3);
+    if (((x & y) & z) == 2u)
+        atomicCounterIncrement(a4);
+    if (((x | y) | z) == 5u)
+        atomicCounterIncrement(a5);
+    if (x < 4u && y < 4u && z < 4u)
+        atomicCounterIncrement(a6);
+    if (x >= 4u || y >= 4u || z >= 4u)
+        atomicCounterIncrement(a7);
+}
+
+[test]
+atomic counters 8
+
+compute 2 4 2
+probe atomic counter 0 == 343
+probe atomic counter 1 == 343
+probe atomic counter 2 == 8
+probe atomic counter 3 == 336
+probe atomic counter 4 == 49
+probe atomic counter 5 == 49
+probe atomic counter 6 == 64
+probe atomic counter 7 == 448
diff --git 
a/tests/spec/arb_compute_variable_group_size/execution/separate-global-id-2.shader_test
 
b/tests/spec/arb_compute_variable_group_size/execution/separate-global-id-2.shader_test
new file mode 100644
index 000000000..abc390b08
--- /dev/null
+++ 
b/tests/spec/arb_compute_variable_group_size/execution/separate-global-id-2.shader_test
@@ -0,0 +1,55 @@
+# Simple test that verifies gl_GlobalInvocationID derived values are
+# computed properly, even when the main shader has no size layout.
+
+[require]
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_compute_shader
+GL_ARB_compute_variable_group_size
+GL_ARB_shader_storage_buffer_object
+
+[compute shader]
+#version 330
+#extension GL_ARB_compute_shader: require
+#extension GL_ARB_shader_storage_buffer_object: require
+#extension GL_ARB_compute_variable_group_size: require
+
+layout(local_size_variable) in;
+
+layout(std430)
+buffer SSBO {
+       uvec2 id[4];
+};
+
+void go() {
+       uint g = gl_GlobalInvocationID.x;
+       uint l = gl_LocalInvocationID.x;
+       id[g] = uvec2(g, l);
+}
+
+[compute shader]
+#version 330
+#extension GL_ARB_compute_shader: require
+
+// no mention of variable group size in this shader
+
+void go();
+
+void main()
+{
+       go();
+}
+
+[test]
+ssbo 0 32
+
+compute group size 2 1 1 2 1 1
+
+probe ssbo uint 0  0 == 0
+probe ssbo uint 0  4 == 0
+probe ssbo uint 0  8 == 1
+probe ssbo uint 0 12 == 1
+probe ssbo uint 0 16 == 2
+probe ssbo uint 0 20 == 0
+probe ssbo uint 0 24 == 3
+probe ssbo uint 0 28 == 1

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

Reply via email to