[Piglit] [PATCH] ARB_robustness: add test for client memory accesses

Brian Paul brianp at vmware.com
Thu Apr 21 13:50:13 PDT 2011


One issue below.

On 04/21/2011 12:34 PM, nobled wrote:
> ---
>   tests/all.tests                               |    7 +
>   tests/spec/arb_robustness/CMakeLists.gl.txt   |    1 +
>   tests/spec/arb_robustness/client-mem-bounds.c |  307 +++++++++++++++++++++++++
>   3 files changed, 315 insertions(+), 0 deletions(-)
>   create mode 100644 tests/spec/arb_robustness/client-mem-bounds.c
>
> diff --git a/tests/all.tests b/tests/all.tests
> index 86675d6..1f7277a 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -705,6 +705,13 @@ arb_sampler_objects = Group()
>   spec['ARB_sampler_objects'] = arb_sampler_objects
>   add_plain_test(arb_sampler_objects, 'sampler-objects')
>
> +# Group ARB_robustness
> +arb_robustness = Group()
> +spec['ARB_robustness'] = arb_robustness
> +add_plain_test(arb_robustness, 'arb_robustness_client-mem-bounds')
> +# TODO: robust vertex buffer access
> +#add_plain_test(arb_robustness, 'arb_robustness_draw-vbo-bounds')
> +
>   # Group ARB_shader_texture_lod
>   arb_shader_texture_lod = Group()
>   spec['ARB_shader_texture_lod'] = arb_shader_texture_lod
> diff --git a/tests/spec/arb_robustness/CMakeLists.gl.txt
> b/tests/spec/arb_robustness/CMakeLists.gl.txt
> index c546134..da36c0a 100644
> --- a/tests/spec/arb_robustness/CMakeLists.gl.txt
> +++ b/tests/spec/arb_robustness/CMakeLists.gl.txt
> @@ -15,5 +15,6 @@ link_libraries (
>   )
>
>   add_executable (arb_robustness_draw-vbo-bounds draw-vbo-bounds.c)
> +add_executable (arb_robustness_client-mem-bounds client-mem-bounds.c)
>
>   # vim: ft=cmake:
> diff --git a/tests/spec/arb_robustness/client-mem-bounds.c
> b/tests/spec/arb_robustness/client-mem-bounds.c
> new file mode 100644
> index 0000000..fbc9f5b
> --- /dev/null
> +++ b/tests/spec/arb_robustness/client-mem-bounds.c
> @@ -0,0 +1,307 @@
> +/*
> + *
> + * 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.
> + *
> + */
> +
> +#include "piglit-util.h"
> +
> +int piglit_width = 320, piglit_height = 320;
> +int piglit_window_mode = GLUT_RGB;
> +
> +#define width (10)
> +#define height (12)
> +#define depth (3)
> +
> +void piglit_init(int argc, char **argv)
> +{
> +    piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
> +
> +   if (!piglit_is_extension_supported("GL_ARB_robustness"))
> +      piglit_report_result(PIGLIT_SKIP);
> +
> +    glClearColor(0.2, 0.2, 0.2, 1.0);
> +}
> +
> +static GLboolean
> +succeeded(int offby)
> +{
> +    GLboolean should_error = (offby<  0);
> +    GLenum err = glGetError();
> +
> +    if (should_error) {
> +        if (err == GL_INVALID_OPERATION)
> +            return GL_TRUE;
> +        fprintf(stderr, "Did not give GL_INVALID_OPERATION "
> +                "with too small a buffer! (off by: %d)\n", offby);
> +        return GL_FALSE;
> +    } else {
> +        if (err == GL_NO_ERROR)
> +            return GL_TRUE;
> +        fprintf(stderr, "Unexpected error! (off by: %d)\n", offby);
> +        return GL_FALSE;
> +    }
> +}
> +
> +static enum piglit_result
> +test_pixelmap(int offby)
> +{
> +#define MAPSIZE 32
> +
> +#define TEST_PIXMAP(type, t)\
> +do {\
> +    GL##type v[MAPSIZE];\
> +    GLsizei bufSize = offby + (int)(sizeof v);\
> +    unsigned i;\
> +\
> +    memset(v, 0, sizeof v);\
> +    for (i = 0; i<  MAPSIZE; i += 2)\
> +        v[i] = 1.0;\
> +\
> +    glClear(GL_COLOR_BUFFER_BIT);\
> +\
> +    glPixelTransferi(GL_MAP_COLOR, GL_FALSE);\
> +    glPixelMap##t##v(GL_PIXEL_MAP_R_TO_R, MAPSIZE, v);\
> +    if (!succeeded(0))\
> +        return PIGLIT_FAILURE;\
> +    glPixelMap##t##v(GL_PIXEL_MAP_G_TO_G, MAPSIZE, v);\
> +    if (!succeeded(0))\
> +        return PIGLIT_FAILURE;\
> +    glPixelMap##t##v(GL_PIXEL_MAP_B_TO_B, MAPSIZE, v);\
> +    if (!succeeded(0))\
> +        return PIGLIT_FAILURE;\
> +    glPixelMap##t##v(GL_PIXEL_MAP_A_TO_A, MAPSIZE, v);\
> +    if (!succeeded(0))\
> +        return PIGLIT_FAILURE;\
> +\
> +    glGetnPixelMap##t##vARB(GL_PIXEL_MAP_R_TO_R, bufSize, v);\
> +    if (!succeeded(offby))\
> +        return PIGLIT_FAILURE;\
> +    glGetnPixelMap##t##vARB(GL_PIXEL_MAP_G_TO_G, bufSize, v);\
> +    if (!succeeded(offby))\
> +        return PIGLIT_FAILURE;\
> +    glGetnPixelMap##t##vARB(GL_PIXEL_MAP_B_TO_B, bufSize, v);\
> +    if (!succeeded(offby))\
> +        return PIGLIT_FAILURE;\
> +    glGetnPixelMap##t##vARB(GL_PIXEL_MAP_A_TO_A, bufSize, v);\
> +    if (!succeeded(offby))\
> +        return PIGLIT_FAILURE;\
> +} while (0)
> +
> +    TEST_PIXMAP(float, f);
> +    TEST_PIXMAP(uint, ui);
> +    TEST_PIXMAP(ushort, us);
> +
> +#undef TEST_PIXMAP
> +#undef MAPSIZE
> +  return PIGLIT_SUCCESS;
> +}
> +
> +static enum piglit_result
> +test_readpix(int offby)
> +{
> +#define TEST_READPIX(gltype, enumtype) \
> +do {\
> +    GL##gltype v[4*width*height];\
> +    GLsizei bufSize = offby + (int)(sizeof v);\
> +\
> +    memset(v, 0, sizeof v);\
> +    glClear(GL_COLOR_BUFFER_BIT);\
> +\
> +    glReadnPixelsARB(0, 0, width, height, GL_RGBA, GL_##enumtype, bufSize, v);\
> +    if (!succeeded(offby))\
> +        return PIGLIT_FAILURE;\
> +    glReadnPixelsARB(1, 1, width, height, GL_RGBA, GL_##enumtype, bufSize, v);\
> +    if (!succeeded(offby))\
> +        return PIGLIT_FAILURE;\
> +} while (0)
> +
> +  TEST_READPIX(float, FLOAT);
> +  TEST_READPIX(int, INT);
> +  TEST_READPIX(byte, BYTE);
> +#undef TEST_READPIX
> +  return PIGLIT_SUCCESS;
> +}
> +
> +static enum piglit_result
> +test_stipple(int offby)
> +{
> +    GLubyte pattern[32*32];

I think this array is wrong.  The polygon stipple pattern is packed as 
a bitmap so each byte represents eight pixels in the pattern.  The 
correct size would be 4*32.

With this change, the test passes with Mesa and NVIDIA's driver.

-Brian


More information about the Piglit mailing list