zink: avoid emitting unnecessary pipeline barriers during update_descriptors
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 19 Aug 2020 19:44:37 +0000 (15:44 -0400)
committerMarge Bot <eric+marge@anholt.net>
Fri, 19 Feb 2021 02:05:13 +0000 (02:05 +0000)
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 <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8945>

src/gallium/drivers/zink/zink_draw.c

index 2b3d379..ef6290b 100644 (file)
@@ -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);