[Piglit] [PATCH 02/21] arb_internalformat_query2: query2 api-error check

Alejandro Piñeiro apinheiro at igalia.com
Fri Jan 22 08:05:49 PST 2016


Similar to the equivalent for arb_internalformat_query, but in
addition to test when a invalid pname/target combination should return
INVALID_ENUM, it also checks that a valid combination returns
NO_ERROR, and testing both GetInternalformativ and
GetInternalformati64v.

The rationale of this is that is really likely that the implementation
of arb_internal_format_query2 would reuse a lot of bits of
arb_internal_format_query, so we want to be sure that a combination
that was invalid with arb_internal_format_query is not considered
invalid by arb_internal_format_query2.

Tested on NVIDIA GeForce GTX 950 - NVIDIA 352.55: pass
---
 tests/all.py                                       |   5 +
 tests/spec/CMakeLists.txt                          |   1 +
 .../arb_internalformat_query2/CMakeLists.gl.txt    |  13 +
 .../spec/arb_internalformat_query2/CMakeLists.txt  |   1 +
 tests/spec/arb_internalformat_query2/api-errors.c  | 179 ++++++++++++++
 tests/spec/arb_internalformat_query2/common.h      | 265 +++++++++++++++++++++
 6 files changed, 464 insertions(+)
 create mode 100644 tests/spec/arb_internalformat_query2/CMakeLists.gl.txt
 create mode 100644 tests/spec/arb_internalformat_query2/CMakeLists.txt
 create mode 100644 tests/spec/arb_internalformat_query2/api-errors.c
 create mode 100644 tests/spec/arb_internalformat_query2/common.h

