From: Mike Blumenkrantz Date: Tue, 16 May 2023 14:03:28 +0000 (-0400) Subject: zink: promote flushed clears to unordered cmdbuf when possible X-Git-Tag: upstream/23.3.3~8285 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=80b8defaf316743cf1e0a7be671b370322d9ae02;p=platform%2Fupstream%2Fmesa.git zink: promote flushed clears to unordered cmdbuf when possible this reuses the unordered_blitting codepath for fb clears for #9016 Part-of: --- diff --git a/src/gallium/drivers/zink/zink_clear.c b/src/gallium/drivers/zink/zink_clear.c index 6b45ba2..a8756ae 100644 --- a/src/gallium/drivers/zink/zink_clear.c +++ b/src/gallium/drivers/zink/zink_clear.c @@ -25,6 +25,7 @@ #include "zink_clear.h" #include "zink_context.h" #include "zink_format.h" +#include "zink_inlines.h" #include "zink_query.h" #include "util/u_blitter.h" @@ -719,9 +720,38 @@ fb_clears_apply_internal(struct zink_context *ctx, struct pipe_resource *pres, i return; if (ctx->batch.in_rp) zink_clear_framebuffer(ctx, BITFIELD_BIT(i)); - else + else { + struct zink_resource *res = zink_resource(pres); + bool queries_disabled = ctx->queries_disabled; + VkCommandBuffer cmdbuf = ctx->batch.state->cmdbuf; + /* slightly different than the u_blitter handling: + * this can be called recursively while unordered_blitting=true + */ + bool can_reorder = zink_screen(ctx->base.screen)->info.have_KHR_dynamic_rendering && + !ctx->render_condition_active && + !ctx->unordered_blitting && + zink_get_cmdbuf(ctx, NULL, res) == ctx->batch.state->barrier_cmdbuf; + if (can_reorder) { + /* set unordered_blitting but NOT blitting: + * let begin_rendering handle layouts + */ + ctx->unordered_blitting = true; + /* for unordered clears, swap the unordered cmdbuf for the main one for the whole op to avoid conditional hell */ + ctx->batch.state->cmdbuf = ctx->batch.state->barrier_cmdbuf; + ctx->rp_changed = true; + ctx->queries_disabled = true; + ctx->batch.state->has_barriers = true; + } /* this will automatically trigger all the clears */ zink_batch_rp(ctx); + if (can_reorder) { + zink_batch_no_rp(ctx); + ctx->unordered_blitting = false; + ctx->rp_changed = true; + ctx->queries_disabled = queries_disabled; + ctx->batch.state->cmdbuf = cmdbuf; + } + } zink_fb_clear_reset(ctx, i); }