[Piglit] [PATCH 03/16] msaa: Make it possible to scale and offset ColorGradientSunburst.

Anuj Phogat anuj.phogat at gmail.com
Thu Jun 21 18:21:21 PDT 2012


On Fri, Jun 15, 2012 at 8:32 AM, Paul Berry <stereotype441 at gmail.com> wrote:
> In order to test that MSAA works properly for integer framebuffers, we
> will need to be able to adjust the outputs of the
> ColorGradientSunburst program to cover the range of signed or unsigned
> integers, rather than the range [0, 1] that is appropriate for testing
> normalized color framebuffers.
>
> This patch makes that possible by adding "scale" and "offset"
> parameters to the ColorGradientSunburst program.
> ---
>  tests/spec/ext_framebuffer_multisample/common.cpp |   47 ++++++++++++++++++++-
>  tests/spec/ext_framebuffer_multisample/common.h   |    3 +
>  2 files changed, 48 insertions(+), 2 deletions(-)
>
> diff --git a/tests/spec/ext_framebuffer_multisample/common.cpp b/tests/spec/ext_framebuffer_multisample/common.cpp
> index ff1ca7f..e1060a8 100644
> --- a/tests/spec/ext_framebuffer_multisample/common.cpp
> +++ b/tests/spec/ext_framebuffer_multisample/common.cpp
> @@ -1009,15 +1009,50 @@ ColorGradientSunburst::ColorGradientSunburst(GLenum out_type)
>  }
>
>
> +/**
> + * Draw the color gradient sunburst, but instead of using color
> + * components that range from 0.0 to 1.0, apply the given scaling
> + * factor and offset to each color component.
> + *
> + * The offset is also applied when clearing the color buffer.
> + */
>  void
> -ColorGradientSunburst::draw(const float (*proj)[4])
> +ColorGradientSunburst::draw_with_scale_and_offset(const float (*proj)[4],
> +                                                 float scale, float offset)
>  {
> -       glClear(GL_COLOR_BUFFER_BIT);
> +       switch (out_type) {
> +       case GL_INT: {
> +               int clear_color[4] = { offset, offset, offset, offset };
> +               glClearBufferiv(GL_COLOR, 0, clear_color);
> +               break;
> +       }
> +       case GL_UNSIGNED_INT: {
> +               unsigned clear_color[4] = { offset, offset, offset, offset };
> +               glClearBufferuiv(GL_COLOR, 0, clear_color);
> +               break;
> +       }
> +       case GL_UNSIGNED_NORMALIZED:
> +       case GL_FLOAT: {
> +               float clear_color[4] = { offset, offset, offset, offset };
> +               glClearBufferfv(GL_COLOR, 0, clear_color);
> +               break;
> +       }
> +       default:
> +               printf("Unrecognized out_type: %s\n",
> +                      piglit_get_gl_enum_name(out_type));
> +               piglit_report_result(PIGLIT_FAIL);
> +               break;
> +       }
>
>        glUseProgram(prog);
>        glUniformMatrix4fv(proj_loc, 1, GL_TRUE, &proj[0][0]);
>        float draw_colors[3][4] =
>                { { 1, 0, 0, 1.0 }, { 0, 1, 0, 0.5 }, { 0, 0, 1, 1.0 } };
> +       for (int i = 0; i < 3; ++i) {
> +               for (int j = 0; j < 4; ++j) {
> +                       draw_colors[i][j] = scale * draw_colors[i][j] + offset;
> +               }
> +       }
>        glUniformMatrix3x4fv(draw_colors_loc, 1, GL_FALSE,
>                             &draw_colors[0][0]);
>        glBindVertexArray(vao);
> @@ -1027,6 +1062,14 @@ ColorGradientSunburst::draw(const float (*proj)[4])
>        }
>  }
>
> +
> +void
> +ColorGradientSunburst::draw(const float (*proj)[4])
> +{
> +       draw_with_scale_and_offset(proj, 1.0, 0.0);
> +}
> +
> +
>  void
>  StencilSunburst::draw(const float (*proj)[4])
>  {
> diff --git a/tests/spec/ext_framebuffer_multisample/common.h b/tests/spec/ext_framebuffer_multisample/common.h
> index b432f86..e7cc9b7 100644
> --- a/tests/spec/ext_framebuffer_multisample/common.h
> +++ b/tests/spec/ext_framebuffer_multisample/common.h
> @@ -355,6 +355,9 @@ public:
>        explicit ColorGradientSunburst(GLenum out_type);
>
>        virtual void draw(const float (*proj)[4]);
> +
> +       void draw_with_scale_and_offset(const float (*proj)[4],
> +                                       float scale, float offset);
>  };
>
>  /**
> --
> 1.7.7.6
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit

Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>


More information about the Piglit mailing list