[Mesa-dev] [PATCH 1/5] i965/meta-fast-clear: Disable GL_FRAMEBUFFER_SRGB during clear
Pohjolainen, Topi
topi.pohjolainen at intel.com
Tue Dec 1 06:05:21 PST 2015
On Wed, Nov 25, 2015 at 06:36:35PM +0100, Neil Roberts wrote:
> Adds MESA_META_FRAMEBUFFER_SRGB to the meta save state so that
> GL_FRAMEBUFFER_SRGB will be disabled when performing the fast clear.
> That way the render surface state will be programmed with the linear
> equivalent format during the clear. This is important for Gen9 because
> the SRGB formats are not marked as losslessly compressible so in
> theory they aren't support for fast clears. It shouldn't make any
> difference whether GL_FRAMEBUFFER_SRGB is enabled for the fast clear
> operation because the color is not actually written to the framebuffer
> so there is no chance for the hardware to apply the SRGB conversion on
> it anyway.
> ---
> src/mesa/drivers/dri/i965/brw_meta_fast_clear.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
> index cf0e56b..b32db3f 100644
> --- a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
> +++ b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
> @@ -505,8 +505,21 @@ fast_clear_attachments(struct brw_context *brw,
> uint32_t fast_clear_buffers,
> struct rect fast_clear_rect)
> {
> + struct gl_context *ctx = &brw->ctx;
> + bool srgb_enabled = ctx->Color.sRGBEnabled;
Could be const.
> +
> assert(brw->gen >= 9);
>
> + /* Make sure the GL_FRAMEBUFFER_SRGB is disabled during fast clear so that
> + * the surface state will always be uploaded with a linear buffer. SRGB
> + * buffers are not supported on Gen9 because they are not marked as
> + * losslessly compressible. This shouldn't matter for the fast clear
> + * because the color is not written to the framebuffer anyway so the
> + * hardware doesn't need to do any SRGB conversion.
Maybe make it a little clearer that color isn't written _during_ fast clear,
this is your choice though. For example:
* losslessly compressible. This shouldn't matter for the fast clear
* because the color is not written to the framebuffer yet and therefore
* hardware doesn't need to do any SRGB conversion during the clear.
Either way:
Reviewed-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
> + */
> + if (srgb_enabled)
> + _mesa_set_framebuffer_srgb(ctx, GL_FALSE);
> +
> brw_bind_rep_write_shader(brw, (float *) fast_clear_color);
>
> /* SKL+ also has a resolve mode for compressed render targets and thus more
> @@ -533,6 +546,9 @@ fast_clear_attachments(struct brw_context *brw,
> }
>
> set_fast_clear_op(brw, 0);
> +
> + if (srgb_enabled)
> + _mesa_set_framebuffer_srgb(ctx, GL_TRUE);
> }
>
> bool
> --
> 1.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list