mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 04:36:07 +00:00
comp/vk: Lock our only VkQueue with a mutex.
This resolved mutlithreading issues as seen in the `multithreading` test of the OpenXR CTS. This patch fixes the test on Vulkan Android and resolves Vulkan validation errors when running on Linux with OpenGL.
This commit is contained in:
parent
fd58ccecc9
commit
9a9d46b85a
|
@ -645,7 +645,9 @@ vk_submit_cmd_buffer(struct vk_bundle *vk, VkCommandBuffer cmd_buffer)
|
|||
}
|
||||
|
||||
// Do the actual submitting.
|
||||
os_mutex_lock(&vk->queue_mutex);
|
||||
ret = vk->vkQueueSubmit(vk->queue, 1, &submitInfo, fence);
|
||||
os_mutex_unlock(&vk->queue_mutex);
|
||||
if (ret != VK_SUCCESS) {
|
||||
VK_ERROR(vk, "Error: Could not submit to queue.\n");
|
||||
goto out_fence;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "xrt/xrt_vulkan_includes.h"
|
||||
#include "xrt/xrt_handles.h"
|
||||
#include "util/u_logging.h"
|
||||
#include "os/os_threading.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -45,6 +46,8 @@ struct vk_bundle
|
|||
uint32_t queue_index;
|
||||
VkQueue queue;
|
||||
|
||||
struct os_mutex queue_mutex;
|
||||
|
||||
bool has_GOOGLE_display_timing;
|
||||
|
||||
VkDebugReportCallbackEXT debug_report_cb;
|
||||
|
|
|
@ -89,8 +89,11 @@ client_vk_swapchain_acquire_image(struct xrt_swapchain *xsc,
|
|||
.commandBufferCount = 1,
|
||||
.pCommandBuffers = &sc->acquire[*out_index],
|
||||
};
|
||||
|
||||
os_mutex_lock(&vk->queue_mutex);
|
||||
VkResult ret =
|
||||
vk->vkQueueSubmit(vk->queue, 1, &submitInfo, VK_NULL_HANDLE);
|
||||
os_mutex_unlock(&vk->queue_mutex);
|
||||
if (ret != VK_SUCCESS) {
|
||||
VK_ERROR(vk, "Error: Could not submit to queue.\n");
|
||||
return XRT_ERROR_FAILED_TO_SUBMIT_VULKAN_COMMANDS;
|
||||
|
@ -121,8 +124,11 @@ client_vk_swapchain_release_image(struct xrt_swapchain *xsc, uint32_t index)
|
|||
.commandBufferCount = 1,
|
||||
.pCommandBuffers = &sc->release[index],
|
||||
};
|
||||
|
||||
os_mutex_lock(&vk->queue_mutex);
|
||||
VkResult ret =
|
||||
vk->vkQueueSubmit(vk->queue, 1, &submitInfo, VK_NULL_HANDLE);
|
||||
os_mutex_unlock(&vk->queue_mutex);
|
||||
if (ret != VK_SUCCESS) {
|
||||
VK_ERROR(vk, "Error: Could not submit to queue.\n");
|
||||
return XRT_ERROR_FAILED_TO_SUBMIT_VULKAN_COMMANDS;
|
||||
|
|
|
@ -117,6 +117,8 @@ compositor_destroy(struct xrt_compositor *xc)
|
|||
vk->device = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
os_mutex_destroy(&vk->queue_mutex);
|
||||
|
||||
if (vk->instance != VK_NULL_HANDLE) {
|
||||
vk->vkDestroyInstance(vk->instance, NULL);
|
||||
vk->instance = VK_NULL_HANDLE;
|
||||
|
@ -932,6 +934,11 @@ compositor_init_vulkan(struct comp_compositor *c)
|
|||
&c->vk, c->settings.selected_gpu_index, required_device_extensions,
|
||||
ARRAY_SIZE(required_device_extensions), optional_device_extensions,
|
||||
ARRAY_SIZE(optional_device_extensions));
|
||||
|
||||
if (os_mutex_init(&c->vk.queue_mutex) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ret != VK_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -173,8 +173,10 @@ renderer_submit_queue(struct comp_renderer *r)
|
|||
.pSignalSemaphores = &r->semaphores.render_complete,
|
||||
};
|
||||
|
||||
os_mutex_lock(&vk->queue_mutex);
|
||||
ret = vk->vkQueueSubmit(r->queue, 1, &comp_submit_info,
|
||||
r->fences[r->current_buffer]);
|
||||
os_mutex_unlock(&vk->queue_mutex);
|
||||
if (ret != VK_SUCCESS) {
|
||||
COMP_ERROR(r->c, "vkQueueSubmit: %s", vk_result_string(ret));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue