[Piglit] [PATCH 1/9] arb_texture_stencil8: add initial texture interface test

Anuj Phogat anuj.phogat at gmail.com
Tue Apr 7 12:26:54 PDT 2015


On Mon, Apr 6, 2015 at 8:39 PM, Dave Airlie <airlied at gmail.com> wrote:
> this just checks the basic API works, and that 3D is rejected.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  tests/spec/CMakeLists.txt                         |   1 +
>  tests/spec/arb_texture_stencil8/CMakeLists.gl.txt |  14 ++
>  tests/spec/arb_texture_stencil8/CMakeLists.txt    |   1 +
>  tests/spec/arb_texture_stencil8/stencil-texture.c | 158 ++++++++++++++++++++++
>  4 files changed, 174 insertions(+)
>  create mode 100644 tests/spec/arb_texture_stencil8/CMakeLists.gl.txt
>  create mode 100644 tests/spec/arb_texture_stencil8/CMakeLists.txt
>  create mode 100644 tests/spec/arb_texture_stencil8/stencil-texture.c
>
> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
> index d921df4..6ccf73d 100644
> --- a/tests/spec/CMakeLists.txt
> +++ b/tests/spec/CMakeLists.txt
> @@ -124,3 +124,4 @@ add_subdirectory (oes_texture_float)
>  add_subdirectory (arb_direct_state_access)
>  add_subdirectory (ext_polygon_offset_clamp)
>  add_subdirectory (arb_pipeline_statistics_query)
> +add_subdirectory (arb_texture_stencil8)
> diff --git a/tests/spec/arb_texture_stencil8/CMakeLists.gl.txt b/tests/spec/arb_texture_stencil8/CMakeLists.gl.txt
> new file mode 100644
> index 0000000..bd3fadd
> --- /dev/null
> +++ b/tests/spec/arb_texture_stencil8/CMakeLists.gl.txt
> @@ -0,0 +1,14 @@
> +include_directories(
> +       ${GLEXT_INCLUDE_DIR}
> +       ${OPENGL_INCLUDE_PATH}
> +)
> +
> +link_libraries (
> +       piglitutil_${piglit_target_api}
> +       ${OPENGL_gl_LIBRARY}
> +       ${OPENGL_glu_LIBRARY}
> +)
> +
> +piglit_add_executable (arb_texture_stencil8-stencil-texture stencil-texture.c)
> +
> +# vim: ft=cmake:
> diff --git a/tests/spec/arb_texture_stencil8/CMakeLists.txt b/tests/spec/arb_texture_stencil8/CMakeLists.txt
> new file mode 100644
> index 0000000..144a306
> --- /dev/null
> +++ b/tests/spec/arb_texture_stencil8/CMakeLists.txt
> @@ -0,0 +1 @@
> +piglit_include_target_api()
> diff --git a/tests/spec/arb_texture_stencil8/stencil-texture.c b/tests/spec/arb_texture_stencil8/stencil-texture.c
> new file mode 100644
> index 0000000..f58f67a
> --- /dev/null
> +++ b/tests/spec/arb_texture_stencil8/stencil-texture.c
> @@ -0,0 +1,158 @@
> +/*
> + * Copyright © 2011 Intel Corporation
> + * Copyright © 2015 Red Hat
> + *
> + * 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 stencil-texture.c
> + * Create a stencil texture.
> + * based on ext_packed_depth_stencil/depth-stencil-texture.c test.
> + */
> +
> +#include "piglit-util-gl.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +       config.supports_gl_compat_version = 12;
> +       config.supports_gl_core_version = 31;
> +
> +       config.window_visual = PIGLIT_GL_VISUAL_RGBA;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +static bool
> +try_TexImage(GLenum internalFormat)
> +{
> +       bool pass = true;
> +       GLuint tex[4];
> +       unsigned i;
> +
> +       printf("Testing glTexImage with %s...\n",
> +              piglit_get_gl_enum_name(internalFormat));
> +
> +       glGenTextures(ARRAY_SIZE(tex), tex);
> +
> +       glBindTexture(GL_TEXTURE_1D, tex[0]);
> +       glTexImage1D(GL_TEXTURE_1D, 0, internalFormat,
> +                    16, 0,
> +                    GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, NULL);
> +       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +       glBindTexture(GL_TEXTURE_2D, tex[1]);
> +       glTexImage2D(GL_TEXTURE_2D, 0, internalFormat,
> +                    16, 16, 0,
> +                    GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, NULL);
> +       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +       /* 3D texture is not in the list of supported STENCIL_INDEX */
> +       glBindTexture(GL_TEXTURE_3D, tex[2]);
> +       glTexImage3D(GL_TEXTURE_3D, 0, internalFormat,
> +                    8, 8, 8, 0,
> +                    GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, NULL);
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       glBindTexture(GL_TEXTURE_CUBE_MAP, tex[3]);
> +
> +       for (i = 0; i < 6; i++) {
> +               glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
> +                            0, internalFormat,
> +                            16, 16, 0,
> +                            GL_STENCIL_INDEX, GL_UNSIGNED_BYTE,
> +                            NULL);
> +               pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +       }
> +
> +       glBindTexture(GL_TEXTURE_1D, 0);
> +       glBindTexture(GL_TEXTURE_2D, 0);
> +       glBindTexture(GL_TEXTURE_3D, 0);
> +       glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
> +
> +       glDeleteTextures(ARRAY_SIZE(tex), tex);
> +
> +       printf("Done.\n\n");
> +
> +       return pass;
> +}
> +
> +static bool
> +try_TexStorage(GLenum internalFormat)
> +{
> +       bool pass = true;
> +       GLuint tex[4];
> +
> +       printf("Testing glTexStorage with %s...\n",
> +              piglit_get_gl_enum_name(internalFormat));
> +
> +       glGenTextures(ARRAY_SIZE(tex), tex);
> +
> +       glBindTexture(GL_TEXTURE_1D, tex[0]);
> +       glTexStorage1D(GL_TEXTURE_1D, 1, internalFormat, 16);
> +       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +       glBindTexture(GL_TEXTURE_2D, tex[1]);
> +       glTexStorage2D(GL_TEXTURE_2D, 1, internalFormat, 16, 16);
> +       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +       glBindTexture(GL_TEXTURE_3D, tex[2]);
> +       glTexStorage3D(GL_TEXTURE_3D, 1, internalFormat, 8, 8, 8);
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       glBindTexture(GL_TEXTURE_CUBE_MAP, tex[3]);
> +       glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, internalFormat, 16, 16);
> +       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +       glBindTexture(GL_TEXTURE_1D, 0);
> +       glBindTexture(GL_TEXTURE_2D, 0);
> +       glBindTexture(GL_TEXTURE_3D, 0);
> +       glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
> +
> +       glDeleteTextures(ARRAY_SIZE(tex), tex);
> +
> +       printf("Done.\n\n");
> +
> +       return pass;
> +}
> +
> +void piglit_init(int argc, char **argv)
> +{
> +       bool pass = true;
> +       bool has_texture_storage;
> +
> +       piglit_require_extension("GL_ARB_texture_stencil8");
> +       has_texture_storage = piglit_get_gl_version() >= 42
> +               || piglit_is_extension_supported("GL_ARB_texture_storage");
> +
> +       pass = try_TexImage(GL_STENCIL_INDEX8) && pass;
> +
> +       if (has_texture_storage) {
> +               pass = try_TexStorage(GL_STENCIL_INDEX8) && pass;
> +       }
> +
> +       piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
> +}
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +       /* UNREACHED */
> +       return PIGLIT_FAIL;
> +}
> --
> 2.1.0
>

{1D, 2D, CUBE_MAP}_ARRAY targets can also be added in the test.
Someone may do it later, If you don't want to add them now.

Patch is:
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list