[Piglit] [PATCH] Triangles should be clipped to the clip volume and therefore shouldn't end up being rasterized outside the viewport.

Stuart Abercrombie sabercrombie at chromium.org
Mon Nov 12 13:21:12 PST 2012


This was failing on Sandy Bridge with guard band clipping enabled.

v2 with a new name, more comments and addition to all.tests.

Reviewed-by: Brian Paul <brianp at vmware.com>
---
 tests/all.tests                             |    1 +
 tests/general/CMakeLists.gl.txt             |    1 +
 tests/general/triangle-guardband-viewport.c |   62 +++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 0 deletions(-)
 create mode 100644 tests/general/triangle-guardband-viewport.c

diff --git a/tests/all.tests b/tests/all.tests
index 0a8a5aa..954a96c 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -556,6 +556,7 @@ add_plain_test(gl11, 'streaming-texture-leak')
 add_plain_test(gl11, 'texredefine')
 add_plain_test(gl11, 'texsubimage')
 add_plain_test(gl11, 'texture-al')
+add_plain_test(gl11, 'triangle-guardband-viewport')
 
 gl10 = Group()
 spec['!OpenGL 1.0'] = gl10
diff --git a/tests/general/CMakeLists.gl.txt b/tests/general/CMakeLists.gl.txt
index 11da25f..a26371c 100644
--- a/tests/general/CMakeLists.gl.txt
+++ b/tests/general/CMakeLists.gl.txt
@@ -134,5 +134,6 @@ piglit_add_executable (occlusion-query-discard occlusion-query-discard.c)
 piglit_add_executable (quad-invariance quad-invariance.c)
 piglit_add_executable (clear-accum clear-accum.c)
 piglit_add_executable (vs-point_size-zero vs-point_size-zero.c)
+piglit_add_executable (triangle-guardband-viewport triangle-guardband-viewport.c)
 
 # vim: ft=cmake:
diff --git a/tests/general/triangle-guardband-viewport.c b/tests/general/triangle-guardband-viewport.c
new file mode 100644
index 0000000..fcd11fe
--- /dev/null
+++ b/tests/general/triangle-guardband-viewport.c
@@ -0,0 +1,62 @@
+/** @file triangle-guardband-vewport.c
+ *
+ * Tests whether clipping of triangles to the clip volume
+ * is reflected in what is rasterized. Specifically,
+ * triangles (unlike some other primitives) should not be
+ * rasterized outside the viewport extents because they should
+ * have been clipped to the clip volume mapping to the viewport.
+ *
+ * Faulty guard-band clipping optimizations have been known to
+ * not honor this requirement.
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+
+	config.window_width = 100;
+	config.window_height = 100;
+	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	GLboolean pass = GL_TRUE;
+	static float green[] = {0.0, 1.0, 0.0, 0.0};
+	static float blue[]  = {0.0, 0.0, 1.0, 0.0};
+
+	/* make the whole window green. */
+	glClearColor(0.0, 1.0, 0.0, 0.0);
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	/* set viewport to the left half of the window */
+	glViewport(0, 0, piglit_width / 2, piglit_height);
+
+	/* draw blue rect extending beyond the right edge of the
+	   frustrum, notionally across the whole window */
+	glColor4fv(blue);
+	piglit_draw_rect(-1.0, -1.0, 4.0, 2.0);
+
+	/* check that the right half of the window, outside
+	   the viewport, still has the clear color */
+	pass &= piglit_probe_rect_rgb(piglit_width/2, 0,
+				piglit_width/2, piglit_height, green);
+
+	piglit_present_results();
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	glMatrixMode(GL_PROJECTION);
+	glLoadIdentity();
+
+	glMatrixMode(GL_MODELVIEW);
+	glLoadIdentity();
+}
-- 
1.7.7.3



More information about the Piglit mailing list