[Piglit] [PATCH] Add tests for glEdgeFlag().
Eric Anholt
eric at anholt.net
Fri Jul 27 17:14:22 PDT 2012
---
tests/all.tests | 5 ++
tests/spec/CMakeLists.txt | 1 +
tests/spec/gl-1.0/CMakeLists.gl.txt | 15 +++++
tests/spec/gl-1.0/CMakeLists.txt | 1 +
tests/spec/gl-1.0/edgeflag-quads.c | 95 +++++++++++++++++++++++++++
tests/spec/gl-1.0/edgeflag.c | 77 ++++++++++++++++++++++
tests/spec/gl-2.0/CMakeLists.gl.txt | 1 +
tests/spec/gl-2.0/edgeflag.c | 124 +++++++++++++++++++++++++++++++++++
8 files changed, 319 insertions(+)
create mode 100644 tests/spec/gl-1.0/CMakeLists.gl.txt
create mode 100644 tests/spec/gl-1.0/CMakeLists.txt
create mode 100644 tests/spec/gl-1.0/edgeflag-quads.c
create mode 100644 tests/spec/gl-1.0/edgeflag.c
create mode 100644 tests/spec/gl-2.0/edgeflag.c
diff --git a/tests/all.tests b/tests/all.tests
index f9a09c5..3dd292e 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -858,6 +858,10 @@ add_plain_test(gl11, 'r300-readcache')
add_plain_test(gl11, 'tri-tex-crash')
add_plain_test(gl11, 'vbo-buffer-unmap')
+gl10 = Group()
+add_concurrent_test(gl10, 'gl-1.0-edgeflag')
+add_concurrent_test(gl10, 'gl-1.0-edgeflag-quads')
+
gl12 = Group()
spec['!OpenGL 1.2'] = gl12
add_texwrap_test1(gl12, '3D')
@@ -872,6 +876,7 @@ add_plain_test(gl14, 'tex1d-2dborder')
gl20 = Group()
spec['!OpenGL 2.0'] = gl20
+add_concurrent_test(gl20, 'gl-2.0-edgeflag')
add_texwrap_test2(gl20, '1D', 'npot')
add_texwrap_test3(gl20, '1D', 'npot', 'proj')
add_texwrap_test2(gl20, '2D', 'npot')
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 09ea171..6021492 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -41,6 +41,7 @@ add_subdirectory (glsl-1.10)
add_subdirectory (glsl-1.20)
add_subdirectory (glsl-1.30)
add_subdirectory (glsl-1.40)
+add_subdirectory (gl-1.0)
add_subdirectory (gl-2.0)
add_subdirectory (gl-2.1)
add_subdirectory (gl-3.0)
diff --git a/tests/spec/gl-1.0/CMakeLists.gl.txt b/tests/spec/gl-1.0/CMakeLists.gl.txt
new file mode 100644
index 0000000..db7fe01
--- /dev/null
+++ b/tests/spec/gl-1.0/CMakeLists.gl.txt
@@ -0,0 +1,15 @@
+include_directories(
+ ${GLEXT_INCLUDE_DIR}
+ ${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+ piglitutil_${piglit_target_api}
+ ${OPENGL_gl_LIBRARY}
+ ${OPENGL_glu_LIBRARY}
+)
+
+piglit_add_executable (gl-1.0-edgeflag edgeflag.c)
+piglit_add_executable (gl-1.0-edgeflag-quads edgeflag-quads.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/gl-1.0/CMakeLists.txt b/tests/spec/gl-1.0/CMakeLists.txt
new file mode 100644
index 0000000..4a012b9
--- /dev/null
+++ b/tests/spec/gl-1.0/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
\ No newline at end of file
diff --git a/tests/spec/gl-1.0/edgeflag-quads.c b/tests/spec/gl-1.0/edgeflag-quads.c
new file mode 100644
index 0000000..c1c20f2
--- /dev/null
+++ b/tests/spec/gl-1.0/edgeflag-quads.c
@@ -0,0 +1,95 @@
+/* Copyright © 2012 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.
+ */
+
+/** @file edgeflag.c
+ *
+ * Test for the glEdgeFlag() API working on GL_QUADs.
+ *
+ * There's a limitation in edge flag handling on Intel's gen6+
+ * hardware that it can't do edgeflag on lists of quads, so they must
+ * be broken down before submission to the hardware.
+ */
+
+#include "piglit-util-gl-common.h"
+#include "minmax-test.h"
+
+PIGLIT_GL_TEST_MAIN(
+ 32 /*window_width*/,
+ 32 /*window_height*/,
+ GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA)
+
+enum piglit_result
+piglit_display(void)
+{
+ bool pass = true;
+ float green[] = {0, 1, 0, 0};
+ float clear[] = {0, 0, 0, 0};
+
+ piglit_ortho_projection(piglit_width, piglit_height, false);
+
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
+ glClearColor(0.0, 0.0, 0.0, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glColor4f(0, 1, 0, 0);
+
+ /* Draw a rectangle, but set the flag to false for the verticals. */
+ glBegin(GL_QUADS);
+ glEdgeFlag(GL_TRUE);
+ glVertex2f(1.5, 1.5);
+ glEdgeFlag(GL_FALSE);
+ glVertex2f(5.5, 1.5);
+ glEdgeFlag(GL_TRUE);
+ glVertex2f(5.5, 5.5);
+ glEdgeFlag(GL_FALSE);
+ glVertex2f(1.5, 5.5);
+
+ glEdgeFlag(GL_TRUE);
+ glVertex2f(11.5, 1.5);
+ glEdgeFlag(GL_FALSE);
+ glVertex2f(15.5, 1.5);
+ glEdgeFlag(GL_TRUE);
+ glVertex2f(15.5, 5.5);
+ glEdgeFlag(GL_FALSE);
+ glVertex2f(11.5, 5.5);
+ glEnd();
+
+ pass = piglit_probe_pixel_rgba(3, 1, green) && pass;
+ pass = piglit_probe_pixel_rgba(3, 5, green) && pass;
+ pass = piglit_probe_pixel_rgba(1, 3, clear) && pass;
+ pass = piglit_probe_pixel_rgba(5, 3, clear) && pass;
+
+ pass = piglit_probe_pixel_rgba(13, 1, green) && pass;
+ pass = piglit_probe_pixel_rgba(13, 5, green) && pass;
+ pass = piglit_probe_pixel_rgba(11, 3, clear) && pass;
+ pass = piglit_probe_pixel_rgba(15, 3, clear) && pass;
+
+ piglit_present_results();
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+}
diff --git a/tests/spec/gl-1.0/edgeflag.c b/tests/spec/gl-1.0/edgeflag.c
new file mode 100644
index 0000000..a32e7dd
--- /dev/null
+++ b/tests/spec/gl-1.0/edgeflag.c
@@ -0,0 +1,77 @@
+/* Copyright © 2012 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.
+ */
+
+/** @file edgeflag.c
+ *
+ * Test for the glEdgeFlag() API working.
+ */
+
+#include "piglit-util-gl-common.h"
+#include "minmax-test.h"
+
+PIGLIT_GL_TEST_MAIN(
+ 32 /*window_width*/,
+ 32 /*window_height*/,
+ GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA)
+
+enum piglit_result
+piglit_display(void)
+{
+ bool pass = true;
+ float green[] = {0, 1, 0, 0};
+ float clear[] = {0, 0, 0, 0};
+
+ piglit_ortho_projection(piglit_width, piglit_height, false);
+
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
+ glClearColor(0.0, 0.0, 0.0, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glColor4f(0, 1, 0, 0);
+
+ /* Draw a rectangle, but set the flag to false for the verticals. */
+ glBegin(GL_POLYGON);
+ glEdgeFlag(GL_TRUE);
+ glVertex2f(1.5, 1.5);
+ glEdgeFlag(GL_FALSE);
+ glVertex2f(5.5, 1.5);
+ glEdgeFlag(GL_TRUE);
+ glVertex2f(5.5, 5.5);
+ glEdgeFlag(GL_FALSE);
+ glVertex2f(1.5, 5.5);
+ glEnd();
+
+ pass = piglit_probe_pixel_rgba(3, 1, green) && pass;
+ pass = piglit_probe_pixel_rgba(3, 5, green) && pass;
+ pass = piglit_probe_pixel_rgba(1, 3, clear) && pass;
+ pass = piglit_probe_pixel_rgba(5, 3, clear) && pass;
+
+ piglit_present_results();
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+}
diff --git a/tests/spec/gl-2.0/CMakeLists.gl.txt b/tests/spec/gl-2.0/CMakeLists.gl.txt
index fb8a82f..4fea1aa 100644
--- a/tests/spec/gl-2.0/CMakeLists.gl.txt
+++ b/tests/spec/gl-2.0/CMakeLists.gl.txt
@@ -11,3 +11,4 @@ link_libraries (
)
piglit_add_executable (vertex-program-two-side vertex-program-two-side.c)
+piglit_add_executable (gl-2.0-edgeflag edgeflag.c)
diff --git a/tests/spec/gl-2.0/edgeflag.c b/tests/spec/gl-2.0/edgeflag.c
new file mode 100644
index 0000000..fbf30c1
--- /dev/null
+++ b/tests/spec/gl-2.0/edgeflag.c
@@ -0,0 +1,124 @@
+/* Copyright © 2012 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.
+ */
+
+/** @file edgeflag.c
+ *
+ * Test for glEdgeFlagPointerv() API working with a GLSL program enabled.
+ *
+ * The i965 driver had a bug where edge flags didn't work under GLSL.
+ * We also use both gl_Vertex and a user attribute so that edge flags
+ * sit in the middle of the list of vertex attributes and results
+ * in Mesa.
+ */
+
+#include "piglit-util-gl-common.h"
+#include "minmax-test.h"
+
+PIGLIT_GL_TEST_MAIN(
+ 32 /*window_width*/,
+ 32 /*window_height*/,
+ GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA)
+
+static GLuint color_index;
+
+enum piglit_result
+piglit_display(void)
+{
+ bool pass = true;
+ float green[] = {0, 1, 0, 0};
+ float clear[] = {0.5, 0.5, 0.5, 0.5};
+ struct {
+ GLfloat x, y;
+ GLfloat r, g, b, a;
+ GLboolean edgeflag;
+ } verts[] = {
+ { 1.5, 1.5, 0.0, 1.0, 0.0, 0.0, GL_TRUE },
+ { 5.5, 1.5, 0.0, 1.0, 0.0, 0.0, GL_FALSE },
+ { 5.5, 5.5, 0.0, 1.0, 0.0, 0.0, GL_TRUE },
+ { 1.5, 5.5, 0.0, 1.0, 0.0, 0.0, GL_FALSE },
+ };
+
+ piglit_ortho_projection(piglit_width, piglit_height, false);
+
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
+ glClearColor(0.5, 0.5, 0.5, 0.5);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glColor4f(0, 1, 0, 0);
+
+ glVertexPointer(2, GL_FLOAT, sizeof(verts[0]), &verts[0].x);
+ glVertexAttribPointer(color_index, 4, GL_FLOAT, GL_FALSE,
+ sizeof(verts[0]), &verts[0].r);
+ glEdgeFlagPointer(sizeof(verts[0]), &verts[0].edgeflag);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableVertexAttribArray(color_index);
+ glEnableClientState(GL_EDGE_FLAG_ARRAY);
+
+ glDrawArrays(GL_POLYGON, 0, 4);
+
+ pass = piglit_probe_pixel_rgba(3, 1, green) && pass;
+ pass = piglit_probe_pixel_rgba(3, 5, green) && pass;
+ pass = piglit_probe_pixel_rgba(1, 3, clear) && pass;
+ pass = piglit_probe_pixel_rgba(5, 3, clear) && pass;
+
+ piglit_present_results();
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+const char *vs_source =
+ "attribute vec4 in_color;\n"
+ "varying vec4 color;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ " gl_Position = ftransform();\n"
+ " color = in_color;\n"
+ "}\n";
+
+const char *fs_source =
+ "varying vec4 color;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ " gl_FragColor = color;\n"
+ "}\n";
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLuint vs, fs, prog;
+
+ vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
+ fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);
+ prog = piglit_link_simple_program(vs, fs);
+
+ if (!prog || !vs || !fs) {
+ printf("VS source:\n%s", vs_source);
+ printf("FS source:\n%s", fs_source);
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ glUseProgram(prog);
+ color_index = glGetAttribLocation(prog, "in_color");
+}
--
1.7.10.4
More information about the Piglit
mailing list