From c5b7efa2938b2d3b9ed787d3d1d090ecad27c0d2 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 6 Jan 2023 09:01:12 +0100 Subject: [PATCH] radv: enable shaders cache for libraries with GPL This was the last missing feature for GPL. The main problem is that the on-disk shaders cache size will increase a lot because we don't deduplicate shaders but there is on-going work to improve that. We also can't use the shaders cache for libraries created with the RETAIN_LINK_TIME_OPTIMIZATION flag and module identifiers because we don't know the SPIR-V and thus can't retain NIR shaders for linking. Signed-off-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/radv_pipeline.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index 3ed4158..63b595f 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -3211,16 +3211,6 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, int64_t pipeline_start = os_time_get_nano(); - /* 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 - * - libraries are created with GPL - */ - if (fast_linking_enabled || keep_executable_info || - (pCreateInfo->flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR)) { - skip_shaders_cache = true; - } - for (unsigned i = 0; i < MESA_VULKAN_SHADER_STAGES; i++) { stages[i].entrypoint = NULL; stages[i].nir = NULL; @@ -3247,6 +3237,23 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, pipeline->base.pipeline_hash = *(uint64_t *)hash; } + /* 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 + * - 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) { + skip_shaders_cache = true; + } else if ((pCreateInfo->flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) && retain_shaders) { + for (uint32_t i = 0; i < MESA_VULKAN_SHADER_STAGES; i++) { + if (stages[i].entrypoint && !stages[i].spirv.size) { + skip_shaders_cache = true; + break; + } + } + } + bool found_in_application_cache = true; if (!skip_shaders_cache && radv_create_shaders_from_pipeline_cache(device, cache, hash, &pipeline->base, NULL, 0, -- 2.7.4