From 06a16c5ea898bf9b2b8aaa6aab76685ce4116d23 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 10 Mar 2010 10:06:10 -0800 Subject: glsl-fs-bug25902: Add a new test for fd.o bug #25902 (965 driver hang). --- tests/all.tests | 1 + tests/shaders/CMakeLists.txt | 1 + tests/shaders/glsl-fs-bug25902.c | 98 +++++++++++++++++++++++++++++++++++++ tests/shaders/glsl-fs-bug25902.frag | 45 +++++++++++++++++ tests/shaders/glsl-tex-mvp.vert | 6 +++ 5 files changed, 151 insertions(+) create mode 100644 tests/shaders/glsl-fs-bug25902.c create mode 100644 tests/shaders/glsl-fs-bug25902.frag create mode 100644 tests/shaders/glsl-tex-mvp.vert diff --git a/tests/all.tests b/tests/all.tests index ea503e4d..50e07d51 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -150,6 +150,7 @@ add_plain_test(shaders, 'glsl-reload-source') add_plain_test(shaders, 'glsl-uniform-out-of-bounds') add_plain_test(shaders, 'glsl-uniform-update') add_plain_test(shaders, 'glsl-unused-varying') +add_plain_test(shaders, 'glsl-fs-bug25902') add_plain_test(shaders, 'glsl-fs-exp2') add_plain_test(shaders, 'glsl-fs-fragcoord') add_plain_test(shaders, 'glsl-fs-log2') diff --git a/tests/shaders/CMakeLists.txt b/tests/shaders/CMakeLists.txt index affe9f7e..5351048d 100644 --- a/tests/shaders/CMakeLists.txt +++ b/tests/shaders/CMakeLists.txt @@ -47,6 +47,7 @@ add_executable (glsl-reload-source glsl-reload-source.c) add_executable (glsl-unused-varying glsl-unused-varying.c) add_executable (glsl-uniform-update glsl-uniform-update.c) add_executable (glsl-uniform-out-of-bounds glsl-uniform-out-of-bounds.c) +add_executable (glsl-fs-bug25902 glsl-fs-bug25902.c) add_executable (glsl-fs-exp2 glsl-fs-exp2.c) add_executable (glsl-fs-fragcoord glsl-fs-fragcoord.c) add_executable (glsl-fs-log2 glsl-fs-log2.c) diff --git a/tests/shaders/glsl-fs-bug25902.c b/tests/shaders/glsl-fs-bug25902.c new file mode 100644 index 00000000..652815cd --- /dev/null +++ b/tests/shaders/glsl-fs-bug25902.c @@ -0,0 +1,98 @@ +/* + * Copyright © 2010 Intel Corporation + * + * 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 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * 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 NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Authors: + * Eric Anholt + * + */ + +/** @file glsl-fs-bug25902.c + * + * Tests for a hang in the i965 driver with a masked texture sample operation + * in the GLSL path. + */ + +#include "piglit-util.h" + +int piglit_width = 100, piglit_height = 100; +int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE; + +static int args_location, tex_location; +static GLint prog; + +enum piglit_result +piglit_display(void) +{ + GLboolean pass = GL_TRUE; + static const float args[4] = {0.0, 1.0, 0.0, 1.0}; + float black[4] = {0.0, 0.0, 0.0, 0.0}; + + glClearColor(0.5, 0.5, 0.5, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + glUniform4fv(args_location, 1, args); + glUniform1i(tex_location, 0); + glColor4f(1.0, 0.0, 0.0, 0.0); + piglit_draw_rect_tex(10, 10, 10, 10, + 0, 0, 1, 1); + + pass &= piglit_probe_pixel_rgb(12, 12, black); + pass &= piglit_probe_pixel_rgb(17, 12, args); + pass &= piglit_probe_pixel_rgb(12, 17, args); + pass &= piglit_probe_pixel_rgb(17, 17, black); + + glutSwapBuffers(); + + return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE; +} + +void +piglit_init(int argc, char **argv) +{ + GLint vs, fs; + float black[4] = {0.0, 0.0, 0.0, 0.0}; + float white[4] = {1.0, 1.0, 1.0, 0.0}; + + if (!GLEW_VERSION_2_0) { + printf("Requires OpenGL 2.0\n"); + piglit_report_result(PIGLIT_SKIP); + } + + piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); + + vs = piglit_compile_shader(GL_VERTEX_SHADER, + "shaders/glsl-tex-mvp.vert"); + fs = piglit_compile_shader(GL_FRAGMENT_SHADER, + "shaders/glsl-fs-bug25902.frag"); + + prog = piglit_link_simple_program(vs, fs); + + glUseProgram(prog); + + piglit_checkerboard_texture(0, 0, + 2, 2, + 1, 1, + black, white); + + args_location = glGetUniformLocation(prog, "args"); + tex_location = glGetUniformLocation(prog, "sampler"); +} diff --git a/tests/shaders/glsl-fs-bug25902.frag b/tests/shaders/glsl-fs-bug25902.frag new file mode 100644 index 00000000..10dd390b --- /dev/null +++ b/tests/shaders/glsl-fs-bug25902.frag @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2009 Nick Bowler + * Copyright © 2010 Intel Corporation + * + * 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 the rights to use, copy, modify, merge, publish, + * distribute, sublicense, 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 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 NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 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. + */ + +uniform vec4 args; +uniform sampler2D sampler; + +void main() +{ + vec4 secondary = texture2D(sampler, gl_TexCoord[0].st); + vec3 colour = args.rgb; + + /* Removing the "if useSecondary" here (but keeping the + * multiplication) causes the shader to work. + * The failure does not depend on the value assigned to useSecondary. + * + * Making colour vec4 and doing vec4 multiplication also causes the + * shader to work. + */ + if (args.a != 0) { + colour *= secondary.rgb; + } + + gl_FragColor = vec4(colour, 1); +} diff --git a/tests/shaders/glsl-tex-mvp.vert b/tests/shaders/glsl-tex-mvp.vert new file mode 100644 index 00000000..a1997476 --- /dev/null +++ b/tests/shaders/glsl-tex-mvp.vert @@ -0,0 +1,6 @@ +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0;" +} + -- cgit v1.2.3