From e8f3c547be151775da90820e945f98f91606287d Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 29 Apr 2020 22:12:12 +0100 Subject: [PATCH] Add fallback to remove queue priorities if device creation fails --- .../vulkan/wrappers/vk_device_funcs.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp index 51558ee96..43c30c715 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp @@ -1438,6 +1438,19 @@ bool WrappedVulkan::Serialise_vkCreateDevice(SerialiserType &ser, VkPhysicalDevi RDCLOG("Creating replay device from physical device %u", physicalDeviceIndex); + rdcarray queuePriorities; + + for(uint32_t i = 0; i < CreateInfo.queueCreateInfoCount; i++) + { + VkDeviceQueueGlobalPriorityCreateInfoEXT *queuePrio = + (VkDeviceQueueGlobalPriorityCreateInfoEXT *)FindNextStruct( + &CreateInfo.pQueueCreateInfos[i], + VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT); + + if(queuePrio) + queuePriorities.push_back(queuePrio); + } + // we must make any modifications locally, so the free of pointers // in the serialised VkDeviceCreateInfo don't double-free VkDeviceCreateInfo createInfo = CreateInfo; @@ -2872,6 +2885,21 @@ bool WrappedVulkan::Serialise_vkCreateDevice(SerialiserType &ser, VkPhysicalDevi vkr = GetDeviceDispatchTable(NULL)->CreateDevice(Unwrap(physicalDevice), &createInfo, NULL, &device); + if(vkr != VK_SUCCESS && !queuePriorities.empty()) + { + RDCWARN("Failed to create logical device: %s. Reducing queue priorities", ToStr(vkr).c_str()); + + for(VkDeviceQueueGlobalPriorityCreateInfoEXT *q : queuePriorities) + { + // medium is considered the default if no priority is set otherwise + if(q->globalPriority > VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT) + q->globalPriority = VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT; + } + + vkr = GetDeviceDispatchTable(NULL)->CreateDevice(Unwrap(physicalDevice), &createInfo, NULL, + &device); + } + if(vkr != VK_SUCCESS) { RDCERR("Failed to create logical device: %s", ToStr(vkr).c_str());