[Piglit] [PATCH 14/15] arb_direct_state_access: Add non-DSA test for DrawBuffers.

Anuj Phogat anuj.phogat at gmail.com
Mon Apr 6 16:47:29 PDT 2015


On Thu, Mar 5, 2015 at 6:01 PM, Laura Ekstrand <laura at jlekstrand.net> wrote:
> ---
>  tests/all.py                                       |   1 +
>  .../spec/arb_direct_state_access/CMakeLists.gl.txt |   1 +
>  .../arb_direct_state_access/drawbuffers-multi.c    | 160 +++++++++++++++++++++
>  3 files changed, 162 insertions(+)
>  create mode 100644 tests/spec/arb_direct_state_access/drawbuffers-multi.c
>
> diff --git a/tests/all.py b/tests/all.py
> index 0ed7cfb..9b7f989 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -4035,6 +4035,7 @@ spec['ARB_direct_state_access']['fbattachmentparam-errors'] = PiglitGLTest(['arb
>  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)
> +spec['ARB_direct_state_access']['drawbuffers-multi'] = PiglitGLTest(['arb_direct_state_access-drawbuffers-multi'], 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 c283321..0bc7364 100644
> --- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
> +++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
> @@ -32,6 +32,7 @@ piglit_add_executable (arb_direct_state_access-fbattachmentparam-errors fbattach
>  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-drawbuffers-multi drawbuffers-multi.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-multi.c b/tests/spec/arb_direct_state_access/drawbuffers-multi.c
> new file mode 100644
> index 0000000..06740b6
> --- /dev/null
> +++ b/tests/spec/arb_direct_state_access/drawbuffers-multi.c
> @@ -0,0 +1,160 @@
> +/*
> + * 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-multi.c
> + *
> + * Tests explicitly setting the read and draw framebuffers. Tests drawing
> + * multiple fragments at the same time.
> + *
> + * Somewhat inspired by tests/general/read-front.c.
> + * Adapted from tests/spec/arb_direct_state_access/drawbuffers.c.
> + */
> +
> +#include "piglit-util-gl.h"
> +#include "piglit-shader.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
> +
> +/*
> + * You must use shaders in order to render to multiple buffers at once.
> + * These duplicate fixed-function gl 1.0 pipeline shading.
> + * Adapted from arb_clear_texture/3d.c.
> + */
> +static const char vs_source[] =
> +       "#version 140\n"
> +       "in vec4 piglit_vertex;\n"
> +       "uniform mat4 proj;\n"
> +       "\n"
> +       "void main()\n"
> +       "{\n"
> +       "        gl_Position = proj * piglit_vertex;\n"
> +       "}\n";
> +
> +static const char fs_source[] =
> +       "#version 140\n"
> +       "uniform vec4 red;\n"
> +       "uniform vec4 green;\n"
> +       "uniform vec4 blue;\n"
> +       "\n"
> +       "void main()\n"
> +       "{\n"
> +       "        gl_FragData[0] = red;\n"
> +       "        gl_FragData[1] = green;\n"
> +       "        gl_FragData[2] = blue;\n"
> +       "}\n";
> +
> +static bool pass = true;
> +static GLuint program;
> +static GLuint fbo;
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +       piglit_require_extension("GL_ARB_direct_state_access");
> +       program = piglit_build_simple_program(vs_source, fs_source);
> +}
> +
> +static void
> +clear_subtest(float color[4], int att, const char *test_name)
> +{
> +       glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
> +       glNamedFramebufferReadBuffer(fbo, GL_COLOR_ATTACHMENT0 + att);
> +       glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
> +
> +       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, 1};
> +       float green[]   = {0, 1, 0, 1};
> +       float blue[]    = {0, 0, 1, 1};
> +       GLuint textures[3];
> +       int i;
> +       GLint red_uniform, green_uniform, blue_uniform, proj_uniform;
> +       GLenum bufs[] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1,
> +                        GL_COLOR_ATTACHMENT2};
> +
> +       /* Set up the shader program. */
> +       glUseProgram(program);
> +       red_uniform = glGetUniformLocation(program, "red");
> +       glUniform4fv(red_uniform, 1, red);
> +       green_uniform = glGetUniformLocation(program, "green");
> +       glUniform4fv(green_uniform, 1, green);
> +       blue_uniform = glGetUniformLocation(program, "blue");
> +       glUniform4fv(blue_uniform, 1, blue);
> +       proj_uniform = glGetUniformLocation(program, "proj");
> +       piglit_ortho_uniform(proj_uniform, piglit_width, piglit_height);
> +
> +       /* 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);
> +
> +       /* Set the draw buffers */
> +       glDrawBuffers(3, bufs);
> +
> +       /* Draw the pretty colors. */
> +       piglit_draw_rect(0, 0, piglit_width, piglit_height);
> +
> +       /* Make sure the correct colors were drawn */
> +       clear_subtest(blue, 2, "Clear 2 to blue");
> +       clear_subtest(red, 0, "Clear 0 to red");
> +       clear_subtest(green, 1, "Clear 1 to green");
> +
> +       /* Show the results of the last subtest on the screen */
> +       if (!piglit_automatic) {
> +               glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
> +               glBlitFramebuffer(0, 0, piglit_width, piglit_height,
> +                                 0, 0, piglit_width, piglit_height,
> +                                 GL_COLOR_BUFFER_BIT, GL_NEAREST);
> +               piglit_present_results();
> +       }
> +
> +
Extra newline here.
> +       glDeleteTextures(3, textures);
> +       glDeleteFramebuffers(1, &fbo);
> +       glDeleteProgram(program);
> +
> +       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