[Piglit] [PATCH 3/3] arb_internalformat_query: Verify minimum maximums
Ian Romanick
idr at freedesktop.org
Tue Dec 11 11:58:49 PST 2012
From: Ian Romanick <ian.d.romanick at intel.com>
This test passes on NVIDIA's closed-source driver (version 304.64 on
GTX260). This driver supports GL_ARB_texture_multisample.
This test fails on AMD's closed-source driver (Catalyst 12.6 on HD
3650). Querying GL_SRGB8_ALPHA8 (for all targets) returns {1, 0, 2}.
This is invalid because it is not descending order, and zero is not
positive. I suspect they intended to return 1 for NUM_SAMPLE_COUNTS,
and {1} for SAMPLES. This driver supports GL_ARB_texture_multisample.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
tests/all.tests | 1 +
.../arb_internalformat_query/CMakeLists.gl.txt | 1 +
tests/spec/arb_internalformat_query/minmax.c | 361 +++++++++++++++++++++
3 files changed, 363 insertions(+)
create mode 100644 tests/spec/arb_internalformat_query/minmax.c
diff --git a/tests/all.tests b/tests/all.tests
index dd71886..fe39a06 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -2000,6 +2000,7 @@ arb_internalformat_query = Group()
spec['ARB_internalformat_query'] = arb_internalformat_query
arb_internalformat_query['misc. API error checks'] = concurrent_test('arb_internalformat_query-api-errors')
arb_internalformat_query['buffer over-run checks'] = concurrent_test('arb_internalformat_query-overrun')
+arb_internalformat_query['minmax'] = concurrent_test('arb_internalformat_query-minmax')
arb_map_buffer_range = Group()
spec['ARB_map_buffer_range'] = arb_map_buffer_range
diff --git a/tests/spec/arb_internalformat_query/CMakeLists.gl.txt b/tests/spec/arb_internalformat_query/CMakeLists.gl.txt
index c8b4dca..50a26b1 100644
--- a/tests/spec/arb_internalformat_query/CMakeLists.gl.txt
+++ b/tests/spec/arb_internalformat_query/CMakeLists.gl.txt
@@ -10,6 +10,7 @@ link_libraries (
)
piglit_add_executable (arb_internalformat_query-api-errors api-errors.c)
+piglit_add_executable (arb_internalformat_query-minmax minmax.c)
piglit_add_executable (arb_internalformat_query-overrun overrun.c)
# vim: ft=cmake:
diff --git a/tests/spec/arb_internalformat_query/minmax.c b/tests/spec/arb_internalformat_query/minmax.c
new file mode 100644
index 0000000..c9fae1a
--- /dev/null
+++ b/tests/spec/arb_internalformat_query/minmax.c
@@ -0,0 +1,361 @@
+/*
+ * Copyright © 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.c
+ * Verify that minimum value requirements for implementation limits are
+ * satisfied.
+ */
+
+#include <limits.h>
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 10;
+ config.window_visual = PIGLIT_GL_VISUAL_RGB;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+#ifndef GL_ARB_texture_multisample
+#define GL_SAMPLE_POSITION 0x8E50
+#define GL_SAMPLE_MASK 0x8E51
+#define GL_SAMPLE_MASK_VALUE 0x8E52
+#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59
+#define GL_TEXTURE_2D_MULTISAMPLE 0x9100
+#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101
+#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102
+#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103
+#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104
+#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105
+#define GL_TEXTURE_SAMPLES 0x9106
+#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107
+#define GL_SAMPLER_2D_MULTISAMPLE 0x9108
+#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109
+#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
+#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B
+#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C
+#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D
+#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E
+#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F
+#define GL_MAX_INTEGER_SAMPLES 0x9110
+#endif
+
+/* These are all the formats that are required to be color-renderable by the
+ * OpenGL 3.0 spec.
+ */
+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
+try(GLenum target, GLenum format, GLint max_samples,
+ const char *max_samples_name)
+{
+ bool pass = true;
+ GLint *buffer;
+ int buffer_size_in_elements;
+ size_t buffer_size_in_bytes;
+ unsigned i;
+ GLint previous;
+
+ glGetInternalformativ(target,
+ format,
+ GL_NUM_SAMPLE_COUNTS,
+ 1, &buffer_size_in_elements);
+ 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) {
+ 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;
+ }
+
+ buffer_size_in_bytes = buffer_size_in_elements * sizeof(GLint);
+ buffer = malloc(buffer_size_in_bytes);
+
+ /* Try GL_SAMPLES
+ */
+ glGetInternalformativ(target,
+ format,
+ GL_SAMPLES,
+ buffer_size_in_elements,
+ buffer);
+ 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 < buffer_size_in_elements; i++) {
+ if (buffer[i] <= 0) {
+ fprintf(stderr,
+ "Invalid sample count [%u] = %d returned "
+ "for %s/%s\n",
+ i, buffer[i],
+ piglit_get_gl_enum_name(target),
+ piglit_get_gl_enum_name(format));
+ pass = false;
+ }
+
+ if (previous == buffer[i]) {
+ fprintf(stderr,
+ "Duplicate values [%u] = [%u] = %d returned "
+ "for %s/%s\n",
+ i - 1, i, buffer[i],
+ piglit_get_gl_enum_name(target),
+ piglit_get_gl_enum_name(format));
+ pass = false;
+ }
+
+ if (previous < buffer[i]) {
+ fprintf(stderr,
+ "Values not in descending order "
+ "([%u] = %d) < ([%u] = %d) returned "
+ "for %s/%s\n",
+ i - 1, previous,
+ i, buffer[i],
+ piglit_get_gl_enum_name(target),
+ piglit_get_gl_enum_name(format));
+ pass = false;
+ }
+
+ previous = buffer[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 (buffer[0] < max_samples) {
+ fprintf(stderr,
+ "GL_SAMPLES (%d) smaller than %s (%d) "
+ "for %s/%s\n",
+ buffer[0],
+ max_samples_name,
+ max_samples,
+ piglit_get_gl_enum_name(target),
+ piglit_get_gl_enum_name(format));
+ pass = false;
+ }
+
+ free(buffer);
+ return pass;
+}
+
+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;
+
+ piglit_require_extension("GL_ARB_framebuffer_object");
+ piglit_require_extension("GL_ARB_internalformat_query");
+
+ glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
+ for (i = 0; i < ARRAY_SIZE(valid_formats); 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 < ARRAY_SIZE(valid_formats); 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);
+}
--
1.7.11.7
More information about the Piglit
mailing list