diff options
author | Brian Paul <brianp@vmware.com> | 2010-10-19 08:13:08 -0600 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2010-10-19 08:13:08 -0600 |
commit | d200ac9da007c91271d3ad5b1c07a3e5103ad60f (patch) | |
tree | b043ad66c2116c6500a8433218b558beb455485d /tests/bugs | |
parent | e7fde7e31670ce4193c8e650c606b1374d025320 (diff) |
tri-tex-crash: new test for a specific bug in Mesa/Gallium/LLVMpipe
Diffstat (limited to 'tests/bugs')
-rw-r--r-- | tests/bugs/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/bugs/tri-tex-crash.c | 134 |
2 files changed, 135 insertions, 0 deletions
diff --git a/tests/bugs/CMakeLists.txt b/tests/bugs/CMakeLists.txt index 0089450a7..2757d59e0 100644 --- a/tests/bugs/CMakeLists.txt +++ b/tests/bugs/CMakeLists.txt @@ -36,3 +36,4 @@ add_executable (fdo23670-drawpix_stencil fdo23670-drawpix_stencil.c) add_executable (fdo24066 fdo24066.c) add_executable (fdo25614-genmipmap fdo25614-genmipmap.c) add_executable (fdo28551 fdo28551.c) +add_executable (tri-tex-crash tri-tex-crash.c) diff --git a/tests/bugs/tri-tex-crash.c b/tests/bugs/tri-tex-crash.c new file mode 100644 index 000000000..68cd52017 --- /dev/null +++ b/tests/bugs/tri-tex-crash.c @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2010 VMware, Inc. + * + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 + * NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COYPRIGTH + * HOLDERS AND/OR THEIR SUPPLIERS 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. + */ + +/** + * @file + * Test drawing a textured triangle. This is to test a Mesa/Gallium + * LLVMpipe crash which only seems to happen when SSE4.1 is not used. + */ + +#include "piglit-util.h" + + +int piglit_width = 400, piglit_height = 400; +int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE; + + +static void +make_texture(void) +{ + GLubyte image[64][64][3]; + int i, j, size; + + for (i = 0; i < 64; i++) { + for (j = 0; j < 64; j++) { + image[i][j][0] = 255; + image[i][j][1] = 0; + image[i][j][2] = 0; + } + } + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + i = 0; + size = 64; + while (size) { + glTexImage2D(GL_TEXTURE_2D, i, GL_RGB, size, size, 0, + GL_RGB, GL_UNSIGNED_BYTE, image); + + size /= 2; + i++; + } + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_NEAREST_MIPMAP_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, + GL_LINEAR); + glEnable(GL_TEXTURE_2D); +} + + +enum piglit_result +piglit_display(void) +{ + /* + * Simply draw a textured tri. The texture is solid red. + * The tri is clipped. + */ + static const GLfloat v[3][4] = { + { 10.0, 10.0, 0.0, 1.0 }, + { 10.0, 1.0, 0.0, 1.0 }, + { 1.0, 1.0, 0.0, 1.0 }, + }; + static const GLfloat t[3][2] = { + { 0, 0 }, + { 1, 0 }, + { 1, 1 } + }; + static const GLfloat red[4] = { 1, 0, 0, 1 }; + enum piglit_result result; + + make_texture(); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glTexCoord2fv(t[0]); glVertex4fv(v[0]); + glTexCoord2fv(t[1]); glVertex4fv(v[1]); + glTexCoord2fv(t[2]); glVertex4fv(v[2]); + glEnd(); + + if (piglit_probe_pixel_rgb(piglit_width-5, piglit_height-20, red)) + result = PIGLIT_SUCCESS; + else + result = PIGLIT_FAILURE; + + glutSwapBuffers(); + + return result; +} + + +static void +reshape(int width, int height) +{ + piglit_width = width; + piglit_height = height; + + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 50.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -25.0); +} + + +void +piglit_init(int argc, char **argv) +{ + glutReshapeFunc(reshape); + reshape(piglit_width, piglit_height); +} |