[Piglit] [PATCH] ext_texture_format_bgra8888: Add test for GL_BGRA format in Tex(Sub)Image calls

Eduardo Lima Mitev elima at igalia.com
Wed Oct 14 18:50:08 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
<https://www.khronos.org/registry/gles/extensions/EXT/EXT_texture_format_BGRA8888.txt>.

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 +
 tests/spec/ext_texture_format_bgra8888/teximage.c  | 103 +++++++++++++++++++++
 5 files changed, 118 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/teximage.c

diff --git a/tests/all.py b/tests/all.py
index 610d89f..144b51e 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-teximage'], 'teximage')
+
 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..38edd70
--- /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-teximage teximage.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/teximage.c b/tests/spec/ext_texture_format_bgra8888/teximage.c
new file mode 100644
index 0000000..cb40db2
--- /dev/null
+++ b/tests/spec/ext_texture_format_bgra8888/teximage.c
@@ -0,0 +1,103 @@
+/*
+ * 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 GLboolean
+run_test(void)
+{
+   GLuint tex;
+
+   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))
+      return 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))
+      return 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))
+      return 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))
+      return 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))
+      return 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))
+      return 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))
+      return false;
+
+   glDeleteTextures(1, &tex);
+
+   return true;
+}
+
+
+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