From 96a300a3f00c5deb6d299c6bd746798fe3ae3c84 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Mon, 2 Sep 2024 14:30:31 +0200 Subject: [PATCH] radv: add support for capturing pipeline binaries When VK_PIPELINE_CREATE_2_CAPTURE_DATA_BIT_KHR is set, implementations shouldn't store pipeline data to an internal cache. Signed-off-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/radv_pipeline_compute.c | 3 ++- src/amd/vulkan/radv_pipeline_graphics.c | 4 +++- src/amd/vulkan/radv_pipeline_rt.c | 9 ++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/amd/vulkan/radv_pipeline_compute.c b/src/amd/vulkan/radv_pipeline_compute.c index 4888b781722..6662aed672d 100644 --- a/src/amd/vulkan/radv_pipeline_compute.c +++ b/src/amd/vulkan/radv_pipeline_compute.c @@ -196,8 +196,9 @@ radv_compute_pipeline_compile(const VkComputePipelineCreateInfo *pCreateInfo, st /* Skip the shaders cache when any of the below are true: * - shaders are captured because it's for debugging purposes + * - binaries are captured for later uses */ - if (keep_executable_info) { + if (keep_executable_info || (pipeline->base.create_flags & VK_PIPELINE_CREATE_2_CAPTURE_DATA_BIT_KHR)) { skip_shaders_cache = true; } diff --git a/src/amd/vulkan/radv_pipeline_graphics.c b/src/amd/vulkan/radv_pipeline_graphics.c index 24fce9b93cb..a27e7fcfbfc 100644 --- a/src/amd/vulkan/radv_pipeline_graphics.c +++ b/src/amd/vulkan/radv_pipeline_graphics.c @@ -2908,10 +2908,12 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk /* Skip the shaders cache when any of the below are true: * - fast-linking is enabled because it's useless to cache unoptimized pipelines * - shaders are captured because it's for debugging purposes + * - binaries are captured for later uses * - graphics pipeline libraries are created with the RETAIN_LINK_TIME_OPTIMIZATION flag and * module identifiers are used (ie. no SPIR-V provided). */ - if (fast_linking_enabled || keep_executable_info) { + if (fast_linking_enabled || keep_executable_info || + (pipeline->base.create_flags & VK_PIPELINE_CREATE_2_CAPTURE_DATA_BIT_KHR)) { skip_shaders_cache = true; } else if (retain_shaders) { assert(pipeline->base.create_flags & VK_PIPELINE_CREATE_2_LIBRARY_BIT_KHR); diff --git a/src/amd/vulkan/radv_pipeline_rt.c b/src/amd/vulkan/radv_pipeline_rt.c index 9565d5ebc7e..06102148f88 100644 --- a/src/amd/vulkan/radv_pipeline_rt.c +++ b/src/amd/vulkan/radv_pipeline_rt.c @@ -622,9 +622,10 @@ radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *ca (library && !has_callable) || always_inlined || (monolithic && rt_stages[idx].stage != MESA_SHADER_RAYGEN); nir_needed &= !rt_stages[idx].nir; if (nir_needed) { + const bool cached = !stage->key.optimisations_disabled && + !(pipeline->base.base.create_flags & VK_PIPELINE_CREATE_2_CAPTURE_DATA_BIT_KHR); rt_stages[idx].stack_size = stage->nir->scratch_size; - rt_stages[idx].nir = radv_pipeline_cache_nir_to_handle(device, cache, stage->nir, rt_stages[idx].sha1, - !stage->key.optimisations_disabled); + rt_stages[idx].nir = radv_pipeline_cache_nir_to_handle(device, cache, stage->nir, rt_stages[idx].sha1, cached); } stage->feedback.duration += os_time_get_nano() - stage_start; @@ -890,9 +891,11 @@ radv_rt_pipeline_compile(struct radv_device *device, const VkRayTracingPipelineC /* Skip the shaders cache when any of the below are true: * - shaders are captured because it's for debugging purposes + * - binaries are captured for later uses * - ray history is enabled */ - if (keep_executable_info || emit_ray_history) { + if (keep_executable_info || emit_ray_history || + (pipeline->base.base.create_flags & VK_PIPELINE_CREATE_2_CAPTURE_DATA_BIT_KHR)) { skip_shaders_cache = true; }