[Piglit] [PATCH 1/1] Add a test for viewport clipping.
Stuart Abercrombie
sabercrombie at chromium.org
Thu Nov 1 18:00:20 PDT 2012
This was failing on Sandy Bridge with guard band clipping enabled.
---
tests/general/CMakeLists.gl.txt | 1 +
tests/general/viewport-clip.c | 51 +++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 0 deletions(-)
create mode 100644 tests/general/viewport-clip.c
diff --git a/tests/general/CMakeLists.gl.txt b/tests/general/CMakeLists.gl.txt
index 11da25f..e1dcf23 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 (viewport-clip viewport-clip.c)
# vim: ft=cmake:
diff --git a/tests/general/viewport-clip.c b/tests/general/viewport-clip.c
new file mode 100644
index 0000000..d4dcdc1
--- /dev/null
+++ b/tests/general/viewport-clip.c
@@ -0,0 +1,51 @@
+/** @file viewport-clip.c
+ *
+ * Tests whether rendering is clipped to the viewport.
+ */
+
+#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};
+
+ /* whole window green. */
+ glClearColor(0.0, 1.0, 0.0, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glViewport(0, 0, piglit_width / 2, piglit_height);
+
+ glColor4fv(blue);
+ piglit_draw_rect(-1.0, -1.0, 4.0, 2.0);
+
+ 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