mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-17 04:15:44 +00:00
comp/vk: Lock command pool calls with a mutex.
This patch resolves multithreading issues as detected by the Vulkan validation when running the OpenXR CTS using OpenGL.
This commit is contained in:
parent
c97404e873
commit
fc3b7fef25
|
@ -557,8 +557,13 @@ vk_init_cmd_buffer(struct vk_bundle *vk, VkCommandBuffer *out_cmd_buffer)
|
|||
.commandBufferCount = 1,
|
||||
};
|
||||
|
||||
os_mutex_lock(&vk->cmd_pool_mutex);
|
||||
|
||||
ret = vk->vkAllocateCommandBuffers(vk->device, &cmd_buffer_info,
|
||||
&cmd_buffer);
|
||||
|
||||
os_mutex_unlock(&vk->cmd_pool_mutex);
|
||||
|
||||
if (ret != VK_SUCCESS) {
|
||||
VK_ERROR(vk, "vkAllocateCommandBuffers: %s",
|
||||
vk_result_string(ret));
|
||||
|
@ -665,7 +670,9 @@ vk_submit_cmd_buffer(struct vk_bundle *vk, VkCommandBuffer cmd_buffer)
|
|||
out_fence:
|
||||
vk->vkDestroyFence(vk->device, fence, NULL);
|
||||
out:
|
||||
os_mutex_lock(&vk->cmd_pool_mutex);
|
||||
vk->vkFreeCommandBuffers(vk->device, vk->cmd_pool, 1, &cmd_buffer);
|
||||
os_mutex_unlock(&vk->cmd_pool_mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ struct vk_bundle
|
|||
|
||||
VkCommandPool cmd_pool;
|
||||
|
||||
struct os_mutex cmd_pool_mutex;
|
||||
|
||||
// clang-format off
|
||||
// Loader functions
|
||||
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
|
||||
|
|
|
@ -118,6 +118,7 @@ compositor_destroy(struct xrt_compositor *xc)
|
|||
}
|
||||
|
||||
os_mutex_destroy(&vk->queue_mutex);
|
||||
os_mutex_destroy(&vk->cmd_pool_mutex);
|
||||
|
||||
if (vk->instance != VK_NULL_HANDLE) {
|
||||
vk->vkDestroyInstance(vk->instance, NULL);
|
||||
|
@ -939,6 +940,10 @@ compositor_init_vulkan(struct comp_compositor *c)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (os_mutex_init(&c->vk.cmd_pool_mutex) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ret != VK_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -216,9 +216,15 @@ create_command_buffer(struct vk_bundle *vk, VkCommandBuffer *out_cmd)
|
|||
};
|
||||
|
||||
VkCommandBuffer cmd = VK_NULL_HANDLE;
|
||||
|
||||
os_mutex_lock(&vk->cmd_pool_mutex);
|
||||
|
||||
ret = vk->vkAllocateCommandBuffers(vk->device, //
|
||||
&cmd_buffer_info, //
|
||||
&cmd); //
|
||||
|
||||
os_mutex_unlock(&vk->cmd_pool_mutex);
|
||||
|
||||
if (ret != VK_SUCCESS) {
|
||||
VK_ERROR(vk, "vkCreateFramebuffer failed: %s",
|
||||
vk_result_string(ret));
|
||||
|
|
Loading…
Reference in a new issue