ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_uniform_buffer_object / bindbuffer-general-point.c
blob5d8498bf44b9faf00680856686d7f4bee8d17389
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 bindbuffer-general-point.c
26 * Tests that the glBindBuffer* entrypoints also bind to the general
27 * binding point.
30 #include "piglit-util-gl.h"
32 PIGLIT_GL_TEST_CONFIG_BEGIN
34 config.supports_gl_compat_version = 10;
35 config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
36 config.khr_no_error_support = PIGLIT_NO_ERRORS;
38 PIGLIT_GL_TEST_CONFIG_END
40 void
41 piglit_init(int argc, char **argv)
43 bool pass = true;
44 GLuint bo[2];
45 GLint binding;
47 piglit_require_extension("GL_ARB_uniform_buffer_object");
49 glGenBuffers(2, bo);
50 glBindBuffer(GL_UNIFORM_BUFFER, bo[0]);
51 glBufferData(GL_UNIFORM_BUFFER, 1, NULL, GL_STATIC_READ);
52 glBindBuffer(GL_UNIFORM_BUFFER, bo[1]);
53 glBufferData(GL_UNIFORM_BUFFER, 1, NULL, GL_STATIC_READ);
55 /* From the GL_ARB_uniform_buffer_object spec:
57 * "Buffer objects are bound to uniform block binding
58 * points by calling one of the commands
60 * void BindBufferRange(...)
61 * void BindBufferBase(...)
63 * There is an array of buffer object binding points with
64 * which uniform blocks can be associated via
65 * UniformBlockBinding, plus a single general binding
66 * point that can be used by other buffer object
67 * manipulation functions (e.g. BindBuffer,
68 * MapBuffer). Both commands bind the buffer object named
69 * by <buffer> to the general binding point, and
70 * additionally bind the buffer object to the binding
71 * point in the array given by <index>."
73 glBindBufferBase(GL_UNIFORM_BUFFER, 0, bo[0]);
74 glGetIntegerv(GL_UNIFORM_BUFFER_BINDING, &binding);
75 if (binding != bo[0]) {
76 fprintf(stderr, "GL_UNIFORM_BUFFER_BINDING[0] was %d, expected %d\n",
77 binding, bo[0]);
78 pass = false;
81 glBindBufferRange(GL_UNIFORM_BUFFER, 1, bo[1], 0, 1);
82 glGetIntegerv(GL_UNIFORM_BUFFER_BINDING, &binding);
83 if (binding != bo[1]) {
84 fprintf(stderr, "GL_UNIFORM_BUFFER_BINDING[1] was %d, expected %d\n",
85 binding, bo[1]);
86 pass = false;
89 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
92 enum piglit_result piglit_display(void)
94 /* UNREACHED */
95 return PIGLIT_FAIL;