From 44df4262f026caa1d5972bca80495a5f973c5d1e Mon Sep 17 00:00:00 2001 From: Jens Weggemann Date: Tue, 18 Apr 2023 08:05:18 +0200 Subject: [PATCH] Tweaked Vulkan transfer queue family selection (#669) Update wiGraphicsDevice_Vulkan.cpp Changed Vulkan transfer queue family search to more to first look for a fully exclusive transfer queue family, even without video and optical flow caps. If that fails, it will fall back to the previous behavior. This change works around driver issues in some scenarios. --- WickedEngine/wiGraphicsDevice_Vulkan.cpp | 39 ++++++++++++++++++------ 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/WickedEngine/wiGraphicsDevice_Vulkan.cpp b/WickedEngine/wiGraphicsDevice_Vulkan.cpp index 08aecf663..7a4270736 100644 --- a/WickedEngine/wiGraphicsDevice_Vulkan.cpp +++ b/WickedEngine/wiGraphicsDevice_Vulkan.cpp @@ -2636,18 +2636,14 @@ using namespace vulkan_internal; familyIndex = 0; for (const auto& queueFamily : queueFamilies) { - if (queueFamily.queueCount > 0 && - queueFamily.queueFlags & VK_QUEUE_TRANSFER_BIT && - !(queueFamily.queueFlags & VK_QUEUE_GRAPHICS_BIT) && - !(queueFamily.queueFlags & VK_QUEUE_COMPUTE_BIT) - ) + if (queueFamily.queueCount > 0 && (queueFamily.queueFlags == VK_QUEUE_TRANSFER_BIT)) { copyFamily = familyIndex; - - if (queueFamily.queueFlags & VK_QUEUE_SPARSE_BINDING_BIT) - { - queues[QUEUE_COPY].sparse_binding_supported = true; - } + } + else if (queueFamily.queueCount > 0 && queueFamily.queueFlags == (VK_QUEUE_TRANSFER_BIT | VK_QUEUE_SPARSE_BINDING_BIT)) + { + copyFamily = familyIndex; + queues[QUEUE_COPY].sparse_binding_supported = true; } if (queueFamily.queueCount > 0 && @@ -2666,6 +2662,29 @@ using namespace vulkan_internal; familyIndex++; } + // If the above search found no transfer family, fall back to the less strict exclusivity criteria + if (copyFamily == VK_QUEUE_FAMILY_IGNORED) + { + familyIndex = 0; + for (const auto& queueFamily : queueFamilies) + { + if (queueFamily.queueCount > 0 && + queueFamily.queueFlags & VK_QUEUE_TRANSFER_BIT && + !(queueFamily.queueFlags & VK_QUEUE_GRAPHICS_BIT) && + !(queueFamily.queueFlags & VK_QUEUE_COMPUTE_BIT) + ) + { + copyFamily = familyIndex; + + if (queueFamily.queueFlags & VK_QUEUE_SPARSE_BINDING_BIT) + { + queues[QUEUE_COPY].sparse_binding_supported = true; + } + } + familyIndex++; + } + } + wi::vector queueCreateInfos; wi::unordered_set uniqueQueueFamilies = { graphicsFamily,copyFamily,computeFamily };