[Piglit] [PATCH 1/2] arb_texture_view: add test for layout consistency via GetTexImage
Chris Forbes
chrisf at ijw.co.nz
Wed Mar 19 02:17:01 PDT 2014
Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
tests/all.py | 1 +
tests/spec/arb_texture_view/CMakeLists.gl.txt | 1 +
.../spec/arb_texture_view/format-consistency-get.c | 136 +++++++++++++++++++++
tests/spec/arb_texture_view/view-classes.h | 126 +++++++++++++++++++
4 files changed, 264 insertions(+)
create mode 100644 tests/spec/arb_texture_view/format-consistency-get.c
create mode 100644 tests/spec/arb_texture_view/view-classes.h
diff --git a/tests/all.py b/tests/all.py
index 8ed7152..8e67eb0 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -2006,6 +2006,7 @@ arb_texture_view['clear-into-view-2d'] = concurrent_test('arb_texture_view-clear
arb_texture_view['clear-into-view-2d-array'] = concurrent_test('arb_texture_view-clear-into-view-2d-array')
arb_texture_view['clear-into-view-layered'] = concurrent_test('arb_texture_view-clear-into-view-layered')
arb_texture_view['copytexsubimage-layers'] = concurrent_test('arb_texture_view-copytexsubimage-layers')
+arb_texture_view['format-consistency-get'] = concurrent_test('arb_texture_view-format-consistency-get')
tdfx_texture_compression_fxt1 = Group()
spec['3DFX_texture_compression_FXT1'] = tdfx_texture_compression_fxt1
diff --git a/tests/spec/arb_texture_view/CMakeLists.gl.txt b/tests/spec/arb_texture_view/CMakeLists.gl.txt
index 249713c..1279fdc 100644
--- a/tests/spec/arb_texture_view/CMakeLists.gl.txt
+++ b/tests/spec/arb_texture_view/CMakeLists.gl.txt
@@ -27,5 +27,6 @@ piglit_add_executable(arb_texture_view-clear-into-view-layered clear-into-view-l
piglit_add_executable(arb_texture_view-rendering-formats rendering-formats.c)
piglit_add_executable(arb_texture_view-rendering-formats2 rendering-formats2.c)
piglit_add_executable(arb_texture_view-copytexsubimage-layers copytexsubimage-layers.c common.c)
+piglit_add_executable(arb_texture_view-format-consistency-get format-consistency-get.c)
# vim: ft=cmake:
diff --git a/tests/spec/arb_texture_view/format-consistency-get.c b/tests/spec/arb_texture_view/format-consistency-get.c
new file mode 100644
index 0000000..a8e4f52
--- /dev/null
+++ b/tests/spec/arb_texture_view/format-consistency-get.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright © 2014 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.
+ *
+ * Author: Chris Forbes <chrisf at ijw.co.nz>
+ */
+
+/**
+ * Tests format consistency for texture views, across all formats in each view class.
+ * Based on the OpenGL 4.4 spec, section 8.26 "Texture Image Loads and Stores".
+ *
+ * Hardware will typically implement views by arranging for the memory layouts to
+ * be trivially aliasable, but the spec is written in terms of conversions via
+ * scratch memory.
+ *
+ * This test ensures that whatever the hardware is doing is consistent with the
+ * specified conversions.
+ */
+
+#include "piglit-util-gl-common.h"
+#include "common.h"
+#include "view-classes.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 15;
+ config.supports_gl_core_version = 31;
+
+ config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL;
+}
+
+bool
+do_test(int bits, struct format_info *fmt)
+{
+ GLuint tex;
+ bool pass = true;
+
+ /* reference pixel data -- up to 16 bytes */
+ char ref[] = {0x0f, 0x1e, 0x2d, 0x3c, 0x4b, 0x5a, 0x69, 0x78,
+ 0x87, 0x96, 0xa5, 0xb4, 0xc3, 0xd2, 0xe1, 0xf0};
+
+ printf("Testing %d bits class:\n", bits);
+
+ glGenTextures(1, &tex);
+ glBindTexture(GL_TEXTURE_2D, tex);
+ glTexStorage2D(GL_TEXTURE_2D, 1, fmt->internalformat,
+ 1, 1);
+
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1,
+ fmt->pixelformat, fmt->pixeltype,
+ ref);
+
+ for (; fmt->internalformat; fmt++) {
+ GLuint view;
+ char data[16];
+ int i;
+
+ glGenTextures(1, &view);
+ glTextureView(view, GL_TEXTURE_2D, tex,
+ fmt->internalformat,
+ 0, 1, 0, 1);
+
+ glBindTexture(GL_TEXTURE_2D, view);
+ glGetTexImage(GL_TEXTURE_2D, 0, fmt->pixelformat,
+ fmt->pixeltype, data);
+
+ if (memcmp(data, ref, bits >> 3)) {
+ piglit_report_subtest_result(PIGLIT_FAIL,
+ piglit_get_gl_enum_name(fmt->internalformat));
+ pass = false;
+
+ printf("expected: \n");
+ for (i = 0; i < bits >> 3; i++) {
+ printf("%02x ", ref[i]);
+ }
+ printf("\n");
+
+ printf("actual: \n");
+ for (i = 0; i < bits >> 3; i++) {
+ printf("%02x ", data[i]);
+ }
+ printf("\n");
+ }
+ else {
+ piglit_report_subtest_result(PIGLIT_PASS,
+ piglit_get_gl_enum_name(fmt->internalformat));
+ }
+
+ glDeleteTextures(1, &view);
+ }
+
+ glDeleteTextures(1, &tex);
+ return pass;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ bool pass = true;
+ pass = do_test(8, view_class_8bits) && pass;
+ pass = do_test(16, view_class_16bits) && pass;
+ pass = do_test(24, view_class_24bits) && pass;
+ pass = do_test(32, view_class_32bits) && pass;
+ pass = do_test(48, view_class_48bits) && pass;
+ pass = do_test(64, view_class_64bits) && pass;
+ pass = do_test(96, view_class_96bits) && pass;
+ pass = do_test(128, view_class_128bits) && pass;
+
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
diff --git a/tests/spec/arb_texture_view/view-classes.h b/tests/spec/arb_texture_view/view-classes.h
new file mode 100644
index 0000000..4a4a3e0
--- /dev/null
+++ b/tests/spec/arb_texture_view/view-classes.h
@@ -0,0 +1,126 @@
+#ifndef VIEW_CLASSES_H
+#define VIEW_CLASSES_H
+
+/*
+ * Copyright © 2014 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.
+ *
+ * Author: Chris Forbes <chrisf at ijw.co.nz>
+ */
+
+/**
+ * View classes for ARB_texture_view format consistency tests.
+ */
+
+struct format_info {
+ GLenum internalformat;
+ GLenum pixelformat;
+ GLenum pixeltype;
+ char *sampler_prefix;
+};
+
+struct format_info view_class_128bits[] = {
+ { GL_RGBA32F, GL_RGBA, GL_FLOAT, "" },
+ { GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT, "u" },
+ { GL_RGBA32I, GL_RGBA_INTEGER, GL_INT, "i" },
+ { 0 },
+};
+
+struct format_info view_class_96bits[] = {
+ { GL_RGB32F, GL_RGB, GL_FLOAT, "" },
+ { GL_RGB32UI, GL_RGB_INTEGER, GL_UNSIGNED_INT, "u" },
+ { GL_RGB32I, GL_RGB_INTEGER, GL_INT, "i" },
+ { 0 },
+};
+
+struct format_info view_class_64bits[] = {
+ { GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, "" },
+ { GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, "u" },
+ { GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT, "i" },
+ { GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, "" },
+ { GL_RG32F, GL_RG, GL_FLOAT, "" },
+ { GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT, "u" },
+ { GL_RG32I, GL_RG_INTEGER, GL_INT, "i" },
+ { GL_RGBA16_SNORM, GL_RGBA, GL_SHORT, "" },
+ { 0 },
+};
+
+struct format_info view_class_48bits[] = {
+ { GL_RGB16F, GL_RGB, GL_HALF_FLOAT, "" },
+ { GL_RGB16, GL_RGB, GL_UNSIGNED_SHORT, "" },
+ { GL_RGB16UI, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, "u" },
+ { GL_RGB16I, GL_RGB_INTEGER, GL_SHORT, "i" },
+ { GL_RGB16_SNORM, GL_RGB, GL_SHORT, "" },
+ { 0 },
+};
+
+struct format_info view_class_32bits[] = {
+ { GL_RG16F, GL_RG, GL_HALF_FLOAT, "" },
+ { GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, "" },
+ { GL_R32F, GL_RED, GL_FLOAT, "" },
+ { GL_RGB10_A2UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, "u" },
+ { GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, "u" },
+ { GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, "u" },
+ { GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT, "u" },
+ { GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE, "i" },
+ { GL_RG16I, GL_RG_INTEGER, GL_SHORT, "i" },
+ { GL_R32I, GL_RED_INTEGER, GL_INT, "i" },
+ { GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, "" },
+ { GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, "" },
+ { GL_RG16, GL_RG, GL_UNSIGNED_SHORT, "" },
+ { GL_RGBA8_SNORM, GL_RGBA, GL_BYTE, "" },
+ { GL_RG16_SNORM, GL_RG, GL_SHORT, "" },
+ { GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, "" },
+ { GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, "" },
+ { 0 },
+};
+
+struct format_info view_class_24bits[] = {
+ { GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, "" },
+ { GL_RGB8_SNORM, GL_RGB, GL_BYTE, "" },
+ { GL_SRGB8, GL_RGB, GL_UNSIGNED_BYTE, "" },
+ { GL_RGB8UI, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, "u" },
+ { GL_RGB8I, GL_RGB_INTEGER, GL_BYTE, "i" },
+ { 0 },
+};
+
+struct format_info view_class_16bits[] = {
+ { GL_R16F, GL_RED, GL_HALF_FLOAT, "" },
+ { GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_BYTE, "u" },
+ { GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT, "u" },
+ { GL_RG8I, GL_RG_INTEGER, GL_BYTE, "i" },
+ { GL_R16I, GL_RED_INTEGER, GL_SHORT, "i" },
+ { GL_RG8, GL_RG, GL_UNSIGNED_BYTE, "" },
+ { GL_R16, GL_RED, GL_UNSIGNED_SHORT, "" },
+ { GL_RG8_SNORM, GL_RG, GL_BYTE, "" },
+ { GL_R16_SNORM, GL_RED, GL_SHORT, "" },
+ { 0 },
+};
+
+struct format_info view_class_8bits[] = {
+ { GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, "u" },
+ { GL_R8I, GL_RED_INTEGER, GL_BYTE, "i" },
+ { GL_R8, GL_RED, GL_UNSIGNED_BYTE, "" },
+ { GL_R8_SNORM, GL_RED, GL_BYTE, "" },
+ { 0 },
+};
+
+#endif
--
1.9.0
More information about the Piglit
mailing list