[Piglit] [PATCH 07/16] msaa/formats: Use a scale and offset for testing integer formats.
Anuj Phogat
anuj.phogat at gmail.com
Fri Jun 22 14:04:57 PDT 2012
On Fri, Jun 15, 2012 at 8:32 AM, Paul Berry <stereotype441 at gmail.com> wrote:
> This patch adapts the MSAA "formats" test so that when drawing into
> integer framebuffers, it applies the necessary scale and offset to
> cover the entire range of possible integer values. When reading
> pixels back from the framebuffer, the test applies the inverse scale
> and offset, so that the result can be compared to the reference RGBA
> image.
> ---
> tests/spec/ext_framebuffer_multisample/formats.cpp | 22 +++++++++++++++++++-
> 1 files changed, 21 insertions(+), 1 deletions(-)
>
> diff --git a/tests/spec/ext_framebuffer_multisample/formats.cpp b/tests/spec/ext_framebuffer_multisample/formats.cpp
> index b54cda7..d2386ad 100644
> --- a/tests/spec/ext_framebuffer_multisample/formats.cpp
> +++ b/tests/spec/ext_framebuffer_multisample/formats.cpp
> @@ -88,6 +88,17 @@ public:
> */
> ColorGradientSunburst *test_pattern;
>
> + /**
> + * Color offset that will be used to draw the test pattern.
> + */
> + float color_offset;
> +
> + /**
> + * Color scale factor that will be used to draw the test
> + * pattern.
> + */
> + float color_scale;
> +
> Fbo fbo_msaa;
> Fbo fbo_downsampled;
> };
> @@ -132,13 +143,19 @@ PatternRenderer::try_setup(GLenum internalformat)
> switch (component_type) {
> case GL_INT:
> test_pattern = test_pattern_ivec4;
> + color_offset = 1.0 - pow(2.0, color_bits[0] - 1);
> + color_scale = -2.0 * color_offset;
> break;
> case GL_UNSIGNED_INT:
> test_pattern = test_pattern_uvec4;
> + color_scale = pow(2.0, color_bits[0]) - 1.0;
> + color_offset = 0.0;
> break;
> case GL_UNSIGNED_NORMALIZED:
> case GL_FLOAT:
> test_pattern = test_pattern_vec4;
> + color_offset = 0.0;
> + color_scale = 1.0;
> break;
> default:
> printf("Unrecognized component type: %s\n",
> @@ -191,7 +208,8 @@ PatternRenderer::draw()
> /* Draw into the MSAA fbo */
> glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo_msaa.handle);
> fbo_msaa.set_viewport();
> - test_pattern->draw(TestPattern::no_projection);
> + test_pattern->draw_with_scale_and_offset(TestPattern::no_projection,
> + color_scale, color_offset);
>
> /* Blit to the downsampled fbo, forcing the image to be downsampled */
> glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo_msaa.handle);
> @@ -267,6 +285,8 @@ PatternRenderer::read_image(GLenum base_format)
> glReadPixels(0, 0, pattern_width, pattern_height, base_format,
> GL_FLOAT, image);
> }
> + for (unsigned i = 0; i < array_size; ++i)
> + image[i] = (image[i] - color_offset) / color_scale;
> return image;
> }
>
> --
> 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