ARB_ubo/referenced-by-shader: pass if shader compiler moves UBOs between shaders
[piglit.git] / tests / spec / arb_transform_feedback3 / bind_buffer_invalid_index.c
blobfc762a384bd2b1b105b256c216ce8ff59598a7b8
1 /*
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
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 DEALINGS
21 * IN THE SOFTWARE.
24 #include "piglit-util-gl.h"
26 /**
27 * @file bind_buffer_invalid_index.c
29 * Tests that invalid index given to BindBufferRange() or BindBufferBase()
30 * is detected and an error is set. The spec says:
32 * "The error INVALID_VALUE is generated by BindBufferRange,
33 * BindBufferOffsetEXT, or BindBufferBase if <target> is
34 * TRANSFORM_FEEDBACK_BUFFER and <index> is greater than or equal to the
35 * value of MAX_TRANSFORM_FEEDBACK_BUFFERS."
38 PIGLIT_GL_TEST_CONFIG_BEGIN
40 config.supports_gl_compat_version = 32;
41 config.supports_gl_core_version = 32;
42 config.khr_no_error_support = PIGLIT_HAS_ERRORS;
44 PIGLIT_GL_TEST_CONFIG_END
46 void
47 piglit_init(int argc, char **argv)
49 GLuint xfb;
50 GLint max_xfb_buffers;
51 bool pass = true;
53 piglit_require_extension("GL_ARB_transform_feedback3");
55 glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_BUFFERS, &max_xfb_buffers);
56 if (!piglit_check_gl_error(GL_NO_ERROR)) {
57 printf("failed to resolve the maximum number of feedback "
58 "buffers\n");
59 piglit_report_result(PIGLIT_FAIL);
62 if (max_xfb_buffers <= 0) {
63 printf("invalid maximum number of feedback buffers: %d\n",
64 max_xfb_buffers);
65 piglit_report_result(PIGLIT_FAIL);
68 /* Set up the transform feedback buffers. */
69 glGenBuffers(1, &xfb);
71 /* Binding to the maximum supported buffer should be fine. */
72 glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, max_xfb_buffers - 1,
73 xfb);
74 if (!piglit_check_gl_error(GL_NO_ERROR)) {
75 printf("failed to bind maximum supported buffer\n");
76 pass = false;
79 /* Unbind. */
80 glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, max_xfb_buffers - 1, 0);
82 glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, max_xfb_buffers, xfb);
83 if (!piglit_check_gl_error(GL_INVALID_VALUE)) {
84 printf("should not be able to bind beyond maximum supported\n");
85 pass = false;
87 /* Unbind. */
88 glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, max_xfb_buffers,
89 0);
92 /* Binding to the maximum supported buffer should be fine. */
93 glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, max_xfb_buffers - 1,
94 xfb, 0, sizeof(GLfloat));
95 if (piglit_check_gl_error(GL_NO_ERROR)) {
96 /* Unbind. */
97 glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER,
98 max_xfb_buffers - 1, 0);
99 } else {
100 printf("failed to bind range in maximum supported buffer\n");
101 pass = false;
104 glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, max_xfb_buffers,
105 xfb, 0, sizeof(GLfloat));
106 if (!piglit_check_gl_error(GL_INVALID_VALUE)) {
107 printf("should not be able to bind beyond maximum supported\n");
108 pass = false;
110 /* Unbind. */
111 glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, max_xfb_buffers,
115 glDeleteBuffers(1, &xfb);
117 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
120 enum piglit_result
121 piglit_display(void)
123 /* Should never be reached */
124 return PIGLIT_FAIL;