[Mesa-dev] [PATCH] meta: Always do GenerateMipmaps in linear colorspace.

Jason Ekstrand jason at jlekstrand.net
Sat Aug 13 00:45:39 UTC 2016


This just occurred to me, but why are we generating mipmaps in meta?  We
could do it in blorp in a half-dozen lines...

On Fri, Aug 12, 2016 at 3:59 PM, Kenneth Graunke <kenneth at whitecape.org>
wrote:

> When generating mipmaps for sRGB textures, force both decode and encode,
> so the filtering is done in linear colorspace, regardless of settings.
>
> Fixes a WebGL conformance test in Chrome:
> https://www.khronos.org/registry/webgl/sdk/tests/
> conformance2/textures/misc/tex-srgb-mipmap.html?webglVersion=2
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/drivers/common/meta_generate_mipmap.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/drivers/common/meta_generate_mipmap.c
> b/src/mesa/drivers/common/meta_generate_mipmap.c
> index 9cebbf7..bbe9d6d 100644
> --- a/src/mesa/drivers/common/meta_generate_mipmap.c
> +++ b/src/mesa/drivers/common/meta_generate_mipmap.c
> @@ -221,9 +221,17 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx,
> GLenum target,
>                                  GL_LINEAR);
>        _mesa_set_sampler_wrap(ctx, mipmap->samp_obj, GL_CLAMP_TO_EDGE,
>                               GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
> +   }
> +
> +   if (ctx->Extensions.EXT_texture_sRGB_decode) {
> +      const struct gl_texture_image *baseImage =
> +         _mesa_select_tex_image(texObj, target, texObj->BaseLevel);
> +      const bool srgb =
> +         _mesa_get_format_color_encoding(baseImage->TexFormat) ==
> GL_SRGB;
>
> -      /* We don't want to encode or decode sRGB values; treat them as
> linear. */
> -      _mesa_set_sampler_srgb_decode(ctx, mipmap->samp_obj,
> GL_SKIP_DECODE_EXT);
> +      _mesa_set_sampler_srgb_decode(ctx, mipmap->samp_obj,
> +                                    srgb ? GL_DECODE_EXT :
> GL_SKIP_DECODE_EXT);
> +      _mesa_set_framebuffer_srgb(ctx, srgb);
>     }
>
>     _mesa_bind_sampler(ctx, ctx->Texture.CurrentUnit, mipmap->samp_obj);
> --
> 2.9.2
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160812/1bcd07bc/attachment.html>


More information about the mesa-dev mailing list