[Piglit] [PATCH 15/16] msaa/formats: Fix testing of sRGB formats.
Paul Berry
stereotype441 at gmail.com
Fri Jun 15 08:32:35 PDT 2012
sRGB buffers use a different blending operation to do multisample
resolves from non-sRGB buffers. Accordingly, when testing sRGB
formats, we need to use an sRGB reference image. This patch modifies
the MSAA "formats" test so that when testing an sRGB format, it
renders the reference image using SRGB8_ALPHA8 format rather than RGBA
format.
This required rearranging the initialization order used in the test,
so that the framebuffer under test is initialized first, so that we
can query it to see whether it is sRGB before initializing the
reference framebuffer.
---
tests/spec/ext_framebuffer_multisample/formats.cpp | 44 +++++++++++++------
1 files changed, 30 insertions(+), 14 deletions(-)
diff --git a/tests/spec/ext_framebuffer_multisample/formats.cpp b/tests/spec/ext_framebuffer_multisample/formats.cpp
index d1e03e5..77a5dc1 100644
--- a/tests/spec/ext_framebuffer_multisample/formats.cpp
+++ b/tests/spec/ext_framebuffer_multisample/formats.cpp
@@ -37,6 +37,10 @@
*
* Finally, the images that were compared are drawn on screen to make
* it easier to diagnose failures.
+ *
+ * When testing sRGB formats, the reference image is rendered using
+ * SRGB8_ALPHA8 format rather than RGBA format (SRGB8_ALPHA8 format is
+ * also well tested by the other MSAA tests).
*/
#include "common.h"
@@ -83,6 +87,11 @@ public:
GLenum component_type;
/**
+ * True if the color buffer uses an sRGB format.
+ */
+ bool is_srgb;
+
+ /**
* ColorGradientSunburst object that will be used to draw the
* test pattern.
*/
@@ -163,6 +172,12 @@ PatternRenderer::try_setup(GLenum internalformat)
piglit_report_result(PIGLIT_FAIL);
}
+ GLint color_encoding;
+ glGetFramebufferAttachmentParameteriv(
+ GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, &color_encoding);
+ is_srgb = color_encoding == GL_SRGB;
+
return true;
}
@@ -456,19 +471,6 @@ test_format(const struct format_desc *format)
printf("Testing %s\n", format->name);
- /* Set up the framebuffers for rendering the reference image.
- * This shouldn't fail.
- */
- bool setup_success = ref_renderer.try_setup(GL_RGBA);
- if (!piglit_check_gl_error(GL_NO_ERROR)) {
- printf("Error setting up reference renderbuffers\n");
- return PIGLIT_FAIL;
- }
- if (!setup_success) {
- printf("Reference framebuffer combination is unsupported\n");
- return PIGLIT_FAIL;
- }
-
/* Set up the framebuffers for rendering the test image. This
* might fail if the format we're testing isn't supported as a
* render target, and that's ok.
@@ -485,7 +487,7 @@ test_format(const struct format_desc *format)
* supported, we might have received a GL error. In either
* case just skip to the next format.
*/
- setup_success = test_renderer.try_setup(format->internalformat);
+ bool setup_success = test_renderer.try_setup(format->internalformat);
if (glGetError() != GL_NO_ERROR) {
printf("Error setting up test renderbuffers\n");
return PIGLIT_SKIP;
@@ -495,6 +497,20 @@ test_format(const struct format_desc *format)
return PIGLIT_SKIP;
}
+ /* Set up the framebuffers for rendering the reference image.
+ * This shouldn't fail.
+ */
+ setup_success = ref_renderer.try_setup(test_renderer.is_srgb ?
+ GL_SRGB8_ALPHA8 : GL_RGBA);
+ if (!piglit_check_gl_error(GL_NO_ERROR)) {
+ printf("Error setting up reference renderbuffers\n");
+ return PIGLIT_FAIL;
+ }
+ if (!setup_success) {
+ printf("Reference framebuffer combination is unsupported\n");
+ return PIGLIT_FAIL;
+ }
+
/* Draw test and reference images, and read them into memory */
test_renderer.set_piglit_tolerance();
test_renderer.draw();
--
1.7.7.6
More information about the Piglit
mailing list