From bbe52934b63a7f4666b3fbca5d87e7a400a3e817 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 19 Apr 2024 14:02:16 +0200 Subject: [PATCH] radv: use radv_pipeline::sha1 for graphics/compute pipelines Signed-off-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/radv_pipeline_cache.c | 9 ++++----- src/amd/vulkan/radv_pipeline_cache.h | 5 ++--- src/amd/vulkan/radv_pipeline_compute.c | 10 ++++------ src/amd/vulkan/radv_pipeline_graphics.c | 11 +++++------ 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c index 326a519ea6a..85f9441f3cc 100644 --- a/src/amd/vulkan/radv_pipeline_cache.c +++ b/src/amd/vulkan/radv_pipeline_cache.c @@ -312,7 +312,7 @@ const struct vk_pipeline_cache_object_ops radv_pipeline_ops = { bool radv_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache *cache, struct radv_pipeline *pipeline, - const unsigned char *sha1, bool *found_in_application_cache) + bool *found_in_application_cache) { *found_in_application_cache = false; @@ -326,7 +326,7 @@ radv_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache } struct vk_pipeline_cache_object *object = - vk_pipeline_cache_lookup_object(cache, sha1, SHA1_DIGEST_LENGTH, &radv_pipeline_ops, found); + vk_pipeline_cache_lookup_object(cache, pipeline->sha1, SHA1_DIGEST_LENGTH, &radv_pipeline_ops, found); if (!object) return false; @@ -349,8 +349,7 @@ radv_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache } void -radv_pipeline_cache_insert(struct radv_device *device, struct vk_pipeline_cache *cache, struct radv_pipeline *pipeline, - const unsigned char *sha1) +radv_pipeline_cache_insert(struct radv_device *device, struct vk_pipeline_cache *cache, struct radv_pipeline *pipeline) { if (device->cache_disabled) return; @@ -365,7 +364,7 @@ radv_pipeline_cache_insert(struct radv_device *device, struct vk_pipeline_cache num_shaders += pipeline->gs_copy_shader ? 1 : 0; struct radv_pipeline_cache_object *pipeline_obj; - pipeline_obj = radv_pipeline_cache_object_create(&device->vk, num_shaders, sha1, 0); + pipeline_obj = radv_pipeline_cache_object_create(&device->vk, num_shaders, pipeline->sha1, 0); if (!pipeline_obj) return; diff --git a/src/amd/vulkan/radv_pipeline_cache.h b/src/amd/vulkan/radv_pipeline_cache.h index 1c9046004b2..87682bdbbad 100644 --- a/src/amd/vulkan/radv_pipeline_cache.h +++ b/src/amd/vulkan/radv_pipeline_cache.h @@ -44,11 +44,10 @@ struct radv_shader *radv_shader_create(struct radv_device *device, struct vk_pip const struct radv_shader_binary *binary, bool skip_cache); bool radv_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache *cache, - struct radv_pipeline *pipeline, const unsigned char *sha1, - bool *found_in_application_cache); + struct radv_pipeline *pipeline, bool *found_in_application_cache); void radv_pipeline_cache_insert(struct radv_device *device, struct vk_pipeline_cache *cache, - struct radv_pipeline *pipeline, const unsigned char *sha1); + struct radv_pipeline *pipeline); bool radv_ray_tracing_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache *cache, struct radv_ray_tracing_pipeline *pipeline, diff --git a/src/amd/vulkan/radv_pipeline_compute.c b/src/amd/vulkan/radv_pipeline_compute.c index ba94f46138c..a8b90686c65 100644 --- a/src/amd/vulkan/radv_pipeline_compute.c +++ b/src/amd/vulkan/radv_pipeline_compute.c @@ -220,7 +220,6 @@ radv_compute_pipeline_compile(const VkComputePipelineCreateInfo *pCreateInfo, st const VkPipelineCreationFeedbackCreateInfo *creation_feedback) { struct radv_shader_binary *cs_binary = NULL; - unsigned char hash[20]; 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); struct radv_shader_stage cs_stage = {0}; @@ -232,9 +231,9 @@ radv_compute_pipeline_compile(const VkComputePipelineCreateInfo *pCreateInfo, st int64_t pipeline_start = os_time_get_nano(); - radv_compute_pipeline_hash(device, pCreateInfo, hash); + radv_compute_pipeline_hash(device, pCreateInfo, pipeline->base.sha1); - pipeline->base.pipeline_hash = *(uint64_t *)hash; + 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 @@ -244,8 +243,7 @@ radv_compute_pipeline_compile(const VkComputePipelineCreateInfo *pCreateInfo, st } bool found_in_application_cache = true; - if (!skip_shaders_cache && - radv_pipeline_cache_search(device, cache, &pipeline->base, hash, &found_in_application_cache)) { + if (!skip_shaders_cache && radv_pipeline_cache_search(device, cache, &pipeline->base, &found_in_application_cache)) { if (found_in_application_cache) pipeline_feedback.flags |= VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT; result = VK_SUCCESS; @@ -268,7 +266,7 @@ radv_compute_pipeline_compile(const VkComputePipelineCreateInfo *pCreateInfo, st cs_stage.feedback.duration += os_time_get_nano() - stage_start; if (!skip_shaders_cache) { - radv_pipeline_cache_insert(device, cache, &pipeline->base, hash); + radv_pipeline_cache_insert(device, cache, &pipeline->base); } free(cs_binary); diff --git a/src/amd/vulkan/radv_pipeline_graphics.c b/src/amd/vulkan/radv_pipeline_graphics.c index 76fbbe60ea4..d19b7bde736 100644 --- a/src/amd/vulkan/radv_pipeline_graphics.c +++ b/src/amd/vulkan/radv_pipeline_graphics.c @@ -2616,7 +2616,6 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk { struct radv_shader_binary *binaries[MESA_VULKAN_SHADER_STAGES] = {NULL}; struct radv_shader_binary *gs_copy_binary = NULL; - unsigned char hash[20]; 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); struct radv_shader_stage stages[MESA_VULKAN_SHADER_STAGES]; @@ -2650,9 +2649,10 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk radv_pipeline_load_retained_shaders(device, pipeline, pCreateInfo, stages); if (radv_should_compute_pipeline_hash(device, pipeline, fast_linking_enabled)) { - radv_hash_shaders(device, hash, stages, MESA_VULKAN_SHADER_STAGES, pipeline_layout, &pipeline_key->gfx_state); + radv_hash_shaders(device, pipeline->base.sha1, stages, MESA_VULKAN_SHADER_STAGES, pipeline_layout, + &pipeline_key->gfx_state); - pipeline->base.pipeline_hash = *(uint64_t *)hash; + pipeline->base.pipeline_hash = *(uint64_t *)pipeline->base.sha1; } /* Skip the shaders cache when any of the below are true: @@ -2674,8 +2674,7 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk } bool found_in_application_cache = true; - if (!skip_shaders_cache && - radv_pipeline_cache_search(device, cache, &pipeline->base, hash, &found_in_application_cache)) { + if (!skip_shaders_cache && radv_pipeline_cache_search(device, cache, &pipeline->base, &found_in_application_cache)) { if (found_in_application_cache) pipeline_feedback.flags |= VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT; @@ -2718,7 +2717,7 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk pipeline->base.shaders, binaries, &pipeline->base.gs_copy_shader, &gs_copy_binary); if (!skip_shaders_cache) { - radv_pipeline_cache_insert(device, cache, &pipeline->base, hash); + radv_pipeline_cache_insert(device, cache, &pipeline->base); } free(gs_copy_binary);