summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Berry <stereotype441@gmail.com>2012-06-15 07:44:31 -0700
committerPaul Berry <stereotype441@gmail.com>2012-06-25 11:13:07 -0700
commitf4a543e87cf215dfa5297df19973c08ce7fddff5 (patch)
tree5c611abbabf507d9729cad832b4126363ce455de
parent98d1e497014626237f0d9a5f3343ac3d8d4e7698 (diff)
msaa/formats: Fix testing of sRGB formats.
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. Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
-rw-r--r--tests/spec/ext_framebuffer_multisample/formats.cpp44
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 6049c89ef..55542aab0 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"
@@ -85,6 +89,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.
*/
@@ -165,6 +174,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;
}
@@ -458,19 +473,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.
@@ -487,7 +489,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;
@@ -497,6 +499,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();