On 10/24/2013 03:49 PM, Jon Ashburn wrote:
Tests texture views with data format changes. 1D textures only.
Uses multiple simultaneous views with different lifetimes and
check results via glGetTexImage().
Tested on Nvidia Quadro 600, all subtests pass.
---
tests/all.tests | 1 +
tests/spec/arb_texture_view/CMakeLists.gl.txt | 1 +
tests/spec/arb_texture_view/lifetime_format.c | 235 ++++++++++++++++++++++++++
3 files changed, 237 insertions(+)
create mode 100644 tests/spec/arb_texture_view/lifetime_format.c
diff --git a/tests/all.tests b/tests/all.tests
index a329156..0856467 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1478,6 +1478,7 @@ arb_texture_view['targets'] =
concurrent_test('arb_texture_view-targets')
arb_texture_view['queries'] = concurrent_test('arb_texture_view-queries')
arb_texture_view['rendering-target'] =
concurrent_test('arb_texture_view-rendering-target')
arb_texture_view['rendering-levels'] =
concurrent_test('arb_texture_view-rendering-levels')
+arb_texture_view['lifetime-format'] =
concurrent_test('arb_texture_view-lifetime-format')
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 a39c7dd..bce50c3 100644
--- a/tests/spec/arb_texture_view/CMakeLists.gl.txt
+++ b/tests/spec/arb_texture_view/CMakeLists.gl.txt
@@ -16,5 +16,6 @@ piglit_add_executable(arb_texture_view-targets targets.c
common.c)
piglit_add_executable(arb_texture_view-queries queries.c)
piglit_add_executable(arb_texture_view-rendering-target rendering_target.c
common.c)
piglit_add_executable(arb_texture_view-rendering-levels rendering_levels.c
common.c)
+piglit_add_executable(arb_texture_view-lifetime-format lifetime_format.c
common.c)
# vim: ft=cmake:
diff --git a/tests/spec/arb_texture_view/lifetime_format.c
b/tests/spec/arb_texture_view/lifetime_format.c
new file mode 100644
index 0000000..c1939c8
--- /dev/null
+++ b/tests/spec/arb_texture_view/lifetime_format.c
@@ -0,0 +1,235 @@
+/*
+ * Copyright © 2013 LunarG, Inc.
+ *
+ * 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: Jon Ashburn <j...@lunarg.com>
+ */
+
+/**
+ * Tests texture views with data format changes. 1D textures only.
+ * Uses multiple simultaneous views with different lifetimes and
+ * check results via glGetTexImage().
+ */
+
+#include "piglit-util-gl-common.h"
+#include "common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 10;
+ config.supports_gl_core_version = 31;
+
+ config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+/* Texture formats. The format_list variable has these fields: */
+struct format_desc {
+ const char *name;
+ GLenum internalfmt;
+ GLenum storagefmt;
+ GLenum imagefmt;
+ GLenum imagetype;
+ GLenum getfmt;
+ GLenum gettype;
+ int red, green, blue, alpha;
+};
+
+#define FORMAT(f) #f, f
+static const struct format_desc format_list[] = {
+ {FORMAT(GL_RGBA8UI), GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE,
+ GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, 8, 8, 8, 8},
+ {FORMAT(GL_RGBA8I), GL_RGBA8I, GL_RGBA, GL_UNSIGNED_BYTE,
+ GL_RGBA_INTEGER, GL_BYTE, 8, 8, 8, 8},
+ {FORMAT(GL_RGB16F), GL_RGB16F, GL_RGB, GL_UNSIGNED_BYTE, GL_RGB,
+ GL_HALF_FLOAT, 16, 16, 16, 0},
+ {FORMAT(GL_RGB16I), GL_RGB16, GL_RGB, GL_UNSIGNED_BYTE,
+ GL_RGB_INTEGER, GL_SHORT, 16, 16, 16, 0},
+ {FORMAT(GL_R16UI), GL_R16, GL_RED, GL_UNSIGNED_BYTE,
+ GL_RED_INTEGER, GL_UNSIGNED_SHORT, 16, 0, 0, 0},
+ {FORMAT(GL_R16F), GL_R16, GL_RED, GL_UNSIGNED_BYTE,
+ GL_RED, GL_HALF_FLOAT, 16, 0, 0, 0},
+ {FORMAT(GL_RGBA16UI), GL_RGBA16, GL_RGBA, GL_UNSIGNED_BYTE,
+ GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, 16, 16, 16, 16},
+ {FORMAT(GL_RGBA16F), GL_RGBA16, GL_RGBA, GL_UNSIGNED_BYTE,
+ GL_RGBA, GL_HALF_FLOAT, 16, 16, 16, 16},
+};
+#undef FORMAT
+
+
+static int
+compare_buffers(unsigned char * buf0, unsigned char *buf1, GLint w)
return bool (true=buffers equal, false=buffers differ)? Maybe call it
buffers_equal()?
Declare the pointers const.
+{
+ int i;
+ for (i = 0; i < w; i++) {
+ if (buf0[i] != buf1[i]) {
+ printf("mismatched texels at index (%d)\n", i);
+ printf(" Buffer0: %u\n", buf0[i]);
+ printf(" Buffer1: %u\n", buf1[i]);
+ return 1;
+ }
+ }
If printing the location isn't important, memcmp() might be used.
+
+ return 0;
+}
+
+static bool
+test_format_lifetime(struct format_desc desc0, struct format_desc desc1)
We'd normally pass the struct params as const pointers, but not a huge deal.
+{
+ GLuint tex, viewTex[3];
+ GLint width = 32, w, levels = 6;
+ GLint l;
+ int bytes;
+ unsigned char *buffer0, *buffer1;
+ bool pass = true;
+
+ glGenTextures(1, &tex);
+ glBindTexture(GL_TEXTURE_1D, tex);
+ glTexStorage1D(GL_TEXTURE_1D, levels, desc0.storagefmt, width);
+ glGenTextures(3, viewTex);
+ glTextureView(viewTex[0], GL_TEXTURE_1D, tex, desc0.internalfmt, 0,
+ levels, 0, 1);
+ glTextureView(viewTex[1], GL_TEXTURE_1D, viewTex[0],
+ desc1.internalfmt, 0, levels, 0, 1);
+
+ pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+ /* load each mipmap with a different color texture */
+ w = width;
+ bytes = (desc0.red + desc0.green + desc0.blue + desc0.alpha) / 8;
+ for (l = 0; l < levels; l++) {
+ GLubyte *buf = create_solid_image(width, 1, 1, bytes, l);
+
PIGLIT_FAIL if buf = NULL?
The rest looks OK.
_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit