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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
|
/* 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.
*/
#include <inttypes.h>
#include <string.h>
#include "piglit-util-gl.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_uint(const char *name, GLuint limit, GLuint val, bool pass)
{
printf("%-50s %8u %8u", name, limit, val);
if (!pass) {
printf(" (ERROR)");
piglit_minmax_pass = false;
}
printf("\n");
}
static void
piglit_report_int64(const char *name, GLint64 limit, GLint64 val, bool pass)
{
printf("%-50s %8"PRId64" %8"PRId64 , name, limit, val);
if (!pass) {
printf(" (ERROR)");
piglit_minmax_pass = false;
}
printf("\n");
}
static void
piglit_report_uint64(const char *name, GLuint64 limit, GLuint64 val, bool pass)
{
printf("%-50s %8"PRIu64" %8"PRIu64 , name, limit, val);
if (!pass) {
printf(" (ERROR)");
piglit_minmax_pass = false;
}
printf("\n");
}
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;
}
}
#define SENTINEL 0xDEADBEEF
static void
piglit_test_int(GLenum token, GLint limit, bool max)
{
const char *name = piglit_get_gl_enum_name(token);
GLint val = SENTINEL;
bool pass;
glGetIntegerv(token, &val);
pass = piglit_check_gl_error(GL_NO_ERROR);
piglit_report_int(name, limit, val,
pass &&
val != (GLint)SENTINEL &&
((max && val <= limit) ||
(!max && val >= limit)));
}
static void
piglit_test_int_v(GLenum token, GLuint index, GLint limit, bool max)
{
char *name;
GLint val = 9999;
asprintf(&name, "%s[%d]", piglit_get_gl_enum_name(token), index);
glGetIntegeri_v(token, index, &val);
piglit_report_int(name, limit, val,
(max && val <= limit) ||
(!max && val >= limit));
}
static void
piglit_test_uint(GLenum token, GLuint limit, bool max)
{
const char *name = piglit_get_gl_enum_name(token);
GLuint val = SENTINEL;
bool pass;
glGetIntegerv(token, (GLint*) &val);
pass = piglit_check_gl_error(GL_NO_ERROR);
piglit_report_uint(name, limit, val,
pass &&
val != SENTINEL &&
((max && val <= limit) ||
(!max && val >= limit)));
}
static void
piglit_test_int64(GLenum token, GLint64 limit, bool max)
{
const char *name = piglit_get_gl_enum_name(token);
GLint64 val = SENTINEL;
bool pass;
glGetInteger64v(token, &val);
pass = piglit_check_gl_error(GL_NO_ERROR);
piglit_report_int64(name, limit, val,
pass &&
val != SENTINEL &&
((max && val <= limit) ||
(!max && val >= limit)));
}
static void
piglit_test_uint64(GLenum token, GLuint64 limit, bool max)
{
const char *name = piglit_get_gl_enum_name(token);
GLuint64 val = SENTINEL;
bool pass;
/* To obtain GLuint64 values, we must use glGetInteger64v.
* Justification is found in the GL_ARB_sync spec:
*
* 30) What is the type of the timeout interval?
*
* RESOLVED: GLuint64. [...] Consequently the type of <timeout>
* has been changed to 'GLuint64' and a corresponding
* 'GetInteger64v' query taking 'GLint64' added (by symmetry
* with GetInteger, where unsigned quantities are queries with
* a function taking a pointer to a signed integer - the pointer
* conversion is harmless).
*/
glGetInteger64v(token, (GLint64*) &val);
pass = piglit_check_gl_error(GL_NO_ERROR);
piglit_report_uint64(name, limit, val,
pass &&
val != SENTINEL &&
((max && val <= limit) ||
(!max && val >= limit)));
}
void piglit_test_min_int_v(GLenum token, GLuint index, GLint min)
{
piglit_test_int_v(token, index, min, false);
}
void piglit_test_max_int_v(GLenum token, GLuint index, GLint max)
{
piglit_test_int_v(token, index, max, true);
}
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);
}
void piglit_test_min_uint(GLenum token, GLuint min)
{
piglit_test_uint(token, min, false);
}
void piglit_test_max_uint(GLenum token, GLuint max)
{
piglit_test_uint(token, max, true);
}
void piglit_test_min_int64(GLenum token, GLint64 min)
{
piglit_test_int64(token, min, false);
}
void piglit_test_max_int64(GLenum token, GLint64 max)
{
piglit_test_int64(token, max, true);
}
void piglit_test_min_uint64(GLenum token, GLuint64 min)
{
piglit_test_uint64(token, min, false);
}
void piglit_test_max_uint64(GLenum token, GLuint64 max)
{
piglit_test_uint64(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 = SENTINEL;
bool pass;
glGetFloatv(token, &val);
pass = piglit_check_gl_error(GL_NO_ERROR);
piglit_report_float(name, limit, val,
pass &&
val != (GLfloat)SENTINEL &&
((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] = {SENTINEL, SENTINEL};
bool pass;
glGetFloatv(token, vals);
pass = piglit_check_gl_error(GL_NO_ERROR);
asprintf(&temp, "%s[0]", name);
piglit_report_float(temp, low, vals[0], pass && vals[0] <= low);
free(temp);
asprintf(&temp, "%s[1]", name);
piglit_report_float(temp, high, vals[1], pass && 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;
}
}
|