[Piglit] [PATCH] arb_texture_stencil8: test updating just stencil of a z32f_s8 texture
Ilia Mirkin
imirkin at alum.mit.edu
Mon Sep 2 20:32:05 UTC 2019
Dave points out that this is actually illegal. I managed to merge the
addition of GL_STENCIL_INDEX as a valid token to glTexSubImage and the
allowance of this for glGetTexImage as one thing. Test withdrawn. Will
try to submit something which tests that the behavior yields a GL
error.
On Tue, Aug 27, 2019 at 9:23 PM Ilia Mirkin <imirkin at alum.mit.edu> wrote:
>
> This extension introduces GL_STENCIL_INDEX as an allowable format for
> glTexSubImage, which can trigger a partial update of a depth/stencil
> texture.
>
> Exploits an assumption about source row stride in mesa's storage helper
> for z32f_s8 stores to trigger failures on (current) mesa.
>
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
> .../arb_texture_stencil8/CMakeLists.gl.txt | 1 +
> tests/spec/arb_texture_stencil8/texsubimage.c | 116 ++++++++++++++++++
> 2 files changed, 117 insertions(+)
> create mode 100644 tests/spec/arb_texture_stencil8/texsubimage.c
>
> diff --git a/tests/spec/arb_texture_stencil8/CMakeLists.gl.txt b/tests/spec/arb_texture_stencil8/CMakeLists.gl.txt
> index d8de83c4d..58b9e625d 100644
> --- a/tests/spec/arb_texture_stencil8/CMakeLists.gl.txt
> +++ b/tests/spec/arb_texture_stencil8/CMakeLists.gl.txt
> @@ -12,5 +12,6 @@ piglit_add_executable (arb_texture_stencil8-stencil-texture stencil-texture.c)
> piglit_add_executable (arb_texture_stencil8-draw draw.c)
> piglit_add_executable (arb_texture_stencil8-fbo-stencil8 fbo-stencil8.c)
> piglit_add_executable (arb_texture_stencil8-getteximage getteximage.c)
> +piglit_add_executable (arb_texture_stencil8-texsubimage texsubimage.c)
>
> # vim: ft=cmake:
> diff --git a/tests/spec/arb_texture_stencil8/texsubimage.c b/tests/spec/arb_texture_stencil8/texsubimage.c
> new file mode 100644
> index 000000000..922644597
> --- /dev/null
> +++ b/tests/spec/arb_texture_stencil8/texsubimage.c
> @@ -0,0 +1,116 @@
> +/*
> + * Copyright (c) 2019 Ilia Mirkin
> + *
> + * 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 texsubimage.c
> + *
> + * Test glTexSubImage with format = GL_STENCIL_INDEX. Based on getteximage.c.
> + */
> +
> +#include "piglit-util-gl.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> + config.supports_gl_compat_version = 12;
> + config.window_visual = PIGLIT_GL_VISUAL_RGBA;
> + config.khr_no_error_support = PIGLIT_NO_ERRORS;
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +
> +#define WIDTH 17
> +#define HEIGHT 17
> +
> +static bool
> +test_z32f_s8(void)
> +{
> + uint32_t tex[WIDTH * HEIGHT * 2];
> + uint32_t buf[WIDTH * HEIGHT * 2];
> + uint8_t update[WIDTH * HEIGHT];
> + bool ret = true;
> + int i;
> +
> + /* init tex data */
> + for (i = 0; i < WIDTH * HEIGHT; i++) {
> + tex[2 * i] = 0x3f800000;
> + tex[2 * i + 1] = 0x80;
> + }
> +
> + /* create texture */
> + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH32F_STENCIL8,
> + WIDTH, HEIGHT, 0,
> + GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, tex);
> + if (!piglit_check_gl_error(GL_NO_ERROR))
> + return false;
> +
> +
> + /* update texture */
> + for (i = 0; i < WIDTH * HEIGHT; i++) {
> + tex[2 * i + 1] = update[i] = i & 0xff;
> + }
> + glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
> + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, WIDTH, HEIGHT,
> + GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, update);
> +
> + /* read back the texture */
> + glGetTexImage(GL_TEXTURE_2D, 0,
> + GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, buf);
> + if (!piglit_check_gl_error(GL_NO_ERROR))
> + return false;
> +
> + /* compare */
> + for (i = 0; i < WIDTH * HEIGHT; i++) {
> + if (buf[2 * i] != tex[2 * i]) {
> + printf("Wrong depth texel data at position (%d,%d): "
> + "Expected 0x%08x, found 0x%08x\n",
> + i % WIDTH, i / WIDTH, tex[2 * i], buf[2 * i]);
> + ret = false;
> + }
> + if (buf[2 * i + 1] != tex[2 * i + 1]) {
> + printf("Wrong stencil texel data at position (%d,%d): "
> + "Expected 0x%08x, found 0x%08x\n",
> + i % WIDTH, i / WIDTH, tex[2 * i + 1], buf[2 * i + 1]);
> + ret = false;
> + }
> + }
> +
> + return ret;
> +}
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> + bool pass;
> +
> + piglit_require_extension("GL_ARB_texture_stencil8");
> +
> + pass = test_z32f_s8();
> +
> + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
> +}
> +
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> + /* unused */
> + return PIGLIT_FAIL;
> +}
> --
> 2.21.0
>
More information about the Piglit
mailing list