diff --git a/tests/all.tests b/tests/all.tests index 3049be9..f77d12a 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -295,6 +295,7 @@ add_plain_test(shaders, 'glsl-bindattriblocation') add_plain_test(shaders, 'glsl-dlist-getattriblocation') add_plain_test(shaders, 'glsl-getactiveuniform-array-size') add_plain_test(shaders, 'glsl-getactiveuniform-count') +add_plain_test(shaders, 'glsl-getactiveuniform-count-uniform') add_plain_test(shaders, 'glsl-getactiveuniform-length') add_plain_test(shaders, 'glsl-getattriblocation') add_plain_test(shaders, 'glsl-invalid-asm-01') diff --git a/tests/shaders/CMakeLists.txt b/tests/shaders/CMakeLists.txt index 637a263..25beffd 100644 --- a/tests/shaders/CMakeLists.txt +++ b/tests/shaders/CMakeLists.txt @@ -63,6 +63,7 @@ add_executable (glsl-explicit-location-05 glsl-explicit-location-05.c) add_executable (glsl-getattriblocation glsl-getattriblocation.c) add_executable (glsl-getactiveuniform-array-size glsl-getactiveuniform-array-size.c) add_executable (glsl-getactiveuniform-count glsl-getactiveuniform-count.c) +add_executable (glsl-getactiveuniform-count-builtin glsl-getactiveuniform-count-builtin.c) add_executable (glsl-getactiveuniform-length glsl-getactiveuniform-length.c) add_executable (glsl-invalid-asm-01 glsl-invalid-asm-01.c) add_executable (glsl-invalid-asm-02 glsl-invalid-asm-02.c) diff --git a/tests/shaders/glsl-getactiveuniform-count-builtin.c b/tests/shaders/glsl-getactiveuniform-count-builtin.c new file mode 100644 index 0000000..70e7738 --- /dev/null +++ b/tests/shaders/glsl-getactiveuniform-count-builtin.c @@ -0,0 +1,76 @@ +/* + * 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: + * Gordon Jin + * + */ + +/** @file glsl-getactiveuniform-count-builtin.c + * + * Based on glsl-getactiveuniform-count.c, and adds a built-in uniform variable. + */ + +#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) +{ + /* unreached */ + return PIGLIT_FAILURE; +} + +void +piglit_init(int argc, char **argv) +{ + GLboolean pass = GL_TRUE; + GLint vs, fs, num; + + 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-getactiveuniform-count-builtin.vert"); + fs = piglit_compile_shader(GL_FRAGMENT_SHADER, + "shaders/glsl-color.frag"); + + prog = piglit_link_simple_program(vs, fs); + + glGetProgramiv(prog, GL_ACTIVE_UNIFORMS, &num); + if (num != 2) { + printf("Unexpected active uniform count " + "(saw %d, expected 2)\n", num); + pass = GL_FALSE; + } + + if (pass) + piglit_report_result(PIGLIT_SUCCESS); + else + piglit_report_result(PIGLIT_FAILURE); +} diff --git a/tests/shaders/glsl-getactiveuniform-count-builtin.vert b/tests/shaders/glsl-getactiveuniform-count-builtin.vert new file mode 100644 index 0000000..5a7d1bd --- /dev/null +++ b/tests/shaders/glsl-getactiveuniform-count-builtin.vert @@ -0,0 +1,7 @@ +uniform vec4 color[4]; + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrixTranspose * gl_Vertex; + gl_FrontColor = color[1]; +}