[Mesa-dev] [PATCH 3/6] meta: Try to do blending of sRGB values in linear colorspace.

Eric Anholt eric at anholt.net
Wed Feb 19 17:30:20 PST 2014


Blending of values would occur when doing GL_LINEAR filtering with
scaling, and in an upcoming commit when doing MSAA resolves.
---
 src/mesa/drivers/common/meta_blit.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c
index be91247..65e2692 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) {
-- 
1.9.rc1



More information about the mesa-dev mailing list