The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

+20
+2
src/xrt/auxiliary/vk/vk_helpers.c
··· 645 645 } 646 646 647 647 // Do the actual submitting. 648 + os_mutex_lock(&vk->queue_mutex); 648 649 ret = vk->vkQueueSubmit(vk->queue, 1, &submitInfo, fence); 650 + os_mutex_unlock(&vk->queue_mutex); 649 651 if (ret != VK_SUCCESS) { 650 652 VK_ERROR(vk, "Error: Could not submit to queue.\n"); 651 653 goto out_fence;
+3
src/xrt/auxiliary/vk/vk_helpers.h
··· 14 14 #include "xrt/xrt_vulkan_includes.h" 15 15 #include "xrt/xrt_handles.h" 16 16 #include "util/u_logging.h" 17 + #include "os/os_threading.h" 17 18 18 19 #ifdef __cplusplus 19 20 extern "C" { ··· 44 45 uint32_t queue_family_index; 45 46 uint32_t queue_index; 46 47 VkQueue queue; 48 + 49 + struct os_mutex queue_mutex; 47 50 48 51 bool has_GOOGLE_display_timing; 49 52
+6
src/xrt/compositor/client/comp_vk_client.c
··· 89 89 .commandBufferCount = 1, 90 90 .pCommandBuffers = &sc->acquire[*out_index], 91 91 }; 92 + 93 + os_mutex_lock(&vk->queue_mutex); 92 94 VkResult ret = 93 95 vk->vkQueueSubmit(vk->queue, 1, &submitInfo, VK_NULL_HANDLE); 96 + os_mutex_unlock(&vk->queue_mutex); 94 97 if (ret != VK_SUCCESS) { 95 98 VK_ERROR(vk, "Error: Could not submit to queue.\n"); 96 99 return XRT_ERROR_FAILED_TO_SUBMIT_VULKAN_COMMANDS; ··· 121 124 .commandBufferCount = 1, 122 125 .pCommandBuffers = &sc->release[index], 123 126 }; 127 + 128 + os_mutex_lock(&vk->queue_mutex); 124 129 VkResult ret = 125 130 vk->vkQueueSubmit(vk->queue, 1, &submitInfo, VK_NULL_HANDLE); 131 + os_mutex_unlock(&vk->queue_mutex); 126 132 if (ret != VK_SUCCESS) { 127 133 VK_ERROR(vk, "Error: Could not submit to queue.\n"); 128 134 return XRT_ERROR_FAILED_TO_SUBMIT_VULKAN_COMMANDS;
+7
src/xrt/compositor/main/comp_compositor.c
··· 117 117 vk->device = VK_NULL_HANDLE; 118 118 } 119 119 120 + os_mutex_destroy(&vk->queue_mutex); 121 + 120 122 if (vk->instance != VK_NULL_HANDLE) { 121 123 vk->vkDestroyInstance(vk->instance, NULL); 122 124 vk->instance = VK_NULL_HANDLE; ··· 932 934 &c->vk, c->settings.selected_gpu_index, required_device_extensions, 933 935 ARRAY_SIZE(required_device_extensions), optional_device_extensions, 934 936 ARRAY_SIZE(optional_device_extensions)); 937 + 938 + if (os_mutex_init(&c->vk.queue_mutex) != 0) { 939 + return false; 940 + } 941 + 935 942 if (ret != VK_SUCCESS) { 936 943 return false; 937 944 }
+2
src/xrt/compositor/main/comp_renderer.c
··· 173 173 .pSignalSemaphores = &r->semaphores.render_complete, 174 174 }; 175 175 176 + os_mutex_lock(&vk->queue_mutex); 176 177 ret = vk->vkQueueSubmit(r->queue, 1, &comp_submit_info, 177 178 r->fences[r->current_buffer]); 179 + os_mutex_unlock(&vk->queue_mutex); 178 180 if (ret != VK_SUCCESS) { 179 181 COMP_ERROR(r->c, "vkQueueSubmit: %s", vk_result_string(ret)); 180 182 }