[Piglit] [PATCH] arb_get_texture_sub_image: new tests for GL_ARB_get_texture_sub_image

Ilia Mirkin imirkin at alum.mit.edu
Tue Jul 14 07:28:50 PDT 2015


On Mon, Jul 13, 2015 at 9:21 PM, Brian Paul <brianp at vmware.com> wrote:
> errors.c - test error detection
> get.c - test glGetTextureSubImage
> getcompressed.c - test glGetCompressedTextureSubImage
> cubemap.c - extra tests for getting cubemap images
> ---
>  tests/all.py                                       |   7 +
>  tests/spec/CMakeLists.txt                          |   1 +
>  .../arb_get_texture_sub_image/CMakeLists.gl.txt    |  17 +
>  .../spec/arb_get_texture_sub_image/CMakeLists.txt  |   1 +
>  tests/spec/arb_get_texture_sub_image/cubemap.c     | 203 ++++++++++
>  tests/spec/arb_get_texture_sub_image/errors.c      | 208 ++++++++++
>  tests/spec/arb_get_texture_sub_image/get.c         | 435 +++++++++++++++++++++
>  .../spec/arb_get_texture_sub_image/getcompressed.c | 337 ++++++++++++++++
>  8 files changed, 1209 insertions(+)
>  create mode 100644 tests/spec/arb_get_texture_sub_image/CMakeLists.gl.txt
>  create mode 100644 tests/spec/arb_get_texture_sub_image/CMakeLists.txt
>  create mode 100644 tests/spec/arb_get_texture_sub_image/cubemap.c
>  create mode 100644 tests/spec/arb_get_texture_sub_image/errors.c
>  create mode 100644 tests/spec/arb_get_texture_sub_image/get.c
>  create mode 100644 tests/spec/arb_get_texture_sub_image/getcompressed.c
>
> diff --git a/tests/all.py b/tests/all.py
> index f2e1765..1872df2 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -2501,6 +2501,13 @@ with profile.group_manager(
>          'GL_DEPTH32F_STENCIL8', 0)
>
>  with profile.group_manager(
> +        PiglitGLTest, grouptools.join('spec', 'arb_get_texture_sub_image')) as g:
> +    g(['arb_get_texture_sub_image-cubemap'])
> +    g(['arb_get_texture_sub_image-errors'])
> +    g(['arb_get_texture_sub_image-get'])
> +    g(['arb_get_texture_sub_image-getcompressed'])
> +
> +with profile.group_manager(
>          PiglitGLTest,
>          grouptools.join('spec', 'arb_texture_env_crossbar')) as g:
>      g(['crossbar'], run_concurrent=False)
> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
> index b0973ac..1421afa 100644
> --- a/tests/spec/CMakeLists.txt
> +++ b/tests/spec/CMakeLists.txt
> @@ -23,6 +23,7 @@ add_subdirectory (arb_framebuffer_object)
>  add_subdirectory (arb_framebuffer_srgb)
>  add_subdirectory (arb_geometry_shader4)
>  add_subdirectory (arb_get_program_binary)
> +add_subdirectory (arb_get_texture_sub_image)
>  add_subdirectory (arb_gpu_shader5)
>  add_subdirectory (arb_gpu_shader_fp64)
>  add_subdirectory (arb_instanced_arrays)
> diff --git a/tests/spec/arb_get_texture_sub_image/CMakeLists.gl.txt b/tests/spec/arb_get_texture_sub_image/CMakeLists.gl.txt
> new file mode 100644
> index 0000000..2194f8c
> --- /dev/null
> +++ b/tests/spec/arb_get_texture_sub_image/CMakeLists.gl.txt
> @@ -0,0 +1,17 @@
> +include_directories(
> +       ${GLEXT_INCLUDE_DIR}
> +       ${OPENGL_INCLUDE_PATH}
> +)
> +
> +link_libraries (
> +       piglitutil_${piglit_target_api}
> +       ${OPENGL_gl_LIBRARY}
> +       ${OPENGL_glu_LIBRARY}
> +)
> +
> +piglit_add_executable (arb_get_texture_sub_image-cubemap cubemap.c)
> +piglit_add_executable (arb_get_texture_sub_image-errors errors.c)
> +piglit_add_executable (arb_get_texture_sub_image-get get.c)
> +piglit_add_executable (arb_get_texture_sub_image-getcompressed getcompressed.c)
> +
> +# vim: ft=cmake:
> diff --git a/tests/spec/arb_get_texture_sub_image/CMakeLists.txt b/tests/spec/arb_get_texture_sub_image/CMakeLists.txt
> new file mode 100644
> index 0000000..144a306
> --- /dev/null
> +++ b/tests/spec/arb_get_texture_sub_image/CMakeLists.txt
> @@ -0,0 +1 @@
> +piglit_include_target_api()
> diff --git a/tests/spec/arb_get_texture_sub_image/cubemap.c b/tests/spec/arb_get_texture_sub_image/cubemap.c
> new file mode 100644
> index 0000000..b11e74c
> --- /dev/null
> +++ b/tests/spec/arb_get_texture_sub_image/cubemap.c
> @@ -0,0 +1,203 @@
> +/*
> + * Copyright 2015 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.
> + */
> +
> +/**
> + * Test glGetTextureSubImage with cube maps.
> + */
> +
> +#include "piglit-util-gl.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +       config.supports_gl_compat_version = 20;
> +       config.window_visual = PIGLIT_GL_VISUAL_RGBA;
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +
> +static void
> +memset_series(unsigned *buffer, unsigned baseValue, unsigned size)
> +{
> +       unsigned i;
> +       for (i = 0; i < size; i++)
> +               buffer[i] = baseValue + i;
> +}
> +
> +
> +static bool
> +compare_series(const unsigned *buffer, unsigned baseValue, unsigned size)
> +{
> +       unsigned i;
> +       for (i = 0; i < size; i++) {
> +               if (buffer[i] != baseValue + i) {
> +                       printf("Expected 0x%08x found 0x%08x\n",
> +                              baseValue + i, buffer[i]);
> +                       return false;
> +               }
> +
> +       }
> +       return true;
> +}
> +
> +
> +static bool
> +test_cube_map(void)
> +{
> +       GLuint tex;
> +       GLuint buffer[8*8];
> +       GLuint results[6*8*8];
> +       int level, face, imgStart;
> +
> +       /* setup 8x8 mipmapped cube texture */
> +       glGenTextures(1, &tex);
> +       glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
> +       glTexStorage2D(GL_TEXTURE_CUBE_MAP, 4, GL_RGBA8, 8, 8);
> +
> +       for (level = 0; level < 4; level++) {
> +               for (face = 0; face < 6; face++) {
> +                       memset_series(buffer, face*10000+level*100,
> +                                     sizeof(buffer)/4);
> +                       glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face,
> +                                       level, 0, 0, 8 >> level, 8 >> level,
> +                                       GL_RGBA, GL_UNSIGNED_INT_8_8_8_8,
> +                                       buffer);
> +               }
> +       }
> +
> +       /* test getting all six faces */
> +       for (level = 0; level < 4; level++) {
> +               /* get all six faces */
> +               memset(results, 0, sizeof(results));
> +               glGetTextureSubImage(tex, level,
> +                                    0, 0, 0,  /* offset */
> +                                    8 >> level, 8 >> level, 6, /* size */
> +                                    GL_RGBA, GL_UNSIGNED_INT_8_8_8_8,
> +                                    sizeof(results), results);
> +
> +               /* check results */
> +               imgStart = 0;
> +               for (face = 0; face < 6; face++) {
> +                       GLuint expected = face * 10000 + level * 100;
> +                       int numTexels = (8 >> level) * (8 >> level);
> +                       if (!compare_series(results + imgStart, expected,
> +                                           numTexels)) {
> +                               printf("Incorrect cubemap texel at "
> +                                      "level %u, face %u\n",
> +                                      level, face);
> +                               return false;
> +                       }
> +                       imgStart += numTexels;
> +               }
> +       }
> +
> +       /* Test getting face sub images (skip last 1x1 mipmap level)
> +        * using four glGetTextureSubImage calls, one per quadrant.
> +        * Note that each call retrieves the quadrant for all six faces
> +        * at once.
> +        */
> +       for (level = 0; level < 3; level++) {
> +               const int w = 4 >> level, h = 4 >> level;
> +               int x, y;
> +
> +               memset(results, 0, sizeof(results));
> +
> +               glPixelStorei(GL_PACK_ROW_LENGTH, w * 2);
> +               glPixelStorei(GL_PACK_IMAGE_HEIGHT, h * 2);
> +
> +               /* lower-left */
> +               x = y = 0;
> +               glPixelStorei(GL_PACK_SKIP_PIXELS, x);
> +               glPixelStorei(GL_PACK_SKIP_ROWS, y);
> +               glGetTextureSubImage(tex, level,
> +                                    x, y, 0,
> +                                    w, h, 6,
> +                                    GL_RGBA, GL_UNSIGNED_INT_8_8_8_8,
> +                                    sizeof(results), results);
> +
> +               /* lower-right */
> +               x = w;
> +               y = 0;
> +               glPixelStorei(GL_PACK_SKIP_PIXELS, x);
> +               glPixelStorei(GL_PACK_SKIP_ROWS, y);
> +               glGetTextureSubImage(tex, level,
> +                                    x, y, 0,
> +                                    w, h, 6,
> +                                    GL_RGBA, GL_UNSIGNED_INT_8_8_8_8,
> +                                    sizeof(results), results);
> +
> +               /* upper-left */
> +               x = 0;
> +               y = h;
> +               glPixelStorei(GL_PACK_SKIP_PIXELS, x);
> +               glPixelStorei(GL_PACK_SKIP_ROWS, y);
> +               glGetTextureSubImage(tex, level,
> +                                    x, y, 0,
> +                                    w, h, 6,
> +                                    GL_RGBA, GL_UNSIGNED_INT_8_8_8_8,
> +                                    sizeof(results), results);
> +
> +               /* upper-right */
> +               x = w;
> +               y = h;
> +               glPixelStorei(GL_PACK_SKIP_PIXELS, x);
> +               glPixelStorei(GL_PACK_SKIP_ROWS, y);
> +               glGetTextureSubImage(tex, level,
> +                                    x, y, 0,
> +                                    w, h, 6,
> +                                    GL_RGBA, GL_UNSIGNED_INT_8_8_8_8,
> +                                    sizeof(results), results);
> +
> +               /* check results */
> +               imgStart = 0;
> +               for (face = 0; face < 6; face++) {
> +                       GLuint expected = face * 10000 + level * 100;
> +                       int numTexels = (8 >> level) * (8 >> level);
> +                       if (!compare_series(results + imgStart, expected,
> +                                           numTexels)) {
> +                               printf("Incorrect cubemap texel at "
> +                                      "level %u, face %u\n",
> +                                      level, face);
> +                               return false;
> +                       }
> +                       imgStart += numTexels;
> +               }
> +       }
> +
> +       return true;
> +}
> +
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +       bool pass;
> +
> +       pass = test_cube_map();
> +
> +       return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> +
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +       piglit_require_extension("GL_ARB_get_texture_sub_image");

Is it worthwhile to add extra tests for GL_ARB_texture_cube_map_array
or is that unlikely to matter?

Also, unless I'm mistaken, this test doesn't draw anything. I've seen
such tests do everything from piglit_init finished by
piglit_report_result. Otherwise they end up displaying a transparent
window when run without -auto, which is confusing. Same comment
applies to your other tests.

  -ilia


More information about the Piglit mailing list