From f4c0f51bd2041a3992eea5121a45702b0a6b2466 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Wed, 14 Apr 2010 18:23:32 +0100 Subject: [PATCH] Add a test for setting a scissor that is fully offscreen The test sets a zero-width and height scissor that is off the edge of the window. This should clip everything. It then tries to fill the window with red triangles. These do not currently get clipped on i965. --- tests/all.tests | 1 + tests/bugs/CMakeLists.txt | 1 + tests/bugs/offscreen-scissor.c | 69 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 0 deletions(-) create mode 100644 tests/bugs/offscreen-scissor.c diff --git a/tests/all.tests b/tests/all.tests index ba1efe0..0f4b4d2 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -258,6 +258,7 @@ add_plain_test(bugs, 'fdo23670-depth_test') add_plain_test(bugs, 'fdo23670-drawpix_stencil') add_plain_test(bugs, 'fdo24066') add_plain_test(bugs, 'fdo25614-genmipmap') +add_plain_test(bugs, 'offscreen-scissor') glx = Group() add_plain_test(glx, 'glx-multithread') diff --git a/tests/bugs/CMakeLists.txt b/tests/bugs/CMakeLists.txt index 3a72a96..ca80ce3 100644 --- a/tests/bugs/CMakeLists.txt +++ b/tests/bugs/CMakeLists.txt @@ -35,3 +35,4 @@ add_executable (fdo23670-depth_test fdo23670-depth_test.c) add_executable (fdo23670-drawpix_stencil fdo23670-drawpix_stencil.c) add_executable (fdo24066 fdo24066.c) add_executable (fdo25614-genmipmap fdo25614-genmipmap.c) +add_executable (offscreen-scissor offscreen-scissor.c) diff --git a/tests/bugs/offscreen-scissor.c b/tests/bugs/offscreen-scissor.c new file mode 100644 index 0000000..ea350d5 --- /dev/null +++ b/tests/bugs/offscreen-scissor.c @@ -0,0 +1,69 @@ +/* + * Test case for setting a scissor that is entirely offscreen. This + * should clip everything but under current Mesa master with i965 it + * clips nothing + */ + +#include "piglit-util.h" + +static int Automatic = 0; + +#define WIN_WIDTH 64 +#define WIN_HEIGHT 64 + +void display(void) +{ + static const GLint triangle_vertices[] = { + -1, -1, + 1, -1, + -1, 1, + 1, 1 + }; + static const GLfloat window_color[] = { 1.0f, 1.0f, 1.0f, 1.0f }; + int pass; + + /* Clear to white */ + glClearColor(1.0f, 1.0f, 1.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + + /* Set a fully offscreen scissor. This should clip everything */ + glEnable(GL_SCISSOR_TEST); + glScissor(0, WIN_HEIGHT, 0, 0); + + /* Fill the window with red triangles */ + glEnableClientState(GL_VERTEX_ARRAY); + glColor3f (1.0f, 0.0f, 0.0f); + glVertexPointer(2, GL_INT, 0, triangle_vertices); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + + glDisable(GL_SCISSOR_TEST); + + /* Verify some pixels around the window */ + pass = piglit_probe_pixel_rgb(0, 0, window_color); + pass = piglit_probe_pixel_rgb(WIN_WIDTH / 2, WIN_HEIGHT / 2, + window_color) && pass; + pass = piglit_probe_pixel_rgb(WIN_WIDTH - 1, WIN_HEIGHT - 1, + window_color) && pass; + + glutSwapBuffers(); + + if (Automatic) + piglit_report_result(pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE); +} + + +int main(int argc, char**argv) +{ + glutInit(&argc, argv); + if (argc == 2 && !strcmp(argv[1], "-auto")) + Automatic = 1; + glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); + glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT); + glutInitWindowPosition(100, 100); + glutCreateWindow("offscreen-scissor"); + glutDisplayFunc(display); + glutMainLoop(); + + return 0; +} -- 1.6.5.rc1.46.g4d818