diff options
author | Eric Anholt <eric@anholt.net> | 2010-03-09 09:52:06 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2010-03-09 09:59:22 -0800 |
commit | 1c5eea9b18e7ac4d287608014dab6ce159cf06e6 (patch) | |
tree | d32e7fe6ad150bb809dfae279fee3d45bda4d5bf | |
parent | 98b984fb14374e8a87371153e1f4c5a7b6ed2bd2 (diff) |
glsl-vs-loop-nested: Test for a failure in the i965 VS with nested loop.
-rw-r--r-- | tests/all.tests | 1 | ||||
-rw-r--r-- | tests/shaders/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/shaders/glsl-vs-loop-nested.c | 119 | ||||
-rw-r--r-- | tests/shaders/glsl-vs-loop-nested.vert | 19 |
4 files changed, 140 insertions, 0 deletions
diff --git a/tests/all.tests b/tests/all.tests index 8e762441..da71ebda 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -158,6 +158,7 @@ add_plain_test(shaders, 'glsl-vs-arrays') add_plain_test(shaders, 'glsl-vs-if') add_plain_test(shaders, 'glsl-vs-if-bool') add_plain_test(shaders, 'glsl-vs-loop') +add_plain_test(shaders, 'glsl-vs-loop-nested') add_plain_test(shaders, 'glsl-vs-mov-after-deref') add_plain_test(shaders, 'glsl-vs-sqrt-zero') add_plain_test(shaders, 'vp-address-01') diff --git a/tests/shaders/CMakeLists.txt b/tests/shaders/CMakeLists.txt index 34a459c7..a04fa6f0 100644 --- a/tests/shaders/CMakeLists.txt +++ b/tests/shaders/CMakeLists.txt @@ -56,6 +56,7 @@ add_executable (glsl-vs-mov-after-deref glsl-vs-mov-after-deref.c) add_executable (glsl-vs-if glsl-vs-if.c) add_executable (glsl-vs-if-bool glsl-vs-if-bool.c) add_executable (glsl-vs-loop glsl-vs-loop.c) +add_executable (glsl-vs-loop-nested glsl-vs-loop-nested.c) add_executable (glsl-vs-sqrt-zero glsl-vs-sqrt-zero.c) add_executable (vp-address-01 vp-address-01.c) add_executable (vp-address-02 vp-address-02.c) diff --git a/tests/shaders/glsl-vs-loop-nested.c b/tests/shaders/glsl-vs-loop-nested.c new file mode 100644 index 00000000..e8a1298b --- /dev/null +++ b/tests/shaders/glsl-vs-loop-nested.c @@ -0,0 +1,119 @@ +/* + * Copyright © 2009-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 <eric@anholt.net> + * Ian Romanick <idr@freedesktop.org> + * + */ + +/** @file glsl-vs-loop-nested.c + * + * Tests that nested loops in the vertex shader work. + * + * Since a value from an attribute is used for the loop counters, the + * compiler cannot simply unroll the loop. This verifies that GLSL + * loops can be correctly generated in the vertex shader. + * + * This was conceived as a test case for freedesktop.org bug #25173. + */ + +#include "piglit-util.h" + +int piglit_width = 100, piglit_height = 100; +int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE; + +static GLint prog; + +enum piglit_result +piglit_display(void) +{ + GLboolean pass = GL_TRUE; + + float color[] = {1.0, 0.0, 0.0, 0.0}; + + unsigned i; + unsigned j; + + glClearColor(0.5, 0.5, 0.5, 0.5); + glClear(GL_COLOR_BUFFER_BIT); + + for (i = 0; i < 3; i++) { + float temp; + float line_color[4]; + unsigned x = 5 + (25 * i); + + for (j = 0; j < 3; j++) { + int y = 5 + (25 * j); + int rotate; + + memcpy(line_color, color, sizeof(line_color)); + for (rotate = 0; rotate < i * j; rotate++) { + temp = line_color[2]; + line_color[2] = line_color[1]; + line_color[1] = line_color[0]; + line_color[0] = temp; + } + line_color[3] = (float) i * 4 + j; + + glColor4fv(line_color); + piglit_draw_rect(x, y, 20, 20); + + pass &= piglit_probe_pixel_rgb(x + 5, y + 5, color); + } + + temp = color[2]; + color[2] = color[1]; + color[1] = color[0]; + color[0] = temp; + } + + + glutSwapBuffers(); + + return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE; +} + +void +piglit_init(int argc, char **argv) +{ + GLint vs, fs; + + /* Set up projection matrix so we can just draw using window + * coordinates. + */ + 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); + } + + vs = piglit_compile_shader(GL_VERTEX_SHADER, + "shaders/glsl-vs-loop-nested.vert"); + fs = piglit_compile_shader(GL_FRAGMENT_SHADER, + "shaders/glsl-color.frag"); + + prog = piglit_link_simple_program(vs, fs); + + glUseProgram(prog); +} diff --git a/tests/shaders/glsl-vs-loop-nested.vert b/tests/shaders/glsl-vs-loop-nested.vert new file mode 100644 index 00000000..f8b691bc --- /dev/null +++ b/tests/shaders/glsl-vs-loop-nested.vert @@ -0,0 +1,19 @@ +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + + int count = int(gl_Color.w); + int count1 = int(count / 4); + int count2 = count - count1 * 4; + vec3 c = gl_Color.xyz; + int i, j; + + for (i = 0; i < count1; i++) { + for (j = 0; j < count2; j++) { + c = c.yzx; + } + } + + gl_FrontColor = vec4(c, 1.0); +} + |