[Piglit] [PATCH v2] ext_texture_format_bgra8888: Add test for GL_BGRA format API errors in Tex(Sub)Image
Eduardo Lima Mitev
elima at igalia.com
Fri Oct 16 10:02:53 PDT 2015
This is a new test that checks valid and invalid combinations of GL_BGRA_EXT
format and internal format in Tex(Sub)Image2D calls, as specified by the
EXT_texture_format_BGRA8888 extension.
Although the test is very basic and doesn't really render anything or check
pixels, it would have prevented the regression described in the bug below,
which was due to an API error. In the future though, more tests should be
added to validate the extension more thoroughly.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92265
---
tests/all.py | 6 ++
tests/spec/CMakeLists.txt | 1 +
.../CMakeLists.gles2.txt | 7 ++
.../ext_texture_format_bgra8888/CMakeLists.txt | 1 +
.../spec/ext_texture_format_bgra8888/api-errors.c | 110 +++++++++++++++++++++
5 files changed, 125 insertions(+)
create mode 100644 tests/spec/ext_texture_format_bgra8888/CMakeLists.gles2.txt
create mode 100644 tests/spec/ext_texture_format_bgra8888/CMakeLists.txt
create mode 100644 tests/spec/ext_texture_format_bgra8888/api-errors.c
diff --git a/tests/all.py b/tests/all.py
index 610d89f..c8220a5 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -2226,6 +2226,12 @@ with profile.group_manager(
g(['arb_occlusion_query2-api'], 'api')
g(['arb_occlusion_query2-render'], 'render')
+# Group EXT_texture_format_BGRA8888 tests
+with profile.group_manager(
+ PiglitGLTest,
+ grouptools.join('spec', 'EXT_texture_format_BGRA8888')) as g:
+ g(['ext_texture_format_bgra8888-api-errors'], 'api-errors')
+
with profile.group_manager(
PiglitGLTest,
grouptools.join('spec', 'ARB_pixel_buffer_object')) as g:
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 5dc37a1..bf22680 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -133,3 +133,4 @@ add_subdirectory (arb_texture_stencil8)
add_subdirectory (arb_vertex_attrib_64bit)
add_subdirectory (ext_framebuffer_blit)
add_subdirectory (mesa_pack_invert)
+add_subdirectory (ext_texture_format_bgra8888)
diff --git a/tests/spec/ext_texture_format_bgra8888/CMakeLists.gles2.txt b/tests/spec/ext_texture_format_bgra8888/CMakeLists.gles2.txt
new file mode 100644
index 0000000..09f4e41
--- /dev/null
+++ b/tests/spec/ext_texture_format_bgra8888/CMakeLists.gles2.txt
@@ -0,0 +1,7 @@
+link_libraries (
+ piglitutil_${piglit_target_api}
+)
+
+piglit_add_executable (ext_texture_format_bgra8888-api-errors api-errors.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/ext_texture_format_bgra8888/CMakeLists.txt b/tests/spec/ext_texture_format_bgra8888/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/ext_texture_format_bgra8888/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/ext_texture_format_bgra8888/api-errors.c b/tests/spec/ext_texture_format_bgra8888/api-errors.c
new file mode 100644
index 0000000..e0fe532
--- /dev/null
+++ b/tests/spec/ext_texture_format_bgra8888/api-errors.c
@@ -0,0 +1,110 @@
+/*
+ * 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
+ * Tests glTex(Sub)Image functions for valid and invalid combinations of
+ * GL_BGRA_EXT format and internal format, as defined by the extension
+ * EXT_texture_format_BGRA888.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_es_version = 20;
+ config.window_visual = PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static bool
+run_test(void)
+{
+ GLuint tex;
+ bool pass = true;
+
+ glGenTextures(1, &tex);
+ glBindTexture(GL_TEXTURE_2D, tex);
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ return false;
+
+ /* glTexImage2D */
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, 2, 2, 0,
+ GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ pass = false;
+
+ /* glTexImage2D, invalid internal format */
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0,
+ GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
+ if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+ pass = false;
+
+ /* glTexImage2D, invalid format */
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, 2, 2, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+ pass = false;
+
+ /* glTexImage2D, invalid type */
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, 2, 2, 0,
+ GL_BGRA_EXT, GL_FLOAT, NULL);
+ if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+ pass = false;
+
+ /* glTexSubImage2D */
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1,
+ GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ pass = false;
+
+ /* glTexSubImage2D, invalid format */
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1,
+ GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+ pass = false;
+
+ /* glTexSubImage2D, invalid type */
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1,
+ GL_BGRA_EXT, GL_FLOAT, NULL);
+ if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+ pass = false;
+
+ glDeleteTextures(1, &tex);
+
+ return pass;
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ GLboolean pass = run_test();
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ piglit_require_extension("GL_EXT_texture_format_BGRA8888");
+}
--
2.5.3
More information about the Piglit
mailing list