[Piglit] [PATCH] Add a basic CopyTexImage test for packed depth/stencil formats.
Paul Berry
stereotype441 at gmail.com
Thu Feb 7 09:48:54 PST 2013
On 5 February 2013 22:52, Kenneth Graunke <kenneth at whitecape.org> wrote:
> This test fills the window with expected depth/stencil values, and uses
> CopyTexImage2D to copy those to a texture. It then reads back the
> texture and verifies that both depth and stencil were successfully
> copied.
>
> This is particularly useful because on Sandybridge and later hardware,
> we use a separate stencil buffer, which means that GPU CopyTexImage
> paths can easily forget to copy stencil.
>
> The existing copyteximage test includes packed depth/stencil formats,
> but only validates the resulting depth values, not stencil.
>
> Cc: Paul Berry <stereotype441 at gmail.com>
>
This is definitely better than what we had before, but I would be more
comfortable if we expanded the test to verify:
(a) that pixels aren't scrambled in some way by glCopyTexImage2D (since
stencil buffers use W tiling, it wouldn't be hugely surprising for us to
have a bug in this department)
(b) that copying works from both FBOs and window system buffers (since
these have different Y coordinate conventions, it wouldn't be surprising
for us to have a bug causing us to flip the Y coordinate in one or the
other case)
(c) that glCopyTexImage3D() is properly respecting the x, y, width, and
height arguments (currently the test just passes in 0 for x and y, and it
doesn't try to read back the width and height of the texture to verify that
they were set correctly)
> ---
> tests/all.tests | 1 +
> tests/texturing/CMakeLists.gl.txt | 1 +
> tests/texturing/copyteximage-depthstencil.c | 109
> ++++++++++++++++++++++++++++
> 3 files changed, 111 insertions(+)
> create mode 100644 tests/texturing/copyteximage-depthstencil.c
>
> Sure enough, testing things catches bugs.
>
> diff --git a/tests/all.tests b/tests/all.tests
> index 2ffc6e1..6bc4d39 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -1618,6 +1618,7 @@
> add_fbo_formats_tests('spec/EXT_packed_depth_stencil',
> 'GL_EXT_packed_depth_sten
> add_texwrap_format_tests(ext_packed_depth_stencil,
> 'GL_EXT_packed_depth_stencil')
> ext_packed_depth_stencil['readpixels-24_8'] =
> PlainExecTest(['ext_packed_depth_stencil-readpixels-24_8', '-auto'])
> add_plain_test(ext_packed_depth_stencil, 'fbo-blit-d24s8')
> +add_plain_test(ext_packed_depth_stencil, 'copyteximage-depthstencil')
> # Note: the buffer sizes of 146, 292, 585, and 1024 hav been chosen to
> # exercise all possible combinations of buffer alignments on i965.
> for texture_size in (146, 292, 585, 1024):
> diff --git a/tests/texturing/CMakeLists.gl.txt
> b/tests/texturing/CMakeLists.gl.txt
> index c9e5d11..b78416b 100644
> --- a/tests/texturing/CMakeLists.gl.txt
> +++ b/tests/texturing/CMakeLists.gl.txt
> @@ -18,6 +18,7 @@ piglit_add_executable (copytexsubimage copytexsubimage.c)
> piglit_add_executable (copyteximage copyteximage.c)
> piglit_add_executable (copyteximage-border copyteximage-border.c)
> piglit_add_executable (copyteximage-clipping copyteximage-clipping.c)
> +piglit_add_executable (copyteximage-depthstencil
> copyteximage-depthstencil.c)
> piglit_add_executable (crossbar crossbar.c)
> piglit_add_executable (cubemap cubemap.c)
> piglit_add_executable (cubemap-shader cubemap-shader.c)
> diff --git a/tests/texturing/copyteximage-depthstencil.c
> b/tests/texturing/copyteximage-depthstencil.c
> new file mode 100644
> index 0000000..65a9558
> --- /dev/null
> +++ b/tests/texturing/copyteximage-depthstencil.c
> @@ -0,0 +1,109 @@
> +/*
> + * Copyright © 2013 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 copyteximage-depthstencil.c
> + *
> + * A basic test that makes sure glCopyTexImage actually copies both depth
> + * and stencil data.
> + */
> +
> +#include "piglit-util-gl-common.h"
> +
> +#define TEX_WIDTH 128
> +#define TEX_HEIGHT 4
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> + config.supports_gl_compat_version = 10;
> +
> + config.window_width = TEX_WIDTH;
> + config.window_height = TEX_HEIGHT;
> + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE |
> + PIGLIT_GL_VISUAL_RGB |
> + PIGLIT_GL_VISUAL_DEPTH |
> + PIGLIT_GL_VISUAL_STENCIL;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> + return PIGLIT_FAIL;
> +}
> +
> +void piglit_init(int argc, char **argv)
> +{
> + GLuint tex;
> + GLfloat depth[TEX_WIDTH * TEX_HEIGHT];
> + GLuint ds[TEX_WIDTH * TEX_HEIGHT];
> + int i;
> +
> + const float expected_depth = 0.7;
> + const int expected_stencil = 0x42;
> +
> + bool pass = true;
> +
> + piglit_require_extension("GL_EXT_packed_depth_stencil");
> +
> + /* Fill the window with expected depth/stencil values */
> + glClearDepth(expected_depth);
> + glClearStencil(expected_stencil);
> + glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
> +
> + /* Copy the data to the texture */
> + glGenTextures(1, &tex);
> + glBindTexture(GL_TEXTURE_2D, tex);
> + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8,
> + 0, 0, TEX_WIDTH, TEX_HEIGHT, 0);
> + piglit_check_gl_error(GL_NO_ERROR);
> +
> + /* Read back the texture */
> + glGetTexImage(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, GL_FLOAT,
> depth);
> + piglit_check_gl_error(GL_NO_ERROR);
> +
> + glGetTexImage(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL,
> GL_UNSIGNED_INT_24_8, ds);
> + piglit_check_gl_error(GL_NO_ERROR);
> +
> + /* Check for expected values */
> + for (i = 0; i < TEX_WIDTH * TEX_HEIGHT; ++i) {
> + int x = i % TEX_WIDTH;
> + int y = i / TEX_WIDTH;
> +
> + unsigned actual_stencil = ds[i] >> 24;
> + float actual_depth = depth[i];
> +
> + if (actual_depth != expected_depth) {
> + printf("Depth at (%d, %d) = %.2f, expected %.2f\n",
> + x, y, actual_depth, expected_depth);
> + pass = false;
> + }
> + if (actual_stencil != expected_stencil) {
> + printf("Stencil at (%d, %d) = 0x%x, expected
> 0x%x\n",
> + x, y, actual_stencil, expected_stencil);
> + pass = false;
> + }
> + }
> +
> + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
> +}
> --
> 1.8.1.2
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20130207/07500bba/attachment.html>
More information about the Piglit
mailing list