Mesa commit 710b1d2e665ed654fb8d52b146fa22469e1dc3a7 introduced a bug
with downloading void-extent blocks that have channel values between 0
and 4 (exclusive). Test this case.
---
 tests/opengl.py                               |  1 +
 .../CMakeLists.gl.txt                         |  1 +
 .../void-extent-dl-bug.c                      | 79 +++++++++++++++++++
 3 files changed, 81 insertions(+)
 create mode 100644 tests/spec/khr_texture_compression_astc/void-extent-dl-bug.c

diff --git a/tests/opengl.py b/tests/opengl.py
index c599eb180..c6512b467 100644
--- a/tests/opengl.py
+++ b/tests/opengl.py
@@ -4390,6 +4390,7 @@ with profile.test_list.group_manager(
     g(['khr_compressed_astc-array_gles3'], 'array-gles')
     g(['khr_compressed_astc-basic_gl'], 'basic-gl')
     g(['khr_compressed_astc-basic_gles2'], 'basic-gles')
+    g(['void-extent-dl-bug'], 'void-extent-dl-bug')
 
     for subtest in ('hdr', 'ldr', 'srgb', "srgb-fp", "srgb-sd"):
         g(['khr_compressed_astc-miptree_gl', '-subtest', subtest],
diff --git a/tests/spec/khr_texture_compression_astc/CMakeLists.gl.txt 
b/tests/spec/khr_texture_compression_astc/CMakeLists.gl.txt
index 089da8488..adaff94f5 100644
--- a/tests/spec/khr_texture_compression_astc/CMakeLists.gl.txt
+++ b/tests/spec/khr_texture_compression_astc/CMakeLists.gl.txt
@@ -6,5 +6,6 @@ 
piglit_add_executable(khr_compressed_astc-miptree_${piglit_target_api} khr_compr
 
piglit_add_executable(khr_compressed_astc-sliced-3d-miptree_${piglit_target_api}
 khr_compressed_astc-sliced-3d-miptree.c)
 piglit_add_executable(khr_compressed_astc-array_${piglit_target_api} 
khr_compressed_astc-miptree-array.c)
 piglit_add_executable(khr_compressed_astc-basic_${piglit_target_api} 
khr_compressed_astc-basic.c)
+piglit_add_executable(void-extent-dl-bug void-extent-dl-bug.c)
 
 # vim: ft=cmake:
diff --git a/tests/spec/khr_texture_compression_astc/void-extent-dl-bug.c 
b/tests/spec/khr_texture_compression_astc/void-extent-dl-bug.c
new file mode 100644
index 000000000..2a9423906
--- /dev/null
+++ b/tests/spec/khr_texture_compression_astc/void-extent-dl-bug.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright © 2018 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"
+#include "common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+       config.supports_gl_compat_version = 11;
+       config.supports_gl_es_version = 20;
+       config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+void
+piglit_init(int argc, char **argv)
+{
+       piglit_require_extension("GL_KHR_texture_compression_astc_ldr");
+}
+
+enum piglit_result
+piglit_display(void)
+{
+       /* Mesa commit 710b1d2e665ed654fb8d52b146fa22469e1dc3a7 introduced a
+        * bug with void-extent blocks that have channel values between 0 and
+        * 4. Test this case.
+        */
+       const short void_extent_block_upload[8] = {0x0DFC,   // ve header
+                                                  0x0000,   // don't care
+                                                  0x0000,   // don't care
+                                                  0x0000,   // don't care
+                                                  0x0001,   // r channel
+                                                  0x0002,   // g channel
+                                                  0x0003,   // b channel
+                                                  0x0004,}; // a channel
+       short void_extent_block_download[8] = {0,};
+
+       bool pass = true;
+       for (int i = 0; i < ARRAY_SIZE(formats); i++) {
+               GLuint tex;
+               glGenTextures(1, &tex);
+               glBindTexture(GL_TEXTURE_2D, tex);
+
+               glCompressedTexImage2D(GL_TEXTURE_2D, 0, formats[i].fmt,
+                                      formats[i].bw, formats[i].bh, 0,
+                                      formats[i].bb, void_extent_block_upload);
+               glGetCompressedTexImage(GL_TEXTURE_2D, 0,
+                                       void_extent_block_download);
+               if (memcmp(void_extent_block_upload,
+                          void_extent_block_download, 16) != 0) {
+                       pass = false;
+                       printf("Failed case %d\n", i);
+               }
+
+               glDeleteTextures(1, &tex);
+       }
+
+       piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
-- 
2.19.0

_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to