[Piglit] [PATCH piglit] Add a test using gl_VertexID with glPolygonMode(GL_POINT)

Neil Roberts neil at linux.intel.com
Thu Oct 23 11:59:01 PDT 2014


This currently exposes a bug in the i965 driver.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84677
---
 tests/all.py                    |   1 +
 tests/general/CMakeLists.gl.txt |   1 +
 tests/general/point-vertex-id.c | 154 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 156 insertions(+)
 create mode 100644 tests/general/point-vertex-id.c

diff --git a/tests/all.py b/tests/all.py
index 17d6689..d343f15 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -506,6 +506,7 @@ add_concurrent_test(shaders, 'useprogram-refcount-1')
 add_concurrent_test(shaders, 'useshaderprogram-bad-type')
 add_concurrent_test(shaders, 'useshaderprogram-bad-program')
 add_concurrent_test(shaders, 'useshaderprogram-flushverts-1')
+add_concurrent_test(shaders, 'point-vertex-id')
 for subtest in ('interstage', 'intrastage', 'vs-gs'):
     cmdline = 'version-mixing {0}'.format(subtest)
     shaders[cmdline] = PiglitGLTest(cmdline, run_concurrent=True)
diff --git a/tests/general/CMakeLists.gl.txt b/tests/general/CMakeLists.gl.txt
index 5917df2..f0a25bc 100644
--- a/tests/general/CMakeLists.gl.txt
+++ b/tests/general/CMakeLists.gl.txt
@@ -85,6 +85,7 @@ piglit_add_executable (pbo-teximage pbo-teximage.c)
 piglit_add_executable (pbo-teximage-tiling pbo-teximage-tiling.c)
 piglit_add_executable (pbo-teximage-tiling-2 pbo-teximage-tiling-2.c)
 piglit_add_executable (point-line-no-cull point-line-no-cull.c)
+piglit_add_executable (point-vertex-id point-vertex-id.c)
 piglit_add_executable (polygon-mode-offset polygon-mode-offset.c)
 piglit_add_executable (polygon-mode polygon-mode.c)
 piglit_add_executable (polygon-offset polygon-offset.c)
diff --git a/tests/general/point-vertex-id.c b/tests/general/point-vertex-id.c
new file mode 100644
index 0000000..f20dfcc
--- /dev/null
+++ b/tests/general/point-vertex-id.c
@@ -0,0 +1,154 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util-gl.h"
+
+/**
+ * @file draw-sync.c
+ *
+ * Tests glPolygonMode(GL_POINT) used in combination with gl_VertexID.
+ * See bug #84677
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 20;
+
+	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char
+vertex_shader[] =
+	"#version 130\n"
+	"\n"
+	"uniform vec2 pos[6];\n"
+	"\n"
+	"void\n"
+	"main()\n"
+	"{\n"
+	"        gl_Position = vec4(pos[gl_VertexID], 0.0, 1.0);\n"
+	"        gl_FrontColor = vec4(1.0);\n"
+	"}\n";
+
+struct vertex {
+	int x, y;
+	GLubyte edge_flag;
+};
+
+static const struct vertex
+vertices[] = {
+	{ 10, 10, GL_TRUE },
+	{ 20, 10, GL_TRUE },
+	{ 10, 20, GL_TRUE },
+	/* This triangle won't be drawn because none of the vertices
+	 * are an edge */
+	{ 30, 10, GL_FALSE },
+	{ 40, 10, GL_FALSE },
+	{ 30, 20, GL_FALSE },
+};
+
+enum piglit_result
+piglit_display(void)
+{
+	bool pass = true;
+	float black[4] = {0.0, 0.0, 0.0, 0.0};
+	float white[4] = {1.0, 1.0, 1.0, 1.0};
+	char uniform_name[16];
+	GLint uniform_location;
+	GLuint program;
+	int i;
+
+	program = piglit_build_simple_program(vertex_shader, NULL);
+
+	glUseProgram(program);
+
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	for (i = 0; i < ARRAY_SIZE(vertices); i++) {
+		sprintf(uniform_name, "pos[%i]", i);
+		uniform_location = glGetUniformLocation(program, uniform_name);
+		glUniform2f(uniform_location,
+			    (vertices[i].x + 0.5f) * 2.0f /
+			    piglit_width - 1.0f,
+			    (vertices[i].y + 0.5f) * 2.0f /
+			    piglit_height - 1.0f);
+	}
+
+	glEnableClientState(GL_EDGE_FLAG_ARRAY);
+	glEdgeFlagPointer(sizeof (struct vertex),
+			  &vertices[0].edge_flag);
+
+	glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
+	glDrawArrays(GL_TRIANGLES, 0, 6);
+
+	/* Area below the dots */
+	pass = pass && piglit_probe_rect_rgba(0, 0,
+					      piglit_width,
+					      vertices[0].y,
+					      black);
+	/* Left of the dots */
+	pass = pass && piglit_probe_rect_rgba(0, vertices[0].y,
+					      vertices[0].x,
+					      vertices[1].y - vertices[0].y + 1,
+					      black);
+	/* In-between the dots */
+	pass = pass && piglit_probe_rect_rgba(vertices[0].x + 1,
+					      vertices[0].y,
+					      vertices[1].x - vertices[0].x - 1,
+					      vertices[1].y - vertices[0].y + 1,
+					      black);
+	/* Right of the dots */
+	pass = pass && piglit_probe_rect_rgba(vertices[1].x + 1,
+					      vertices[0].y,
+					      piglit_width - vertices[1].x - 1,
+					      vertices[1].y - vertices[0].y + 1,
+					      black);
+	/* Above the dots */
+	pass = pass && piglit_probe_rect_rgba(0, vertices[2].y + 1,
+					      piglit_width,
+					      piglit_height - vertices[2].y - 1,
+					      black);
+
+	/* At the dots */
+	for (i = 0; i < ARRAY_SIZE(vertices); i++) {
+		if (vertices[i].edge_flag) {
+			pass = pass && piglit_probe_pixel_rgba(vertices[i].x,
+							       vertices[i].y,
+							       white);
+		}
+	}
+
+	glUseProgram(0);
+	glDeleteProgram(program);
+
+	piglit_present_results();
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_GLSL_version(130);
+}
-- 
1.9.3



More information about the Piglit mailing list