mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-17 20:28:45 +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,
|
.commandBufferCount = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
os_mutex_lock(&vk->cmd_pool_mutex);
|
||||||
|
|
||||||
ret = vk->vkAllocateCommandBuffers(vk->device, &cmd_buffer_info,
|
ret = vk->vkAllocateCommandBuffers(vk->device, &cmd_buffer_info,
|
||||||
&cmd_buffer);
|
&cmd_buffer);
|
||||||
|
|
||||||
|
os_mutex_unlock(&vk->cmd_pool_mutex);
|
||||||
|
|
||||||
if (ret != VK_SUCCESS) {
|
if (ret != VK_SUCCESS) {
|
||||||
VK_ERROR(vk, "vkAllocateCommandBuffers: %s",
|
VK_ERROR(vk, "vkAllocateCommandBuffers: %s",
|
||||||
vk_result_string(ret));
|
vk_result_string(ret));
|
||||||
|
@ -665,7 +670,9 @@ vk_submit_cmd_buffer(struct vk_bundle *vk, VkCommandBuffer cmd_buffer)
|
||||||
out_fence:
|
out_fence:
|
||||||
vk->vkDestroyFence(vk->device, fence, NULL);
|
vk->vkDestroyFence(vk->device, fence, NULL);
|
||||||
out:
|
out:
|
||||||
|
os_mutex_lock(&vk->cmd_pool_mutex);
|
||||||
vk->vkFreeCommandBuffers(vk->device, vk->cmd_pool, 1, &cmd_buffer);
|
vk->vkFreeCommandBuffers(vk->device, vk->cmd_pool, 1, &cmd_buffer);
|
||||||
|
os_mutex_unlock(&vk->cmd_pool_mutex);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,8 @@ struct vk_bundle
|
||||||
|
|
||||||
VkCommandPool cmd_pool;
|
VkCommandPool cmd_pool;
|
||||||
|
|
||||||
|
struct os_mutex cmd_pool_mutex;
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
// Loader functions
|
// Loader functions
|
||||||
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
|
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
|
||||||
|
|
|
@ -118,6 +118,7 @@ compositor_destroy(struct xrt_compositor *xc)
|
||||||
}
|
}
|
||||||
|
|
||||||
os_mutex_destroy(&vk->queue_mutex);
|
os_mutex_destroy(&vk->queue_mutex);
|
||||||
|
os_mutex_destroy(&vk->cmd_pool_mutex);
|
||||||
|
|
||||||
if (vk->instance != VK_NULL_HANDLE) {
|
if (vk->instance != VK_NULL_HANDLE) {
|
||||||
vk->vkDestroyInstance(vk->instance, NULL);
|
vk->vkDestroyInstance(vk->instance, NULL);
|
||||||
|
@ -939,6 +940,10 @@ compositor_init_vulkan(struct comp_compositor *c)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (os_mutex_init(&c->vk.cmd_pool_mutex) != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (ret != VK_SUCCESS) {
|
if (ret != VK_SUCCESS) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,9 +216,15 @@ create_command_buffer(struct vk_bundle *vk, VkCommandBuffer *out_cmd)
|
||||||
};
|
};
|
||||||
|
|
||||||
VkCommandBuffer cmd = VK_NULL_HANDLE;
|
VkCommandBuffer cmd = VK_NULL_HANDLE;
|
||||||
|
|
||||||
|
os_mutex_lock(&vk->cmd_pool_mutex);
|
||||||
|
|
||||||
ret = vk->vkAllocateCommandBuffers(vk->device, //
|
ret = vk->vkAllocateCommandBuffers(vk->device, //
|
||||||
&cmd_buffer_info, //
|
&cmd_buffer_info, //
|
||||||
&cmd); //
|
&cmd); //
|
||||||
|
|
||||||
|
os_mutex_unlock(&vk->cmd_pool_mutex);
|
||||||
|
|
||||||
if (ret != VK_SUCCESS) {
|
if (ret != VK_SUCCESS) {
|
||||||
VK_ERROR(vk, "vkCreateFramebuffer failed: %s",
|
VK_ERROR(vk, "vkCreateFramebuffer failed: %s",
|
||||||
vk_result_string(ret));
|
vk_result_string(ret));
|
||||||
|
|
Loading…
Reference in a new issue