2 * Copyright © 2011 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 DEALINGS
24 #include "piglit-util-gl.h"
29 * Tests that conditional rendering appropriately affects commands
30 * inside of display lists. From the GL_ARB_uniform_buffer_object
33 * "(33) Which uniform buffer object commands must be excluded
36 * RESOLUTION: Resolved
38 * When used with 3.1 (where display lists have been removed
39 * altogether) obviously, this question is moot.
41 * For GL 2.0/3.0, this should be resolved with the following
46 * UniformBlockBinding should follow the precedent of glUniform (for
47 * setting samplers) which *does* get included in display lists.
51 * Since we use the BindBufferOffset/BindBufferRange API
52 * introduced by OpenGL 3.0, and those routines are already
53 * excluded, there's no additions to the display list exclusion
57 PIGLIT_GL_TEST_CONFIG_BEGIN
59 config
.supports_gl_compat_version
= 10;
61 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGBA
;
62 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
64 PIGLIT_GL_TEST_CONFIG_END
67 "#extension GL_ARB_uniform_buffer_object : enable\n"
68 "uniform A { float a; };\n"
69 "uniform B { float b; };\n"
71 " gl_FragColor = vec4(a + b);\n"
82 check_binding(int line
, GLuint prog
, int index
, int binding
)
84 GLint current_binding
;
86 glGetActiveUniformBlockiv(prog
, index
, GL_UNIFORM_BLOCK_BINDING
,
89 if (current_binding
!= binding
) {
90 printf("%s:%d: Binding %d should be %d, was %d\n",
91 __FILE__
, line
, index
, binding
, current_binding
);
100 piglit_init(int argc
, char **argv
)
108 piglit_require_extension("GL_ARB_uniform_buffer_object");
110 prog
= piglit_build_simple_program(NULL
, source
);
112 /* Test that glUniformBlockBinding() goes into display lists. */
113 glUniformBlockBinding(prog
, 0, 0);
114 glUniformBlockBinding(prog
, 0, 1);
116 list
= glGenLists(1);
117 glNewList(list
, GL_COMPILE_AND_EXECUTE
);
118 glUniformBlockBinding(prog
, 0, 2);
119 glUniformBlockBinding(prog
, 1, 3);
122 pass
= check_binding(__LINE__
, prog
, 0, 2) && pass
;
123 pass
= check_binding(__LINE__
, prog
, 1, 3) && pass
;
125 glUniformBlockBinding(prog
, 0, 0);
126 glUniformBlockBinding(prog
, 0, 1);
130 pass
= check_binding(__LINE__
, prog
, 0, 2) && pass
;
131 pass
= check_binding(__LINE__
, prog
, 1, 3) && pass
;
133 /* Test that glBindBufferBase()/glBindBufferRange() fail
134 * inside a display list.
137 glBindBuffer(GL_UNIFORM_BUFFER
, bo
[0]);
138 glBufferData(GL_UNIFORM_BUFFER
, 4, NULL
, GL_STATIC_DRAW
);
139 glBindBuffer(GL_UNIFORM_BUFFER
, bo
[1]);
140 glBufferData(GL_UNIFORM_BUFFER
, 4, NULL
, GL_STATIC_DRAW
);
142 pass
= piglit_check_gl_error(0) && pass
;
144 glBindBufferBase(GL_UNIFORM_BUFFER
, 0, bo
[0]);
145 glBindBufferBase(GL_UNIFORM_BUFFER
, 1, bo
[0]);
147 glNewList(list
, GL_COMPILE
);
148 glBindBufferBase(GL_UNIFORM_BUFFER
, 0, bo
[1]);
149 glBindBufferRange(GL_UNIFORM_BUFFER
, 1, bo
[1], 0, 4);
152 glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING
, 0, ¤t_bo
);
153 if (current_bo
!= bo
[1]) {
154 fprintf(stderr
, "glBindBufferBase() during display list compile "
155 "set BO to %d, expected %d\n",
159 glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING
, 1, ¤t_bo
);
160 if (current_bo
!= bo
[1]) {
161 fprintf(stderr
, "glBindBufferRange() during display list "
162 "compile set BO to %d, expected %d\n",
167 glBindBufferBase(GL_UNIFORM_BUFFER
, 0, bo
[0]);
168 glBindBufferBase(GL_UNIFORM_BUFFER
, 1, bo
[0]);
171 glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING
, 0, ¤t_bo
);
172 if (current_bo
!= bo
[0]) {
173 fprintf(stderr
, "glBindBufferBase() during display list exec "
174 "set BO to %d, expected %d\n",
178 glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING
, 1, ¤t_bo
);
179 if (current_bo
!= bo
[0]) {
180 fprintf(stderr
, "glBindBufferRange() during display list exec "
181 "set BO to %d, expected %d\n",
185 pass
= piglit_check_gl_error(0) && pass
;
187 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);