[Mesa-dev] [PATCH 9/9] i965: Fall back to normal blorp clear instead of meta clear
Jason Ekstrand
jason at jlekstrand.net
Fri Jun 16 23:02:29 UTC 2017
On Fri, Jun 16, 2017 at 2:01 PM, Ian Romanick <idr at freedesktop.org> wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> When intel_miptree_alloc_non_msrt_mcs fails, fall back to normal blorp
> color clear instead of falling back to meta. With this change,
> brw_blorp_clear_color can never fail.
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
> src/mesa/drivers/dri/i965/brw_blorp.c | 28 +++++++++++++---------------
> src/mesa/drivers/dri/i965/brw_blorp.h | 2 +-
> src/mesa/drivers/dri/i965/brw_clear.c | 19 ++++++++++---------
> 3 files changed, 24 insertions(+), 25 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c
> b/src/mesa/drivers/dri/i965/brw_blorp.c
> index 24867e8..6a79984 100644
> --- a/src/mesa/drivers/dri/i965/brw_blorp.c
> +++ b/src/mesa/drivers/dri/i965/brw_blorp.c
> @@ -725,7 +725,7 @@ irb_logical_mt_layer(struct intel_renderbuffer *irb)
> return physical_to_logical_layer(irb->mt, irb->mt_layer);
> }
>
> -static bool
> +static void
> do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,
> struct gl_renderbuffer *rb, unsigned buf,
> bool partial_clear, bool encode_srgb)
> @@ -750,7 +750,7 @@ do_single_blorp_clear(struct brw_context *brw, struct
> gl_framebuffer *fb,
>
> /* If the clear region is empty, just return. */
> if (x0 == x1 || y0 == y1)
> - return true;
> + return;
>
> bool can_fast_clear = !partial_clear;
>
> @@ -782,14 +782,16 @@ do_single_blorp_clear(struct brw_context *brw,
> struct gl_framebuffer *fb,
> if (!irb->mt->mcs_buf) {
>
You might as well roll this check into the one above it and drop a level of
nesting.
Other than that, this looks great. Thanks!
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
> assert(!intel_miptree_is_lossless_compressed(brw, irb->mt));
> if (!intel_miptree_alloc_non_msrt_mcs(brw, irb->mt, false)) {
> - /* MCS allocation failed--probably this will only happen in
> - * out-of-memory conditions. But in any case, try to recover
> - * by falling back to a non-blorp clear technique.
> + /* There are a few reasons in addition to out-of-memory, that
> can
> + * cause intel_miptree_alloc_non_msrt_mcs to fail. Try to
> recover
> + * by falling back to non-fast clear.
> */
> - return false;
> + can_fast_clear = false;
> }
> }
> + }
>
> + if (can_fast_clear) {
> const enum isl_aux_state aux_state =
> intel_miptree_get_aux_state(irb->mt, irb->mt_level,
> logical_layer);
> union isl_color_value clear_color =
> @@ -802,7 +804,7 @@ do_single_blorp_clear(struct brw_context *brw, struct
> gl_framebuffer *fb,
> if (aux_state == ISL_AUX_STATE_CLEAR &&
> memcmp(&irb->mt->fast_clear_color,
> &clear_color, sizeof(clear_color)) == 0)
> - return true;
> + return;
>
> irb->mt->fast_clear_color = clear_color;
>
> @@ -872,10 +874,10 @@ do_single_blorp_clear(struct brw_context *brw,
> struct gl_framebuffer *fb,
> blorp_batch_finish(&batch);
> }
>
> - return true;
> + return;
> }
>
> -bool
> +void
> brw_blorp_clear_color(struct brw_context *brw, struct gl_framebuffer *fb,
> GLbitfield mask, bool partial_clear, bool
> encode_srgb)
> {
> @@ -894,15 +896,11 @@ brw_blorp_clear_color(struct brw_context *brw,
> struct gl_framebuffer *fb,
> if (rb == NULL)
> continue;
>
> - if (!do_single_blorp_clear(brw, fb, rb, buf, partial_clear,
> - encode_srgb)) {
> - return false;
> - }
> -
> + do_single_blorp_clear(brw, fb, rb, buf, partial_clear, encode_srgb);
> irb->need_downsample = true;
> }
>
> - return true;
> + return;
> }
>
> void
> diff --git a/src/mesa/drivers/dri/i965/brw_blorp.h
> b/src/mesa/drivers/dri/i965/brw_blorp.h
> index fd1b5cc..636c993 100644
> --- a/src/mesa/drivers/dri/i965/brw_blorp.h
> +++ b/src/mesa/drivers/dri/i965/brw_blorp.h
> @@ -59,7 +59,7 @@ brw_blorp_copy_miptrees(struct brw_context *brw,
> unsigned dst_x, unsigned dst_y,
> unsigned src_width, unsigned src_height);
>
> -bool
> +void
> brw_blorp_clear_color(struct brw_context *brw, struct gl_framebuffer *fb,
> GLbitfield mask, bool partial_clear, bool
> encode_srgb);
>
> diff --git a/src/mesa/drivers/dri/i965/brw_clear.c
> b/src/mesa/drivers/dri/i965/brw_clear.c
> index 809e279..77c0dc4 100644
> --- a/src/mesa/drivers/dri/i965/brw_clear.c
> +++ b/src/mesa/drivers/dri/i965/brw_clear.c
> @@ -228,16 +228,14 @@ brw_clear(struct gl_context *ctx, GLbitfield mask)
> }
>
> if (mask & BUFFER_BITS_COLOR) {
> - const bool encode_srgb = ctx->Color.sRGBEnabled;
> - if (brw_blorp_clear_color(brw, fb, mask, partial_clear,
> encode_srgb)) {
> - debug_mask("blorp color", mask & BUFFER_BITS_COLOR);
> - mask &= ~BUFFER_BITS_COLOR;
> - }
> + brw_blorp_clear_color(brw, fb, mask, partial_clear,
> + ctx->Color.sRGBEnabled);
> + debug_mask("blorp color", mask & BUFFER_BITS_COLOR);
> + mask &= ~BUFFER_BITS_COLOR;
> }
>
> - GLbitfield tri_mask = mask & (BUFFER_BITS_COLOR |
> - BUFFER_BIT_STENCIL |
> - BUFFER_BIT_DEPTH);
> + GLbitfield tri_mask = mask & (BUFFER_BIT_STENCIL |
> + BUFFER_BIT_DEPTH);
>
> if (tri_mask) {
> debug_mask("tri", tri_mask);
> @@ -250,7 +248,10 @@ brw_clear(struct gl_context *ctx, GLbitfield mask)
> }
> }
>
> - /* Any strange buffers get passed off to swrast */
> + /* Any strange buffers get passed off to swrast. The only thing that
> + * should be left at this point is the accumulation buffer.
> + */
> + assert((mask & ~BUFFER_BIT_ACCUM) == 0);
> if (mask) {
> debug_mask("swrast", mask);
> _swrast_Clear(ctx, mask);
> --
> 2.9.4
>
> _______________________________________________
> 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/20170616/c9e9b8b9/attachment-0001.html>
More information about the mesa-dev
mailing list