[Piglit] [PATCH] arb_texture_view-mipgen: add test to verify correct format is used for mipgen

Ilia Mirkin imirkin at alum.mit.edu
Tue Jan 12 16:28:30 PST 2016


On Tue, Jan 12, 2016 at 7:20 PM,  <sroland at vmware.com> wrote:
> From: Roland Scheidegger <sroland at vmware.com>
>
> At least mesa/st fails this right now (always uses the initial format for mip
> gen).
> ---
>  tests/all.py                                  |   1 +
>  tests/spec/arb_texture_view/CMakeLists.gl.txt |   1 +
>  tests/spec/arb_texture_view/mipgen.c          | 102 ++++++++++++++++++++++++++
>  3 files changed, 104 insertions(+)
>  create mode 100644 tests/spec/arb_texture_view/mipgen.c
>
> diff --git a/tests/all.py b/tests/all.py
> index d9f88d6..0a97d26 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -2480,6 +2480,7 @@ with profile.group_manager(
>      g(['arb_texture_view-cubemap-view'], 'cubemap-view')
>      g(['arb_texture_view-texture-immutable-levels'], 'immutable_levels')
>      g(['arb_texture_view-max-level'], 'max-level')
> +    g(['arb_texture_view-mipgen'], 'mipgen')
>      g(['arb_texture_view-params'], 'params')
>      g(['arb_texture_view-formats'], 'formats')
>      g(['arb_texture_view-targets'], 'targets')
> diff --git a/tests/spec/arb_texture_view/CMakeLists.gl.txt b/tests/spec/arb_texture_view/CMakeLists.gl.txt
> index 772f8b4..47b3320 100644
> --- a/tests/spec/arb_texture_view/CMakeLists.gl.txt
> +++ b/tests/spec/arb_texture_view/CMakeLists.gl.txt
> @@ -17,6 +17,7 @@ piglit_add_executable(arb_texture_view-formats formats.c common.c)
>  piglit_add_executable(arb_texture_view-getteximage-srgb getteximage-srgb.c)
>  piglit_add_executable(arb_texture_view-lifetime-format lifetime_format.c common.c)
>  piglit_add_executable(arb_texture_view-max-level max-level.c)
> +piglit_add_executable(arb_texture_view-mipgen mipgen.c)
>  piglit_add_executable(arb_texture_view-params params.c)
>  piglit_add_executable(arb_texture_view-queries queries.c)
>  piglit_add_executable(arb_texture_view-rendering-formats rendering-formats.c)
> diff --git a/tests/spec/arb_texture_view/mipgen.c b/tests/spec/arb_texture_view/mipgen.c
> new file mode 100644
> index 0000000..0f96f77
> --- /dev/null
> +++ b/tests/spec/arb_texture_view/mipgen.c
> @@ -0,0 +1,102 @@
> +/*
> + * Copyright © 2016 VMware, 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.
> + */
> +
> +/**
> + * Verifies that mipmap generation uses the right format (from view,
> + * not what was originally specified).
> + */
> +
> +#include "piglit-util-gl.h"
> +#include "common.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +       config.supports_gl_compat_version = 20;
> +
> +       config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +static const char *TestName = "arb_texture_view-mipgen";
> +
> +/**
> + * Create view with different view format and generate mipmap.
> + */
> +static bool
> +test_mipgen(void)
> +{
> +       GLuint tex, new_tex;
> +       GLint width = 4, height = 4, levels = 2;
> +       bool pass = true;
> +
> +       glGenTextures(1, &tex);
> +       glBindTexture(GL_TEXTURE_2D, tex);
> +
> +       glTexStorage2D(GL_TEXTURE_2D, levels, GL_R8, width, height);
> +
> +       /* averaging these as snorm values should give 0 */
> +       GLubyte buf[4][4] =
> +               {{0xFF, 0x01, 0xFF, 0x01},
> +                {0xFF, 0x01, 0xFF, 0x01},
> +                {0xFF, 0x01, 0xFF, 0x01},
> +                {0xFF, 0x01, 0xFF, 0x01}};
> +       GLbyte res[4];
> +
> +       glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height,
> +                       GL_RED, GL_UNSIGNED_BYTE, buf);
> +
> +       glGenTextures(1, &new_tex);
> +
> +       glTextureView(new_tex, GL_TEXTURE_2D, tex,  GL_R8_SNORM, 0, 2, 0, 1);
> +       glBindTexture(GL_TEXTURE_2D, new_tex);
> +       glGenerateMipmap(GL_TEXTURE_2D);
> +       glPixelStorei(GL_PACK_ALIGNMENT, 1);
> +       glGetTexImage(GL_TEXTURE_2D, 1, GL_RED, GL_BYTE, &res);
> +       pass = !res[0] && !res[1] && !res[2] && !res[3];
> +
> +       if (!pass) {
> +               printf("expected 0, got %d %d %d %d\n",
> +                      res[0], res[1], res[2], res[3]);
> +       }
> +
> +       glDeleteTextures(1, &new_tex);
> +       glDeleteTextures(1, &tex);
> +
> +       return pass;
> +}
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +       bool pass = true;
> +       pass = test_mipgen();
> +       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;

I think this should all just live in piglit_init -- no drawing is
done, nothing is displayed.

I was just asking about this on #dri-devel (as a result of the
generate_mipmaps patch)... glad someone got to writing this test!

With the move to piglit_init, this is

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

> +       return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +       piglit_require_extension("GL_ARB_texture_storage");
> +       piglit_require_extension("GL_ARB_texture_view");
> +}
> --
> 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