Module: Mesa
Branch: main
Commit: c809c05f4f58679a7349d3583e78fc72352c3854
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c809c05f4f58679a7349d3583e78fc72352c3854

Author: Friedrich Vock <[email protected]>
Date:   Mon Mar 13 21:16:47 2023 +0100

radv: Hash pipeline libraries separately

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22686>

---

 src/amd/vulkan/radv_pipeline_cache.c | 8 ++++++++
 src/amd/vulkan/radv_pipeline_rt.c    | 9 ++++++++-
 src/amd/vulkan/radv_private.h        | 1 +
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/amd/vulkan/radv_pipeline_cache.c 
b/src/amd/vulkan/radv_pipeline_cache.c
index 8ae1494fc5a..dceed6ae349 100644
--- a/src/amd/vulkan/radv_pipeline_cache.c
+++ b/src/amd/vulkan/radv_pipeline_cache.c
@@ -107,6 +107,14 @@ radv_hash_rt_shaders(unsigned char *hash, const 
VkRayTracingPipelineCreateInfoKH
       _mesa_sha1_update(&ctx, &groups[i].handle, sizeof(struct 
radv_pipeline_group_handle));
    }
 
+   if (pCreateInfo->pLibraryInfo) {
+      for (uint32_t i = 0; i < pCreateInfo->pLibraryInfo->libraryCount; ++i) {
+         RADV_FROM_HANDLE(radv_pipeline, lib_pipeline, 
pCreateInfo->pLibraryInfo->pLibraries[i]);
+         struct radv_ray_tracing_lib_pipeline *lib = 
radv_pipeline_to_ray_tracing_lib(lib_pipeline);
+         _mesa_sha1_update(&ctx, lib->sha1, SHA1_DIGEST_LENGTH);
+      }
+   }
+
    const uint32_t pipeline_flags =
       pCreateInfo->flags & 
(VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR |
                             VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR |
diff --git a/src/amd/vulkan/radv_pipeline_rt.c 
b/src/amd/vulkan/radv_pipeline_rt.c
index 2bc06c9198f..f9d13274d23 100644
--- a/src/amd/vulkan/radv_pipeline_rt.c
+++ b/src/amd/vulkan/radv_pipeline_rt.c
@@ -374,6 +374,7 @@ radv_rt_pipeline_library_create(VkDevice _device, 
VkPipelineCache _cache,
    RADV_FROM_HANDLE(radv_device, device, _device);
    struct radv_ray_tracing_lib_pipeline *pipeline;
    VkResult result = VK_SUCCESS;
+   bool keep_statistic_info = radv_pipeline_capture_shader_stats(device, 
pCreateInfo->flags);
 
    VkRayTracingPipelineCreateInfoKHR local_create_info =
       radv_create_merged_rt_create_info(pCreateInfo);
@@ -391,6 +392,9 @@ radv_rt_pipeline_library_create(VkDevice _device, 
VkPipelineCache _cache,
 
    radv_pipeline_init(device, &pipeline->base, RADV_PIPELINE_RAY_TRACING_LIB);
 
+   struct radv_pipeline_key key =
+      radv_generate_pipeline_key(device, &pipeline->base, pCreateInfo->flags);
+
    pipeline->ctx = ralloc_context(NULL);
 
    result = radv_rt_fill_group_info(device, pCreateInfo, pipeline->groups);
@@ -419,6 +423,9 @@ radv_rt_pipeline_library_create(VkDevice _device, 
VkPipelineCache _cache,
       memcpy(pipeline->group_infos, local_create_info.pGroups, size);
    }
 
+   radv_hash_rt_shaders(pipeline->sha1, pCreateInfo, &key, pipeline->groups,
+                        radv_get_hash_flags(device, keep_statistic_info));
+
    *pPipeline = radv_pipeline_to_handle(&pipeline->base);
 
 pipeline_fail:
@@ -608,7 +615,7 @@ radv_rt_pipeline_create(VkDevice _device, VkPipelineCache 
_cache,
 
    struct radv_pipeline_key key = radv_generate_rt_pipeline_key(device, 
rt_pipeline, pCreateInfo->flags);
 
-   radv_hash_rt_shaders(hash, &local_create_info, &key, rt_pipeline->groups,
+   radv_hash_rt_shaders(hash, pCreateInfo, &key, rt_pipeline->groups,
                         radv_get_hash_flags(device, keep_statistic_info));
 
    /* First check if we can get things from the cache before we take the 
expensive step of
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 35c2296a4fd..91a20bf4f73 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -2303,6 +2303,7 @@ struct radv_ray_tracing_lib_pipeline {
    VkPipelineShaderStageCreateInfo *stages;
    unsigned group_count;
    VkRayTracingShaderGroupCreateInfoKHR *group_infos;
+   uint8_t sha1[SHA1_DIGEST_LENGTH];
    struct radv_ray_tracing_group groups[];
 };
 

Reply via email to