On 27.01.2011 07:34, Eric Anholt wrote: > On Wed, 26 Jan 2011 13:30:04 +0100, Christoph Bumiller > <e0425...@student.tuwien.ac.at> wrote: >> The current copy propagation code would propagate TEMP[0].x from (6) >> into TEMP[1].x from (8) in the following, which is clearly wrong: >> >> 6: MOV TEMP[1].x, TEMP[0].xxxx >> 7: MOV TEMP[0].x, TEMP[0].yyyy >> 8: MOV TEMP[0].y, TEMP[1].xxxx >> 9: ADD TEMP[1].x, TEMP[0].zzzz, IMM[0].yyyy >> 10: MOV TEMP[0].z, TEMP[1].xxxx >> >> Possible patch and a small program to check this attached. >> Tested with llvmpipe. > Thanks for catching this! Could you cut it down to a nice small > shader_test for piglit so we can regression test? Here you are, a piglit test.
>From 33254fc7501a6664951b03822f3c9ea32ddeca9b Mon Sep 17 00:00:00 2001 From: Christoph Bumiller <e0425...@student.tuwien.ac.at> Date: Thu, 27 Jan 2011 23:19:04 +0100 Subject: [PATCH] glsl: add test for copy propagation bug --- tests/all.tests | 1 + tests/shaders/CMakeLists.txt | 1 + tests/shaders/glsl-copy-propagation-bug.c | 112 +++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 0 deletions(-) create mode 100644 tests/shaders/glsl-copy-propagation-bug.c diff --git a/tests/all.tests b/tests/all.tests index 0ce6d34..cd1e00d 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -661,6 +661,7 @@ add_shader_generic(shaders, 'glsl-const-initializer-02') add_shader_generic(shaders, 'glsl-const-initializer-03') add_plain_test(shaders, 'glsl-sin') add_plain_test(shaders, 'glsl-cos') +add_plain_test(shaders, 'glsl-copy-propagation-bug') add_plain_test(shaders, 'glsl-vs-if-bool') add_plain_test(shaders, 'glsl-vs-loop') add_shader_generic(shaders, 'glsl-vs-loop-break') diff --git a/tests/shaders/CMakeLists.txt b/tests/shaders/CMakeLists.txt index f34e6f7..88370e0 100644 --- a/tests/shaders/CMakeLists.txt +++ b/tests/shaders/CMakeLists.txt @@ -159,6 +159,7 @@ add_executable (glsl-cos glsl-cos.c) IF (UNIX) target_link_libraries(glsl-cos m) ENDIF (UNIX) +add_executable (glsl-copy-propagation-bug glsl-copy-propagation-bug.c) add_executable (glsl-kwin-blur-1 glsl-kwin-blur-1.c) add_executable (glsl-kwin-blur-2 glsl-kwin-blur-2.c) add_executable (link-mismatch-layout-01 link-mismatch-layout-01.c) diff --git a/tests/shaders/glsl-copy-propagation-bug.c b/tests/shaders/glsl-copy-propagation-bug.c new file mode 100644 index 0000000..5d6199b --- /dev/null +++ b/tests/shaders/glsl-copy-propagation-bug.c @@ -0,0 +1,112 @@ +/* + * Copyright © 2011 Christoph Bumiller + * + * 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: + * Christoph Bumiller + * + */ + +/** @file glsl-swap.c + * + * Tests a bug in copy propagation that turns + * e.g. { a = v.x; v.x = v.y; v.y = a } into { v.x = v.y; v.y = v.x; } + */ + +#include "piglit-util.h" + +int piglit_width = 32, piglit_height = 32; +int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE; + +static char vs_code[] = + "varying vec4 colour;\n" + + "void main()\n" + "{\n" + " gl_Position = ftransform();\n" + " colour = vec4(0.0, 1.0, 0.0, 1.0);\n" + "}\n"; + +static char fs_code[] = + "varying vec4 colour;\n" + + "void main()\n" + "{\n" + " vec4 col = colour;\n" + " while (col.b < 0.6) {\n" /* prevent direct propagation of input */ + " float r = col.r;\n" + " col.r = col.g;\n" + " col.g = r;\n" + " col.b += 0.25;\n" + " }\n" + " gl_FragColor = col;\n" + "}\n"; + +static GLuint setup_shaders() +{ + GLuint vs, fs, prog; + + vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_code); + fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_code); + prog = piglit_link_simple_program(vs, fs); + + glUseProgram(prog); + return prog; +} + +static GLboolean test() +{ + GLint prog; + float color[4] = {1, 0, 0.75, 1}; + + prog = setup_shaders(); + + piglit_draw_rect(0, 0, 32, 32); + + assert(glGetError() == 0); + + return piglit_probe_pixel_rgb(1, 1, color); +} + +enum piglit_result piglit_display(void) +{ + GLboolean pass; + + glClearColor(0.5, 0.5, 0.5, 0.5); + glClear(GL_COLOR_BUFFER_BIT); + + pass = test(); + + glutSwapBuffers(); + + return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE; +} + +void piglit_init(int argc, char **argv) +{ + piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); + + if (!GLEW_VERSION_2_0) { + printf("Requires OpenGL 2.0\n"); + piglit_report_result(PIGLIT_SKIP); + } +} + -- 1.7.2.2
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev