From f289e8eddc41a63924f327a8a292eb3fba488927 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Tue, 26 Aug 2025 20:13:23 +0200 Subject: [PATCH] radv: only expose permitted global queue priorities It's the responsability of the application to check for VK_ERROR_NOT_PERMITTED, but filtering not permitted priorities seems better. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13775 Signed-off-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/radv_physical_device.c | 26 +++++++++++++++++--------- src/amd/vulkan/radv_queue.c | 14 +------------- src/amd/vulkan/radv_queue.h | 17 +++++++++++++++++ 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/src/amd/vulkan/radv_physical_device.c b/src/amd/vulkan/radv_physical_device.c index f7eefcb4dc9..346c809bd14 100644 --- a/src/amd/vulkan/radv_physical_device.c +++ b/src/amd/vulkan/radv_physical_device.c @@ -2657,12 +2657,21 @@ radv_get_physical_device_queue_family_properties(struct radv_physical_device *pd *pCount = idx; } -static const VkQueueGlobalPriority radv_global_queue_priorities[] = { - VK_QUEUE_GLOBAL_PRIORITY_LOW, - VK_QUEUE_GLOBAL_PRIORITY_MEDIUM, - VK_QUEUE_GLOBAL_PRIORITY_HIGH, - VK_QUEUE_GLOBAL_PRIORITY_REALTIME, -}; +static void +radv_get_global_queue_priorities(struct radv_physical_device *pdev, VkQueueFamilyGlobalPriorityProperties *prop) +{ + struct radeon_winsys *ws = pdev->ws; + + prop->priorityCount = 0; + + for (uint32_t p = VK_QUEUE_GLOBAL_PRIORITY_LOW; p <= VK_QUEUE_GLOBAL_PRIORITY_REALTIME; p <<= 1) { + if (ws->ctx_is_priority_permitted(ws, vk_to_radeon_priority(p)) != VK_SUCCESS) + continue; + + prop->priorities[prop->priorityCount++] = p; + assert(prop->priorityCount < VK_MAX_GLOBAL_PRIORITY_SIZE); + } +} VKAPI_ATTR void VKAPI_CALL radv_GetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, uint32_t *pCount, @@ -2686,9 +2695,8 @@ radv_GetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, ui switch (ext->sType) { case VK_STRUCTURE_TYPE_QUEUE_FAMILY_GLOBAL_PRIORITY_PROPERTIES: { VkQueueFamilyGlobalPriorityProperties *prop = (VkQueueFamilyGlobalPriorityProperties *)ext; - STATIC_ASSERT(ARRAY_SIZE(radv_global_queue_priorities) <= VK_MAX_GLOBAL_PRIORITY_SIZE); - prop->priorityCount = ARRAY_SIZE(radv_global_queue_priorities); - memcpy(&prop->priorities, radv_global_queue_priorities, sizeof(radv_global_queue_priorities)); + + radv_get_global_queue_priorities(pdev, prop); break; } case VK_STRUCTURE_TYPE_QUEUE_FAMILY_QUERY_RESULT_STATUS_PROPERTIES_KHR: { diff --git a/src/amd/vulkan/radv_queue.c b/src/amd/vulkan/radv_queue.c index 9bf15bda2de..53360eb0f49 100644 --- a/src/amd/vulkan/radv_queue.c +++ b/src/amd/vulkan/radv_queue.c @@ -31,19 +31,7 @@ radv_get_queue_global_priority(const VkDeviceQueueGlobalPriorityCreateInfo *pObj if (!pObj) return RADEON_CTX_PRIORITY_MEDIUM; - switch (pObj->globalPriority) { - case VK_QUEUE_GLOBAL_PRIORITY_REALTIME: - return RADEON_CTX_PRIORITY_REALTIME; - case VK_QUEUE_GLOBAL_PRIORITY_HIGH: - return RADEON_CTX_PRIORITY_HIGH; - case VK_QUEUE_GLOBAL_PRIORITY_MEDIUM: - return RADEON_CTX_PRIORITY_MEDIUM; - case VK_QUEUE_GLOBAL_PRIORITY_LOW: - return RADEON_CTX_PRIORITY_LOW; - default: - UNREACHABLE("Illegal global priority value"); - return RADEON_CTX_PRIORITY_INVALID; - } + return vk_to_radeon_priority(pObj->globalPriority); } static VkResult diff --git a/src/amd/vulkan/radv_queue.h b/src/amd/vulkan/radv_queue.h index 2eb909aa843..df82c3761e7 100644 --- a/src/amd/vulkan/radv_queue.h +++ b/src/amd/vulkan/radv_queue.h @@ -117,4 +117,21 @@ enum amd_ip_type radv_queue_ring(const struct radv_queue *queue); enum amd_ip_type radv_queue_family_to_ring(const struct radv_physical_device *dev, enum radv_queue_family f); +static inline enum radeon_ctx_priority +vk_to_radeon_priority(VkQueueGlobalPriority priority) +{ + switch (priority) { + case VK_QUEUE_GLOBAL_PRIORITY_REALTIME: + return RADEON_CTX_PRIORITY_REALTIME; + case VK_QUEUE_GLOBAL_PRIORITY_HIGH: + return RADEON_CTX_PRIORITY_HIGH; + case VK_QUEUE_GLOBAL_PRIORITY_MEDIUM: + return RADEON_CTX_PRIORITY_MEDIUM; + case VK_QUEUE_GLOBAL_PRIORITY_LOW: + return RADEON_CTX_PRIORITY_LOW; + default: + return RADEON_CTX_PRIORITY_INVALID; + } +} + #endif /* RADV_QUEUE_H */