perf/pixel-rate: new pixel throughput microbenchmark
[piglit.git] / tests / spec / glsl-1.50 / execution / vs-named-block-no-modify.c
blob38737a2515a0999fcae548b1f2cd86b0d9cbca20
1 /*
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
13 * Software.
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.
25 /**
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
37 * block.
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[] =
52 "#version 150\n"
53 "\n"
54 "in vec4 piglit_vertex;\n"
55 "\n"
56 "uniform testBlock {\n"
57 " int a;\n"
58 " float b;\n"
59 " mat4 c;\n"
60 "};\n"
61 "\n"
62 "flat out int oa;\n"
63 "out float ob;\n"
64 "out mat4 oc;\n"
65 "\n"
66 "void main() {\n"
67 " gl_Position = piglit_vertex;\n"
68 " oa = a + 1;\n"
69 " ob = b * 2;\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"
74 "}\n";
76 /* again, operations are just to touch data */
77 static const char fs_text[] =
78 "#version 150\n"
79 "\n"
80 "flat in int oa;\n"
81 "in float ob;\n"
82 "in mat4 oc;\n"
83 "out vec4 FragColor;\n"
84 "\n"
85 "void main() {\n"
86 " FragColor = vec4(float(oa) * oc[0][0],\n"
87 " ob * oc[1][1],\n"
88 " oc[2][2],\n"
89 " oc[3][3]);\n"
90 "}\n";
92 static GLuint prog;
94 void
95 piglit_init(int argc, char **argv)
97 bool pass = true;
99 int a_loc = -2;
100 int b_loc = -3;
101 int c_loc = -4;
103 prog = piglit_build_simple_program(vs_text, fs_text);
105 glUseProgram(prog);
107 /* get uniforms, locations should be -1 if glGetUniformLocation
108 * can't retrieve their location */
110 a_loc = glGetUniformLocation(prog, "a");
111 if(a_loc != -1) {
112 printf("a_loc incorrectly assigned a location: %d", a_loc);
113 pass = false;
116 b_loc = glGetUniformLocation(prog, "b");
117 if(b_loc != -1) {
118 printf("b_loc incorrectly assigned a location: %d", b_loc);
119 pass = false;
122 c_loc = glGetUniformLocation(prog, "c");
123 if(c_loc != -1) {
124 printf("c_loc incorrectly assigned a location: %d", c_loc);
125 pass = false;
128 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
131 enum piglit_result
132 piglit_display(void)
134 /* should not reach */
135 return PIGLIT_FAIL;