[Piglit] [PATCH] colormaterial-query test

Tapani Pälli tapani.palli at intel.com
Tue May 22 23:01:40 PDT 2012


introduce a new test which checks that GL_COLOR_MATERIAL state
does not get lost with sequential queries.

Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
---
 tests/all.tests                     |    1 +
 tests/general/CMakeLists.gl.txt     |    1 +
 tests/general/colormaterial-query.c |   80 +++++++++++++++++++++++++++++++++++
 3 files changed, 82 insertions(+), 0 deletions(-)
 create mode 100644 tests/general/colormaterial-query.c

diff --git a/tests/all.tests b/tests/all.tests
index 59d2983..5286f55 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -260,6 +260,7 @@ add_plain_test(general, 'dlist-fdo3129-01')
 add_plain_test(general, 'dlist-fdo3129-02')
 add_plain_test(general, 'dlist-fdo31590')
 add_plain_test(general, 'draw-arrays-colormaterial')
+add_plain_test(general, 'colormaterial-query')
 add_plain_test(general, 'draw-batch')
 add_plain_test(general, 'draw-copypixels-sync')
 add_plain_test(general, 'draw-elements')
diff --git a/tests/general/CMakeLists.gl.txt b/tests/general/CMakeLists.gl.txt
index 2c93b56..5929d3b 100644
--- a/tests/general/CMakeLists.gl.txt
+++ b/tests/general/CMakeLists.gl.txt
@@ -31,6 +31,7 @@ piglit_add_executable (depth_clamp depth_clamp.c)
 piglit_add_executable (depthfunc depthfunc.c)
 piglit_add_executable (depthrange-clear depthrange-clear.c)
 piglit_add_executable (draw-arrays-colormaterial draw-arrays-colormaterial.c)
+piglit_add_executable (colormaterial-query colormaterial-query.c)
 piglit_add_executable (draw-batch draw-batch.c)
 piglit_add_executable (draw-copypixels-sync draw-copypixels-sync.c)
 piglit_add_executable (draw-elements draw-elements.c)
diff --git a/tests/general/colormaterial-query.c b/tests/general/colormaterial-query.c
new file mode 100644
index 0000000..4934dca
--- /dev/null
+++ b/tests/general/colormaterial-query.c
@@ -0,0 +1,80 @@
+/*
+ * 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 colormaterial-query.c
+ * Test sequential calls to glMaterialfv and glGetMaterialfv
+ *
+ * This test exercises a Mesa bug where 2 sequential queries with
+ * glGetMaterialfv get wrong result.
+ *
+ * \author Tapani Pälli <tapani.palli at intel.com>
+ */
+
+#include "piglit-util.h"
+
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGBA | GLUT_ALPHA | GLUT_DOUBLE;
+
+enum piglit_result
+piglit_display(void)
+{
+	static const GLfloat ambient[4] = { 0.6f, 0.6f, 0.6f, 1.0f};
+	static const GLfloat color[4] = { 1.0f, 0.0f, 0.0f, 1.0f};
+	static GLfloat result[4];
+
+	GLboolean pass = GL_TRUE;
+
+	glEnable(GL_COLOR_MATERIAL);
+	glEnable(GL_LIGHTING);
+
+	/* set a color */
+	glColor4f(color[0], color[1], color[2], color[3]);
+
+	/* 1st query that works */
+	glMaterialfv(GL_FRONT, GL_AMBIENT, ambient);
+	glGetMaterialfv(GL_FRONT, GL_AMBIENT, (GLfloat*)result);
+
+	if(memcmp(color, result, sizeof(&color)) != 0)
+		pass = GL_FALSE;
+
+	/* 2nd query that fails if the bug exists */
+	glMaterialfv(GL_FRONT, GL_AMBIENT, ambient);
+	glGetMaterialfv(GL_FRONT, GL_AMBIENT, (GLfloat*)result);
+
+	if(memcmp(color, result, sizeof(&color)) != 0)
+		pass = GL_FALSE;
+
+	glDisable(GL_LIGHTING);
+	glDisable(GL_COLOR_MATERIAL);
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+	/* nop */
+}
-- 
1.7.7.6



More information about the Piglit mailing list