[Piglit] [PATCH 2/3] arb_compute_shader: Test spilling with large block sizes.
Dylan Baker
baker.dylan.c at gmail.com
Tue Apr 12 07:34:40 UTC 2016
Quoting Bas Nieuwenhuizen (2016-04-11 06:45:29)
> Signed-off-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
> ---
> tests/all.py | 1 +
> tests/spec/arb_compute_shader/CMakeLists.gl.txt | 1 +
> tests/spec/arb_compute_shader/large-block-size.c | 106 +++++++++++++++++++++++
> 3 files changed, 108 insertions(+)
> create mode 100644 tests/spec/arb_compute_shader/large-block-size.c
>
> diff --git a/tests/all.py b/tests/all.py
> index da1c257..72c540c 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -4255,6 +4255,7 @@ with profile.group_manager(
> g(['arb_compute_shader-render-and-compute'], 'render-and-compute')
> g(['arb_compute_shader-zero-dispatch-size'], 'zero-dispatch-size')
> g(['arb_compute_shader-conditional-dispatch'], 'conditional-dispatch')
> + g(['arb_compute_shader-large-block-size'], 'large-block-size')
>
> with profile.group_manager(
> PiglitGLTest,
> diff --git a/tests/spec/arb_compute_shader/CMakeLists.gl.txt b/tests/spec/arb_compute_shader/CMakeLists.gl.txt
> index 02ede80..a264626 100644
> --- a/tests/spec/arb_compute_shader/CMakeLists.gl.txt
> +++ b/tests/spec/arb_compute_shader/CMakeLists.gl.txt
> @@ -19,5 +19,6 @@ piglit_add_executable (arb_compute_shader-local-id local-id.c ${depends})
> piglit_add_executable (arb_compute_shader-render-and-compute render-and-compute.c ${depends})
> piglit_add_executable (arb_compute_shader-zero-dispatch-size zero-dispatch-size.c ${depends})
> piglit_add_executable (arb_compute_shader-conditional-dispatch conditional-dispatch.c)
> +piglit_add_executable (arb_compute_shader-large-block-size large-block-size.c)
>
> # vim: ft=cmake:
> diff --git a/tests/spec/arb_compute_shader/large-block-size.c b/tests/spec/arb_compute_shader/large-block-size.c
> new file mode 100644
> index 0000000..e34c440
> --- /dev/null
> +++ b/tests/spec/arb_compute_shader/large-block-size.c
> @@ -0,0 +1,106 @@
> +/*
> + * Copyright 2016 Bas Nieuwenhuizen
> + *
> + * 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.
> + */
> +
> +/*
> + * Tests that shaders with large numbers of variables can still be used with
> + * large blocks. The result has two parts: it should not hang / show VM faults
> + * and it should give the right solution.
> + */
> +
> +#include "piglit-util-gl.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> + config.supports_gl_core_version = 42;
> +
> + config.window_width = 320;
> + config.window_height = 320;
> + config.window_visual = PIGLIT_GL_VISUAL_RGB;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +const char *cs_source =
> + "#version 420\n"
> + "#extension GL_ARB_compute_shader : require\n"
> + "#extension GL_ARB_shader_storage_buffer_object : require\n"
> + "layout (local_size_x = 1024, local_size_y = 1, local_size_z = 1) in;\n"
> + "layout(binding = 0, std430) buffer Result {\n"
> + " int result[1024];\n"
> + "};\n"
> + "uniform int a, b, c;\n"
> + "void main() {\n"
> + " int arr[65];\n"
> + " arr[0] = a;\n"
> + " for(int i = 1; i < 65; ++i)\n"
> + " arr[i] = (arr[i - 1] * a + b) % c;\n"
> + " for(int i = 63; i >= 0; --i)\n"
> + " arr[i] = (arr[i + 1] * a + b) % c;\n"
> + " result[gl_GlobalInvocationID.x] = arr[0];\n"
> + "}\n";
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> + return PIGLIT_FAIL;
> +}
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> + unsigned shader, prog, buffer;
> + int *data;
> + int i;
> + bool result = true;
> +
> + piglit_require_gl_version(42);
> + piglit_require_extension("GL_ARB_compute_shader");
> + piglit_require_extension("GL_ARB_shader_storage_buffer_object");
> +
> + shader = piglit_compile_shader_text(GL_COMPUTE_SHADER, cs_source);
> + prog = piglit_link_simple_program_multiple_shaders(shader, 0);
> + glDeleteShader(shader);
> +
> + glGenBuffers(1, &buffer);
> + glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, buffer);
> + glBufferData(GL_SHADER_STORAGE_BUFFER, 1024 * sizeof(uint32_t), NULL,
> + GL_DYNAMIC_DRAW);
> +
> + glUseProgram(prog);
> + glUniform1i(glGetUniformLocation(prog, "a"), 3);
> + glUniform1i(glGetUniformLocation(prog, "b"), 557);
> + glUniform1i(glGetUniformLocation(prog, "c"), 65537);
> +
> + glDispatchCompute(1, 1, 1);
> +
> + data = (int*)glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_READ_ONLY);
> + for (i = 0; i < 1024; ++i)
> + if (data[i] != 2967)
> + result = false;
Shouldn't you break here?
> +
> + glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
> +
> + glDeleteProgram(prog);
> + glDeleteBuffers(1, &buffer);
> +
> + piglit_report_result(result ? PIGLIT_PASS : PIGLIT_FAIL);
> +}
> --
> 2.8.0
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/piglit/attachments/20160412/ceafc3bc/attachment.sig>
More information about the Piglit
mailing list