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
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 getprogramiv.c
26 * From the GL_ARB_uniform_buffer_object spec:
28 * "If <pname> is ACTIVE_UNIFORM_BLOCKS the number of uniform
29 * blocks for <program> containing active uniforms is returned.
31 * If <pname> is ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, the length
32 * of the longest active uniform block name, including the null
33 * terminator, is returned."
36 #include "piglit-util-gl.h"
38 PIGLIT_GL_TEST_CONFIG_BEGIN
40 config
.supports_gl_compat_version
= 10;
41 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
| PIGLIT_GL_VISUAL_DOUBLE
;
42 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
44 PIGLIT_GL_TEST_CONFIG_END
52 "#extension GL_ARB_uniform_buffer_object : enable\n"
53 "uniform a { float u1; };\n"
55 " gl_FragColor = vec4(u1);\n"
60 "#extension GL_ARB_uniform_buffer_object : enable\n"
61 "uniform a { float u1; };\n"
62 "uniform b { float u2; };\n"
64 " gl_FragColor = vec4(u1 + u2);\n"
69 "#extension GL_ARB_uniform_buffer_object : enable\n"
70 "uniform a { float u1; };\n"
71 "uniform bb { float u2; };\n"
73 " gl_FragColor = vec4(u1 + u2);\n"
78 "#extension GL_ARB_uniform_buffer_object : enable\n"
79 "uniform aa { float u1; };\n"
80 "uniform b { float u2; };\n"
82 " gl_FragColor = vec4(u1 + u2);\n"
92 const char *source
= tests
[test
].source
;
93 int namelen
= 9999, blocks
= 9999;
95 prog
= piglit_build_simple_program(NULL
, source
);
97 glGetProgramiv(prog
, GL_ACTIVE_UNIFORM_BLOCKS
, &blocks
);
98 if (blocks
!= tests
[test
].blocks
) {
100 "%d: Bad GL_ACTIVE_UNIFORM_BLOCKS "
101 "%d, expected %d. Source:\n%s",
102 test
, blocks
, tests
[test
].blocks
, source
);
106 glGetProgramiv(prog
, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH
, &namelen
);
107 if (namelen
!= tests
[test
].namelen
) {
109 "%d: Bad GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH "
110 "%d, expected %d. Source:\n%s",
111 test
, namelen
, tests
[test
].namelen
, source
);
115 glDeleteProgram(prog
);
121 piglit_init(int argc
, char **argv
)
126 piglit_require_extension("GL_ARB_uniform_buffer_object");
128 for (i
= 0; i
< ARRAY_SIZE(tests
); i
++) {
129 pass
= test_shader(i
) && pass
;
132 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);
135 enum piglit_result
piglit_display(void)