Mesa (master): i965: Respect GL_TEXTURE_SRGB_DECODE_EXT in GenerateMipmaps()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Oct 30 20:00:20 UTC 2018


Module: Mesa
Branch: master
Commit: 337a808062c756b474ee80a9ac04b5a3dbbeb67e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=337a808062c756b474ee80a9ac04b5a3dbbeb67e

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Mon Oct 29 15:29:10 2018 -0700

i965: Respect GL_TEXTURE_SRGB_DECODE_EXT in GenerateMipmaps()

Apparently, we're supposed to look at the texture object's built-in
sampler object's sRGB decode setting in order to decide whether to
decode/downsample/re-encode, or simply downsample as-is.  Previously,
I had always done the decoding/encoding.

Fixes SKQP's Skia_Unit_Tests.SRGBMipMaps test.

Reviewed-by: Tapani Pälli <tapani.palli at intel.com>

---

 src/mesa/drivers/dri/i965/brw_generate_mipmap.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_generate_mipmap.c b/src/mesa/drivers/dri/i965/brw_generate_mipmap.c
index 32c2933f72..4125ae6e11 100644
--- a/src/mesa/drivers/dri/i965/brw_generate_mipmap.c
+++ b/src/mesa/drivers/dri/i965/brw_generate_mipmap.c
@@ -105,6 +105,23 @@ brw_generate_mipmap(struct gl_context *ctx, GLenum target,
       last_layer = base_size->array_len - 1;
    }
 
+   /* The GL_EXT_texture_sRGB_decode extension's issues section says:
+    *
+    *    "10) How is mipmap generation of sRGB textures affected by the
+    *     TEXTURE_SRGB_DECODE_EXT parameter?
+    *
+    *     RESOLVED:  When the TEXTURE_SRGB_DECODE parameter is DECODE_EXT
+    *     for an sRGB texture, mipmap generation should decode sRGB texels
+    *     to a linear RGB color space, perform downsampling, then encode
+    *     back to an sRGB color space.  (Issue 24 in the EXT_texture_sRGB
+    *     specification provides a rationale for why.)  When the parameter
+    *     is SKIP_DECODE_EXT instead, mipmap generation skips the encode
+    *     and decode steps during mipmap generation.  By skipping the
+    *     encode and decode steps, sRGB mipmap generation should match
+    *     the mipmap generation for a non-sRGB texture."
+    */
+   bool do_srgb = tex_obj->Sampler.sRGBDecode == GL_DECODE_EXT;
+
    for (unsigned dst_level = base_level + 1;
         dst_level <= last_level;
         dst_level++) {
@@ -121,7 +138,7 @@ brw_generate_mipmap(struct gl_context *ctx, GLenum target,
                                  minify(base_size->width, dst_level),
                                  minify(base_size->height, dst_level),
                                  GL_LINEAR, false, false,
-                                 true, true);
+                                 do_srgb, do_srgb);
       }
    }
 }




More information about the mesa-commit mailing list