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 namedrenderbuffer.c
26 * Tests NamedRenderbufferStorage* functions to see if they behaves in the
27 * expected way, throwing the correct errors, etc. Also test
28 * glGetRenderbufferParameteriv.
30 * From OpenGL 4.5, section 9.2.4 "Renderbuffer Objects", page 298:
32 * "void NamedRenderbufferStorageMultisample(uint renderbuffer, sizei samples,
33 * enum internalformat,sizei width,
37 * For NamedRenderbufferStorageMultisample, renderbuffer is the name of the
38 * renderbuffer object. internalformat must be color-renderable,
39 * depth-renderable, or stencilrenderable (as defined in section 9.4). width
40 * and height are the dimensions in pixels of the renderbuffer. Upon success,
41 * RenderbufferStorageMultisample deletes any existing data store for the
42 * renderbuffer image, and the contents of the data store are undefined.
43 * RENDERBUFFER_WIDTH is set to width, RENDERBUFFER_HEIGHT is set to
44 * height, and RENDERBUFFER_INTERNAL_FORMAT is set to internalformat.
45 * If samples is zero, then RENDERBUFFER_SAMPLES is set to zero. Otherwise
46 * samples represents a request for a desired minimum number of samples. Since
47 * different implementations may support different sample counts for
48 * multisampled rendering, the actual number of samples allocated for the
49 * renderbuffer image is implementation-dependent. However, the resulting value
50 * for RENDERBUFFER_SAMPLES is guaranteed to be greater than or equal to
51 * samples and no more than the next larger sample count supported by the
52 * implementation. A GL implementation may vary its allocation of internal
53 * component resolution based on any *RenderbufferStorageMultisample parameter
54 * (except target and renderbuffer), but the allocation and chosen internal
55 * format must not be a function of any other state and cannot be changed once
56 * they are established.
59 * An INVALID_ENUM error is generated by RenderbufferStorageMultisample
60 * if target is not RENDERBUFFER.
61 * An INVALID_OPERATION error is generated by NamedRenderbufferStorageMultisample
62 * if renderbuffer is not the name of an existing renderbuffer object.
63 * An INVALID_VALUE error is generated if samples, width, or height is negative.
64 * An INVALID_OPERATION error is generated if samples is greater than the
65 * maximum number of samples supported for internalformat (see
66 * GetInternalformativ in section 22.3).
67 * An INVALID_ENUM error is generated if internalformat is not one of the
68 * color-renderable, depth-renderable, or stencil-renderable formats defined
70 * An INVALID_VALUE error is generated if either width or height is greater
71 * than the value of MAX_RENDERBUFFER_SIZE.
73 * void NamedRenderbufferStorage(uint renderbuffer, enum internalformat,
74 * sizei width, sizei height);
75 * are equivalent to [...] NamedRenderbufferStorageMultisample(renderbuffer, 0,
76 * internalformat, width, height);"
79 #include "piglit-util-gl.h"
80 #include "dsa-utils.h"
82 PIGLIT_GL_TEST_CONFIG_BEGIN
84 config
.supports_gl_core_version
= 31;
86 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
|
87 PIGLIT_GL_VISUAL_DOUBLE
;
88 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
90 PIGLIT_GL_TEST_CONFIG_END
93 piglit_init(int argc
, char **argv
)
95 piglit_require_extension("GL_ARB_direct_state_access");
96 piglit_require_extension("GL_ARB_framebuffer_object");
103 GLuint ids
[10], genID
;
106 /* Test retrieving information about an unexisting buffer */
107 glCreateRenderbuffers(10, ids
);
108 piglit_check_gl_error(GL_NO_ERROR
);
110 if (piglit_khr_no_error
)
113 /* Check some various cases of errors */
114 glNamedRenderbufferStorageMultisample(1337, 0, GL_RGBA
, 1024, 768);
115 PIGLIT_SUBTEST_ERROR(GL_INVALID_OPERATION
, pass
, "set unexisting "
118 glGetNamedRenderbufferParameteriv(1337, GL_RENDERBUFFER_WIDTH
, &width
);
119 PIGLIT_SUBTEST_ERROR(GL_INVALID_OPERATION
, pass
, "get unexisting "
122 glGetNamedRenderbufferParameteriv(ids
[0], GL_TRUE
, &width
);
123 PIGLIT_SUBTEST_ERROR(GL_INVALID_ENUM
, pass
, "get unexisting parameter");
125 /* Test retrieving information on an un-initialized buffer */
126 glGenRenderbuffers(1, &genID
);
127 piglit_check_gl_error(GL_NO_ERROR
);
129 glGetNamedRenderbufferParameteriv(1337, GL_RENDERBUFFER_WIDTH
, &width
);
130 PIGLIT_SUBTEST_ERROR(GL_INVALID_OPERATION
, pass
, "get uninitialized "
133 /* Test the width/heights limits */
134 glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE
, &size
);
136 glNamedRenderbufferStorageMultisample(ids
[0], 0, GL_RGBA
, -1, 768);
137 PIGLIT_SUBTEST_ERROR(GL_INVALID_VALUE
, pass
, "width < 0");
139 glNamedRenderbufferStorageMultisample(ids
[0], 0, GL_RGBA
, size
+ 1,
141 PIGLIT_SUBTEST_ERROR(GL_INVALID_VALUE
, pass
,
142 "width == MAX_RENDER_SIZE(%d) + 1", size
);
144 glNamedRenderbufferStorageMultisample(ids
[0], 0, GL_RGBA
, 1024, -1);
145 PIGLIT_SUBTEST_ERROR(GL_INVALID_VALUE
, pass
, "height < 0");
147 glNamedRenderbufferStorageMultisample(ids
[0], 0, GL_RGBA
, 1024,
149 PIGLIT_SUBTEST_ERROR(GL_INVALID_VALUE
, pass
,
150 "height == MAX_RENDER_SIZE(%d) + 1", size
);
152 /* Test the samples limits */
153 glGetIntegerv(GL_MAX_SAMPLES
, &size
);
155 glNamedRenderbufferStorageMultisample(ids
[0], -1, GL_RGBA
, 1024, 768);
156 PIGLIT_SUBTEST_ERROR(GL_INVALID_VALUE
, pass
, "samples < 0");
158 glNamedRenderbufferStorageMultisample(ids
[0], size
+ 1, GL_RGBA
, 1024,
160 PIGLIT_SUBTEST_ERROR(GL_INVALID_OPERATION
, pass
,
161 "samples == MAX_SAMPLES(%d) + 1", size
);
164 glNamedRenderbufferStorageMultisample(ids
[0], 0, GL_TRUE
, 1024, 768);
165 PIGLIT_SUBTEST_ERROR(GL_INVALID_ENUM
, pass
, "invalid internalformat");
168 /* bind one buffer so as we can check we never change its state */
169 glBindRenderbuffer(GL_RENDERBUFFER
, ids
[1]);
170 piglit_check_gl_error(GL_NO_ERROR
);
172 /* Test to change the parameters of an unbound renderbuffer */
173 glNamedRenderbufferStorageMultisample(ids
[0], 0, GL_RGBA
, 1024,
175 PIGLIT_SUBTEST_ERROR(GL_NO_ERROR
, pass
, "update unbound buffer");
177 glGetNamedRenderbufferParameteriv(ids
[0], GL_RENDERBUFFER_WIDTH
,
179 piglit_check_gl_error(GL_NO_ERROR
);
180 PIGLIT_SUBTEST_CONDITION(width
== 1024, pass
,
181 "width of the unbound buffer updated");
183 glGetRenderbufferParameteriv(GL_RENDERBUFFER
, GL_RENDERBUFFER_WIDTH
,
185 piglit_check_gl_error(GL_NO_ERROR
);
186 PIGLIT_SUBTEST_CONDITION(width
== 0, pass
,
187 "width of the bound buffer unchanged");
190 glDeleteRenderbuffers(10, ids
);
192 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;