ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_uniform_buffer_object / negative-bindbufferrange-range.c
blob72ab623ff0f9ca06cf8f68ddf0ef76484b804aa1
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-bindbufferrange-range.c
26 * From the GL_ARB_uniform_buffer_object spec:
28 * "For BindBufferRange, <offset> specifies a starting offset into
29 * the buffer object <buffer>, and <size> specifies the amount of
30 * data that can be read from the buffer object while used as the
31 * storage for a uniform block. Both <offset> and <size> are in
32 * basic machine units. The error INVALID_VALUE is generated if
33 * the value of <size> is less than or equal to zero, if <offset>
34 * + <size> is greater than the value of BUFFER_SIZE, or if
35 * <offset> is not a multiple of the implementation-dependent
36 * required alignment
37 * (UNIFORM_BUFFER_OFFSET_ALIGNMENT). BindBufferBase is
38 * equivalent to calling BindBufferRange with <offset> zero and
39 * <size> equal to the size of <buffer>."
42 #include "piglit-util-gl.h"
44 PIGLIT_GL_TEST_CONFIG_BEGIN
46 config.supports_gl_compat_version = 10;
47 config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
48 config.khr_no_error_support = PIGLIT_HAS_ERRORS;
50 PIGLIT_GL_TEST_CONFIG_END
52 void
53 piglit_init(int argc, char **argv)
55 bool pass = true;
56 GLint alignment;
57 GLuint bo;
58 int size = 1024;
59 int index = 0;
60 int i;
62 piglit_require_extension("GL_ARB_uniform_buffer_object");
64 glGenBuffers(1, &bo);
65 glBindBuffer(GL_UNIFORM_BUFFER, bo);
66 glBufferData(GL_UNIFORM_BUFFER, size, NULL, GL_STATIC_READ);
68 glBindBufferRange(GL_UNIFORM_BUFFER, index, bo, 0, 0);
69 if (!piglit_check_gl_error(GL_INVALID_VALUE))
70 pass = false;
72 glBindBufferRange(GL_UNIFORM_BUFFER, index, bo, 0, -1);
73 if (!piglit_check_gl_error(GL_INVALID_VALUE))
74 pass = false;
76 /* Note: we don't check the following condition (which is
77 * specified in OpenGL specs from 3.0 through 4.1):
79 * "The error INVALID_VALUE is generated if size is less
80 * than or equal to zero or if offset + size is greater
81 * than the value of BUFFER_SIZE."
83 * This text was dropped from OpenGL 4.2, and it does not
84 * appear in the GLES 3.0 spec. Since this is a deliberate
85 * relaxation of error conditions in order to allow clients to
86 * work, it seems sensible to allow implementations to apply
87 * this change even if the GL version is less than 4.2.
90 glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &alignment);
91 for (i = 1; i < alignment; i++) {
92 glBindBufferRange(GL_UNIFORM_BUFFER, index, bo, i, 4);
93 if (!piglit_check_gl_error(GL_INVALID_VALUE))
94 pass = false;
97 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
100 enum piglit_result piglit_display(void)
102 /* UNREACHED */
103 return PIGLIT_FAIL;