[Piglit] [PATCH 6/6] arb_shader_ballot: test peeling away the first invocation

Nicolai Hähnle nhaehnle at gmail.com
Fri Mar 31 17:02:28 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at 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



More information about the Piglit mailing list