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
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 /** @file buffer-binding.c
26 * Test that glBindBufferBase() and glBindBufferRange() have the
27 * necessary error checking for atomic counter buffers and that they
28 * update the buffer metadata correctly.
33 PIGLIT_GL_TEST_CONFIG_BEGIN
35 config
.supports_gl_core_version
= 31;
37 config
.window_width
= 1;
38 config
.window_height
= 1;
39 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGBA
;
40 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
42 PIGLIT_GL_TEST_CONFIG_END
45 run_test_bind_at(unsigned i
)
49 glGenBuffers(1, &buffer
);
51 glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER
, i
, buffer
);
55 glBufferData(GL_ATOMIC_COUNTER_BUFFER
, 4, NULL
, GL_STATIC_DRAW
);
56 glDeleteBuffers(1, &buffer
);
62 run_test_bind_range(unsigned i
)
68 glGenBuffers(1, &buffer
);
70 glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER
, i
, buffer
);
71 if (!piglit_check_gl_error(GL_NO_ERROR
)) {
72 printf("Initial buffer binding failed.\n");
76 glBufferData(GL_ATOMIC_COUNTER_BUFFER
, 16, NULL
, GL_STATIC_DRAW
);
78 if (!piglit_khr_no_error
) {
79 glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER
, i
, buffer
, 6, 5);
80 if (!piglit_check_gl_error(GL_INVALID_VALUE
)) {
81 printf("Misaligned buffer range binding didn't "
82 "generate a GL_INVALID_VALUE error.\n");
87 glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER
, i
, buffer
, 8, 5);
88 if (!piglit_check_gl_error(GL_NO_ERROR
)) {
89 printf("Buffer range binding failed.\n");
93 glGetIntegerv(GL_ATOMIC_COUNTER_BUFFER_BINDING
, &binding
);
94 if (!piglit_check_gl_error(GL_NO_ERROR
) ||
96 printf("Unexpected generic counter buffer binding: 0x%x.\n",
101 glGetIntegeri_v(GL_ATOMIC_COUNTER_BUFFER_BINDING
, i
, &binding
);
102 if (!piglit_check_gl_error(GL_NO_ERROR
) ||
104 printf("Unexpected counter buffer binding %d: 0x%x.\n",
109 glGetIntegeri_v(GL_ATOMIC_COUNTER_BUFFER_START
, i
, &start
);
110 if (!piglit_check_gl_error(GL_NO_ERROR
) ||
112 printf("Unexpected counter buffer offset 0x%x.\n",
117 glGetIntegeri_v(GL_ATOMIC_COUNTER_BUFFER_SIZE
, i
, &size
);
118 if (!piglit_check_gl_error(GL_NO_ERROR
) ||
120 printf("Unexpected counter buffer size: 0x%x.\n",
125 glDeleteBuffers(1, &buffer
);
131 piglit_init(int argc
, char **argv
)
133 struct atomic_counters_limits ls
= atomic_counters_get_limits();
134 enum piglit_result status
= PIGLIT_PASS
;
136 piglit_require_gl_version(31);
137 piglit_require_extension("GL_ARB_shader_atomic_counters");
139 atomic_counters_subtest(&status
, GL_NONE
,
140 "Atomic buffer binding below the "
141 "implementation limit",
142 run_test_bind_at
, ls
.bindings
- 1);
144 if (!piglit_khr_no_error
) {
145 atomic_counters_subtest(&status
, GL_NONE
,
146 "Atomic buffer binding above the "
147 "implementation limit",
148 !run_test_bind_at
, ls
.bindings
);
151 atomic_counters_subtest(&status
, GL_NONE
,
152 "Atomic buffer range binding",
153 run_test_bind_range
, ls
.bindings
- 1);
155 piglit_report_result(status
);