From ed768337050e663691ee66b08c6061f7b41430f4 Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen Date: Sat, 18 Feb 2023 16:16:27 +0100 Subject: [PATCH] radv: Implement & expose VK_EXT_pipeline_library_group_handles. Part-of: --- docs/features.txt | 1 + docs/relnotes/new_features.txt | 1 + src/amd/vulkan/radv_device.c | 7 +++++++ src/amd/vulkan/radv_pipeline.c | 1 + src/amd/vulkan/radv_pipeline_rt.c | 18 ++++++++++++++---- src/amd/vulkan/radv_private.h | 2 ++ 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/docs/features.txt b/docs/features.txt index 5cecd442bb8..c0cdbe4c02e 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -572,6 +572,7 @@ Khronos extensions that are not part of any Vulkan version: VK_EXT_non_seamless_cube_map DONE (anv, lvp, radv, tu) VK_EXT_pci_bus_info DONE (anv, radv, vn) VK_EXT_physical_device_drm DONE (anv, radv, tu, v3dv, vn) + VK_EXT_pipeline_library_group_handles DONE (radv) VK_EXT_pipeline_robustness DONE (v3dv) VK_EXT_post_depth_coverage DONE (anv/gfx10+, lvp, radv/gfx10+) VK_EXT_primitive_topology_list_restart DONE (anv, lvp, radv, tu, v3dv, vn) diff --git a/docs/relnotes/new_features.txt b/docs/relnotes/new_features.txt index e69de29bb2d..a4539452674 100644 --- a/docs/relnotes/new_features.txt +++ b/docs/relnotes/new_features.txt @@ -0,0 +1 @@ +VK_EXT_pipeline_library_group_handles on RADV diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 1f4a12299c1..4d79a13b457 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -630,6 +630,7 @@ radv_physical_device_get_supported_extensions(const struct radv_physical_device #endif .EXT_pipeline_creation_cache_control = true, .EXT_pipeline_creation_feedback = true, + .EXT_pipeline_library_group_handles = true, .EXT_post_depth_coverage = device->rad_info.gfx_level >= GFX10, .EXT_primitive_topology_list_restart = true, .EXT_primitives_generated_query = true, @@ -1810,6 +1811,12 @@ radv_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, features->rayQuery = true; break; } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_LIBRARY_GROUP_HANDLES_FEATURES_EXT: { + VkPhysicalDevicePipelineLibraryGroupHandlesFeaturesEXT *features = + (VkPhysicalDevicePipelineLibraryGroupHandlesFeaturesEXT *)ext; + features->pipelineLibraryGroupHandles = true; + break; + } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR: { VkPhysicalDeviceRayTracingPipelineFeaturesKHR *features = (VkPhysicalDeviceRayTracingPipelineFeaturesKHR *)ext; diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index af2b2af1cd8..0189e5164bc 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -142,6 +142,7 @@ radv_pipeline_destroy(struct radv_device *device, struct radv_pipeline *pipeline struct radv_library_pipeline *library_pipeline = radv_pipeline_to_library(pipeline); ralloc_free(library_pipeline->ctx); + free(library_pipeline->group_handles); } else if (pipeline->type == RADV_PIPELINE_GRAPHICS_LIB) { struct radv_graphics_lib_pipeline *gfx_pipeline_lib = radv_pipeline_to_graphics_lib(pipeline); diff --git a/src/amd/vulkan/radv_pipeline_rt.c b/src/amd/vulkan/radv_pipeline_rt.c index 19db7f69198..599a7430d74 100644 --- a/src/amd/vulkan/radv_pipeline_rt.c +++ b/src/amd/vulkan/radv_pipeline_rt.c @@ -227,6 +227,11 @@ radv_rt_pipeline_library_create(VkDevice _device, VkPipelineCache _cache, if (!local_create_info.pStages || !local_create_info.pGroups) goto fail; + VkResult result = + radv_create_group_handles(device, &local_create_info, &pipeline->group_handles); + if (result != VK_SUCCESS) + goto fail; + if (local_create_info.stageCount) { pipeline->stage_count = local_create_info.stageCount; @@ -326,6 +331,7 @@ radv_rt_pipeline_library_create(VkDevice _device, VkPipelineCache _cache, free((void *)local_create_info.pStages); return VK_SUCCESS; fail: + free(pipeline->groups); ralloc_free(pipeline->ctx); free((void *)local_create_info.pGroups); free((void *)local_create_info.pStages); @@ -567,16 +573,20 @@ radv_GetRayTracingShaderGroupHandlesKHR(VkDevice device, VkPipeline _pipeline, u uint32_t groupCount, size_t dataSize, void *pData) { RADV_FROM_HANDLE(radv_pipeline, pipeline, _pipeline); - struct radv_ray_tracing_pipeline *rt_pipeline = radv_pipeline_to_ray_tracing(pipeline); + struct radv_pipeline_group_handle *handles; + if (pipeline->type == RADV_PIPELINE_LIBRARY) { + handles = radv_pipeline_to_library(pipeline)->group_handles; + } else { + handles = radv_pipeline_to_ray_tracing(pipeline)->group_handles; + } char *data = pData; - STATIC_ASSERT(sizeof(*rt_pipeline->group_handles) <= RADV_RT_HANDLE_SIZE); + STATIC_ASSERT(sizeof(*handles) <= RADV_RT_HANDLE_SIZE); memset(data, 0, groupCount * RADV_RT_HANDLE_SIZE); for (uint32_t i = 0; i < groupCount; ++i) { - memcpy(data + i * RADV_RT_HANDLE_SIZE, &rt_pipeline->group_handles[firstGroup + i], - sizeof(*rt_pipeline->group_handles)); + memcpy(data + i * RADV_RT_HANDLE_SIZE, &handles[firstGroup + i], sizeof(*handles)); } return VK_SUCCESS; diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index f0816afe1d8..56a37cc9a2d 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -2215,6 +2215,8 @@ struct radv_library_pipeline { struct { uint8_t sha1[SHA1_DIGEST_LENGTH]; } *hashes; + + struct radv_pipeline_group_handle *group_handles; }; struct radv_graphics_lib_pipeline {