2 * Copyright (c) 2017 Timothy Arceri
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 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the 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,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NON-INFRINGEMENT. IN NO EVENT SHALL VMWARE AND/OR THEIR SUPPLIERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 * Tests that api errors are thrown where expected for the
27 * GL_EXT_memory_object extension.
30 #include "piglit-util-gl.h"
32 PIGLIT_GL_TEST_CONFIG_BEGIN
34 config
.supports_gl_compat_version
= 20; /* Need 2.0 for DSA tests */
35 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
| PIGLIT_GL_VISUAL_DOUBLE
;
36 config
.khr_no_error_support
= PIGLIT_HAS_ERRORS
;
38 PIGLIT_GL_TEST_CONFIG_END
42 test_tex_storage_errors(GLenum target
, bool dsa
)
44 const GLint width
= 64, height
= 4, depth
= 8;
47 assert(target
== GL_TEXTURE_1D
||
48 target
== GL_TEXTURE_2D
||
49 target
== GL_TEXTURE_3D
);
51 glGenTextures(1, &tex
);
52 glBindTexture(target
, tex
);
54 /* Test that passing 0 for <memory> results in an error. */
55 if (target
== GL_TEXTURE_1D
) {
57 glTextureStorageMem1DEXT(tex
, 1, GL_RGBA8
, width
, 0,
60 glTexStorageMem1DEXT(target
, 1, GL_RGBA8
, width
, 0,
64 else if (target
== GL_TEXTURE_2D
) {
66 glTextureStorageMem2DEXT(tex
, 1, GL_RGBA8
, width
,
69 glTexStorageMem2DEXT(target
, 1, GL_RGBA8
, width
,
73 else if (target
== GL_TEXTURE_3D
) {
75 glTextureStorageMem3DEXT(tex
, 1, GL_RGBA8
, width
,
78 glTexStorageMem3DEXT(target
, 1, GL_RGBA8
, width
,
83 /* From the EXT_external_objects spec:
85 * "An INVALID_VALUE error is generated if <memory> is 0 ..."
87 return piglit_check_gl_error(GL_INVALID_VALUE
);
91 test_tex_storage_ms_errors(GLenum target
, bool dsa
)
93 const GLint width
= 64, height
= 4, depth
= 8;
96 assert(target
== GL_TEXTURE_2D_MULTISAMPLE
||
97 target
== GL_TEXTURE_2D_MULTISAMPLE_ARRAY
);
99 glGenTextures(1, &tex
);
100 glBindTexture(target
, tex
);
102 /* Test that passing 0 for <memory> results in an error. */
103 if (target
== GL_TEXTURE_2D_MULTISAMPLE
) {
105 glTextureStorageMem2DMultisampleEXT(tex
, 1, GL_RGBA8
,
109 glTexStorageMem2DMultisampleEXT(target
, 1, GL_RGBA8
,
114 else if (target
== GL_TEXTURE_2D_MULTISAMPLE_ARRAY
) {
116 glTextureStorageMem3DMultisampleEXT(tex
, 1, GL_RGBA8
,
121 glTexStorageMem3DMultisampleEXT(target
, 1, GL_RGBA8
,
128 /* From the EXT_external_objects spec:
130 * "An INVALID_VALUE error is generated if <memory> is 0 ..."
132 return piglit_check_gl_error(GL_INVALID_VALUE
);
135 #define BUF_SIZE (12 * 4 * sizeof(float))
138 test_buffer_storage_errors(bool dsa
)
142 glGenBuffers(1, &buffer
);
143 glBindBuffer(GL_ARRAY_BUFFER
, buffer
);
145 /* Test that passing 0 for <memory> results in an error. */
147 glNamedBufferStorageMemEXT(buffer
, BUF_SIZE
, 0, 0);
149 glBufferStorageMemEXT(GL_ARRAY_BUFFER
, BUF_SIZE
, 0, 0);
152 /* From the EXT_external_objects spec:
154 * "An INVALID_VALUE error is generated if <memory> is 0 ..."
156 return piglit_check_gl_error(GL_INVALID_VALUE
);
161 const bool subtest_pass = (f); \
162 piglit_report_subtest_result(subtest_pass \
163 ? PIGLIT_PASS : PIGLIT_FAIL, \
165 pass = pass && subtest_pass; \
171 /* TODO: currently this test only tests for errors when we pass 0 for
172 * <memory>. We need to test for other errors.
176 bool dsa
= piglit_is_extension_supported("GL_ARB_direct_state_access");
178 X(test_tex_storage_errors(GL_TEXTURE_1D
, false), "1D texture");
179 X(test_tex_storage_errors(GL_TEXTURE_2D
, false), "2D texture");
180 X(test_tex_storage_errors(GL_TEXTURE_3D
, false), "3D texture");
183 X(test_tex_storage_errors(GL_TEXTURE_1D
, true), "1D texture direct state access");
184 X(test_tex_storage_errors(GL_TEXTURE_2D
, true), "2D texture direct state access");
185 X(test_tex_storage_errors(GL_TEXTURE_3D
, true), "3D texture direct state access");
188 if (piglit_is_extension_supported("GL_ARB_texture_storage_multisample")) {
189 X(test_tex_storage_ms_errors(GL_TEXTURE_2D_MULTISAMPLE
, false), "2D texture ms");
190 X(test_tex_storage_ms_errors(GL_TEXTURE_2D_MULTISAMPLE_ARRAY
, false), "3D texture ms");
193 X(test_tex_storage_ms_errors(GL_TEXTURE_2D_MULTISAMPLE
, true), "2D texture ms direct state access");
194 X(test_tex_storage_ms_errors(GL_TEXTURE_2D_MULTISAMPLE_ARRAY
, true), "3D texture ms direct state access");
198 if (piglit_is_extension_supported("GL_ARB_buffer_storage")) {
199 X(test_buffer_storage_errors(false), "buffer storage");
202 X(test_buffer_storage_errors(true), "buffer storage direct state access");
206 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
211 piglit_init(int argc
, char **argv
)
213 /* From the EXT_external_objects spec:
215 * "GL_EXT_memory_object requires ARB_texture_storage or a
216 * version of OpenGL or OpenGL ES that incorporates it."
218 piglit_require_extension("GL_ARB_texture_storage");
219 piglit_require_extension("GL_EXT_memory_object");