summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Abercrombie <sabercrombie@chromium.org>2012-11-14 14:30:45 -0800
committerEric Anholt <eric@anholt.net>2012-11-15 10:56:58 -0800
commit7a0f6cde3456400fd2f025e070764dc6e2f8760a (patch)
tree9a30fdd1dc00eae60206994343636c20447a509d
parent93d7c5c2298ebb3a083f523645811674cf779e6c (diff)
Add a test for viewport triangle clipping.
Triangles should be clipped to the clip volume and therefore shouldn't end up being rasterized outside the viewport. This was failing on Sandy Bridge with guard band clipping enabled. v2: new test name, more comments and addition to all.tests. v3: Eric's comments incorporated, and the explicit window size removed. v4: minor style tweaks by Eric, and Brian's probe-related review. Reviewed-by: Eric Anholt <eric@anholt.net>
-rw-r--r--tests/all.tests1
-rw-r--r--tests/general/CMakeLists.gl.txt1
-rw-r--r--tests/general/triangle-guardband-viewport.c78
3 files changed, 80 insertions, 0 deletions
diff --git a/tests/all.tests b/tests/all.tests
index 62292426..edee65cc 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -557,6 +557,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_concurrent_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 0a5cd11e..efaa56e6 100644
--- a/tests/general/CMakeLists.gl.txt
+++ b/tests/general/CMakeLists.gl.txt
@@ -137,5 +137,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 00000000..1f921914
--- /dev/null
+++ b/tests/general/triangle-guardband-viewport.c
@@ -0,0 +1,78 @@
+/* Copyright 2012 Google Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ * Authors:
+ * Stuart Abercrombie <sabercrombie@google.com>
+*/
+
+/** @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_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+ bool pass = 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)
+{
+}