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
|
/*
* Copyright © 2015 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.c
* Verify that minimum value requirements for implementation limits
* are satisfied. Equivalent to query1 minmax, but testing against
* GetInternalformati64v too.
*/
#include <limits.h>
#include "common.h"
#include <inttypes.h> /* for PRIu64 macro */
#define ERROR_HEADER(data) test_data_get_testing64(data) ? \
fprintf(stderr, "64 bit query: ") : \
fprintf(stderr, "32 bit query: ");
PIGLIT_GL_TEST_CONFIG_BEGIN
config.supports_gl_compat_version = 10;
config.window_visual = PIGLIT_GL_VISUAL_RGB;
config.khr_no_error_support = PIGLIT_NO_ERRORS;
PIGLIT_GL_TEST_CONFIG_END
/* These are all the formats that are required to be color-renderable
* by the OpenGL 3.0 spec.
*
* But note that GL_ALPHA8 was removed on 3.1 and beyond on core, or
* if ARB_compatibility is missing, so we need to take that into
* account.
*/
static const GLenum valid_formats[] = {
GL_RGBA32F,
GL_RGBA16,
GL_RGBA16F,
GL_RGBA8,
GL_SRGB8_ALPHA8,
GL_R11F_G11F_B10F,
GL_RG32F,
GL_RG16,
GL_RG16F,
GL_RG8,
GL_R32F,
GL_R16,
GL_R16F,
GL_R8,
GL_ALPHA8,
};
static const GLenum valid_integer_formats[] = {
GL_RGBA32I,
GL_RGBA32UI,
GL_RGBA16I,
GL_RGBA16UI,
GL_RGBA8I,
GL_RGBA8UI,
GL_RG32I,
GL_RG32UI,
GL_RG16I,
GL_RG16UI,
GL_RG8I,
GL_RG8UI,
GL_R32I,
GL_R32UI,
GL_R16I,
GL_R16UI,
GL_R8I,
GL_R8UI,
};
static const GLenum valid_depth_formats[] = {
GL_DEPTH_COMPONENT16,
GL_DEPTH_COMPONENT24,
GL_DEPTH_COMPONENT32F,
};
static const GLenum valid_targets_with_tms[] = {
GL_RENDERBUFFER,
GL_TEXTURE_2D_MULTISAMPLE,
GL_TEXTURE_2D_MULTISAMPLE_ARRAY,
};
enum piglit_result
piglit_display(void)
{
return PIGLIT_FAIL;
}
static bool
real_try(GLenum target, GLenum format, GLint max_samples,
const char *max_samples_name,
test_data *data_counts,
test_data *data_samples)
{
bool pass = true;
int buffer_size_in_elements = 0;
unsigned i;
GLint previous;
test_data_set_params_size(data_counts, 1);
test_data_execute(data_counts, target, format,
GL_NUM_SAMPLE_COUNTS);
buffer_size_in_elements = test_data_value_at_index(data_counts, 0);
pass = piglit_check_gl_error(0)
&& pass;
/* The GL_ARB_internalformat_query spec says:
*
* "Add new table 6.X Internalformat-specific
* Implementation Dependent Values after 6.52"
*
* Minimum
* Get Value Type Get Command Value
* --------- ---- ----------- -------
* SAMPLES 0*xZ+ GetInternalformativ fn1
* NUM_SAMPLE_COUNTS Z+ GetInternalformativ 1
*
* fn1: see section 6.X."
*/
if (buffer_size_in_elements < 1) {
ERROR_HEADER(data_counts);
fprintf(stderr,
"GL_NUM_SAMPLE_COUNTS is %d for %s/%s\n",
buffer_size_in_elements,
piglit_get_gl_enum_name(target),
piglit_get_gl_enum_name(format));
return false;
}
test_data_set_params_size(data_samples, buffer_size_in_elements);
/* Try GL_SAMPLES
*/
test_data_execute(data_samples, target,
format, GL_SAMPLES);
pass = piglit_check_gl_error(0)
&& pass;
/* The GL_ARB_internalformat_query spec says:
*
* "- SAMPLES: The sample counts supported for this
* <format> and <target> are written into <params>, in
* descending order. Only positive values are
* returned."
*
* We take "positive" to mean greater than zero. Zero isn't a
* valid sample count for multisampling. It's the special
* value used to request non-multisampling.
*/
previous = INT_MAX;
for (i = 0; i < test_data_get_params_size(data_samples); i++) {
if (test_data_value_at_index(data_samples, i) <= 0) {
ERROR_HEADER(data_samples);
fprintf(stderr,
"Invalid sample count [%u] = %" PRIi64 " returned "
"for %s/%s (num sample counts = %i)\n",
i, test_data_value_at_index(data_samples, i),
piglit_get_gl_enum_name(target),
piglit_get_gl_enum_name(format),
buffer_size_in_elements);
pass = false;
}
if (previous == test_data_value_at_index(data_samples, i)) {
ERROR_HEADER(data_samples);
fprintf(stderr,
"Duplicate values [%u] = [%u] = %" PRIi64 " returned "
"for %s/%s (num sample counts = %i)\n",
i - 1, i, test_data_value_at_index(data_samples, i),
piglit_get_gl_enum_name(target),
piglit_get_gl_enum_name(format),
buffer_size_in_elements);
pass = false;
}
if (previous < test_data_value_at_index(data_samples, i)) {
ERROR_HEADER(data_samples);
fprintf(stderr,
"Values not in descending order "
"([%u] = %d) < ([%u] = %" PRIi64 ") returned "
"for %s/%s (num sample counts = %i)\n",
i - 1, previous,
i, test_data_value_at_index(data_samples, i),
piglit_get_gl_enum_name(target),
piglit_get_gl_enum_name(format),
buffer_size_in_elements);
pass = false;
}
previous = test_data_value_at_index(data_samples, i);
}
/* The GL_ARB_internalformat_query spec says:
*
* "The maximum value in SAMPLES is guaranteed to be at
* least the lowest of the following:
*
* - The value of GetIntegerv(MAX_INTEGER_SAMPLES), if
* <internalformat> is a signed or unsigned integer format.
* - The value of GetIntegerv(MAX_DEPTH_TEXTURE_SAMPLES), if
* <internalformat> is a depth/stencil-renderable format and
* <target> is TEXTURE_2D_MULTISAMPLE or
* TEXTURE_2D_MULTISAMPLE_ARRAY.
* - The value of GetIntegerv(MAX_COLOR_TEXTURE_SAMPLES), if
* <internalformat> is a color-renderable format and <target>
* is TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY.
* - The value of GetIntegerv(MAX_SAMPLES)."
*
* Separate tests will verify the values for GL_MAX_*_SAMPLES.
*/
if (test_data_value_at_index(data_samples, 0) < max_samples) {
ERROR_HEADER(data_samples);
fprintf(stderr,
"GL_SAMPLES (%" PRIi64 ") smaller than %s (%d) "
"for %s/%s\n",
test_data_value_at_index(data_samples, 0),
max_samples_name,
max_samples,
piglit_get_gl_enum_name(target),
piglit_get_gl_enum_name(format));
pass = false;
}
return pass;
}
/*
* This is a wrapping method that handles the need to test using
* GetInternalformativ and GetInternalformati64v. This way piglit_init
* is basically the same that query1 counterpart, and real_try is just
* try() at query1, but using the test_data structs. Also helps on the
* indentation.
*/
static bool
try(GLenum target, GLenum format, GLint max_samples,
const char *max_samples_name)
{
/* real params_size will be set at real_try() */
test_data *data_counts = test_data_new(0, 0);
test_data *data_samples = test_data_new(0, 0);
bool result;
int testing64;
for (testing64 = 0; testing64 <= 1; testing64++) {
test_data_set_testing64(data_counts, testing64);
test_data_set_testing64(data_samples, testing64);
result = real_try(target, format, max_samples, max_samples_name,
data_counts, data_samples);
}
test_data_clear(&data_counts);
test_data_clear(&data_samples);
return result;
}
void
piglit_init(int argc, char **argv)
{
bool pass = true;
unsigned i;
const bool tms_supported =
piglit_is_extension_supported("GL_ARB_texture_multisample");
GLint max_samples;
GLint valid_formats_size = ARRAY_SIZE(valid_formats);
piglit_require_extension("GL_ARB_framebuffer_object");
piglit_require_extension("GL_ARB_internalformat_query2");
initialize_valid_internalformats();
/* Need GL 3 or extensions to support the valid_formats[] above */
if (piglit_get_gl_version() < 30) {
piglit_require_extension("GL_ARB_texture_rg");
piglit_require_extension("GL_ARB_texture_float");
}
/* GL_ALPHA8 was removed on OpenGL 3.1 core, or if
* ARB_compatibility is missing, so on that case we skip that
* format
*/
if (piglit_get_gl_version() >= 31 &&
(piglit_is_core_profile ||
!piglit_is_extension_supported("GL_ARB_compatibility")))
valid_formats_size = valid_formats_size - 1;
glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
for (i = 0; i < valid_formats_size; i++) {
pass = try(GL_RENDERBUFFER,
valid_formats[i],
max_samples,
"GL_MAX_SAMPLES")
&& pass;
}
if (!tms_supported) {
for (i = 0; i < ARRAY_SIZE(valid_depth_formats); i++) {
pass = try(GL_RENDERBUFFER,
valid_depth_formats[i],
max_samples,
"GL_MAX_SAMPLES")
&& pass;
}
/* The OpenGL 3.1 spec says:
*
* "The error INVALID_OPERATION may be generated if
* internalformat is a signed or unsigned integer format,
* samples is greater than one, and the implementation
* does not support multisampled integer renderbuffers
* (see “Required Renderbuffer Formats” below)."
*
* In OpenGL 3.2 or ARB_texture_multisample the query
* GL_MAX_INTEGER_SAMPLES is used to determine the
* maximum number of samples for integer buffers.
* This is checked in the other code path.
*/
for (i = 0; i < ARRAY_SIZE(valid_integer_formats); i++) {
pass = try(GL_RENDERBUFFER,
valid_integer_formats[i],
1,
"one")
&& pass;
}
} else {
for (i = 0; i < ARRAY_SIZE(valid_targets_with_tms); i++) {
const char *max_samples_name;
unsigned j;
if (valid_targets_with_tms[i] == GL_RENDERBUFFER) {
glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
max_samples_name = "GL_MAX_SAMPLES";
} else {
glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES,
&max_samples);
max_samples_name = "GL_MAX_COLOR_TEXTURE_SAMPLES";
}
for (j = 0; j < valid_formats_size; j++) {
pass = try(valid_targets_with_tms[i],
valid_formats[j],
max_samples,
max_samples_name)
&& pass;
}
if (valid_targets_with_tms[i] == GL_RENDERBUFFER) {
glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
max_samples_name = "GL_MAX_SAMPLES";
} else {
glGetIntegerv(GL_MAX_DEPTH_TEXTURE_SAMPLES,
&max_samples);
max_samples_name = "GL_MAX_DEPTH_TEXTURE_SAMPLES";
}
for (j = 0; j < ARRAY_SIZE(valid_depth_formats); j++) {
pass = try(valid_targets_with_tms[i],
valid_depth_formats[j],
max_samples,
max_samples_name)
&& pass;
}
glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &max_samples);
max_samples_name = "GL_MAX_INTEGER_SAMPLES";
for (j = 0; j < ARRAY_SIZE(valid_integer_formats); j++) {
pass = try(valid_targets_with_tms[i],
valid_integer_formats[j],
max_samples,
max_samples_name)
&& pass;
}
}
}
piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
|