lavapipe: skip "pipeline barriers" if they're first or last in a cmdbuf
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 12 May 2021 03:27:17 +0000 (23:27 -0400)
committerMarge Bot <eric+marge@anholt.net>
Thu, 27 May 2021 00:12:48 +0000 (00:12 +0000)
barriers just trigger a full flush, which is unnecessary if it's:
* the first cmd in a cmdbuf, as the previous cmdbuf will have already
  flushed and so this is flushing nothing
* the last cmd in a cmdbuf, as there will be a flush immediately after
  returning from this function

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10762>

src/gallium/frontends/lavapipe/lvp_execute.c

index 2716453..d4ffa99 100644 (file)
@@ -2928,6 +2928,7 @@ static void lvp_execute_cmd_buffer(struct lvp_cmd_buffer *cmd_buffer,
                                    struct rendering_state *state)
 {
    struct lvp_cmd_buffer_entry *cmd;
+   bool first = true;
 
    LIST_FOR_EACH_ENTRY(cmd, &cmd_buffer->cmds, cmd_link) {
       switch (cmd->cmd_type) {
@@ -3035,6 +3036,11 @@ static void lvp_execute_cmd_buffer(struct lvp_cmd_buffer *cmd_buffer,
          handle_wait_events(cmd, state);
          break;
       case LVP_CMD_PIPELINE_BARRIER:
+         /* skip flushes since every cmdbuf does a flush
+            after iterating its cmds and so this is redundant
+          */
+         if (first || cmd->cmd_link.next == &cmd_buffer->cmds)
+            continue;
          handle_pipeline_barrier(cmd, state);
          break;
       case LVP_CMD_BEGIN_QUERY:
@@ -3126,6 +3132,7 @@ static void lvp_execute_cmd_buffer(struct lvp_cmd_buffer *cmd_buffer,
          handle_set_stencil_op(cmd, state);
          break;
       }
+      first = false;
    }
 }