diff --git a/tests/all.py b/tests/all.py
index f5b5b76..8bfd817 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3634,6 +3634,11 @@ with profile.group_manager(
     g(['arb_internalformat_query-minmax'], 'minmax')
 
 with profile.group_manager(
+        PiglitGLTest,
+        grouptools.join('spec', 'arb_internalformat_query2')) as g:
+    g(['arb_internalformat_query2-api-errors'], 'API error checks')
+
+with profile.group_manager(
         PiglitGLTest, grouptools.join('spec', 'arb_map_buffer_range')) as g:
     g(['map_buffer_range_error_check'], run_concurrent=False)
     g(['map_buffer_range_test'], run_concurrent=False)
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 8ddfe70..c322a3a 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -31,6 +31,7 @@ add_subdirectory (arb_gpu_shader5)
 add_subdirectory (arb_gpu_shader_fp64)
 add_subdirectory (arb_instanced_arrays)
 add_subdirectory (arb_internalformat_query)
+add_subdirectory (arb_internalformat_query2)
 add_subdirectory (arb_invalidate_subdata)
 add_subdirectory (arb_map_buffer_alignment)
 add_subdirectory (arb_map_buffer_range)
diff --git a/tests/spec/arb_internalformat_query2/CMakeLists.gl.txt b/tests/spec/arb_internalformat_query2/CMakeLists.gl.txt
new file mode 100644
index 0000000..7a0e857
--- /dev/null
+++ b/tests/spec/arb_internalformat_query2/CMakeLists.gl.txt
@@ -0,0 +1,13 @@
+include_directories(
+	${GLEXT_INCLUDE_DIR}
+	${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+	piglitutil_${piglit_target_api}
+	${OPENGL_gl_LIBRARY}
+)
+
+piglit_add_executable (arb_internalformat_query2-api-errors api-errors.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/arb_internalformat_query2/CMakeLists.txt b/tests/spec/arb_internalformat_query2/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/arb_internalformat_query2/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_internalformat_query2/api-errors.c b/tests/spec/arb_internalformat_query2/api-errors.c
new file mode 100644
index 0000000..e88480c
--- /dev/null
+++ b/tests/spec/arb_internalformat_query2/api-errors.c
@@ -0,0 +1,179 @@
+/*
+ * 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 api-errors.c
+ * Verify a handful of error conditions required by the spec.
+ *
+ * None of these subtests is large enough to warrant a separate test case.
+ *
+ * Equivalent to internalformat_query-api-errors, with testing
+ * GetInternalformati64v and in addition to test that a INVALID_ENUM
+ * is returned with an invalid combination, it also tests that a valid
+ * combination doesn't return an INVALID_ENUM.
+ *
+ * The rationale of this is that is really likely that the implementation
+ * of arb_internal_format_query2 would reuse a lot of bits of
+ * arb_internal_format_query, so we want to be sure that a combination
+ * that was invalid with arb_internal_format_query is not considered
+ * invalid by arb_internal_format_query2.
+ *
+ */
+
+#include "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
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_FAIL;
+}
+
+static bool
+try(const GLenum *targets, unsigned num_targets,
+    const GLenum *pnames, unsigned num_pnames,
+    GLenum expected_error)
+{
+        GLint params[64];
+        GLint64 params64[64];
+        bool pass = true;
+        unsigned i;
+        unsigned j;
+
+	for (i = 0; i < num_targets; i++) {
+                for (j = 0; j < num_pnames; j++) {
+                        bool this_test;
+                        bool this_test64;
+
+                        /* We can use any internalformat, as we are
+                         * just checking that the pname/target
+                         * combination is or not valid. Knowing if the
+                         * internalformat is supported is done on
+                         * query2 using INTERNALFORMAT_SUPPORTED
+                         * pname*/
+
+                        glGetInternalformativ(targets[i],
+                                              GL_RGBA,
+                                              pnames[j],
+                                              ARRAY_SIZE(params),
+                                              params);
+
+                        this_test =
+                                piglit_check_gl_error(expected_error);
+
+                        glGetInternalformati64v(targets[i],
+                                                GL_RGBA,
+                                                pnames[j],
+                                                ARRAY_SIZE(params),
+                                                params64);
+
+                        this_test64 =
+                                piglit_check_gl_error(expected_error);
+
+                        if (this_test && this_test64)
+                                continue;
+
+                        fprintf(stderr,
+                                "    Failing case was "
+                                "target = %s, pname = %s\n",
+                                piglit_get_gl_enum_name(targets[i]),
+                                piglit_get_gl_enum_name(pnames[j]));
+
+                        if (!this_test)
+                                fprintf(stderr,
+                                        "    Calling glGetInternalformativ\n");
+                        if (!this_test64)
+                                fprintf(stderr,
+                                        "    Calling glGetInternalformati64v\n");
+                        pass = false;
+                }
+	}
+
+	return pass;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	bool pass = true;
+
+	piglit_require_extension("GL_ARB_framebuffer_object");
+	piglit_require_extension("GL_ARB_internalformat_query2");
+
+	/* The GL_ARB_internalformat_query2 spec says:
+         *
+         * The INVALID_ENUM error is generated if the <target> parameter to
+         * GetInternalformati*v is not one of the targets listed in Table 6.xx.
+         *
+         * The INVALID_ENUM error is generated if the <pname> parameter is
+         * not one of the listed possibilities.
+         *
+         * So we will test that with all the listed pname/targets, no
+         * error is returned, and that without those, INVALID_ENUM is
+         * returned.
+	 */
+        pass = try(valid_targets, ARRAY_SIZE(valid_targets),
+                   valid_pnames, ARRAY_SIZE(valid_pnames),
+                   GL_NO_ERROR)
+                && pass;
+
+        pass = try(invalid_targets, ARRAY_SIZE(invalid_targets),
+                   valid_pnames, ARRAY_SIZE(valid_pnames),
+                   GL_INVALID_ENUM)
+                && pass;
+
+        pass = try(valid_targets, ARRAY_SIZE(valid_targets),
+                   invalid_pnames, ARRAY_SIZE(invalid_pnames),
+                   GL_INVALID_ENUM)
+                && pass;
+
+        pass = try(invalid_targets, ARRAY_SIZE(invalid_targets),
+                   invalid_pnames, ARRAY_SIZE(invalid_pnames),
+                   GL_INVALID_ENUM)
+                && pass;
+
+	/* The GL_ARB_internalformat_query spec says:
+	 *
+	 *     "If the <bufSize> parameter to GetInternalformativ is negative,
+	 *     then an INVALID_VALUE error is generated."
+         *
+         * Although not specified on query2 spec, we understand that
+         * it should be the case, and is a missing on the query2
+         * spec. It is properly checked on all the query2
+         * implementations we tested so far.
+	 */
+	glGetInternalformativ(valid_targets[0],
+			      GL_RGBA,
+			      valid_pnames[0],
+			      -1, NULL);
+	pass = piglit_check_gl_error(GL_INVALID_VALUE)
+		&& pass;
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
diff --git a/tests/spec/arb_internalformat_query2/common.h b/tests/spec/arb_internalformat_query2/common.h
new file mode 100644
index 0000000..5cce88b
--- /dev/null
+++ b/tests/spec/arb_internalformat_query2/common.h
@@ -0,0 +1,265 @@
+/*
+ * 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.
+ */
+
+#include "piglit-util-gl.h"
+
+static const GLenum valid_targets[] = {
+        GL_TEXTURE_1D,
+        GL_TEXTURE_1D_ARRAY,
+        GL_TEXTURE_2D,
+        GL_TEXTURE_2D_ARRAY,
+        GL_TEXTURE_3D,
+        GL_TEXTURE_CUBE_MAP,
+        GL_TEXTURE_CUBE_MAP_ARRAY,
+        GL_TEXTURE_RECTANGLE,
+        GL_TEXTURE_BUFFER,
+        GL_RENDERBUFFER,
+        GL_TEXTURE_2D_MULTISAMPLE,
+        GL_TEXTURE_2D_MULTISAMPLE_ARRAY,
+};
+
+static const GLenum invalid_targets[] = {
+        GL_FRAMEBUFFER,
+        GL_COLOR_ATTACHMENT0,
+        GL_COLOR_ATTACHMENT1,
+        GL_COLOR_ATTACHMENT2,
+        GL_COLOR_ATTACHMENT3,
+        GL_COLOR_ATTACHMENT4,
+        GL_COLOR_ATTACHMENT5,
+        GL_COLOR_ATTACHMENT6,
+        GL_COLOR_ATTACHMENT7,
+        GL_COLOR_ATTACHMENT8,
+        GL_COLOR_ATTACHMENT9,
+        GL_COLOR_ATTACHMENT10,
+        GL_COLOR_ATTACHMENT11,
+        GL_COLOR_ATTACHMENT12,
+        GL_COLOR_ATTACHMENT13,
+        GL_COLOR_ATTACHMENT14,
+        GL_COLOR_ATTACHMENT15,
+        GL_DEPTH_ATTACHMENT,
+        GL_STENCIL_ATTACHMENT,
+        GL_TEXTURE_4D_SGIS,
+        GL_TEXTURE_RENDERBUFFER_NV,
+};
+
+static const GLenum valid_pnames[] = {
+        GL_SAMPLES,
+        GL_NUM_SAMPLE_COUNTS,
+        GL_INTERNALFORMAT_SUPPORTED,
+        GL_INTERNALFORMAT_PREFERRED,
+        GL_INTERNALFORMAT_RED_SIZE,
+        GL_INTERNALFORMAT_GREEN_SIZE,
+        GL_INTERNALFORMAT_BLUE_SIZE,
+        GL_INTERNALFORMAT_ALPHA_SIZE,
+        GL_INTERNALFORMAT_DEPTH_SIZE,
+        GL_INTERNALFORMAT_STENCIL_SIZE,
+        GL_INTERNALFORMAT_SHARED_SIZE,
+        GL_INTERNALFORMAT_RED_TYPE,
+        GL_INTERNALFORMAT_GREEN_TYPE,
+        GL_INTERNALFORMAT_BLUE_TYPE,
+        GL_INTERNALFORMAT_ALPHA_TYPE,
+        GL_INTERNALFORMAT_DEPTH_TYPE,
+        GL_INTERNALFORMAT_STENCIL_TYPE,
+        GL_MAX_WIDTH,
+        GL_MAX_HEIGHT,
+        GL_MAX_DEPTH,
+        GL_MAX_LAYERS,
+        GL_MAX_COMBINED_DIMENSIONS,
+        GL_COLOR_COMPONENTS,
+        GL_DEPTH_COMPONENTS,
+        GL_STENCIL_COMPONENTS,
+        GL_COLOR_RENDERABLE,
+        GL_DEPTH_RENDERABLE,
+        GL_STENCIL_RENDERABLE,
+        GL_FRAMEBUFFER_RENDERABLE,
+        GL_FRAMEBUFFER_RENDERABLE_LAYERED,
+        GL_FRAMEBUFFER_BLEND,
+        GL_READ_PIXELS,
+        GL_READ_PIXELS_FORMAT,
+        GL_READ_PIXELS_TYPE,
+        GL_TEXTURE_IMAGE_FORMAT,
+        GL_TEXTURE_IMAGE_TYPE,
+        GL_GET_TEXTURE_IMAGE_FORMAT,
+        GL_GET_TEXTURE_IMAGE_TYPE,
+        GL_MIPMAP,
+        GL_MANUAL_GENERATE_MIPMAP,
+        GL_AUTO_GENERATE_MIPMAP,
+        GL_COLOR_ENCODING,
+        GL_SRGB_READ,
+        GL_SRGB_WRITE,
+        GL_SRGB_DECODE_ARB,
+        GL_FILTER,
+        GL_VERTEX_TEXTURE,
+        GL_TESS_CONTROL_TEXTURE,
+        GL_TESS_EVALUATION_TEXTURE,
+        GL_GEOMETRY_TEXTURE,
+        GL_FRAGMENT_TEXTURE,
+        GL_COMPUTE_TEXTURE,
+        GL_TEXTURE_SHADOW,
+        GL_TEXTURE_GATHER,
+        GL_TEXTURE_GATHER_SHADOW,
+        GL_SHADER_IMAGE_LOAD,
+        GL_SHADER_IMAGE_STORE,
+        GL_SHADER_IMAGE_ATOMIC,
+        GL_IMAGE_TEXEL_SIZE,
+        GL_IMAGE_COMPATIBILITY_CLASS,
+        GL_IMAGE_PIXEL_FORMAT,
+        GL_IMAGE_PIXEL_TYPE,
+        GL_IMAGE_FORMAT_COMPATIBILITY_TYPE,
+        GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST,
+        GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST,
+        GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE,
+        GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE,
+        GL_TEXTURE_COMPRESSED,
+        GL_TEXTURE_COMPRESSED_BLOCK_WIDTH,
+        GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT,
+        GL_TEXTURE_COMPRESSED_BLOCK_SIZE,
+        GL_CLEAR_BUFFER,
+        GL_TEXTURE_VIEW,
+        GL_VIEW_COMPATIBILITY_CLASS
+};
+
+static const GLenum invalid_pnames[] = {
+        GL_RED_BITS,
+        GL_GREEN_BITS,
+        GL_BLUE_BITS,
+        GL_ALPHA_BITS,
+        GL_DEPTH_BITS,
+        GL_STENCIL_BITS,
+        GL_MAX_3D_TEXTURE_SIZE,
+        GL_MAX_CUBE_MAP_TEXTURE_SIZE,
+        GL_TEXTURE_INTERNAL_FORMAT,
+        GL_TEXTURE_WIDTH,
+        GL_TEXTURE_HEIGHT,
+        GL_TEXTURE_COMPONENTS,
+};
+
+/* From spec:
+ *
+ *  "<internalformats> that must be supported (in GL 4.2 or later)
+ *   include the following:
+ *    - "sized internal formats" from Table 3.12, 3.13, and 3.15,
+ *    - any specific "compressed internal format" from Table 3.14,
+ *    - any "image unit format" from Table 3.21.
+ *    - any generic "compressed internal format" from Table 3.14, if
+ *      the implementation accepts it for any texture specification
+ *      commands, and
+ *    - unsized or base internal format, if the implementation accepts
+ *      it for texture or image specification."
+ */
+static const GLenum valid_internalformats[] = {
+        /* Base/unsized internal format (from Table 3.11) */
+        GL_DEPTH_COMPONENT,
+        GL_DEPTH_STENCIL,
+        GL_RED,
+        GL_RG,
+        GL_RGB,
+        GL_RGBA,
+        /* Table 3.12 (Table 3.15 and 3.21 included here) */
+        GL_R8,
+        GL_R8_SNORM,
+        GL_R16,
+        GL_R16_SNORM,
+        GL_RG8,
+        GL_RG8_SNORM,
+        GL_RG16,
+        GL_RG16_SNORM,
+        GL_R3_G3_B2,
+        GL_RGB4,
+        GL_RGB5,
+        GL_RGB8,
+        GL_RGB8_SNORM,
+        GL_RGB10,
+        GL_RGB12,
+        GL_RGB16,
+        GL_RGB16_SNORM,
+        GL_RGBA2,
+        GL_RGBA4,
+        GL_RGB5_A1,
+        GL_RGBA8,
+        GL_RGBA8_SNORM,
+        GL_RGB10_A2,
+        GL_RGB10_A2UI,
+        GL_RGBA12,
+        GL_RGBA16,
+        GL_RGBA16_SNORM,
+        GL_SRGB8,
+        GL_SRGB8_ALPHA8,
+        GL_R16F,
+        GL_RG16F,
+        GL_RGB16F,
+        GL_RGBA16F,
+        GL_R32F,
+        GL_RG32F,
+        GL_RGB32F,
+        GL_RGBA32F,
+        GL_R11F_G11F_B10F,
+        GL_RGB9_E5,
+        GL_R8I,
+        GL_R8UI,
+        GL_R16I,
+        GL_R16UI,
+        GL_R32I,
+        GL_R32UI,
+        GL_RG8I,
+        GL_RG16I,
+        GL_RG16UI,
+        GL_RG32I,
+        GL_RG32UI,
+        GL_RGB8I,
+        GL_RGB8UI,
+        GL_RGB16I,
+        GL_RGB16UI,
+        GL_RGB32I,
+        GL_RGB32UI,
+        GL_RGBA8I,
+        GL_RGBA8UI,
+        GL_RGBA16I,
+        GL_RGBA16UI,
+        GL_RGBA32I,
+        GL_RGBA32UI,
+        /* Table 3.13 */
+        GL_DEPTH_COMPONENT16,
+        GL_DEPTH_COMPONENT24,
+        GL_DEPTH_COMPONENT32,
+        GL_DEPTH_COMPONENT32F,
+        GL_DEPTH24_STENCIL8,
+        GL_DEPTH32F_STENCIL8,
+        /* Table 3.14 (both specific and generic) */
+        GL_COMPRESSED_RED,
+        GL_COMPRESSED_RG,
+        GL_COMPRESSED_RGB,
+        GL_COMPRESSED_RGBA,
+        GL_COMPRESSED_SRGB,
+        GL_COMPRESSED_SRGB_ALPHA,
+        GL_COMPRESSED_RED_RGTC1,
+        GL_COMPRESSED_SIGNED_RED_RGTC1,
+        GL_COMPRESSED_RG_RGTC2,
+        GL_COMPRESSED_SIGNED_RG_RGTC2,
+        GL_COMPRESSED_RGBA_BPTC_UNORM,
+        GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM,
+        GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT,
+        GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT,
+};
+
+
-- 
2.1.4



More information about the Piglit mailing list