ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_uniform_buffer_object / negative-getactiveuniformsiv.c
blob117adcfa116d9169989c60aa77db36d77b7bcffb
1 /*
2 * Copyright © 2012 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.
24 /** @file negative-getactiveuniformsiv.c
26 * From the GL_ARB_uniform_buffer_object spec:
28 * "If any index is greater than or equal to the value of
29 * ACTIVE_UNIFORMS, the error INVALID_VALUE is generated.
31 * For GetActiveUniformsiv, <uniformCount> indicates both the
32 * number of elements in the array of indices <uniformIndices>
33 * and the number of parameters written to <params> upon
34 * successful return. <pname> identifies a property of each
35 * uniform in <uniformIndices> that should be written into the
36 * corresponding element of <params>. If an error occurs,
37 * nothing will be written to <params>.
39 * The error INVALID_VALUE is generated by GetUniformIndices,
40 * GetActiveUniformsiv, GetActiveUniformName,
41 * GetUniformBlockIndex, GetActiveUniformBlockiv,
42 * GetActiveUniformBlockName, and UniformBlockBinding if
43 * <program> is not a value generated by GL.
45 * The error INVALID_ENUM is generated by GetActiveUniformsiv and
46 * GetActiveUniformBlockiv if <pname> is not one of the accepted
47 * values."
50 #include "piglit-util-gl.h"
51 #include "uniform-types.h"
53 PIGLIT_GL_TEST_CONFIG_BEGIN
55 config.supports_gl_compat_version = 10;
57 config.window_width = 10;
58 config.window_height = 10;
59 config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
60 config.khr_no_error_support = PIGLIT_HAS_ERRORS;
62 PIGLIT_GL_TEST_CONFIG_END
64 void
65 piglit_init(int argc, char **argv)
67 bool pass = true;
68 const char *fs_source =
69 "#extension GL_ARB_uniform_buffer_object : require\n"
70 "uniform ubo {\n"
71 " float u;\n"
72 "};\n"
73 "\n"
74 "void main() {\n"
75 " gl_FragColor = vec4(u);\n"
76 "}\n";
77 GLuint prog;
78 GLint junk = 0xd0d0;
79 GLint unwritten_junk = junk;
80 GLuint good_index = 0, bad_index = 1;
82 piglit_require_extension("GL_ARB_uniform_buffer_object");
84 prog = piglit_build_simple_program(NULL, fs_source);
86 /* Test a bad pname (it's one for glActiveUniformBlockiv). */
87 glGetActiveUniformsiv(prog, 1, &good_index,
88 GL_UNIFORM_BLOCK_BINDING, &junk);
89 if (!piglit_check_gl_error(GL_INVALID_ENUM) || junk != unwritten_junk)
90 pass = false;
92 /* Bad active uniform index. "Each active uniform, whether in
93 * a named uniform block or in the default block, is assigned
94 * an index when a program is linked. These indices are
95 * assigned in consecutive order, beginning with zero. The
96 * indices assigned to a set of uniforms in a program may be
97 * queried by calling". We only have one active uniform.
99 glGetActiveUniformsiv(prog, 1, &bad_index, GL_UNIFORM_TYPE, &junk);
100 if (!piglit_check_gl_error(GL_INVALID_VALUE) || junk != unwritten_junk)
101 pass = false;
103 /* Test bad program name by deleting ours */
104 glDeleteProgram(prog);
105 glGetActiveUniformsiv(prog, 1, &good_index, GL_UNIFORM_TYPE, &junk);
106 if (!piglit_check_gl_error(GL_INVALID_VALUE) || junk != unwritten_junk)
107 pass = false;
109 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
112 enum piglit_result piglit_display(void)
114 /* UNREACHED */
115 return PIGLIT_FAIL;