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 internalformat-size-checks.c
26 * Verify a handful of conditions required by the following pnames:
27 * - INTERNALFORMAT_RED_SIZE
28 * - INTERNALFORMAT_GREEN_SIZE
29 * - INTERNALFORMAT_BLUE_SIZE
30 * - INTERNALFORMAT_ALPHA_SIZE
31 * - INTERNALFORMAT_DEPTH_SIZE
32 * - INTERNALFORMAT_STENCIL_SIZE
33 * - INTERNALFORMAT_SHARED_SIZE
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
46 static const GLenum pnames
[] = {
47 GL_INTERNALFORMAT_RED_SIZE
,
48 GL_INTERNALFORMAT_GREEN_SIZE
,
49 GL_INTERNALFORMAT_BLUE_SIZE
,
50 GL_INTERNALFORMAT_ALPHA_SIZE
,
51 GL_INTERNALFORMAT_DEPTH_SIZE
,
52 GL_INTERNALFORMAT_STENCIL_SIZE
,
53 GL_INTERNALFORMAT_SHARED_SIZE
,
66 * "- INTERNALFORMAT_<X>_SIZE
68 * For uncompressed internal formats, queries of these values return
69 * the actual resolutions that would be used for storing image array
70 * components for the resource. For compressed internal formats, the
71 * resolutions returned specify the component resolution of an
72 * uncompressed internal format that produces an image of roughly the
73 * same quality as the compressed algorithm. For textures this query
74 * will return the same information as querying
75 * GetTexLevelParameter{if}v for TEXTURE_*_SIZE would return. If the
76 * internal format is unsupported, or if a particular component is not
77 * present in the format, 0 is written to <params>."
79 * So try_textures_size check if it is 0 when not supported, and that
80 * the returned value is the same that the one returned by
81 * GetTextLevelParameter when supported.
84 try_textures_size(const GLenum
*targets
, unsigned num_targets
,
85 const GLenum
*internalformats
, unsigned num_internalformats
,
93 for (i
= 0; i
< num_targets
; i
++) {
94 for (j
= 0; j
< num_internalformats
; j
++) {
99 supported
= check_query2_dependencies(pname
, targets
[i
])
100 && test_data_check_supported(data
, targets
[i
],
103 test_data_execute(data
, targets
[i
], internalformats
[j
],
107 piglit_check_gl_error(GL_NO_ERROR
);
109 value_test
= supported
?
110 test_data_check_against_get_tex_level_parameter(data
,
113 internalformats
[j
]) :
114 test_data_is_unsupported_response(data
, pname
);
116 if (error_test
&& value_test
)
119 print_failing_case(targets
[i
], internalformats
[j
],
130 check_textures_size(void)
132 bool check_pass
= true;
133 test_data
*data
= test_data_new(0, 1);
137 for (i
= 0; i
< ARRAY_SIZE(pnames
); i
++) {
140 if (!piglit_is_gles()) {
141 if (pnames
[i
] == GL_INTERNALFORMAT_SHARED_SIZE
||
142 pnames
[i
] == GL_INTERNALFORMAT_STENCIL_SIZE
) {
147 for (testing64
= 0; testing64
<= 1; testing64
++) {
148 test_data_set_testing64(data
, testing64
);
150 pass
= try_textures_size(texture_targets
, ARRAY_SIZE(texture_targets
),
151 valid_internalformats
, num_valid_internalformats
,
156 piglit_report_subtest_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
,
157 "%s", piglit_get_gl_enum_name(pnames
[i
]));
159 check_pass
= check_pass
&& pass
;
162 test_data_clear(&data
);
168 piglit_init(int argc
, char **argv
)
172 piglit_require_extension("GL_ARB_internalformat_query2");
173 initialize_valid_internalformats();
175 pass
= check_textures_size()
178 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);