1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
/* Copyright © 2011-2012 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
/** @file minmax-test.c
*
* Helpers for performing minimuTest for the minimum maximum values in section 6.2 "State Tables"
* of the GL 3.0 spec.
*/
#define _GNU_SOURCE
#include <string.h>
#include "piglit-util-gl-common.h"
#include "minmax-test.h"
bool piglit_minmax_pass = true;
void piglit_print_minmax_header(void)
{
printf("%-50s %8s %8s\n", "token", "minimum", "value");
}
static void
piglit_report_int(const char *name, GLint limit, GLint val, bool pass)
{
if (pass) {
printf("%-50s %8d %8d\n", name, limit, val);
} else {
fprintf(stderr, "%-50s %8d %8d (ERROR)\n",
name, limit, val);
piglit_minmax_pass = false;
}
}
static void
piglit_report_float(const char *name, GLfloat limit, GLfloat val, bool pass)
{
if (pass) {
printf("%-50s %8.1f %8.1f\n", name, limit, val);
} else {
fprintf(stderr, "%-50s %8f %8f (ERROR)\n",
name, limit, val);
piglit_minmax_pass = false;
}
}
static void
piglit_test_int(GLenum token, GLint limit, bool max)
{
const char *name = piglit_get_gl_enum_name(token);
GLint val = 9999;
glGetIntegerv(token, &val);
piglit_report_int(name, limit, val,
(max && val <= limit) ||
(!max && val >= limit));
}
void piglit_test_min_int(GLenum token, GLint min)
{
piglit_test_int(token, min, false);
}
void piglit_test_max_int(GLenum token, GLint max)
{
piglit_test_int(token, max, true);
}
static void
piglit_test_float(GLenum token, GLfloat limit, bool max)
{
const char *name = piglit_get_gl_enum_name(token);
GLfloat val = -9999;
glGetFloatv(token, &val);
piglit_report_float(name, limit, val,
(max && val <= limit) ||
(!max && val >= limit));
}
void piglit_test_min_float(GLenum token, GLfloat min)
{
piglit_test_float(token, min, false);
}
void piglit_test_max_float(GLenum token, GLfloat max)
{
piglit_test_float(token, max, true);
}
/** Tests tha the range referneced by the token covers at least low-high. */
void piglit_test_range_float(GLenum token, GLfloat low, GLfloat high)
{
const char *name = piglit_get_gl_enum_name(token);
char *temp;
GLfloat vals[2] = {9999, 9999};
glGetFloatv(token, vals);
asprintf(&temp, "%s[0]", name);
piglit_report_float(temp, low, vals[0], vals[0] <= low);
free(temp);
asprintf(&temp, "%s[1]", name);
piglit_report_float(temp, high, vals[1], vals[1] >= high);
free(temp);
}
void piglit_test_min_viewport_dimensions(void)
{
int min_w, min_h;
GLint dims[2] = {9999, 9999};
if (piglit_get_gl_version() < 30) {
/* FINISHME:
*
* "The maximum viewport dimensions must be
* greater than or equal to the larger of the
* visible dimensions of the display being
* rendered to (if a display exists), and the
* largest renderbuffer image which can be
* successfully created and attached to a
* framebuffer object (see chapter 4). INVALID
* VALUE is generated if either w or h is
* negative."
*
* We're only looking at RB limits here.
*/
int rb_size = 9999;
glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &rb_size);
min_w = rb_size;
min_h = rb_size;
} else {
/* FINISHME:
*
* "The maximum viewport dimensions must be
* greater than or equal to the visible
* dimensions of the display being rendered to."
*
* Surely the screen is at least 1024x768, right?
*/
min_w = 1024;
min_h = 768;
}
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims);
piglit_report_int("GL_MAX_VIEWPORT_DIMS[0]", min_w, dims[0],
dims[0] >= min_w);
piglit_report_int("GL_MAX_VIEWPORT_DIMS[1]", min_h, dims[1],
dims[1] >= min_h);
}
void
piglit_test_oq_bits()
{
GLint dims[2] = {9999, 9999};
GLint minbits, oqbits = 9999;
/* From the GL 2.1 specification:
*
* "The number of query counter bits may be zero, in which
* case the counter contains no useful
* information. Otherwise, the minimum number of bits
* allowed is a function of the implementation’s maximum
* viewport dimensions (MAX_VIEWPORT_DIMS). In this case,
* the counter must be able to represent at least two
* overdraws for every pixel in the viewport The formula
* to compute the allowable minimum value (where n is the
* minimum number of bits) is:
*
* n = min{32, log2(maxViewportWidth ∗ maxViewportHeight * 2}"
*/
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, dims);
minbits = log2((float)dims[0] * dims[1] * 2);
if (minbits > 32)
minbits = 32;
glGetQueryiv(GL_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS, &oqbits);
if (oqbits == 0 || oqbits >= minbits) {
printf("%-50s 0 / %2d %8d\n",
"GL_QUERY_COUNTER_BITS(GL_SAMPLES_PASSED)",
minbits, oqbits);
} else {
fprintf(stderr,
"%-50s 0 / %2d %8d\n",
"GL_QUERY_COUNTER_BITS(GL_SAMPLES_PASSED)",
minbits, oqbits);
piglit_minmax_pass = false;
}
}
void
piglit_test_tf_bits(GLenum target)
{
GLint bits = 9999;
const char *name;
if (target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN)
name = "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN bits";
else
name = "GL_PRIMITIVES_GENERATED bits";
/* From the GL 3.0 specification, page 329:
*
* "If pname is QUERY_COUNTER_BITS, the
* implementation-dependent number of query counter bits
* may be zero, in which case the counter contains no
* useful information.
*
* For primitive queries (PRIMITIVES GENERATED and
* TRANSFORM FEEDBACK PRIMITIVES WRITTEN) if the number
* of bits is non-zero, the minimum number of bits
* allowed is 32."
*/
glGetQueryiv(target, GL_QUERY_COUNTER_BITS, &bits);
if (bits == 0 || bits >= 32) {
printf("%-50s %8s %8d\n", name, "0 / 32", bits);
} else {
fprintf(stderr, "%-50s %8s %8d (ERROR)\n",
name, "0 / 32", bits);
piglit_minmax_pass = false;
}
}
|