summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Jerez <currojerez@riseup.net>2014-12-04 12:52:35 +0200
committerFrancisco Jerez <currojerez@riseup.net>2015-02-03 19:10:57 +0200
commit380705e6c0b86f75a9fd34706492e1cd7cf0acef (patch)
treecedac7f9bba542a34ac38c343561a17f820078f9
parent7b7821cfb76a2d768d0fd5396e83b95f7ab6f1da (diff)
arb_shader_image_load_store: Import test for the maximum texture size.
Test that images work as expected up to the maximum texture dimensions reported by the implementation for each target. The test is carried out one dimension at a time to avoid creating huge textures (a 16Kx16K RGBA32F texture is already 4GB), but this is not always possible because e.g. both dimensions of a cubemap necessarily have to be equal. There is a hard-coded limit for the total texture size (which is especially stringent in quick mode) to make sure that the implementation doesn't make us do anything stupid like creating a 32 GB cubemap array texture.
-rw-r--r--tests/all.py1
-rw-r--r--tests/quick.py2
-rw-r--r--tests/spec/arb_shader_image_load_store/CMakeLists.gl.txt1
-rw-r--r--tests/spec/arb_shader_image_load_store/max-size.c197
4 files changed, 201 insertions, 0 deletions
diff --git a/tests/all.py b/tests/all.py
index 1deb3c407..00b0113fa 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4442,6 +4442,7 @@ arb_shader_image_load_store['invalid'] = PiglitGLTest(['arb_shader_image_load_st
arb_shader_image_load_store['layer'] = PiglitGLTest(['arb_shader_image_load_store-layer'], run_concurrent=True)
arb_shader_image_load_store['level'] = PiglitGLTest(['arb_shader_image_load_store-level'], run_concurrent=True)
arb_shader_image_load_store['max-images'] = PiglitGLTest(['arb_shader_image_load_store-max-images'], run_concurrent=True)
+arb_shader_image_load_store['max-size'] = PiglitGLTest(['arb_shader_image_load_store-max-size'], run_concurrent=True)
profile.tests['hiz'] = hiz
profile.tests['fast_color_clear'] = fast_color_clear
diff --git a/tests/quick.py b/tests/quick.py
index d82410068..2f7eac267 100644
--- a/tests/quick.py
+++ b/tests/quick.py
@@ -17,3 +17,5 @@ profile.tests['spec']['ARB_shader_image_load_store']['coherency'] = PiglitGLTest
['arb_shader_image_load_store-coherency', '--quick'], run_concurrent=True)
profile.tests['spec']['ARB_shader_image_load_store']['host-mem-barrier'] = PiglitGLTest(
['arb_shader_image_load_store-host-mem-barrier', '--quick'], run_concurrent=True)
+profile.tests['spec']['ARB_shader_image_load_store']['max-size'] = PiglitGLTest(
+ ['arb_shader_image_load_store-max-size', '--quick'], run_concurrent=True)
diff --git a/tests/spec/arb_shader_image_load_store/CMakeLists.gl.txt b/tests/spec/arb_shader_image_load_store/CMakeLists.gl.txt
index 2871b48da..461628cd6 100644
--- a/tests/spec/arb_shader_image_load_store/CMakeLists.gl.txt
+++ b/tests/spec/arb_shader_image_load_store/CMakeLists.gl.txt
@@ -23,5 +23,6 @@ piglit_add_executable(arb_shader_image_load_store-invalid invalid.c ${depends})
piglit_add_executable(arb_shader_image_load_store-layer layer.c ${depends})
piglit_add_executable(arb_shader_image_load_store-level level.c ${depends})
piglit_add_executable(arb_shader_image_load_store-max-images max-images.c ${depends})
+piglit_add_executable(arb_shader_image_load_store-max-size max-size.c ${depends})
# vim: ft=cmake:
diff --git a/tests/spec/arb_shader_image_load_store/max-size.c b/tests/spec/arb_shader_image_load_store/max-size.c
new file mode 100644
index 000000000..bd080913b
--- /dev/null
+++ b/tests/spec/arb_shader_image_load_store/max-size.c
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 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.
+ */
+
+/** @file max-size.c
+ *
+ * Check that images work as expected up to the maximum texture size
+ * reported for each target.
+ */
+
+#include "common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+config.supports_gl_core_version = 32;
+
+config.window_width = 1;
+config.window_height = 1;
+config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static bool
+init_image(const struct image_info img, unsigned unit)
+{
+ const unsigned n = image_num_components(img.format) * product(img.size);
+ uint32_t *pixels = malloc(sizeof(uint32_t) * n);
+ bool ret;
+ int i;
+
+ for (i = 0; i < n; ++i)
+ pixels[i] = (unit == 0 ? encode(img.format, i) : 0);
+
+ ret = upload_image(img, unit, pixels);
+
+ free(pixels);
+ return ret;
+}
+
+static bool
+check(const struct image_info img)
+{
+ const unsigned n = image_num_components(img.format) * product(img.size);
+ uint32_t *pixels = malloc(sizeof(uint32_t) * n);
+ uint32_t *expect = malloc(sizeof(uint32_t) * n);
+ bool ret;
+ int i;
+
+ for (i = 0; i < n; ++i)
+ expect[i] = encode(img.format, i);
+
+ ret = download_image(img, 1, pixels) &&
+ check_pixels_v(img, pixels, expect);
+
+ free(expect);
+ free(pixels);
+ return ret;
+}
+
+static bool
+run_test(const struct image_target_info *target,
+ const struct image_extent size)
+{
+ const struct grid_info grid = {
+ GL_FRAGMENT_SHADER_BIT,
+ get_image_format(GL_RGBA32F),
+ image_optimal_extent(size)
+ };
+ const struct image_info img = {
+ target, grid.format, size,
+ image_format_epsilon(grid.format)
+ };
+ GLuint prog = generate_program(
+ grid, GL_FRAGMENT_SHADER,
+ concat(image_hunk(img, ""),
+ hunk("readonly uniform IMAGE_T src_img;\n"
+ "writeonly uniform IMAGE_T dst_img;\n"
+ "\n"
+ "GRID_T op(ivec2 idx, GRID_T x) {\n"
+ " imageStore(dst_img, IMAGE_ADDR(idx),"
+ " imageLoad(src_img, IMAGE_ADDR(idx)));\n"
+ " return x;\n"
+ "}\n"), NULL));
+ bool ret = prog && init_fb(grid) &&
+ init_image(img, 0) &&
+ init_image(img, 1) &&
+ set_uniform_int(prog, "src_img", 0) &&
+ set_uniform_int(prog, "dst_img", 1) &&
+ draw_grid(grid, prog) &&
+ check(img);
+
+ glDeleteProgram(prog);
+ return ret;
+}
+
+static struct image_extent
+get_test_extent(const struct image_target_info *target, unsigned d)
+{
+ const struct image_extent ls = image_target_limits(target);
+ const unsigned high = ~0, low = 8;
+ struct image_extent ext;
+ int i;
+
+ for (i = 0; i < 4; ++i)
+ set_idx(ext, i, MIN2(get_idx(ls, i), (i == d ? high : low)));
+
+ if (target->target == GL_TEXTURE_CUBE_MAP ||
+ target->target == GL_TEXTURE_CUBE_MAP_ARRAY) {
+ /* Cube maps have to be square and the number of faces
+ * should be a multiple of six. */
+ ext.y = ext.x;
+ ext.z = 6 * MAX2(ext.z / 6, 1);
+
+ } else if (image_target_samples(target) > 1) {
+ /* Use the maximum number of samples to keep things
+ * interesting. */
+ ext.x = image_target_samples(target);
+ }
+
+ return ext;
+}
+
+static bool
+should_test_dimension(const struct image_target_info *target, int d)
+{
+ const struct image_extent ls = image_target_limits(target);
+
+ return get_idx(ls, d) > 1 &&
+ /* Skip second cube map dimension as faces have to be
+ * square. */
+ !(target->target == GL_TEXTURE_CUBE_MAP && d >= 1) &&
+ !(target->target == GL_TEXTURE_CUBE_MAP_ARRAY && d == 1) &&
+ /* Skip sample dimension. */
+ !(image_target_samples(target) > 1 && d == 0);
+}
+
+static bool
+is_test_reasonable(bool quick, const struct image_extent size)
+{
+ /* Set an arbitrary limit on the number of texels so the test
+ * doesn't take forever. */
+ return product(size) < (quick ? 4 : 64) * 1024 * 1024;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ const bool quick = (argc >= 2 && !strcmp(argv[1], "--quick"));
+ enum piglit_result status = PIGLIT_PASS;
+ const struct image_target_info *target;
+ int d;
+
+ piglit_require_extension("GL_ARB_shader_image_load_store");
+
+ for (target = image_targets(); target->name; ++target) {
+ for (d = 0; d < 4; ++d) {
+ if (should_test_dimension(target, d)) {
+ const struct image_extent size =
+ get_test_extent(target, d);
+
+ subtest(&status,
+ is_test_reasonable(quick, size),
+ run_test(target, size),
+ "image%s max size test/%dx%dx%dx%d",
+ target->name,
+ size.x, size.y, size.z, size.w);
+ }
+ }
+ }
+
+ piglit_report_result(status);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL;
+}