Mesa (main): lavapipe: fix fencing when submitting multiple cmdbufs

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri May 14 03:14:14 UTC 2021


Module: Mesa
Branch: main
Commit: cf3f17a64345d59c7f044e9ccd04631b930003d3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cf3f17a64345d59c7f044e9ccd04631b930003d3

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Thu May 13 18:14:51 2021 -0400

lavapipe: fix fencing when submitting multiple cmdbufs

a fence applies to all the submitted cmdbufs, so it's necessary to do
the flush which creates the user fence after all the cmdbufs have been
processed in order to avoid creating a fence that only applies to the
first cmdbuf

Fixes: b38879f8c5f ("vallium: initial import of the vulkan frontend")

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

---

 src/gallium/frontends/lavapipe/lvp_device.c  | 13 +++++++++++--
 src/gallium/frontends/lavapipe/lvp_execute.c |  8 --------
 src/gallium/frontends/lavapipe/lvp_private.h |  1 -
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/gallium/frontends/lavapipe/lvp_device.c b/src/gallium/frontends/lavapipe/lvp_device.c
index 0e8124868a8..0febdc17607 100644
--- a/src/gallium/frontends/lavapipe/lvp_device.c
+++ b/src/gallium/frontends/lavapipe/lvp_device.c
@@ -1108,9 +1108,18 @@ static int queue_thread(void *data)
       mtx_unlock(&queue->m);
       //execute
       for (unsigned i = 0; i < task->cmd_buffer_count; i++) {
-         lvp_execute_cmds(queue->device, queue, task->fence, task->cmd_buffers[i]);
+         lvp_execute_cmds(queue->device, queue, task->cmd_buffers[i]);
       }
-      if (!task->cmd_buffer_count && task->fence)
+
+      if (task->cmd_buffer_count) {
+         struct pipe_fence_handle *handle = NULL;
+         queue->ctx->flush(queue->ctx, task->fence ? &handle : NULL, 0);
+         if (task->fence) {
+            mtx_lock(&queue->device->fence_lock);
+            task->fence->handle = handle;
+            mtx_unlock(&queue->device->fence_lock);
+         }
+      } else if (task->fence)
          task->fence->signaled = true;
       p_atomic_dec(&queue->count);
       mtx_lock(&queue->m);
diff --git a/src/gallium/frontends/lavapipe/lvp_execute.c b/src/gallium/frontends/lavapipe/lvp_execute.c
index 828b44814e3..30b09a2ba0d 100644
--- a/src/gallium/frontends/lavapipe/lvp_execute.c
+++ b/src/gallium/frontends/lavapipe/lvp_execute.c
@@ -3131,11 +3131,9 @@ static void lvp_execute_cmd_buffer(struct lvp_cmd_buffer *cmd_buffer,
 
 VkResult lvp_execute_cmds(struct lvp_device *device,
                           struct lvp_queue *queue,
-                          struct lvp_fence *fence,
                           struct lvp_cmd_buffer *cmd_buffer)
 {
    struct rendering_state state;
-   struct pipe_fence_handle *handle = NULL;
    memset(&state, 0, sizeof(state));
    state.pctx = queue->ctx;
    state.blend_dirty = true;
@@ -3145,12 +3143,6 @@ VkResult lvp_execute_cmds(struct lvp_device *device,
    /* create a gallium context */
    lvp_execute_cmd_buffer(cmd_buffer, &state);
 
-   state.pctx->flush(state.pctx, fence ? &handle : NULL, 0);
-   if (fence) {
-      mtx_lock(&device->fence_lock);
-      fence->handle = handle;
-      mtx_unlock(&device->fence_lock);
-   }
    state.start_vb = -1;
    state.num_vb = 0;
    state.pctx->set_vertex_buffers(state.pctx, 0, 0, PIPE_MAX_ATTRIBS, false, NULL);
diff --git a/src/gallium/frontends/lavapipe/lvp_private.h b/src/gallium/frontends/lavapipe/lvp_private.h
index 40b4d6b76b2..361a4d236e7 100644
--- a/src/gallium/frontends/lavapipe/lvp_private.h
+++ b/src/gallium/frontends/lavapipe/lvp_private.h
@@ -1106,7 +1106,6 @@ struct lvp_cmd_buffer_entry {
 
 VkResult lvp_execute_cmds(struct lvp_device *device,
                           struct lvp_queue *queue,
-                          struct lvp_fence *fence,
                           struct lvp_cmd_buffer *cmd_buffer);
 
 struct lvp_image *lvp_swapchain_get_image(VkSwapchainKHR swapchain,



More information about the mesa-commit mailing list