[Piglit] [PATCH 1/3] glx-visuals-depth: New test for basic depth functionality per visual.

Eric Anholt eric at anholt.net
Tue Jan 17 11:00:07 PST 2012


There have been concerns that some changes in the intel driver might
break specific visuals.
---
 tests/all.tests               |    1 +
 tests/glx/CMakeLists.gl.txt   |    1 +
 tests/glx/glx-visuals-depth.c |  104 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 106 insertions(+), 0 deletions(-)
 create mode 100644 tests/glx/glx-visuals-depth.c

diff --git a/tests/all.tests b/tests/all.tests
index bee985d..b1cc91e 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -603,6 +603,7 @@ glx['glx-pixmap13-life'].runConcurrent = True
 add_plain_test(glx, 'glx-pixmap-multi')
 glx['glx-pixmap-multi'].runConcurrent = True
 add_plain_test(glx, 'glx-tfp')
+add_plain_test(glx, 'glx-visuals-depth')
 add_plain_test(glx, 'glx-visuals-stencil')
 add_plain_test(glx, 'glx-window-life')
 glx['glx-window-life'].runConcurrent = True
diff --git a/tests/glx/CMakeLists.gl.txt b/tests/glx/CMakeLists.gl.txt
index 66a46ce..c20bec7 100644
--- a/tests/glx/CMakeLists.gl.txt
+++ b/tests/glx/CMakeLists.gl.txt
@@ -49,6 +49,7 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
 	add_executable (glx-pixmap-multi glx-pixmap-multi.c)
 	add_executable (glx-pixmap-crosscheck glx-pixmap-crosscheck.c)
 
+	add_executable (glx-visuals-depth glx-visuals-depth.c)
 	add_executable (glx-visuals-stencil glx-visuals-stencil.c)
 
 	add_executable (glx-copy-sub-buffer glx-copy-sub-buffer.c)
diff --git a/tests/glx/glx-visuals-depth.c b/tests/glx/glx-visuals-depth.c
new file mode 100644
index 0000000..3d9259c
--- /dev/null
+++ b/tests/glx/glx-visuals-depth.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright © 2011 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.
+ *
+ * Authors:
+ *    Eric Anholt <eric at anholt.net>
+ *
+ */
+
+/**
+ * @file glx-visuals-depth.c
+ *
+ * Tests that when a depth buffer is reported as present in the GLX
+ * visual that it behaves appropriately (can set a value in it with
+ * drawing, and use the depth test on that value), and that when a
+ * depth buffer is not present the depth test always passes even
+ * if we try to enable it.
+ */
+
+#include "piglit-util.h"
+#include "piglit-glx-util.h"
+
+int piglit_width = 20;
+int piglit_height = 20;
+
+enum piglit_result
+draw(Display *dpy, GLXFBConfig config)
+{
+	int dbits;
+	float green[3] = {0.0, 1.0, 0.0};
+	float blue[3] = {0.0, 0.0, 1.0};
+	float *left, *right;
+	bool pass = true;
+
+	glXGetFBConfigAttrib(dpy, config, GLX_DEPTH_SIZE, &dbits);
+
+	piglit_ortho_projection(piglit_width, piglit_height, false);
+
+	glEnable(GL_DEPTH_TEST);
+	glDepthFunc(GL_ALWAYS);
+
+	/* Set half the FB to depth 0, half to 1, and everything blue */
+	glColor3fv(blue);
+	piglit_draw_rect_z(1.0,
+			   0, 0,
+			   piglit_width / 2, piglit_height);
+	piglit_draw_rect_z(0.0,
+			   piglit_width / 2, 0,
+			   piglit_width, piglit_height);
+
+	/* Now draw a rect trying to set just the 1 values to green. */
+	glColor3fv(green);
+	glDepthFunc(GL_LESS);
+	piglit_draw_rect_z(0.5,
+			   0, 0, piglit_width, piglit_height);
+
+	/* If there was a depth buffer, then we get half the window
+	 * set to green.  Otherwise, the depth test always passes
+	 * and the whole thing should have been set green.
+	 */
+	if (dbits) {
+		left = blue;
+		right = green;
+	} else {
+		left = green;
+		right = green;
+	}
+
+	pass = pass && piglit_probe_rect_rgb(0, 0,
+					     piglit_width / 2, piglit_height,
+					     left);
+	pass = pass && piglit_probe_rect_rgb(piglit_width / 2, 0,
+					     piglit_width - piglit_width / 2,
+					     piglit_height,
+					     right);
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+int
+main(int argc, char **argv)
+{
+	piglit_report_result(piglit_glx_iterate_visuals(draw));
+
+	return 0;
+}
-- 
1.7.7.3



More information about the Piglit mailing list