nvk: No-op implement VK_KHR_global_priority

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32433>
This commit is contained in:
Faith Ekstrand 2024-09-13 10:58:59 -05:00 committed by Marge Bot
parent 0819e04f21
commit f9e993dfaf
3 changed files with 52 additions and 0 deletions

View file

@ -122,6 +122,7 @@ nvk_get_device_extensions(const struct nvk_instance *instance,
(nvk_nak_stages(info) & VK_SHADER_STAGE_FRAGMENT_BIT) != 0,
.KHR_fragment_shading_rate = info->cls_eng3d >= TURING_A,
.KHR_get_memory_requirements2 = true,
.KHR_global_priority = true,
.KHR_image_format_list = true,
.KHR_imageless_framebuffer = true,
#ifdef NVK_USE_WSI_PLATFORM
@ -218,6 +219,8 @@ nvk_get_device_extensions(const struct nvk_instance *instance,
.EXT_extended_dynamic_state2 = true,
.EXT_extended_dynamic_state3 = true,
.EXT_external_memory_dma_buf = true,
.EXT_global_priority = true,
.EXT_global_priority_query = true,
.EXT_graphics_pipeline_library = true,
.EXT_host_query_reset = true,
.EXT_host_image_copy = info->cls_eng3d >= TURING_A,
@ -443,6 +446,9 @@ nvk_get_device_features(const struct nv_device_info *info,
.primitiveFragmentShadingRate = info->cls_eng3d >= TURING_A,
.attachmentFragmentShadingRate = info->cls_eng3d >= TURING_A,
/* VK_KHR_global_priority */
.globalPriorityQuery = true,
/* VK_KHR_index_type_uint8 */
.indexTypeUint8 = true,
@ -1618,6 +1624,21 @@ nvk_GetPhysicalDeviceQueueFamilyProperties2(
p->queueFamilyProperties.timestampValidBits = 64;
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: {
VkQueueFamilyGlobalPriorityProperties *p = (void *)ext;
p->priorityCount = 1;
p->priorities[0] = VK_QUEUE_GLOBAL_PRIORITY_MEDIUM;
break;
}
default:
vk_debug_ignored_stype(ext->sType);
break;
}
}
}
}
}

View file

@ -25,6 +25,7 @@ struct nvkmd_pdev;
struct nvk_queue_family {
VkQueueFlags queue_flags;
uint32_t queue_count;
VkQueueGlobalPriority max_priority;
};
struct nvk_memory_heap {

View file

@ -469,6 +469,18 @@ nvk_queue_init_context_state(struct nvk_queue *queue)
return nvk_queue_submit_simple(queue, nv_push_dw_count(&push), push_data);
}
static VkQueueGlobalPriority
get_queue_global_priority(const VkDeviceQueueCreateInfo *pCreateInfo)
{
const VkDeviceQueueGlobalPriorityCreateInfo *priority_info =
vk_find_struct_const(pCreateInfo->pNext,
DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO);
if (priority_info == NULL)
return VK_QUEUE_GLOBAL_PRIORITY_MEDIUM;
return priority_info->globalPriority;
}
VkResult
nvk_queue_init(struct nvk_device *dev, struct nvk_queue *queue,
const VkDeviceQueueCreateInfo *pCreateInfo,
@ -481,6 +493,24 @@ nvk_queue_init(struct nvk_device *dev, struct nvk_queue *queue,
const struct nvk_queue_family *queue_family =
&pdev->queue_families[pCreateInfo->queueFamilyIndex];
const VkQueueGlobalPriority global_priority =
get_queue_global_priority(pCreateInfo);
/* From the Vulkan 1.3.295 spec:
*
* "If the globalPriorityQuery feature is enabled and the requested
* global priority is not reported via
* VkQueueFamilyGlobalPriorityPropertiesKHR, the driver implementation
* must fail the queue creation. In this scenario,
* VK_ERROR_INITIALIZATION_FAILED is returned."
*/
if (dev->vk.enabled_features.globalPriorityQuery &&
global_priority != VK_QUEUE_GLOBAL_PRIORITY_MEDIUM)
return VK_ERROR_INITIALIZATION_FAILED;
if (global_priority > VK_QUEUE_GLOBAL_PRIORITY_MEDIUM)
return VK_ERROR_NOT_PERMITTED;
result = vk_queue_init(&queue->vk, &dev->vk, pCreateInfo, index_in_family);
if (result != VK_SUCCESS)
return result;