[Piglit] [PATCH 1/2] arb_clear_buffer_object-unaligned: new test for unaligned byte clears

Ilia Mirkin imirkin at alum.mit.edu
Sun Nov 8 02:07:40 PST 2015


On Sun, Nov 8, 2015 at 5:03 AM, Marek Olšák <maraeo at gmail.com> wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
>  tests/all.py                                       |   1 +
>  .../spec/arb_clear_buffer_object/CMakeLists.gl.txt |   1 +
>  tests/spec/arb_clear_buffer_object/unaligned.c     | 110 +++++++++++++++++++++
>  3 files changed, 112 insertions(+)
>  create mode 100644 tests/spec/arb_clear_buffer_object/unaligned.c
>
> diff --git a/tests/all.py b/tests/all.py
> index 8de1e17..8329643 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -3689,6 +3689,7 @@ with profile.group_manager(
>      g(['arb_clear_buffer_object-sub-mapped'])
>      g(['arb_clear_buffer_object-sub-overlap'])
>      g(['arb_clear_buffer_object-sub-simple'])
> +    g(['arb_clear_buffer_object-unaligned'])
>      g(['arb_clear_buffer_object-zero-size'])
>
>  with profile.group_manager(
> diff --git a/tests/spec/arb_clear_buffer_object/CMakeLists.gl.txt b/tests/spec/arb_clear_buffer_object/CMakeLists.gl.txt
> index 3a1565d..19fa309 100644
> --- a/tests/spec/arb_clear_buffer_object/CMakeLists.gl.txt
> +++ b/tests/spec/arb_clear_buffer_object/CMakeLists.gl.txt
> @@ -18,6 +18,7 @@ piglit_add_executable (arb_clear_buffer_object-sub-invalid-size sub-invalid-size
>  piglit_add_executable (arb_clear_buffer_object-sub-mapped sub-mapped.c common.c)
>  piglit_add_executable (arb_clear_buffer_object-sub-overlap sub-overlap.c common.c)
>  piglit_add_executable (arb_clear_buffer_object-sub-simple sub-simple.c common.c)
> +piglit_add_executable (arb_clear_buffer_object-unaligned unaligned.c common.c)
>  piglit_add_executable (arb_clear_buffer_object-zero-size zero-size.c common.c)
>
>  # vim: ft=cmake:
> diff --git a/tests/spec/arb_clear_buffer_object/unaligned.c b/tests/spec/arb_clear_buffer_object/unaligned.c
> new file mode 100644
> index 0000000..b73cbf7
> --- /dev/null
> +++ b/tests/spec/arb_clear_buffer_object/unaligned.c
> @@ -0,0 +1,110 @@
> +/*
> + * Copyright © 2014 Intel Corporation
> + * Copyright © 2015 Advanced Micro Devices, 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.
> + */
> +
> +/**
> + * \file unaligned.c
> + *
> + * Test R8 copying with non-dword alignment.
> + */
> +
> +#include "piglit-util-gl.h"
> +#include "common.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +       config.supports_gl_compat_version = 15;
> +       config.supports_gl_core_version = 31;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +#define SIZE (1 << 20)
> +
> +static bool debug;
> +
> +static void
> +clear_buffer(int i, unsigned offset, unsigned size, unsigned char value, char *cpu)
> +{
> +       glClearBufferSubData(GL_ARRAY_BUFFER, GL_R8, offset, size,
> +                            GL_RED, GL_UNSIGNED_BYTE, &value);
> +       memset(cpu+offset, value, size);
> +
> +       if (debug && !check_array_buffer_data(SIZE, cpu)) {
> +               printf("Clear %i failed: offset=%i (%%4 = %i), size=%i (%%4 = %i)\n",
> +                      i, offset, offset % 4, size, size % 4);
> +               piglit_report_result(PIGLIT_FAIL);
> +       }
> +}
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +       bool pass = true;
> +       GLuint buffer;
> +       int i;
> +       unsigned offset, size;
> +       char *cpu = malloc(SIZE);
> +
> +       if (!cpu)
> +               piglit_report_result(PIGLIT_FAIL);
> +
> +       for (i = 1; i < argc; i++)
> +               if (!strcmp(argv[i], "-debug"))
> +                       debug = true;
> +
> +       piglit_require_extension("GL_ARB_clear_buffer_object");
> +       glGenBuffers(1, &buffer);
> +       glBindBuffer(GL_ARRAY_BUFFER, buffer);
> +       glBufferData(GL_ARRAY_BUFFER, SIZE, NULL, GL_STREAM_READ);
> +
> +       clear_buffer(0, 0, SIZE, 0, cpu);
> +
> +       srand(6487216);
> +       for (i = 1; i <= 200; i++) {
> +               offset = rand() % SIZE;
> +               size = 1 + (rand() % (SIZE - offset));
> +
> +               clear_buffer(i, offset, size, rand(), cpu);
> +       }
> +
> +       /* and some small unaligned copies within one dword */
> +       for (; i < 230; i++) {
> +               offset = (rand() % (SIZE/4)) * 4 + 1 + (rand() % 2);
> +               size = 1;
> +
> +               clear_buffer(i, offset, size, rand(), cpu);
> +       }
> +
> +       pass = piglit_check_gl_error(GL_NO_ERROR) &&
> +              check_array_buffer_data(SIZE, cpu);
> +       glDeleteBuffers(1, &buffer);
> +       piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
> +       free(cpu);

free first. piglit_report_result == exit(). Otherwise this is

Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>

> +}
> +
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +       return PIGLIT_PASS;
> +}
> --
> 2.1.4
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list