[Mesa-dev] [PATCH - Mesa 10/10] st/mesa: Make Gallium's BlitFramebuffer follow the GL 4.4 sRGB rules.

Nicolai Hähnle nhaehnle at gmail.com
Mon Aug 8 11:06:58 UTC 2016


I'm glad your sanity is still hanging on :) I particularly like the "Yes 
& No" in the comparison table.

Anyway, this patch and the piglit patches are

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

On 05.08.2016 01:14, Kenneth Graunke wrote:
> OpenGL 4.4 specifies that BlitFramebuffer should perform sRGB encode
> and decode like ES 3.x does, but only when GL_FRAMEBUFFER_SRGB is
> enabled.  This is technically incompatible in certain cases, but is
> more consistent across GL, ES, and WebGL, and more flexible.
>
> The NVIDIA 367.35 drivers appear to follow this behavior.
>
> For the awful spec analysis, please read Piglit's
> tests/spec/arb_framebuffer_srgb/blit.c, which explains the differences
> between GL 4.1, 4.2, 4.3 (2012), 4.3 (2013), and 4.4, and why this
> is the right rule to implement.
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/state_tracker/st_cb_blit.c | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
>
> Whoever designed this interface did a very nice job.  Making this change
> was really simple.  I wrote the obvious code, tested it with llvmpipe,
> and it appears to be working.
>
> diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c
> index 5e7c34c..cfcf3f7 100644
> --- a/src/mesa/state_tracker/st_cb_blit.c
> +++ b/src/mesa/state_tracker/st_cb_blit.c
> @@ -44,6 +44,14 @@
>
>  #include "util/u_format.h"
>
> +static void
> +st_adjust_blit_for_srgb(struct pipe_blit_info *blit, bool framebuffer_srgb)
> +{
> +   if (!framebuffer_srgb) {
> +      blit->dst.format = util_format_linear(blit->dst.format);
> +      blit->src.format = util_format_linear(blit->src.format);
> +   }
> +}
>
>  static void
>  st_BlitFramebuffer(struct gl_context *ctx,
> @@ -197,12 +205,14 @@ st_BlitFramebuffer(struct gl_context *ctx,
>                    blit.dst.resource = dstSurf->texture;
>                    blit.dst.level = dstSurf->u.tex.level;
>                    blit.dst.box.z = dstSurf->u.tex.first_layer;
> -                  blit.dst.format = util_format_linear(dstSurf->format);
> +                  blit.dst.format = dstSurf->format;
>
>                    blit.src.resource = srcObj->pt;
>                    blit.src.level = srcAtt->TextureLevel;
>                    blit.src.box.z = srcAtt->Zoffset + srcAtt->CubeMapFace;
> -                  blit.src.format = util_format_linear(srcObj->pt->format);
> +                  blit.src.format = srcObj->pt->format;
> +
> +                  st_adjust_blit_for_srgb(&blit, ctx->Color.sRGBEnabled);
>
>                    st->pipe->blit(st->pipe, &blit);
>                    dstRb->defined = true; /* front buffer tracking */
> @@ -233,12 +243,14 @@ st_BlitFramebuffer(struct gl_context *ctx,
>                    blit.dst.resource = dstSurf->texture;
>                    blit.dst.level = dstSurf->u.tex.level;
>                    blit.dst.box.z = dstSurf->u.tex.first_layer;
> -                  blit.dst.format = util_format_linear(dstSurf->format);
> +                  blit.dst.format = dstSurf->format;
>
>                    blit.src.resource = srcSurf->texture;
>                    blit.src.level = srcSurf->u.tex.level;
>                    blit.src.box.z = srcSurf->u.tex.first_layer;
> -                  blit.src.format = util_format_linear(srcSurf->format);
> +                  blit.src.format = srcSurf->format;
> +
> +                  st_adjust_blit_for_srgb(&blit, ctx->Color.sRGBEnabled);
>
>                    st->pipe->blit(st->pipe, &blit);
>                    dstRb->defined = true; /* front buffer tracking */
>


More information about the mesa-dev mailing list