ARB_ubo/referenced-by-shader: pass if shader compiler moves UBOs between shaders
[piglit.git] / tests / spec / arb_uniform_buffer_object / negative-bindbuffer-target.c
blob2355bbe1cced15b38a4159cd2a576d0360007b27
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 negative-bindbuffer-target.c
26 * Tests for errors when binding with a bad target.
29 #include "piglit-util-gl.h"
31 PIGLIT_GL_TEST_CONFIG_BEGIN
33 config.supports_gl_compat_version = 10;
34 config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
35 config.khr_no_error_support = PIGLIT_HAS_ERRORS;
37 PIGLIT_GL_TEST_CONFIG_END
39 void
40 piglit_init(int argc, char **argv)
42 /* We don't need to check extensions for these targets, since
43 * we're expecting INVALID_ENUM anyway.
45 GLenum targets[] = {
46 0xd0d0d0d0,
47 GL_ARRAY_BUFFER,
48 GL_ELEMENT_ARRAY_BUFFER,
49 GL_COPY_READ_BUFFER,
50 GL_COPY_WRITE_BUFFER,
51 GL_PIXEL_PACK_BUFFER,
52 GL_PIXEL_UNPACK_BUFFER,
53 GL_TEXTURE_BUFFER
55 bool pass = true;
56 int i;
57 GLuint bo;
59 piglit_require_extension("GL_ARB_uniform_buffer_object");
61 glGenBuffers(1, &bo);
62 glBindBuffer(GL_UNIFORM_BUFFER, bo);
63 glBufferData(GL_UNIFORM_BUFFER, 1, NULL, GL_STATIC_READ);
65 /* From the GL_ARB_uniform_buffer_object spec:
67 * "The error INVALID_ENUM is generated by
68 * BindBufferRange and BindBufferBase if <target> is not
69 * an accepted indexable buffer object target."
71 for (i = 0; i < ARRAY_SIZE(targets); i++) {
72 glBindBufferBase(targets[i], 0, bo);
73 if (!piglit_check_gl_error(GL_INVALID_ENUM)) {
74 printf("Fail on target 0x%08x (%s)\n",
75 targets[i],
76 piglit_get_gl_enum_name(targets[i]));
77 pass = false;
80 glBindBufferRange(targets[i], 0, bo, 0, 1);
81 if (!piglit_check_gl_error(GL_INVALID_ENUM)) {
82 printf("Fail on target 0x%08x (%s)\n",
83 targets[i],
84 piglit_get_gl_enum_name(targets[i]));
85 pass = false;
89 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
92 enum piglit_result piglit_display(void)
94 /* UNREACHED */
95 return PIGLIT_FAIL;