diff --git a/src/asahi/vulkan/hk_physical_device.c b/src/asahi/vulkan/hk_physical_device.c index 59f6227c27c..a97c78297be 100644 --- a/src/asahi/vulkan/hk_physical_device.c +++ b/src/asahi/vulkan/hk_physical_device.c @@ -152,10 +152,8 @@ hk_get_device_extensions(const struct hk_instance *instance, .EXT_extended_dynamic_state2 = true, .EXT_extended_dynamic_state3 = true, .EXT_external_memory_dma_buf = true, - // TODO - .EXT_global_priority = false, - // TODO - .EXT_global_priority_query = false, + .EXT_global_priority = true, + .EXT_global_priority_query = true, .EXT_graphics_pipeline_library = true, .EXT_host_query_reset = true, .EXT_host_image_copy = true, @@ -1347,6 +1345,13 @@ hk_GetPhysicalDeviceMemoryProperties2( } } +static const VkQueueGlobalPriorityKHR hk_global_queue_priorities[] = { + VK_QUEUE_GLOBAL_PRIORITY_LOW_KHR, + VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR, + VK_QUEUE_GLOBAL_PRIORITY_HIGH_KHR, + VK_QUEUE_GLOBAL_PRIORITY_REALTIME_KHR, +}; + VKAPI_ATTR void VKAPI_CALL hk_GetPhysicalDeviceQueueFamilyProperties2( VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, @@ -1367,19 +1372,14 @@ hk_GetPhysicalDeviceQueueFamilyProperties2( p->queueFamilyProperties.minImageTransferGranularity = (VkExtent3D){1, 1, 1}; - vk_foreach_struct(ext, p->pNext) { - switch (ext->sType) { - case VK_STRUCTURE_TYPE_QUEUE_FAMILY_GLOBAL_PRIORITY_PROPERTIES_KHR: { - VkQueueFamilyGlobalPriorityPropertiesKHR *props = (void *)ext; - - /* TODO: support multiple priorities */ - props->priorityCount = 1; - props->priorities[0] = VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT; - break; - } - default: - break; - } + VkQueueFamilyGlobalPriorityPropertiesKHR *prio = vk_find_struct( + p->pNext, QUEUE_FAMILY_GLOBAL_PRIORITY_PROPERTIES_KHR); + if (prio) { + STATIC_ASSERT(ARRAY_SIZE(hk_global_queue_priorities) <= + VK_MAX_GLOBAL_PRIORITY_SIZE_KHR); + prio->priorityCount = ARRAY_SIZE(hk_global_queue_priorities); + memcpy(&prio->priorities, hk_global_queue_priorities, + sizeof(hk_global_queue_priorities)); } } } diff --git a/src/asahi/vulkan/hk_queue.c b/src/asahi/vulkan/hk_queue.c index e18af2c401c..7922e6e0109 100644 --- a/src/asahi/vulkan/hk_queue.c +++ b/src/asahi/vulkan/hk_queue.c @@ -539,6 +539,20 @@ hk_queue_submit(struct vk_queue *vk_queue, struct vk_queue_submit *submit) return VK_SUCCESS; } +static uint32_t +translate_priority(enum VkQueueGlobalPriorityKHR prio) +{ + /* clang-format off */ + switch (prio) { + case VK_QUEUE_GLOBAL_PRIORITY_REALTIME_KHR: return 0; + case VK_QUEUE_GLOBAL_PRIORITY_HIGH_KHR: return 1; + case VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR: return 2; + case VK_QUEUE_GLOBAL_PRIORITY_LOW_KHR: return 3; + default: unreachable("Invalid VkQueueGlobalPriorityKHR"); + } + /* clang-format on */ +} + VkResult hk_queue_init(struct hk_device *dev, struct hk_queue *queue, const VkDeviceQueueCreateInfo *pCreateInfo, @@ -552,14 +566,10 @@ hk_queue_init(struct hk_device *dev, struct hk_queue *queue, const VkDeviceQueueGlobalPriorityCreateInfoKHR *priority_info = vk_find_struct_const(pCreateInfo->pNext, DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_KHR); - const enum VkQueueGlobalPriorityKHR global_priority = + const enum VkQueueGlobalPriorityKHR priority = priority_info ? priority_info->globalPriority : VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR; - if (global_priority != VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR) { - return VK_ERROR_INITIALIZATION_FAILED; - } - result = vk_queue_init(&queue->vk, &dev->vk, pCreateInfo, index_in_family); if (result != VK_SUCCESS) return result; @@ -570,7 +580,7 @@ hk_queue_init(struct hk_device *dev, struct hk_queue *queue, DRM_ASAHI_QUEUE_CAP_RENDER | DRM_ASAHI_QUEUE_CAP_BLIT | DRM_ASAHI_QUEUE_CAP_COMPUTE, - 2); + translate_priority(priority)); if (drmSyncobjCreate(dev->dev.fd, 0, &queue->drm.syncobj)) { mesa_loge("drmSyncobjCreate() failed %d\n", errno);