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 DEALINGS
25 * \file format-components.c
27 * Tests if the values returned by:
30 * * STENCIL_COMPONENTS
33 * are correct for all the internalformats.
38 PIGLIT_GL_TEST_CONFIG_BEGIN
40 config
.supports_gl_compat_version
= 10;
41 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
;
42 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
44 PIGLIT_GL_TEST_CONFIG_END
52 static const GLenum pnames
[] = {
54 GL_STENCIL_COMPONENTS
,
59 is_color_format(GLenum internalformat
)
61 switch (internalformat
) {
103 case GL_R11F_G11F_B10F
:
128 case GL_COMPRESSED_RED
:
129 case GL_COMPRESSED_RG
:
130 case GL_COMPRESSED_RGB
:
131 case GL_COMPRESSED_RGBA
:
132 case GL_COMPRESSED_SRGB
:
133 case GL_COMPRESSED_SRGB_ALPHA
:
134 case GL_COMPRESSED_RED_RGTC1
:
135 case GL_COMPRESSED_SIGNED_RED_RGTC1
:
136 case GL_COMPRESSED_RG_RGTC2
:
137 case GL_COMPRESSED_SIGNED_RG_RGTC2
:
138 case GL_COMPRESSED_RGBA_BPTC_UNORM
:
139 case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM
:
140 case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT
:
141 case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT
:
142 case GL_COMPRESSED_RGB8_ETC2
:
143 case GL_COMPRESSED_SRGB8_ETC2
:
144 case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2
:
145 case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2
:
146 case GL_COMPRESSED_RGBA8_ETC2_EAC
:
147 case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
:
148 case GL_COMPRESSED_R11_EAC
:
149 case GL_COMPRESSED_SIGNED_R11_EAC
:
150 case GL_COMPRESSED_RG11_EAC
:
151 case GL_COMPRESSED_SIGNED_RG11_EAC
:
159 is_depth_format(GLenum internalformat
)
161 switch (internalformat
) {
162 case GL_DEPTH_COMPONENT
:
163 case GL_DEPTH_COMPONENT16
:
164 case GL_DEPTH_COMPONENT24
:
165 case GL_DEPTH_COMPONENT32
:
166 case GL_DEPTH_COMPONENT32F
:
167 case GL_DEPTH_STENCIL
:
168 case GL_DEPTH24_STENCIL8_EXT
:
169 case GL_DEPTH32F_STENCIL8
:
176 is_stencil_format(GLenum internalformat
)
178 switch (internalformat
) {
179 case GL_STENCIL_INDEX
:
180 case GL_DEPTH_STENCIL
:
181 case GL_DEPTH24_STENCIL8_EXT
:
182 case GL_DEPTH32F_STENCIL8
:
190 try(const GLenum
*targets
, unsigned num_targets
,
191 const GLenum
*internalformats
, unsigned num_internalformats
,
192 const GLenum pname
, test_data
*data
)
198 for (i
= 0; i
< num_targets
; i
++) {
199 for (j
= 0; j
< num_internalformats
; j
++) {
201 bool value_test
= true;
204 supported
= check_query2_dependencies(pname
, targets
[i
])
205 && test_data_check_supported(data
, targets
[i
],
208 test_data_execute(data
, targets
[i
], internalformats
[j
],
212 piglit_check_gl_error(GL_NO_ERROR
);
215 value_test
= test_data_is_unsupported_response(data
, pname
);
217 GLint returned_value
= test_data_value_at_index(data
, 0);
218 GLint expected_value
= -1;
221 case GL_COLOR_COMPONENTS
:
222 expected_value
= is_color_format(internalformats
[j
]);
224 case GL_STENCIL_COMPONENTS
:
225 expected_value
= is_stencil_format(internalformats
[j
]);
227 case GL_DEPTH_COMPONENTS
:
228 expected_value
= is_depth_format(internalformats
[j
]);
231 assert(!"incorrect pname for test");
235 value_test
= (returned_value
== expected_value
);
238 if (error_test
&& value_test
)
241 print_failing_case(targets
[i
], internalformats
[j
], pname
, data
);
251 check_format_components(void)
253 bool check_pass
= true;
254 test_data
*data
= test_data_new(0, 1);
258 for (i
= 0; i
< ARRAY_SIZE(pnames
); i
++) {
261 for (testing64
= 0; testing64
<= 1; testing64
++) {
262 test_data_set_testing64(data
, testing64
);
264 pass
= try(valid_targets
, ARRAY_SIZE(valid_targets
),
265 valid_internalformats
, num_valid_internalformats
,
270 piglit_report_subtest_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
,
271 "%s", piglit_get_gl_enum_name(pnames
[i
]));
273 check_pass
= check_pass
&& pass
;
276 test_data_clear(&data
);
282 piglit_init(int argc
, char **argv
)
286 piglit_require_extension("GL_ARB_internalformat_query2");
287 initialize_valid_internalformats();
289 pass
= check_format_components()
292 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);