[Piglit] [PATCH] ARB_vertex_program: Test interaction with fixed-function when VP is disabled

Ian Romanick idr at freedesktop.org
Thu Apr 5 12:38:30 PDT 2012


From: Ian Romanick <ian.d.romanick at intel.com>

While doing some work on Mesa, I accidentally introduced a bug in this
area.  I was surprised that we didn't already have a test.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 tests/all.tests                                    |    1 +
 tests/spec/arb_vertex_program/CMakeLists.gl.txt    |    1 +
 .../ff_interaction-vp_disabled.c                   |   98 ++++++++++++++++++++
 3 files changed, 100 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/arb_vertex_program/ff_interaction-vp_disabled.c

diff --git a/tests/all.tests b/tests/all.tests
index 0cf81da..a36468e 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1259,6 +1259,7 @@ arb_vertex_buffer_object['mixed-immediate-and-vbo'] = PlainExecTest(['arb_vertex
 
 arb_vertex_program = Group()
 spec['ARB_vertex_program'] = arb_vertex_program
+arb_vertex_program['Fixed-function interaction: Disable vertex program'] = concurrent_test('arb_vertex_program-ff_interaction-vp_disabled')
 arb_vertex_program['getenv4d-with-error'] = PlainExecTest(['arb_vertex_program-getenv4d-with-error', '-auto'])
 arb_vertex_program['getlocal4d-with-error'] = PlainExecTest(['arb_vertex_program-getlocal4d-with-error', '-auto'])
 arb_vertex_program['clip-plane-transformation arb'] = concurrent_test('clip-plane-transformation arb')
diff --git a/tests/spec/arb_vertex_program/CMakeLists.gl.txt b/tests/spec/arb_vertex_program/CMakeLists.gl.txt
index a6e6252..a912193 100644
--- a/tests/spec/arb_vertex_program/CMakeLists.gl.txt
+++ b/tests/spec/arb_vertex_program/CMakeLists.gl.txt
@@ -11,6 +11,7 @@ link_libraries (
 	${GLUT_glut_LIBRARY}
 )
 
+piglit_add_executable (arb_vertex_program-ff_interaction-vp_disabled ff_interaction-vp_disabled.c)
 piglit_add_executable (arb_vertex_program-getenv4d-with-error getenv4d-with-error.c)
 piglit_add_executable (arb_vertex_program-getlocal4d-with-error getlocal4d-with-error.c)
 piglit_add_executable (arb_vertex_program-minmax minmax.c)
diff --git a/tests/spec/arb_vertex_program/ff_interaction-vp_disabled.c b/tests/spec/arb_vertex_program/ff_interaction-vp_disabled.c
new file mode 100644
index 0000000..74f581a
--- /dev/null
+++ b/tests/spec/arb_vertex_program/ff_interaction-vp_disabled.c
@@ -0,0 +1,98 @@
+/*
+ * 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 ff_interaction-vp_disabled.c
+ *
+ * Test interactions with fixed-function.  Compile and configure a vertex
+ * shader, but disable it.  Rendering should use fixed function instead.
+ */
+
+#include "piglit-util.h"
+
+int piglit_width = 64, piglit_height = 64;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+static const char vp_code[] =
+	"!!ARBvp1.0\n"
+	"MOV	result.position, vertex.position;"
+	"MOV	result.color, {1., 0., 0., 1.};"
+	"END"
+	;
+
+enum piglit_result
+piglit_display(void)
+{
+	static const float red[4] = { 1.0, 0.0, 0.0, 1.0 };
+	static const float green[4] = { 0.0, 1.0, 0.0, 1.0 };
+	bool pass;
+
+	glColor3f(0.0, 1.0, 0.0);
+
+	glEnable(GL_VERTEX_PROGRAM_ARB);
+	glBegin(GL_TRIANGLE_FAN);
+	glVertex2f(-1.0, -1.0);
+	glVertex2f(-1.0,  1.0);
+	glVertex2f( 0.0,  1.0);
+	glVertex2f( 0.0, -1.0);
+	glEnd();
+
+	glDisable(GL_VERTEX_PROGRAM_ARB);
+	glBegin(GL_TRIANGLE_FAN);
+	glVertex2f( 0.0, -1.0);
+	glVertex2f( 0.0,  1.0);
+	glVertex2f( 1.0,  1.0);
+	glVertex2f( 1.0, -1.0);
+	glEnd();
+
+	pass = piglit_probe_rect_rgb(0,
+				     0,
+				     piglit_width / 2,
+				     piglit_height / 2,
+				     red)
+		&& piglit_probe_rect_rgb(piglit_width / 2,
+					 piglit_height / 2,
+					 piglit_width / 2,
+					 piglit_height / 2,
+					 green);
+
+	piglit_present_results();
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_extension("GL_ARB_vertex_program");
+
+	glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 1);
+	glProgramStringARB(GL_VERTEX_PROGRAM_ARB,
+			   GL_PROGRAM_FORMAT_ASCII_ARB,
+			   strlen(vp_code),
+			   vp_code);
+
+	glMatrixMode(GL_PROJECTION);
+	glLoadIdentity();
+	glMatrixMode(GL_MODELVIEW);
+	glLoadIdentity();
+}
-- 
1.7.6.5



More information about the Piglit mailing list