summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2014-10-23 17:05:59 +0100
committerNeil Roberts <neil@linux.intel.com>2014-11-17 14:24:50 +0000
commit4c3fbba18ab0438c042075280aa817179ef3a719 (patch)
treebd7763a68b6c0c45c1be140c6805ecf7747bdd36
parente0c0726dc3c0ccfcc3bb11db34ae430dde2e2498 (diff)
Add a test using gl_VertexID with glPolygonMode(GL_POINT)
This currently exposes a bug in the i965 driver. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84677
-rw-r--r--tests/all.py1
-rw-r--r--tests/general/CMakeLists.gl.txt1
-rw-r--r--tests/general/point-vertex-id.c153
3 files changed, 155 insertions, 0 deletions
diff --git a/tests/all.py b/tests/all.py
index f2c5c1f14..776630a62 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -496,6 +496,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 8ec536c88..cf340974b 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 000000000..72aef03c9
--- /dev/null
+++ b/tests/general/point-vertex-id.c
@@ -0,0 +1,153 @@
+/*
+ * 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 point-vertex-id.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};
+ GLint pos_location;
+ GLuint program;
+ int i;
+
+ program = piglit_build_simple_program(vertex_shader, NULL);
+
+ glUseProgram(program);
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ pos_location = glGetUniformLocation(program, "pos");
+
+ for (i = 0; i < ARRAY_SIZE(vertices); i++) {
+ glUniform2f(pos_location + i,
+ (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, ARRAY_SIZE(vertices));
+
+ /* 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);
+}