[Piglit] [PATCH 11/15] arb_direct_state_access: Add test for glDrawBuffer/glReadBuffer.

Anuj Phogat anuj.phogat at gmail.com
Mon Apr 6 16:46:40 PDT 2015


On Thu, Mar 5, 2015 at 6:01 PM, Laura Ekstrand <laura at jlekstrand.net> wrote:
> This lays the groundwork for testing NamedFramebufferDrawBuffer,
> NamedFramebufferDrawBuffers, and NamedFramebufferReadBuffer.
> ---
>  tests/all.py                                       |   1 +
>  .../spec/arb_direct_state_access/CMakeLists.gl.txt |   1 +
>  tests/spec/arb_direct_state_access/drawbuffers.c   | 110 +++++++++++++++++++++
>  3 files changed, 112 insertions(+)
>  create mode 100644 tests/spec/arb_direct_state_access/drawbuffers.c
>
> diff --git a/tests/all.py b/tests/all.py
> index ffa5b2e..0ed7cfb 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -4034,6 +4034,7 @@ spec['ARB_direct_state_access']['checkfbstatus-errors'] = PiglitGLTest(['arb_dir
>  spec['ARB_direct_state_access']['fbattachmentparam-errors'] = PiglitGLTest(['arb_direct_state_access-fbattachmentparam-errors'], run_concurrent=True)
>  spec['ARB_direct_state_access']['invalidateframebuffer'] = PiglitGLTest(['arb_direct_state_access-invalidateframebuffer'], run_concurrent=True)
>  spec['ARB_direct_state_access']['clearnamedframebuffer'] = PiglitGLTest(['arb_direct_state_access-clearnamedframebuffer'], run_concurrent=True)
> +spec['ARB_direct_state_access']['drawbuffers'] = PiglitGLTest(['arb_direct_state_access-drawbuffers'], run_concurrent=True)
>
>  arb_shader_image_load_store = spec['ARB_shader_image_load_store']
>  arb_shader_image_load_store['atomicity'] = PiglitGLTest(['arb_shader_image_load_store-atomicity'], run_concurrent=True)
> diff --git a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
> index f83dc01..c283321 100644
> --- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
> +++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
> @@ -31,6 +31,7 @@ piglit_add_executable (arb_direct_state_access-checkfbstatus-errors checkfbstatu
>  piglit_add_executable (arb_direct_state_access-fbattachmentparam-errors fbattachmentparam-errors.c)
>  piglit_add_executable (arb_direct_state_access-invalidateframebuffer invalidateframebuffer.c)
>  piglit_add_executable (arb_direct_state_access-clearnamedframebuffer clearnamedframebuffer.c)
> +piglit_add_executable (arb_direct_state_access-drawbuffers drawbuffers.c)
>  piglit_add_executable (arb_direct_state_access-dsa-textures dsa-textures.c dsa-utils.c)
>  piglit_add_executable (arb_direct_state_access-texturesubimage texturesubimage.c)
>  piglit_add_executable (arb_direct_state_access-bind-texture-unit bind-texture-unit.c)
> diff --git a/tests/spec/arb_direct_state_access/drawbuffers.c b/tests/spec/arb_direct_state_access/drawbuffers.c
> new file mode 100644
> index 0000000..6e7ecf5
> --- /dev/null
> +++ b/tests/spec/arb_direct_state_access/drawbuffers.c
> @@ -0,0 +1,110 @@
> +/*
> + * Copyright © 2015 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.
> + */
> +
> +/** @file drawbuffers.c
> + *
> + * Tests explicitly setting the read and draw framebuffers.
> + *
> + * Somewhat inspired by tests/general/read-front.c.
> + */
> +
> +#include "piglit-util-gl.h"
> +#include "dsa-utils.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +       config.supports_gl_compat_version = 32;
> +
> +       config.window_visual = PIGLIT_GL_VISUAL_RGBA |
> +                              PIGLIT_GL_VISUAL_DOUBLE;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +static bool pass = true;
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +       piglit_require_extension("GL_ARB_direct_state_access");
> +}
> +
> +static GLuint fbo;
> +
> +static void
> +clear_to_color(float color[4], int att)
> +{
> +       glClearColor(color[0], color[1], color[2], color[3]);
> +       glDrawBuffer(GL_COLOR_ATTACHMENT0 + att);
> +       glClear(GL_COLOR_BUFFER_BIT);
> +}
> +
> +static void
> +clear_subtest(float color[4], int att, const char *test_name)
> +{
> +       glReadBuffer(GL_COLOR_ATTACHMENT0 + att);
> +       piglit_check_gl_error(GL_NO_ERROR);
> +       SUBTESTCONDITION(piglit_probe_rect_rgb(0, 0, piglit_width,
> +                        piglit_height, color), pass, test_name);
> +}
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +       float red[]     = {1.0, 0.0, 0.0, 0.0};
> +       float green[]   = {0.0, 1.0, 0.0, 0.0};
> +       float blue[]    = {0.0, 0.0, 1.0, 0.0};
> +       GLuint textures[3];
> +       int i;
> +
> +       /* Make a custom framebuffer with three color attachments */
> +       glCreateFramebuffers(1, &fbo);
> +       glCreateTextures(GL_TEXTURE_2D, 3, textures);
> +       for (i = 0; i < 3; ++i) {
> +               glTextureStorage2D(textures[i], 1, GL_RGBA8,
> +                                  piglit_width, piglit_height);
> +               glNamedFramebufferTexture(fbo, GL_COLOR_ATTACHMENT0 + i,
> +                                         textures[i], 0);
> +       }
> +
> +       glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
> +       glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
> +       piglit_check_gl_error(GL_NO_ERROR);
> +
> +       /* The clearing steps and the testing steps are separate and in a
> +        * different order to make sure that GL_COLOR_ATTACHMENT0 + att is
> +        * selecting the correct attachment.
> +        */
> +       clear_to_color(green, 1);
> +       clear_to_color(blue, 2);
> +       clear_to_color(red, 0);
> +
> +       clear_subtest(blue, 2, "Clear 2 to blue");
> +       clear_subtest(red, 0, "Clear 0 to red");
> +       clear_subtest(green, 1, "Clear 1 to green");
> +
> +
Extra newline here.
> +       glDeleteTextures(3, textures);
> +       glDeleteFramebuffers(1, &fbo);
> +
> +       return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> --
> 2.1.0
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list