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 buffer-targets.c
26 * Tests that the GL_UNIFORM_BUFFER target is accepted by other gl
29 * From the GL_ARB_uniform_buffer_object spec:
31 * "Accepted by the <target> parameters of BindBuffer, BufferData,
32 * BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, and
38 #include "piglit-util-gl.h"
40 PIGLIT_GL_TEST_CONFIG_BEGIN
42 config
.supports_gl_compat_version
= 10;
43 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
| PIGLIT_GL_VISUAL_DOUBLE
;
44 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
46 PIGLIT_GL_TEST_CONFIG_END
49 piglit_init(int argc
, char **argv
)
53 uint8_t in_data
[1] = {0xaa};
54 uint8_t out_data
[1] = {0xd0};
57 piglit_require_extension("GL_ARB_uniform_buffer_object");
61 glBindBuffer(GL_UNIFORM_BUFFER
, bo
);
62 pass
= pass
&& piglit_check_gl_error(0);
64 glBufferData(GL_UNIFORM_BUFFER
, 1, NULL
, GL_STATIC_READ
);
65 pass
= pass
&& piglit_check_gl_error(0);
67 glBufferSubData(GL_UNIFORM_BUFFER
, 0, 1, in_data
);
68 pass
= pass
&& piglit_check_gl_error(0);
70 ptr1
= glMapBuffer(GL_UNIFORM_BUFFER
, GL_READ_ONLY
);
71 pass
= pass
&& piglit_check_gl_error(0);
73 glGetBufferPointerv(GL_UNIFORM_BUFFER
, GL_BUFFER_MAP_POINTER
, &ptr2
);
74 pass
= pass
&& piglit_check_gl_error(0);
77 glUnmapBuffer(GL_UNIFORM_BUFFER
);
78 pass
= pass
&& piglit_check_gl_error(0);
80 glGetBufferSubData(GL_UNIFORM_BUFFER
, 0, 1, out_data
);
81 pass
= pass
&& piglit_check_gl_error(0);
82 assert(memcmp(in_data
, out_data
, sizeof(in_data
)) == 0);
84 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);
87 enum piglit_result
piglit_display(void)