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: b38879f8c5 ("vallium: initial import of the vulkan frontend")

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10795>
(cherry picked from commit cf3f17a643)
This commit is contained in:
Mike Blumenkrantz 2021-05-13 18:14:51 -04:00 committed by Eric Engestrom
parent abd4ab6ffa
commit bb8b8b8fb5
4 changed files with 12 additions and 12 deletions

View file

@ -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"
},

View file

@ -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);

View file

@ -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);

View file

@ -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,