For a long time, the Mesa i965 driver has contained a hack to override
color spaces to sRGB when doing multisample resolves, with the following
justification:

* It has been observed that mulitisample resolves produce slightly better
* looking images when averaging is done using destination format. NVIDIA's
* proprietary OpenGL driver also follow this approach.  So, we choose to
* follow it in our driver.
*
* When multisampling, if the source and destination formats are equal
* (aside from the color space), we choose to blit in sRGB space to get
* this higher quality image.

I've never understood the purpose of this hack.  It sort of makes sense
in a "never decode, never encode" world.  But with the new GL 4.4 rules,
where encoding and decoding is optional, I'm not sure that it has any
place - the colorspaces should be application directed.

That said, this Piglit test appears to expect that resolves will be
done in the sRGB color space for TEST_TYPE_SRGB, so let's make it
explicitly request OpenGL to make that happen.

This makes a number of subtests pass on NVIDIA 367.35 on a GTX 980:
- accuracy {2,4,8,32} srgb depthstencil
- accuracy {2,4,8,32} srgb depthstencil linear
- accuracy {2,4,8,32} srgb small depthstencil
- accuracy {2,4,8,32} srgb small depthstencil linear
(The 16x and all_samples variants still fail on NVIDIA.)

No change on i965, as it currently ignores GL_FRAMEBUFFER_SRGB but
has the hack to do resolves in sRGB regardless.  It will soon drop
the hack, but start respecting GL_FRAMEBUFFER_SRGB.

Signed-off-by: Kenneth Graunke <kenn...@whitecape.org>
---
 tests/spec/ext_framebuffer_multisample/common.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/spec/ext_framebuffer_multisample/common.cpp 
b/tests/spec/ext_framebuffer_multisample/common.cpp
index 735bcc5..b6df91c 100644
--- a/tests/spec/ext_framebuffer_multisample/common.cpp
+++ b/tests/spec/ext_framebuffer_multisample/common.cpp
@@ -326,10 +326,14 @@ Test::resolve(Fbo *fbo, GLbitfield which_buffers)
        glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo->handle);
        glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolve_fbo.handle);
        resolve_fbo.set_viewport();
+
+       if (srgb)
+               glEnable(GL_FRAMEBUFFER_SRGB);
        glBlitFramebuffer(0, 0, fbo->config.width, fbo->config.height,
                          0, 0, resolve_fbo.config.width,
                          resolve_fbo.config.height,
                          which_buffers, filter_mode);
+       glDisable(GL_FRAMEBUFFER_SRGB);
 }
 
 /**
-- 
2.9.2

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to