From 32d04bcdcd279554e719f80565cd61f93a741373 Mon Sep 17 00:00:00 2001 From: Julia Zhang Date: Tue, 24 Mar 2026 16:15:02 +0800 Subject: [PATCH] vulkan: return pQueue with matching flags Searching device->queues only according to queueIndex and queueFamilyIndex could cause this issue: if there are two queues A and B created with same queueIndex and queueFamilyIndex but different flags. When user try to get B but vk_foreach_queue loop return A when it get A and find it have the request queueIndex and queueFamilyIndex. So this add a check of queue flags and return the queue with matching flags, queueIndex and queueFamilyIndex. Signed-off-by: Julia Zhang Part-of: --- src/vulkan/runtime/vk_device.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/vulkan/runtime/vk_device.c b/src/vulkan/runtime/vk_device.c index a1ac002241b..bf8dc38d003 100644 --- a/src/vulkan/runtime/vk_device.c +++ b/src/vulkan/runtime/vk_device.c @@ -471,15 +471,6 @@ vk_common_GetDeviceQueue2(VkDevice _device, { VK_FROM_HANDLE(vk_device, device, _device); - struct vk_queue *queue = NULL; - vk_foreach_queue(iter, device) { - if (iter->queue_family_index == pQueueInfo->queueFamilyIndex && - iter->index_in_family == pQueueInfo->queueIndex) { - queue = iter; - break; - } - } - /* From the Vulkan 1.1.70 spec: * * "The queue returned by vkGetDeviceQueue2 must have the same flags @@ -487,10 +478,17 @@ vk_common_GetDeviceQueue2(VkDevice _device, * VkDeviceQueueCreateInfo instance. If no matching flags were specified * at device creation time then pQueue will return VK_NULL_HANDLE." */ - if (queue && queue->flags == pQueueInfo->flags) - *pQueue = vk_queue_to_handle(queue); - else - *pQueue = VK_NULL_HANDLE; + struct vk_queue *queue = NULL; + vk_foreach_queue(iter, device) { + if (iter->queue_family_index == pQueueInfo->queueFamilyIndex && + iter->index_in_family == pQueueInfo->queueIndex && + iter->flags == pQueueInfo->flags) { + queue = iter; + break; + } + } + + *pQueue = queue ? vk_queue_to_handle(queue) : VK_NULL_HANDLE; } VKAPI_ATTR VkResult VKAPI_CALL