[Piglit] [PATCH] Test that the fs gl_PrimitiveID input works even when there's no gs.
Paul Berry
stereotype441 at gmail.com
Wed Oct 23 05:45:54 CEST 2013
For i965/gen7 hardware, the driver has to go to extra work to make
gl_PrimitiveID work in the case where there is no geometry shader. So
we need a separate test to make sure that works properly.
---
.../execution/primitive-id-no-gs.shader_test | 60 ++++++++++++++++++++++
1 file changed, 60 insertions(+)
create mode 100644 tests/spec/glsl-1.50/execution/primitive-id-no-gs.shader_test
diff --git a/tests/spec/glsl-1.50/execution/primitive-id-no-gs.shader_test b/tests/spec/glsl-1.50/execution/primitive-id-no-gs.shader_test
new file mode 100644
index 0000000..7f89a8a
--- /dev/null
+++ b/tests/spec/glsl-1.50/execution/primitive-id-no-gs.shader_test
@@ -0,0 +1,60 @@
+# Check proper functioning of the gl_PrimitiveID fragment shader
+# input, in the case where there is no geometry shader.
+
+[require]
+GLSL >= 1.50
+
+[vertex shader]
+#version 150
+
+in vec4 piglit_vertex;
+flat out int vertex_id;
+
+void main()
+{
+ gl_Position = piglit_vertex;
+ vertex_id = gl_VertexID;
+}
+
+[fragment shader]
+#version 150
+
+flat in int vertex_id;
+
+void main()
+{
+ /* We draw a triangle fan containing 6 vertices, so the relationship between
+ * the primitive ID and the input vertex ID's should be:
+ *
+ * Primitive ID Vertex ID's Provoking vertex ID
+ * 0 0 1 2 2
+ * 1 0 2 3 3
+ * 2 0 3 4 4
+ * 3 0 4 5 5
+ *
+ * Since vertex_id uses interpolation qualifier "flat", it should
+ * always receive the value from the provoking vertex. Therefore,
+ * by the table above, it should always be 2 greater than the
+ * expected value of gl_PrimitiveID.
+ */
+ int expected_primitive_id = vertex_id - 2;
+ if (expected_primitive_id == gl_PrimitiveID)
+ gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+ else
+ gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[vertex data]
+piglit_vertex/float/2
+-1.0 -1.0
+-1.0 1.0
+ 0.0 1.0
+ 1.0 1.0
+ 1.0 0.0
+ 1.0 -1.0
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+draw arrays GL_TRIANGLE_FAN 0 6
+probe all rgba 0.0 1.0 0.0 1.0
--
1.8.4.1
More information about the Piglit
mailing list