[Piglit] [PATCH 2/3] GL 3.2: Test that Clear() clears no buffers when passed a value of 0

Paul Berry stereotype441 at gmail.com
Thu Aug 8 14:58:23 PDT 2013


On 6 August 2013 10:29, Nicholas Mack <nichmack at gmail.com> wrote:

> ---
>  tests/spec/gl-3.2/CMakeLists.gl.txt  |  2 +-
>  tests/spec/gl-3.2/clear-no-buffers.c | 90
> ++++++++++++++++++++++++++++++++++++
>

This test also needs to be added to all.tests.


>  2 files changed, 91 insertions(+), 1 deletion(-)
>  create mode 100644 tests/spec/gl-3.2/clear-no-buffers.c
>
> diff --git a/tests/spec/gl-3.2/CMakeLists.gl.txt
> b/tests/spec/gl-3.2/CMakeLists.gl.txt
> index 49e9279..1e2225a 100644
> --- a/tests/spec/gl-3.2/CMakeLists.gl.txt
> +++ b/tests/spec/gl-3.2/CMakeLists.gl.txt
> @@ -10,6 +10,6 @@ link_libraries (
>  )
>
>  piglit_add_executable (gl-3.2-minmax minmax.c)
> -piglit_add_executable (gl-3.2-draw-buffers-errors draw-buffers-errors.c)
> +piglit_add_executable (gl-3.2-clear-none clear-no-buffers.c)
>

Don't remove the piglit_add_executable(...) declaration from the previous
test.  Just add the new declaration for this test.

Also, please name the test executable consistently with the .c file, e.g.

piglit_add_executable (gl-3.2-clear-no-buffers clear-no-buffers.c)


>
>  # vim: ft=cmake:
> diff --git a/tests/spec/gl-3.2/clear-no-buffers.c
> b/tests/spec/gl-3.2/clear-no-buffers.c
> new file mode 100644
> index 0000000..52566fc
> --- /dev/null
> +++ b/tests/spec/gl-3.2/clear-no-buffers.c
> @@ -0,0 +1,90 @@
> +/**
> + * 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.
> + */
> +
> +/**
> + * Test that Clear() clears no buffers when passed 0
> + *
> + * Section 4.2.3(Clearing the Buffers) of OpenGL 3.2 Core says:
> + * "The value to which each buffer is cleared depends on the setting of
> the
> + *  clear value for that buffer. If buf is zero, no buffers are cleared."
> + *
> + */
> +
> +#include "piglit-util-gl-common.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +       config.supports_gl_compat_version = 10;
> +        //config.supports_gl_core_version = 32;
>

As with the previous patch, this should be:

    config.supports_gl_compat_version = 32;
    config.supports_gl_core_version = 32;



> +
> +        config.window_width = 64;
> +        config.window_height = 64;
>

We try not to set the window width and height unless the test specifically
requires a certain window size.  This test should work at any window size,
so I would recommend dropping the above two lines.



> +        config.window_visual = PIGLIT_GL_VISUAL_RGB |
> +                               PIGLIT_GL_VISUAL_DOUBLE |
> +                               PIGLIT_GL_VISUAL_DEPTH |
> +                               PIGLIT_GL_VISUAL_STENCIL;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +//static GLuint fbo;
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +       //glGenFramebuffers(1, &fbo);
>

This extraneous comment (and the two in piglit_display) should be removed.


> +}
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +       bool pass = true;
> +       float green[] = {0, 1, 0};
> +
> +       glEnable(GL_DEPTH_TEST);
> +       //glDepthFunc(GL_LEQUAL);
> +
> +       /* Set first base values to the buffers */
> +       glClearColor(0.0, 1.0, 0.0, 1.0);
> +       glClearDepth(.8);
> +       glClearStencil(1);
> +       //glClearBufferfi(GL_DEPTH_STENCIL, 0, .8, 1);
> +       glClear(GL_COLOR_BUFFER_BIT |
> +               GL_DEPTH_BUFFER_BIT |
> +               GL_STENCIL_BUFFER_BIT);
> +
> +       /* Set a second value to the buffers */
> +       glClearColor(1.0, 0.0, 0.0, 1.0);
> +       glClearDepth(.2);
> +       glClearStencil(2);
> +
> +       glClear(0);
>

If the call to glClear() causes a GL error and does nothing, the test will
pass.  To make sure that error condition gets caught, I'd recommend adding:

    if (!piglit_check_gl_error(GL_NO_ERROR))
        pass = false;



> +
> +       /* if probe returns the first value, glClear(0) didn't clear
> values */
> +       pass = piglit_probe_pixel_rgb(32, 32, green) && pass;
> +       pass = piglit_probe_pixel_depth(32, 32, .8) && pass;
> +       pass = piglit_probe_pixel_stencil(32, 32, 1) && pass;
>

Usually for tests like this, we go ahead and probe the entire output
window, rather than just a single pixel, like so:

pass = piglit_probe_rect_rgb(0, 0, piglit_width, piglit_height, green) &&
pass;
pass = piglit_probe_rect_depth(0, 0, piglit_width, piglit_height, .8) &&
pass;
pass = piglit_probe_rect_stencil(0, 0, piglit_width, piglit_height, 1) &&
pass;

With those comments all addressed, this patch is:

Reviewed-by: Paul Berry <stereotype441 at gmail.com>


> +
> +       piglit_present_results();
> +
> +       return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> --
> 1.8.3.1
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20130808/dca7e976/attachment.html>


More information about the Piglit mailing list