[Piglit] [PATCH 06/10] arb_tessellation_shader: add tests to exercise gl_PrimitiveID

Marek Olšák maraeo at gmail.com
Mon Jul 27 17:02:35 PDT 2015


From: Chris Forbes <chrisf at ijw.co.nz>

v2: fixed by Marek

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
---
 .../execution/tcs-primitiveid.shader_test          | 72 ++++++++++++++++++++++
 .../execution/tes-primitiveid.shader_test          | 68 ++++++++++++++++++++
 2 files changed, 140 insertions(+)
 create mode 100644 tests/spec/arb_tessellation_shader/execution/tcs-primitiveid.shader_test
 create mode 100644 tests/spec/arb_tessellation_shader/execution/tes-primitiveid.shader_test

diff --git a/tests/spec/arb_tessellation_shader/execution/tcs-primitiveid.shader_test b/tests/spec/arb_tessellation_shader/execution/tcs-primitiveid.shader_test
new file mode 100644
index 0000000..0aea046
--- /dev/null
+++ b/tests/spec/arb_tessellation_shader/execution/tcs-primitiveid.shader_test
@@ -0,0 +1,72 @@
+# Test the gl_PrimitiveID input in the TCS.
+
+[require]
+GLSL >= 1.50
+GL_ARB_tessellation_shader
+GL_ARB_shader_atomic_counters
+
+[vertex shader]
+#version 150
+
+out int id;
+
+void main()
+{
+	id = gl_VertexID;
+}
+
+[tessellation control shader]
+#version 150
+#extension GL_ARB_tessellation_shader : require
+#extension GL_ARB_shader_atomic_counters: require
+
+layout(vertices = 4) out;
+in int id[];
+
+layout(binding=0) uniform atomic_uint matches;
+layout(binding=0, offset=4) uniform atomic_uint mismatches;
+
+void main()
+{
+	/* we have single-vertex patches. primitive id == vertex id */
+	if (id[0] == gl_PrimitiveID)
+		atomicCounterIncrement(matches);
+	else
+		atomicCounterIncrement(mismatches);
+
+	/* cull the patch */
+	gl_TessLevelInner[0] = 0.0;
+	gl_TessLevelInner[1] = 0.0;
+
+	gl_TessLevelOuter[0] = 0.0;
+	gl_TessLevelOuter[1] = 0.0;
+	gl_TessLevelOuter[2] = 0.0;
+	gl_TessLevelOuter[3] = 0.0;
+}
+
+[tessellation evaluation shader]
+#version 150
+#extension GL_ARB_tessellation_shader : require
+
+layout(quads, equal_spacing) in;
+
+void main()
+{
+	gl_Position = vec4(0);
+}
+
+[fragment shader]
+#version 150
+
+void main()
+{
+	gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+}
+
+[test]
+atomic counters 2
+patch parameter vertices 1
+draw arrays GL_PATCHES 0 4
+
+probe atomic counter 0 == 16
+probe atomic counter 1 == 0
diff --git a/tests/spec/arb_tessellation_shader/execution/tes-primitiveid.shader_test b/tests/spec/arb_tessellation_shader/execution/tes-primitiveid.shader_test
new file mode 100644
index 0000000..2ff96d3
--- /dev/null
+++ b/tests/spec/arb_tessellation_shader/execution/tes-primitiveid.shader_test
@@ -0,0 +1,68 @@
+# Test the gl_PrimitiveID input in the TES.
+
+[require]
+GLSL >= 1.50
+GL_ARB_tessellation_shader
+GL_ARB_shader_atomic_counters
+
+[vertex shader passthrough]
+
+[tessellation control shader]
+#version 150
+#extension GL_ARB_tessellation_shader : require
+
+layout(vertices = 1) out;
+patch out int id;
+
+void main()
+{
+	id = gl_PrimitiveID;
+
+	gl_TessLevelInner[0] = 1.0;
+	gl_TessLevelInner[1] = 1.0;
+
+	gl_TessLevelOuter[0] = 1.0;
+	gl_TessLevelOuter[1] = 1.0;
+	gl_TessLevelOuter[2] = 1.0;
+	gl_TessLevelOuter[3] = 1.0;
+}
+
+[tessellation evaluation shader]
+#version 150
+#extension GL_ARB_tessellation_shader : require
+#extension GL_ARB_shader_atomic_counters: require
+
+layout(quads, equal_spacing) in;
+patch in int id;
+
+layout(binding=0) uniform atomic_uint matches;
+layout(binding=0, offset=4) uniform atomic_uint mismatches;
+
+void main()
+{
+	gl_Position = vec4(0);
+
+	/* primitive ID observed in TES should be the same as in TCS */
+	if (id == gl_PrimitiveID)
+		atomicCounterIncrement(matches);
+	else
+		atomicCounterIncrement(mismatches);
+
+}
+
+[fragment shader]
+#version 150
+
+void main()
+{
+	gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+}
+
+[test]
+atomic counters 2
+patch parameter vertices 1
+draw arrays GL_PATCHES 0 4
+
+probe atomic counter 0 == 16
+probe atomic counter 1 == 0
+
-- 
2.1.4



More information about the Piglit mailing list