[Piglit] [PATCH] Added a test that checks if program have allocated more memory than allowed that program get correct gl_error. From the ARB_texture_buffer_object extension spec: While buffer textures can be substantially larger than equivalent one-dimensional textures; the maximum texture size supported for buffer textures in the initial implementation of this extension is 2^27 texels, versus 2^13 (8192) texels for otherwise equivalent one-dimensional textures.

Ilia Mirkin imirkin at alum.mit.edu
Wed May 30 15:25:49 UTC 2018


Please read up on how commit logs are meant to be structured. The
subject should be a max of like 60 chars, and the body should be
wrapped to 72 columns.

On Wed, May 30, 2018 at 8:08 AM, Illia Iorin <illia.iorin at gmail.com> wrote:
> ---
>  tests/opengl.py                               |  1 +
>  .../CMakeLists.gl.txt                         |  1 +
>  .../negative-bad-oom.c                        | 85 +++++++++++++++++++
>  3 files changed, 87 insertions(+)
>  create mode 100644 tests/spec/arb_texture_buffer_object/negative-bad-oom.c
>
> diff --git a/tests/opengl.py b/tests/opengl.py
> index 9c43d32c9..56cf4f041 100644
> --- a/tests/opengl.py
> +++ b/tests/opengl.py
> @@ -2365,6 +2365,7 @@ with profile.test_list.group_manager(
>      g(['arb_texture_buffer_object-max-size'], 'max-size')
>      g(['arb_texture_buffer_object-minmax'], 'minmax')
>      g(['arb_texture_buffer_object-negative-bad-bo'], 'negative-bad-bo')
> +    g(['arb_texture_buffer_object-negative-bad-oom'], 'negative-bad-oom')
>      g(['arb_texture_buffer_object-negative-bad-format'], 'negative-bad-format')
>      g(['arb_texture_buffer_object-negative-bad-target'], 'negative-bad-target')
>      g(['arb_texture_buffer_object-negative-unsupported'],
> diff --git a/tests/spec/arb_texture_buffer_object/CMakeLists.gl.txt b/tests/spec/arb_texture_buffer_object/CMakeLists.gl.txt
> index 959ca0c2f..98d1e16d8 100644
> --- a/tests/spec/arb_texture_buffer_object/CMakeLists.gl.txt
> +++ b/tests/spec/arb_texture_buffer_object/CMakeLists.gl.txt
> @@ -25,3 +25,4 @@ piglit_add_executable (arb_texture_buffer_object-subdata-sync subdata-sync.c)
>  piglit_add_executable (arb_texture_buffer_object-unused-name unused-name.c)
>  piglit_add_executable (arb_texture_buffer_object-fetch-outside-bounds fetch-outside-bounds.c)
>  piglit_add_executable (arb_texture_buffer_object-indexed indexed.c)
> +piglit_add_executable (arb_texture_buffer_object-negative-bad-oom negative-bad-oom.c)
> \ No newline at end of file
> diff --git a/tests/spec/arb_texture_buffer_object/negative-bad-oom.c b/tests/spec/arb_texture_buffer_object/negative-bad-oom.c
> new file mode 100644
> index 000000000..61bfae365
> --- /dev/null
> +++ b/tests/spec/arb_texture_buffer_object/negative-bad-oom.c
> @@ -0,0 +1,85 @@
> +/* Copyright © 2018 Illia Iorin
> + *
> + * 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 negative-bad-oom.c
> +* From the ARB_texture_buffer_object extension spec:
> +*
> +*    While buffer textures can be substantially larger than equivalent
> +*    one-dimensional textures; the maximum texture size supported for buffer
> +*    textures in the initial implementation of this extension is 2^27 texels,
> +*    versus 2^13 (8192) texels for otherwise equivalent one-dimensional
> +*    textures.
> +*
> +*/
> +#include "piglit-util-gl.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +       config.supports_gl_compat_version = 10;
> +       config.supports_gl_core_version = 31;
> +
> +       config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
> +       config.khr_no_error_support = PIGLIT_HAS_ERRORS;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +       return PIGLIT_FAIL; /* UNREACHED */
> +}
> +
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +       GLuint tex, tbo;
> +       static const uint8_t data[4] = {0x00, 0xff, 0x00, 0x00};
> +       GLuint prog;
> +       GLint max;
> +       //GLenum err;
> +
> +       glGenBuffers(1, &tbo);
> +       glBindBuffer(GL_TEXTURE_BUFFER, tbo);
> +
> +       glGenTextures(1, &tex);
> +       glBindTexture(GL_TEXTURE_BUFFER, tex);
> +
> +       glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &max);
> +
> +       if (max >= 512 * 1024 * 1024) {
> +               /* Buffer sizes >= 2G are a bit dicey, ideally this
> +                * test would try various formats, including GL_R8.
> +                */

This comment sure looks familiar...

I think in this case, your test will fail, since if the max is over
512M, and you cap it to 512M, then 512M + 1000 will still be within
the max.

  -ilia

> +               printf("MAX_TEXTURE_BUFFER_SIZE >= 512M, "
> +                      "testing with size 512M-1\n");
> +               max = 512 * 1024 * 1024 - 1;
> +       }
> +       max += 1000;
> +       glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA8, tbo);
> +       glBufferData(GL_TEXTURE_BUFFER,
> +                    max * sizeof(data), NULL, GL_STATIC_READ);
> +       if (!piglit_check_gl_error(GL_OUT_OF_MEMORY))
> +               piglit_report_result(PIGLIT_FAIL);
> +
> +       piglit_report_result(PIGLIT_PASS);
> +}
> \ No newline at end of file
> --
> 2.17.0
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list