ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_uniform_buffer_object / negative-getactiveuniformblockiv.c
blob14c1629d090b0a7cd9bd1b53d8ffe88e45c1b0aa
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-getactiveuniformblockiv.c
26 * From the GL_ARB_uniform_buffer_object spec:
28 * "<uniformBlockIndex> is an active uniform block index of
29 * <program>. If <uniformBlockIndex> is greater than or equal to
30 * the value of ACTIVE_UNIFORM_BLOCKS, or is not the index of an
31 * active uniform block in <program>, the error INVALID_VALUE is
32 * generated.
34 * If no error occurs, the uniform block parameter(s) specified
35 * by <pname> are returned in <params>. Otherwise, nothing will
36 * be written to <params>.
38 * The error INVALID_VALUE is generated by GetUniformIndices,
39 * GetActiveUniformsiv, GetActiveUniformName,
40 * GetUniformBlockIndex, GetActiveUniformBlockiv,
41 * GetActiveUniformBlockName, and UniformBlockBinding if
42 * <program> is not a value generated by GL.
44 * The error INVALID_ENUM is generated by GetActiveUniformsiv and
45 * GetActiveUniformBlockiv if <pname> is not one of the accepted
46 * values."
49 #include "piglit-util-gl.h"
50 #include "uniform-types.h"
52 PIGLIT_GL_TEST_CONFIG_BEGIN
54 config.supports_gl_compat_version = 10;
55 config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
56 config.khr_no_error_support = PIGLIT_HAS_ERRORS;
58 PIGLIT_GL_TEST_CONFIG_END
60 void
61 piglit_init(int argc, char **argv)
63 bool pass = true;
64 const char *fs_source =
65 "#extension GL_ARB_uniform_buffer_object : require\n"
66 "uniform ubo {\n"
67 " float u;\n"
68 "};\n"
69 "\n"
70 "void main() {\n"
71 " gl_FragColor = vec4(u);\n"
72 "}\n";
73 GLuint prog;
74 GLint junk = 0xd0d0, unwritten_junk = junk;
76 piglit_require_extension("GL_ARB_uniform_buffer_object");
78 prog = piglit_build_simple_program(NULL, fs_source);
80 /* Test a bad pname (it's one for glActiveUniformsiv). */
81 glGetActiveUniformBlockiv(prog, 0, GL_UNIFORM_TYPE, &junk);
82 if (!piglit_check_gl_error(GL_INVALID_ENUM) || junk != unwritten_junk)
83 pass = false;
85 /* Bad active uniform block index. "The indices of the active
86 * uniform blocks of a program are assigned in consecutive
87 * order, beginning with zero."
89 glGetActiveUniformBlockiv(prog, 1, GL_UNIFORM_BLOCK_BINDING, &junk);
90 if (!piglit_check_gl_error(GL_INVALID_VALUE) || junk != unwritten_junk)
91 pass = false;
93 /* Test bad program name by deleting ours */
94 glDeleteProgram(prog);
95 glGetActiveUniformBlockiv(prog, 0, GL_UNIFORM_BLOCK_BINDING, &junk);
96 if (!piglit_check_gl_error(GL_INVALID_VALUE) || junk != unwritten_junk)
97 pass = false;
99 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
102 enum piglit_result piglit_display(void)
104 /* UNREACHED */
105 return PIGLIT_FAIL;