diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index 4b18c5581b6..dffd99570ae 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -70,6 +70,18 @@ radv_pipeline_capture_shader_stats(const struct radv_device *device, VkPipelineC (instance->vk.trace_mode & RADV_TRACE_MODE_RGP); } +bool +radv_pipeline_skip_shaders_cache(const struct radv_device *device, const struct radv_pipeline *pipeline) +{ + const bool keep_executable_info = radv_pipeline_capture_shaders(device, pipeline->create_flags); + + /* 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 + */ + return keep_executable_info || (pipeline->create_flags & VK_PIPELINE_CREATE_2_CAPTURE_DATA_BIT_KHR); +} + void radv_pipeline_init(struct radv_device *device, struct radv_pipeline *pipeline, enum radv_pipeline_type type) { diff --git a/src/amd/vulkan/radv_pipeline.h b/src/amd/vulkan/radv_pipeline.h index 10f79e95a4b..84f66d31a85 100644 --- a/src/amd/vulkan/radv_pipeline.h +++ b/src/amd/vulkan/radv_pipeline.h @@ -76,6 +76,8 @@ bool radv_shader_need_indirect_descriptor_sets(const struct radv_shader *shader) bool radv_pipeline_capture_shader_stats(const struct radv_device *device, VkPipelineCreateFlags2KHR flags); +bool radv_pipeline_skip_shaders_cache(const struct radv_device *device, const struct radv_pipeline *pipeline); + void radv_pipeline_init(struct radv_device *device, struct radv_pipeline *pipeline, enum radv_pipeline_type type); void radv_pipeline_destroy(struct radv_device *device, struct radv_pipeline *pipeline, diff --git a/src/amd/vulkan/radv_pipeline_compute.c b/src/amd/vulkan/radv_pipeline_compute.c index 44f02f9cbbe..1f2067b7c15 100644 --- a/src/amd/vulkan/radv_pipeline_compute.c +++ b/src/amd/vulkan/radv_pipeline_compute.c @@ -183,11 +183,11 @@ radv_compute_pipeline_compile(const VkComputePipelineCreateInfo *pCreateInfo, st struct radv_shader_binary *cs_binary = NULL; bool keep_executable_info = radv_pipeline_capture_shaders(device, pipeline->base.create_flags); bool keep_statistic_info = radv_pipeline_capture_shader_stats(device, pipeline->base.create_flags); + const bool skip_shaders_cache = radv_pipeline_skip_shaders_cache(device, &pipeline->base); struct radv_shader_stage cs_stage = {0}; VkPipelineCreationFeedback pipeline_feedback = { .flags = VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT, }; - bool skip_shaders_cache = false; VkResult result = VK_SUCCESS; int64_t pipeline_start = os_time_get_nano(); @@ -196,14 +196,6 @@ radv_compute_pipeline_compile(const VkComputePipelineCreateInfo *pCreateInfo, st pipeline->base.pipeline_hash = *(uint64_t *)pipeline->base.sha1; - /* 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 || (pipeline->base.create_flags & VK_PIPELINE_CREATE_2_CAPTURE_DATA_BIT_KHR)) { - skip_shaders_cache = true; - } - bool found_in_application_cache = true; if (!skip_shaders_cache && radv_compute_pipeline_cache_search(device, cache, pipeline, &found_in_application_cache)) { diff --git a/src/amd/vulkan/radv_pipeline_graphics.c b/src/amd/vulkan/radv_pipeline_graphics.c index d76dae3c653..a845a5e4ae1 100644 --- a/src/amd/vulkan/radv_pipeline_graphics.c +++ b/src/amd/vulkan/radv_pipeline_graphics.c @@ -2914,13 +2914,13 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk struct radv_shader_binary *gs_copy_binary = NULL; bool keep_executable_info = radv_pipeline_capture_shaders(device, pipeline->base.create_flags); bool keep_statistic_info = radv_pipeline_capture_shader_stats(device, pipeline->base.create_flags); + bool skip_shaders_cache = radv_pipeline_skip_shaders_cache(device, &pipeline->base); struct radv_shader_stage *stages = gfx_state->stages; const VkPipelineCreationFeedbackCreateInfo *creation_feedback = vk_find_struct_const(pCreateInfo->pNext, PIPELINE_CREATION_FEEDBACK_CREATE_INFO); VkPipelineCreationFeedback pipeline_feedback = { .flags = VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT, }; - bool skip_shaders_cache = false; VkResult result = VK_SUCCESS; const bool retain_shaders = !!(pipeline->base.create_flags & VK_PIPELINE_CREATE_2_RETAIN_LINK_TIME_OPTIMIZATION_INFO_BIT_EXT); @@ -2936,13 +2936,10 @@ 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 || - (pipeline->base.create_flags & VK_PIPELINE_CREATE_2_CAPTURE_DATA_BIT_KHR)) { + if (fast_linking_enabled) { 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 97ccfcf2ce4..30beaea30a3 100644 --- a/src/amd/vulkan/radv_pipeline_rt.c +++ b/src/amd/vulkan/radv_pipeline_rt.c @@ -909,12 +909,11 @@ radv_rt_pipeline_compile(struct radv_device *device, const VkRayTracingPipelineC struct radv_serialized_shader_arena_block *capture_replay_blocks, const VkPipelineCreationFeedbackCreateInfo *creation_feedback) { - const bool keep_executable_info = radv_pipeline_capture_shaders(device, pipeline->base.base.create_flags); + bool skip_shaders_cache = radv_pipeline_skip_shaders_cache(device, &pipeline->base.base); const bool emit_ray_history = !!device->rra_trace.ray_history_buffer; VkPipelineCreationFeedback pipeline_feedback = { .flags = VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT, }; - bool skip_shaders_cache = false; VkResult result = VK_SUCCESS; int64_t pipeline_start = os_time_get_nano(); @@ -923,15 +922,11 @@ radv_rt_pipeline_compile(struct radv_device *device, const VkRayTracingPipelineC pipeline->base.base.pipeline_hash = *(uint64_t *)pipeline->base.base.sha1; /* 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 * - group handles are saved and reused on a subsequent run (ie. capture/replay) */ - if (keep_executable_info || emit_ray_history || - (pipeline->base.base.create_flags & - (VK_PIPELINE_CREATE_2_CAPTURE_DATA_BIT_KHR | - VK_PIPELINE_CREATE_2_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR))) { + if (emit_ray_history || (pipeline->base.base.create_flags & + VK_PIPELINE_CREATE_2_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) { skip_shaders_cache = true; }