2 * Copyright © 2013 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
21 * DEALINGS IN THE SOFTWARE.
26 * \file named-block-no-modify.c
28 * Test that uniform variables contained within a named uniform block cannot be
29 * accessed by the glUniform* commands.
31 * Section 2.11.4 (Uniform Variables) of the GL 3.2 spec says:
32 * "Uniforms in a named uniform block are not assigned a location and may
33 * not be modified using the Uniform* commands."
35 * Test relies on the behavior of glGetUniform returning -1 for uniforms
36 * that have not been assigned a location, such as those in a named uniform
40 #include "piglit-util-gl.h"
42 PIGLIT_GL_TEST_CONFIG_BEGIN
44 config
.supports_gl_core_version
= 32;
45 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
47 PIGLIT_GL_TEST_CONFIG_END
49 /* the operations in this shader are not strictly relevant, only that they
50 * do not get discarded */
51 static const char vs_text
[] =
54 "in vec4 piglit_vertex;\n"
56 "uniform testBlock {\n"
67 " gl_Position = piglit_vertex;\n"
70 " oc[0] = c[0] * 1;\n"
71 " oc[1] = c[1] * 2;\n"
72 " oc[2] = c[2] * 3;\n"
73 " oc[3] = c[3] * 4;\n"
76 /* again, operations are just to touch data */
77 static const char fs_text
[] =
83 "out vec4 FragColor;\n"
86 " FragColor = vec4(float(oa) * oc[0][0],\n"
95 piglit_init(int argc
, char **argv
)
103 prog
= piglit_build_simple_program(vs_text
, fs_text
);
107 /* get uniforms, locations should be -1 if glGetUniformLocation
108 * can't retrieve their location */
110 a_loc
= glGetUniformLocation(prog
, "a");
112 printf("a_loc incorrectly assigned a location: %d", a_loc
);
116 b_loc
= glGetUniformLocation(prog
, "b");
118 printf("b_loc incorrectly assigned a location: %d", b_loc
);
122 c_loc
= glGetUniformLocation(prog
, "c");
124 printf("c_loc incorrectly assigned a location: %d", c_loc
);
128 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);
134 /* should not reach */