2 * Copyright 2015 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 create-renderbuffers.c
26 * Tests glCreateRenderbuffers to see if it behaves in the expected way, throwing
27 * the correct errors, etc.
29 * From OpenGL 4.5, section 9.2.4 "Renderbuffer Objects", page 297:
31 * "void CreateRenderbuffers( sizei n, uint *renderbuffers );
33 * CreateRenderbuffers returns n previously unused renderbuffer names in
34 * renderbuffers, each representing a new renderbuffer object which is a state
35 * vector comprising all the state and with the initial values listed in table
36 * 23.27. The state of each renderbuffer object is as if a name returned from
37 * GenRenderbuffers had been bound to the RENDERBUFFER target, except that any
38 * existing binding to RENDERBUFFER is not affected.
41 * An INVALID_VALUE error is generated if n is negative."
44 #include "piglit-util-gl.h"
45 #include "dsa-utils.h"
47 PIGLIT_GL_TEST_CONFIG_BEGIN
49 config
.supports_gl_core_version
= 31;
51 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
|
52 PIGLIT_GL_VISUAL_DOUBLE
;
53 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
55 PIGLIT_GL_TEST_CONFIG_END
58 piglit_init(int argc
, char **argv
)
60 piglit_require_extension("GL_ARB_direct_state_access");
61 piglit_require_extension("GL_ARB_framebuffer_object");
73 /* Throw some invalid inputs at glCreateRenderbuffers */
74 if (!piglit_khr_no_error
) {
76 glCreateRenderbuffers(-1, ids
);
77 PIGLIT_SUBTEST_ERROR(GL_INVALID_VALUE
, pass
, "n < 0");
80 /* Throw some valid inputs at glCreateRenderbuffers. */
83 glCreateRenderbuffers(0, NULL
);
84 PIGLIT_SUBTEST_ERROR(GL_NO_ERROR
, pass
, "n == 0");
86 /* n is more than 1 */
87 glCreateRenderbuffers(10, ids
);
88 PIGLIT_SUBTEST_ERROR(GL_NO_ERROR
, pass
, "n > 1");
90 /* test the default state of dsa-created render buffer objects */
91 PIGLIT_SUBTEST_CONDITION(glIsRenderbuffer(ids
[2]), pass
,
94 glBindRenderbuffer(GL_RENDERBUFFER
, ids
[2]);
95 piglit_check_gl_error(GL_NO_ERROR
);
97 glGetRenderbufferParameteriv(GL_RENDERBUFFER
,
98 GL_RENDERBUFFER_WIDTH
, ¶m
);
99 piglit_check_gl_error(GL_NO_ERROR
);
100 PIGLIT_SUBTEST_CONDITION(param
== 0, pass
,
101 "default width(%d) == 0", param
);
103 glGetRenderbufferParameteriv(GL_RENDERBUFFER
,
104 GL_RENDERBUFFER_HEIGHT
, ¶m
);
105 piglit_check_gl_error(GL_NO_ERROR
);
106 PIGLIT_SUBTEST_CONDITION(param
== 0, pass
,
107 "default height(%d) == 0", param
);
109 glGetRenderbufferParameteriv(GL_RENDERBUFFER
,
110 GL_RENDERBUFFER_INTERNAL_FORMAT
, ¶m
);
111 piglit_check_gl_error(GL_NO_ERROR
);
112 PIGLIT_SUBTEST_CONDITION(param
== GL_RGBA
, pass
,
113 "default internal format == RGBA");
115 glGetRenderbufferParameteriv(GL_RENDERBUFFER
,
116 GL_RENDERBUFFER_RED_SIZE
, ¶m
);
117 piglit_check_gl_error(GL_NO_ERROR
);
118 PIGLIT_SUBTEST_CONDITION(param
== 0, pass
,
119 "default red size(%d) == 0", param
);
121 glGetRenderbufferParameteriv(GL_RENDERBUFFER
,
122 GL_RENDERBUFFER_GREEN_SIZE
, ¶m
);
123 piglit_check_gl_error(GL_NO_ERROR
);
124 PIGLIT_SUBTEST_CONDITION(param
== 0, pass
,
125 "default green size(%d) == 0", param
);
127 glGetRenderbufferParameteriv(GL_RENDERBUFFER
,
128 GL_RENDERBUFFER_BLUE_SIZE
, ¶m
);
129 piglit_check_gl_error(GL_NO_ERROR
);
130 PIGLIT_SUBTEST_CONDITION(param
== 0, pass
,
131 "default blue size(%d) == 0", param
);
133 glGetRenderbufferParameteriv(GL_RENDERBUFFER
,
134 GL_RENDERBUFFER_ALPHA_SIZE
, ¶m
);
135 piglit_check_gl_error(GL_NO_ERROR
);
136 PIGLIT_SUBTEST_CONDITION(param
== 0, pass
,
137 "default alpha size(%d) == 0", param
);
139 glGetRenderbufferParameteriv(GL_RENDERBUFFER
,
140 GL_RENDERBUFFER_DEPTH_SIZE
, ¶m
);
141 piglit_check_gl_error(GL_NO_ERROR
);
142 PIGLIT_SUBTEST_CONDITION(param
== 0, pass
,
143 "default depth size(%d) == 0", param
);
145 glGetRenderbufferParameteriv(GL_RENDERBUFFER
,
146 GL_RENDERBUFFER_STENCIL_SIZE
, ¶m
);
147 piglit_check_gl_error(GL_NO_ERROR
);
148 PIGLIT_SUBTEST_CONDITION(param
== 0, pass
,
149 "default stencil size(%d) == 0", param
);
151 glGetRenderbufferParameteriv(GL_RENDERBUFFER
,
152 GL_RENDERBUFFER_SAMPLES
, ¶m
);
153 piglit_check_gl_error(GL_NO_ERROR
);
154 PIGLIT_SUBTEST_CONDITION(param
== 0, pass
,
155 "default no. of samples(%d) == 0", param
);
157 glGetObjectLabel(GL_RENDERBUFFER
, ids
[2], 11, &length
, label
);
158 piglit_check_gl_error(GL_NO_ERROR
);
159 PIGLIT_SUBTEST_CONDITION(length
== 0, pass
,
160 "default label size(%d) == 0", length
);
163 glDeleteRenderbuffers(10, ids
);
165 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;