framework/replay: disable AA accounting when comparing with no tolerance
[piglit.git] / tests / spec / arb_internalformat_query2 / internalformat-size-checks.c
blobca96287cdee23bc550150a031410343983feee22
1 /*
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
13 * Software.
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
21 * IN THE SOFTWARE.
24 /**
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
36 #include "common.h"
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,
57 enum piglit_result
58 piglit_display(void)
60 return PIGLIT_FAIL;
64 * From spec:
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.
83 static bool
84 try_textures_size(const GLenum *targets, unsigned num_targets,
85 const GLenum *internalformats, unsigned num_internalformats,
86 const GLenum pname,
87 test_data *data)
89 bool pass = true;
90 unsigned i;
91 unsigned j;
93 for (i = 0; i < num_targets; i++) {
94 for (j = 0; j < num_internalformats; j++) {
95 bool error_test;
96 bool value_test;
97 bool supported;
99 supported = check_query2_dependencies(pname, targets[i])
100 && test_data_check_supported(data, targets[i],
101 internalformats[j]);
103 test_data_execute(data, targets[i], internalformats[j],
104 pname);
106 error_test =
107 piglit_check_gl_error(GL_NO_ERROR);
109 value_test = supported ?
110 test_data_check_against_get_tex_level_parameter(data,
111 targets[i],
112 pname,
113 internalformats[j]) :
114 test_data_is_unsupported_response(data, pname);
116 if (error_test && value_test)
117 continue;
119 print_failing_case(targets[i], internalformats[j],
120 pname, data);
122 pass = false;
126 return pass;
129 static bool
130 check_textures_size(void)
132 bool check_pass = true;
133 test_data *data = test_data_new(0, 1);
134 unsigned i;
135 int testing64;
137 for (i = 0; i < ARRAY_SIZE(pnames); i++) {
138 bool pass = true;
140 if (!piglit_is_gles()) {
141 if (pnames[i] == GL_INTERNALFORMAT_SHARED_SIZE ||
142 pnames[i] == GL_INTERNALFORMAT_STENCIL_SIZE) {
143 continue;
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,
152 pnames[i],
153 data)
154 && pass;
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);
164 return check_pass;
167 void
168 piglit_init(int argc, char **argv)
170 bool pass = true;
172 piglit_require_extension("GL_ARB_internalformat_query2");
173 initialize_valid_internalformats();
175 pass = check_textures_size()
176 && pass;
178 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);