summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2014-02-10 11:20:11 -0800
committerEric Anholt <[email protected]>2014-02-21 10:43:38 -0800
commitf7f15d3c2d570c524be0dc7b2744f9af546605d7 (patch)
tree720acdde58b6cece953e12eba441b4fcb6caa617
parent7d2f73e73759d6508833d76181295cdd3e0588fe (diff)
meta: Try to do blending of sRGB values in linear colorspace.
Blending of values would occur when doing GL_LINEAR filtering with scaling, and in an upcoming commit when doing MSAA resolves. Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r--src/mesa/drivers/common/meta_blit.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c
index be91247c57c..65e26920340 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -375,13 +375,33 @@ blitframebuffer_texture(struct gl_context *ctx,
_mesa_SamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
_mesa_SamplerParameteri(sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- /* Always do our blits with no sRGB decode or encode. Note that
- * GL_FRAMEBUFFER_SRGB has already been disabled by
- * _mesa_meta_begin().
+ /* Always do our blits with no net sRGB decode or encode.
+ *
+ * However, if both the src and dst can be srgb decode/encoded, enable them
+ * so that we do any blending (from scaling or from MSAA resolves) in the
+ * right colorspace.
+ *
+ * Our choice of not doing any net encode/decode is from the GL 3.0
+ * specification:
+ *
+ * "Blit operations bypass the fragment pipeline. The only fragment
+ * operations which affect a blit are the pixel ownership test and the
+ * scissor test."
+ *
+ * The GL 4.4 specification disagrees and says that the sRGB part of the
+ * fragment pipeline applies, but this was found to break applications.
*/
if (ctx->Extensions.EXT_texture_sRGB_decode) {
- _mesa_SamplerParameteri(sampler, GL_TEXTURE_SRGB_DECODE_EXT,
- GL_SKIP_DECODE_EXT);
+ if (_mesa_get_format_color_encoding(rb->Format) == GL_SRGB &&
+ ctx->DrawBuffer->Visual.sRGBCapable) {
+ _mesa_SamplerParameteri(sampler, GL_TEXTURE_SRGB_DECODE_EXT,
+ GL_DECODE_EXT);
+ _mesa_set_framebuffer_srgb(ctx, GL_TRUE);
+ } else {
+ _mesa_SamplerParameteri(sampler, GL_TEXTURE_SRGB_DECODE_EXT,
+ GL_SKIP_DECODE_EXT);
+ /* set_framebuffer_srgb was set by _mesa_meta_begin(). */
+ }
}
if (!glsl_version) {