From 017dbd63fb9544863705903e696368c5bf9cb725 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 19 Aug 2020 15:44:37 -0400 Subject: [PATCH] zink: avoid emitting unnecessary pipeline barriers during update_descriptors if the current state of the resource matches the desired state, we don't need to emit anything, and we can potentially avoid ending a renderpass Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/gallium/drivers/zink/zink_draw.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/zink/zink_draw.c b/src/gallium/drivers/zink/zink_draw.c index 2b3d379..ef6290b 100644 --- a/src/gallium/drivers/zink/zink_draw.c +++ b/src/gallium/drivers/zink/zink_draw.c @@ -425,14 +425,18 @@ update_descriptors(struct zink_context *ctx, struct zink_screen *screen, bool is } } - struct zink_batch *batch; + struct zink_batch *batch = NULL; if (num_transitions > 0) { - if (is_compute) - batch = &ctx->compute_batch; - else - batch = zink_batch_no_rp(ctx); - for (int i = 0; i < num_transitions; ++i) { + if (!zink_resource_needs_barrier(transitions[i].res, + transitions[i].layout, + transitions[i].stage)) + continue; + if (is_compute) + batch = &ctx->compute_batch; + else + batch = zink_batch_no_rp(ctx); + if (transitions[i].res->base.target == PIPE_BUFFER) zink_resource_buffer_barrier(batch->cmdbuf, transitions[i].res, transitions[i].layout, transitions[i].stage); -- 2.7.4