[Piglit] [PATCH] glsl-1.50-execution-primitive-id-no-gs-first-vertex: First provoking vertex variation.

jfonseca at vmware.com jfonseca at vmware.com
Mon Dec 1 07:57:27 PST 2014


From: José Fonseca <jfonseca at vmware.com>

Adapt the primitive-id-no-gs-first test case to first provoking vertex
convention, exposing a bug in llvmpipe.
---
 tests/shaders/shader_runner.c                      | 15 ++++++
 .../primitive-id-no-gs-first-vertex.shader_test    | 63 ++++++++++++++++++++++
 2 files changed, 78 insertions(+)
 create mode 100644 tests/spec/glsl-1.50/execution/primitive-id-no-gs-first-vertex.shader_test

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 628ef44..fb498fb 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -1924,6 +1924,19 @@ set_patch_parameter(const char *line)
 #endif
 }
 
+void
+set_provoking_vertex(const char *line)
+{
+	if (string_match("first", line)) {
+		glProvokingVertexEXT(GL_FIRST_VERTEX_CONVENTION_EXT);
+	} else if (string_match("last", line)) {
+		glProvokingVertexEXT(GL_LAST_VERTEX_CONVENTION_EXT);
+	} else {
+		fprintf(stderr, "Unknown provoking vertex parameter `%s'\n", line);
+		piglit_report_result(PIGLIT_FAIL);
+	}
+}
+
 static const struct string_to_enum enable_table[] = {
 	{ "GL_CLIP_PLANE0", GL_CLIP_PLANE0 },
 	{ "GL_CLIP_PLANE1", GL_CLIP_PLANE1 },
@@ -2601,6 +2614,8 @@ piglit_display(void)
 			set_parameter(line + strlen("parameter "));
 		} else if (string_match("patch parameter ", line)) {
 			set_patch_parameter(line + strlen("patch parameter "));
+		} else if (string_match("provoking vertex ", line)) {
+			set_provoking_vertex(line + strlen("provoking vertex "));
 		} else if (string_match("link error", line)) {
 			link_error_expected = true;
 			if (link_ok) {
diff --git a/tests/spec/glsl-1.50/execution/primitive-id-no-gs-first-vertex.shader_test b/tests/spec/glsl-1.50/execution/primitive-id-no-gs-first-vertex.shader_test
new file mode 100644
index 0000000..dd97b0f
--- /dev/null
+++ b/tests/spec/glsl-1.50/execution/primitive-id-no-gs-first-vertex.shader_test
@@ -0,0 +1,63 @@
+# Check proper functioning of the gl_PrimitiveID fragment shader
+# input, in the case where there is no geometry shader, and provoking vertex
+# is set to first vertex.
+
+[require]
+GLSL >= 1.50
+GL_EXT_provoking_vertex
+
+[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        1
+   *  1             0 2 3        2
+   *  2             0 3 4        3
+   *  3             0 4 5        4
+   *
+   * 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 - 1;
+  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
+provoking vertex first
+draw arrays GL_TRIANGLE_FAN 0 6
+probe all rgba 0.0 1.0 0.0 1.0
-- 
2.1.0



More information about the Piglit mailing list