2 * Copyright © 2009 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 /** @file getactiveuniform-constant.c
27 #include "piglit-util-gl.h"
29 PIGLIT_GL_TEST_CONFIG_BEGIN
31 config
.supports_gl_compat_version
= 10;
33 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DOUBLE
;
35 PIGLIT_GL_TEST_CONFIG_END
37 static const char vs_code
[] =
45 " vec4[](vec4( 1, 2, 3, 4),\n"
46 " vec4( 5, 6, 7, 8),\n"
47 " vec4( 9, 10, 11, 12),\n"
48 " vec4(13, 14, 15, 16));\n"
51 " gl_Position = a + b + c + d + vv[i]\n;"
55 static const char fs_code
[] =
64 " const vec4 fv[] =\n"
65 " vec4[](vec4( 1, 2, 3, 4),\n"
66 " vec4( 5, 6, 7, 8),\n"
67 " vec4( 9, 10, 11, 12),\n"
68 " vec4(13, 14, 15, 16));\n"
70 " gl_FragColor = e + f + g + h + fv[j]\n;"
74 static const char *all_uniform_names
[] = {
87 static bool uniform_seen
[ARRAY_SIZE(all_uniform_names
)] = {
92 piglit_init(int argc
, char **argv
)
101 piglit_require_GLSL_version(120);
103 vs
= piglit_compile_shader_text(GL_VERTEX_SHADER
, vs_code
);
104 fs
= piglit_compile_shader_text(GL_FRAGMENT_SHADER
, fs_code
);
105 prog
= piglit_link_simple_program(vs
, fs
);
107 glGetProgramiv(prog
, GL_ACTIVE_UNIFORMS
, &num
);
108 for (i
= 0; i
< num
; i
++) {
116 glGetActiveUniform(prog
,
123 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
125 /* Try to find the name in the table of known names.
126 * If the name is not found, fail.
129 for (j
= 0; j
< ARRAY_SIZE(all_uniform_names
); j
++) {
130 if (strcmp(name
, all_uniform_names
[j
]) == 0) {
132 uniform_seen
[j
] = true;
139 "Uniform name \"%s\" returned by "
140 "glGetActiveUniform, but should not have "
147 for (i
= 0; i
< ARRAY_SIZE(uniform_seen
); i
++) {
148 if (!uniform_seen
[i
]) {
150 "Uniform name \"%s\" was not returned by "
151 "glGetActiveUniform, but should have "
153 all_uniform_names
[i
]);
158 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);