From bb8b8b8fb5d340facbca29d6b79dc49b889200cc Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 13 May 2021 18:14:51 -0400 Subject: [PATCH] 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 Part-of: (cherry picked from commit cf3f17a64345d59c7f044e9ccd04631b930003d3) --- .pick_status.json | 2 +- src/gallium/frontends/lavapipe/lvp_device.c | 13 +++++++++++-- src/gallium/frontends/lavapipe/lvp_execute.c | 8 -------- src/gallium/frontends/lavapipe/lvp_private.h | 1 - 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 6f690fdf51a..7147e319653 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -292,7 +292,7 @@ "description": "lavapipe: fix fencing when submitting multiple cmdbufs", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "b38879f8c5f57b7f1802e433e33181bdf5e72aef" }, diff --git a/src/gallium/frontends/lavapipe/lvp_device.c b/src/gallium/frontends/lavapipe/lvp_device.c index 7f58d1d1d34..f02d4796acd 100644 --- a/src/gallium/frontends/lavapipe/lvp_device.c +++ b/src/gallium/frontends/lavapipe/lvp_device.c @@ -1079,9 +1079,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 a1b1ab2d5ca..c1e6e396bfc 100644 --- a/src/gallium/frontends/lavapipe/lvp_execute.c +++ b/src/gallium/frontends/lavapipe/lvp_execute.c @@ -3142,11 +3142,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; @@ -3156,12 +3154,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 d1e0b27ce31..4567b09db30 100644 --- a/src/gallium/frontends/lavapipe/lvp_private.h +++ b/src/gallium/frontends/lavapipe/lvp_private.h @@ -1103,7 +1103,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,