From: Nicolai Hähnle <nicolai.haeh...@amd.com>

---
 .../fs-readFirstInvocation-uint-if.shader_test     | 32 ++++++++++++++
 .../fs-readFirstInvocation-uint-loop.shader_test   | 49 ++++++++++++++++++++++
 2 files changed, 81 insertions(+)
 create mode 100644 
tests/spec/arb_shader_ballot/execution/fs-readFirstInvocation-uint-if.shader_test
 create mode 100644 
tests/spec/arb_shader_ballot/execution/fs-readFirstInvocation-uint-loop.shader_test

diff --git 
a/tests/spec/arb_shader_ballot/execution/fs-readFirstInvocation-uint-if.shader_test
 
b/tests/spec/arb_shader_ballot/execution/fs-readFirstInvocation-uint-if.shader_test
new file mode 100644
index 0000000..0c63436
--- /dev/null
+++ 
b/tests/spec/arb_shader_ballot/execution/fs-readFirstInvocation-uint-if.shader_test
@@ -0,0 +1,32 @@
+[require]
+GL >= 3.2
+GLSL >= 1.50
+GL_ARB_shader_ballot
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 150
+#extension GL_ARB_shader_ballot : require
+
+out vec4 outcolor;
+
+void main() {
+       uint first_invocation = 
readFirstInvocationARB(gl_SubGroupInvocationARB);
+
+       outcolor = vec4(0.0, 1.0, 0.0, 1.0);
+
+       if (first_invocation != gl_SubGroupInvocationARB) {
+               uint new_first_invocation = 
readFirstInvocationARB(gl_SubGroupInvocationARB);
+
+               if (first_invocation == new_first_invocation)
+                       outcolor = vec4(1.0, 0.0, first_invocation / 255.0, 
gl_SubGroupInvocationARB / 255.0);
+       }
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
diff --git 
a/tests/spec/arb_shader_ballot/execution/fs-readFirstInvocation-uint-loop.shader_test
 
b/tests/spec/arb_shader_ballot/execution/fs-readFirstInvocation-uint-loop.shader_test
new file mode 100644
index 0000000..d1f98f4
--- /dev/null
+++ 
b/tests/spec/arb_shader_ballot/execution/fs-readFirstInvocation-uint-loop.shader_test
@@ -0,0 +1,49 @@
+[require]
+GL >= 3.2
+GLSL >= 1.50
+GL_ARB_shader_ballot
+GL_ARB_gpu_shader_int64
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 150
+#extension GL_ARB_shader_ballot : require
+#extension GL_ARB_gpu_shader_int64 : require
+
+out vec4 outcolor;
+
+void main() {
+       uint64_t active_set = ballotARB(true);
+       int i;
+
+       int num_active = 0;
+       for (i = 0; i < 64; ++i) {
+               if ((active_set & (1ul << i)) != 0ul)
+                       num_active++;
+       }
+
+       /* This loop should terminate even without the loop condition. We simply
+        * add the condition here to ensure termination when there are shader
+        * compiler bugs.
+        */
+       for (i = 0; i < num_active; ++i) {
+               uint first_invocation = 
readFirstInvocationARB(gl_SubGroupInvocationARB);
+
+               if (first_invocation == gl_SubGroupInvocationARB)
+                       break;
+       }
+
+       if (i >= num_active) {
+               outcolor = vec4(1.0, 0.0, i / 255.0, gl_SubGroupInvocationARB / 
255.0);
+       } else {
+               outcolor = vec4(0.0, 1.0, 0.0, 1.0);
+       }
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
-- 
2.9.3

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

Reply via email to