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 samples-pnames.c
26 * Verify a handful of conditions required by the spec for
27 * NUM_SAMPLE_COUNTS and SAMPLES pnames.
29 * This cover query1 overrun test, plus query1 api-error.
34 PIGLIT_GL_TEST_CONFIG_BEGIN
36 config
.supports_gl_compat_version
= 10;
37 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
;
38 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
40 PIGLIT_GL_TEST_CONFIG_END
42 static const GLenum without_multisample_targets
[] = {
49 GL_TEXTURE_CUBE_MAP_ARRAY
,
54 static const GLenum non_renderable_internalformats
[] = {
58 GL_COMPRESSED_LUMINANCE
,
59 GL_COMPRESSED_LUMINANCE_ALPHA
,
60 GL_COMPRESSED_INTENSITY
,
62 GL_COMPRESSED_SRGB_ALPHA
,
63 GL_COMPRESSED_SLUMINANCE
,
64 GL_COMPRESSED_SLUMINANCE_ALPHA
,
67 GL_COMPRESSED_RED_RGTC1
,
68 GL_COMPRESSED_SIGNED_RED_RGTC1
,
69 GL_COMPRESSED_RG_RGTC2
,
70 GL_COMPRESSED_SIGNED_RG_RGTC2
,
71 GL_COMPRESSED_RGBA_BPTC_UNORM_ARB
,
72 GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB
,
73 GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB
,
74 GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB
,
75 GL_COMPRESSED_RGB_S3TC_DXT1_EXT
,
76 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
,
77 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
,
78 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
,
79 GL_COMPRESSED_RGB_FXT1_3DFX
,
80 GL_COMPRESSED_RGBA_FXT1_3DFX
,
81 GL_COMPRESSED_SRGB_S3TC_DXT1_EXT
,
82 GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
,
83 GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
,
84 GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
,
85 GL_COMPRESSED_LUMINANCE_LATC1_EXT
,
86 GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT
,
87 GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT
,
88 GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT
,
97 GL_LUMINANCE_INTEGER_EXT
,
98 GL_LUMINANCE_ALPHA_INTEGER_EXT
,
101 static const GLenum tex_shared_exponent_formats
[] = {
112 fill_data_and_copy(test_data
*data
,
113 test_data
*data_copy
)
117 for (i
= 0; i
< test_data_get_params_size(data
); i
++) {
118 /* It seems very unlikely that an implementation will
119 * support 0xDEADBEEF samples*/
120 test_data_set_value_at_index(data
, i
, 0xDEADBEEF);
121 test_data_set_value_at_index(data_copy
, i
, 0xDEADBEEF);
126 check_params_unmodified(test_data
*data
,
127 test_data
*data_copy
)
132 for (i
= 0; i
< test_data_get_params_size(data
); i
++) {
133 result
= test_data_equal_at_index(data
, data_copy
, i
);
143 try(const GLenum
*targets
, unsigned num_targets
,
144 const GLenum
*internalformats
, unsigned num_internalformats
,
145 GLenum pname
, test_data
*data
)
147 test_data
*data_copy
= test_data_clone(data
);
152 for (i
= 0; i
< num_targets
; i
++) {
153 for (j
= 0; j
< num_internalformats
; j
++) {
157 /* Needed for to check if the data was unmodified */
158 fill_data_and_copy(data
, data_copy
);
160 /* First we try with size 0 */
161 test_data_execute_with_size(data
, targets
[i
],
166 piglit_check_gl_error(GL_NO_ERROR
);
168 value_test
= check_params_unmodified(data
, data_copy
);
170 /* Now we try with a real size */
171 test_data_execute(data
, targets
[i
], internalformats
[j
],
174 error_test
= error_test
&&
175 piglit_check_gl_error(GL_NO_ERROR
);
177 if (pname
== GL_NUM_SAMPLE_COUNTS
) {
178 value_test
= value_test
&&
179 test_data_is_unsupported_response(data
,
180 GL_NUM_SAMPLE_COUNTS
);
182 value_test
= value_test
&&
183 check_params_unmodified(data
, data_copy
);
186 if (error_test
&& value_test
)
189 print_failing_case(targets
[i
], internalformats
[j
], pname
, data
);
195 test_data_clear(&data_copy
);
201 check_num_sample_counts(void)
204 test_data
*data
= test_data_new(0, 64);
207 for (testing64
= 0; testing64
<= 1; testing64
++) {
208 test_data_set_testing64(data
, testing64
);
210 /* The GL_ARB_internalformat_query2 spec says:
212 * - NUM_SAMPLE_COUNTS: The number of sample counts that would
213 * be returned by querying SAMPLES is returned in <params>.
214 * * If <internalformat> is not color-renderable,
215 * depth-renderable, or stencil-renderable (as defined
216 * in section 4.4.4) ...
218 pass
= try(valid_targets
, ARRAY_SIZE(valid_targets
),
219 non_renderable_internalformats
, ARRAY_SIZE(non_renderable_internalformats
),
220 GL_NUM_SAMPLE_COUNTS
, data
)
223 /* RGB9_E5 is not defined as color-renderable unless
224 * EXT_texture_shared_exponent is exposed.
226 if (!piglit_is_extension_supported("GL_EXT_texture_shared_exponent")) {
227 pass
= try(valid_targets
, ARRAY_SIZE(valid_targets
),
228 tex_shared_exponent_formats
, 1,
229 GL_NUM_SAMPLE_COUNTS
, data
)
234 * ... or if <target> does not support
235 * multiple samples (ie other than
236 * TEXTURE_2D_MULTISAMPLE,
237 * TEXTURE_2D_MULTISAMPLE_ARRAY, or RENDERBUFFER), 0 is
240 pass
= try(without_multisample_targets
, ARRAY_SIZE(without_multisample_targets
),
241 valid_internalformats
, num_valid_internalformats
,
242 GL_NUM_SAMPLE_COUNTS
, data
)
246 piglit_report_subtest_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
,
247 "%s", piglit_get_gl_enum_name(GL_NUM_SAMPLE_COUNTS
));
249 test_data_clear(&data
);
258 test_data
*data
= test_data_new(0, 64);
262 * Note: Checking if we are getting a proper min and maximum
263 * value, and if the returned values are positive in
264 * descending order is done at minmax test, as that one needs
265 * to use SAMPLES and NUM_SAMPLES_COUNT combined. This test
266 * file is about testing each pname individually.
269 for (testing64
= 0; testing64
<= 1; testing64
++) {
270 test_data_set_testing64(data
, testing64
);
271 /* The GL_ARB_internalformat_query2 spec for SAMPLES says:
273 * If <internalformat> is not color-renderable, depth-renderable, or
274 * stencil-renderable (as defined in section 4.4.4),
277 pass
= try(valid_targets
, ARRAY_SIZE(valid_targets
),
278 non_renderable_internalformats
, ARRAY_SIZE(non_renderable_internalformats
),
282 /* RGB9_E5 is not defined as color-renderable unless
283 * EXT_texture_shared_exponent is exposed.
285 if (!piglit_is_extension_supported("GL_EXT_texture_shared_exponent")) {
286 pass
= try(valid_targets
, ARRAY_SIZE(valid_targets
),
287 tex_shared_exponent_formats
, 1,
293 * or if <target> does not support multiple samples (ie other
294 * than TEXTURE_2D_MULTISAMPLE, TEXTURE_2D_MULTISAMPLE_ARRAY,
295 * or RENDERBUFFER), <params> is not modified.
298 pass
= try(without_multisample_targets
, ARRAY_SIZE(without_multisample_targets
),
299 valid_internalformats
, num_valid_internalformats
,
304 piglit_report_subtest_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
,
305 "%s", piglit_get_gl_enum_name(GL_SAMPLES
));
307 test_data_clear(&data
);
313 piglit_init(int argc
, char **argv
)
317 piglit_require_extension("GL_ARB_framebuffer_object");
318 piglit_require_extension("GL_ARB_internalformat_query2");
319 initialize_valid_internalformats();
321 pass
= check_num_sample_counts() && pass
;
322 pass
= check_samples() && pass
;
324 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);