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

Author: Samuel Pitoiset <samuel.pitoi...@gmail.com>
Date:   Fri Jan 12 12:01:51 2024 +0100

radv/rt: re-use radv_ray_tracing_stage::sha1 for hashing RT pipelines

radv_ray_tracing_stage::sha1 is radv_pipeline_key+shader_sha1 which
should be similar to what the code was doing.

Signed-off-by: Samuel Pitoiset <samuel.pitoi...@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27030>

---

 src/amd/vulkan/radv_pipeline_cache.c | 21 +++++----------------
 src/amd/vulkan/radv_pipeline_rt.c    |  2 +-
 src/amd/vulkan/radv_private.h        |  6 +++---
 3 files changed, 9 insertions(+), 20 deletions(-)

diff --git a/src/amd/vulkan/radv_pipeline_cache.c 
b/src/amd/vulkan/radv_pipeline_cache.c
index fc357ad9058..98a69505965 100644
--- a/src/amd/vulkan/radv_pipeline_cache.c
+++ b/src/amd/vulkan/radv_pipeline_cache.c
@@ -68,19 +68,8 @@ radv_hash_shaders(const struct radv_device *device, unsigned 
char *hash, const s
 }
 
 void
-radv_hash_rt_stages(struct mesa_sha1 *ctx, const 
VkPipelineShaderStageCreateInfo *stages, unsigned stage_count)
-{
-   for (unsigned i = 0; i < stage_count; ++i) {
-      unsigned char hash[20];
-      vk_pipeline_hash_shader_stage(&stages[i], NULL, hash);
-      _mesa_sha1_update(ctx, hash, sizeof(hash));
-   }
-}
-
-void
-radv_hash_rt_shaders(const struct radv_device *device, unsigned char *hash,
-                     const VkRayTracingPipelineCreateInfoKHR *pCreateInfo, 
const struct radv_pipeline_key *key,
-                     const struct radv_ray_tracing_group *groups)
+radv_hash_rt_shaders(const struct radv_device *device, unsigned char *hash, 
const struct radv_ray_tracing_stage *stages,
+                     const VkRayTracingPipelineCreateInfoKHR *pCreateInfo, 
const struct radv_ray_tracing_group *groups)
 {
    RADV_FROM_HANDLE(radv_pipeline_layout, layout, pCreateInfo->layout);
    struct mesa_sha1 ctx;
@@ -90,9 +79,9 @@ radv_hash_rt_shaders(const struct radv_device *device, 
unsigned char *hash,
    if (layout)
       _mesa_sha1_update(&ctx, layout->sha1, sizeof(layout->sha1));
 
-   _mesa_sha1_update(&ctx, key, sizeof(*key));
-
-   radv_hash_rt_stages(&ctx, pCreateInfo->pStages, pCreateInfo->stageCount);
+   for (uint32_t i = 0; i < pCreateInfo->stageCount; i++) {
+      _mesa_sha1_update(&ctx, stages[i].sha1, sizeof(stages[i].sha1));
+   }
 
    for (uint32_t i = 0; i < pCreateInfo->groupCount; i++) {
       _mesa_sha1_update(&ctx, &pCreateInfo->pGroups[i].type, 
sizeof(pCreateInfo->pGroups[i].type));
diff --git a/src/amd/vulkan/radv_pipeline_rt.c 
b/src/amd/vulkan/radv_pipeline_rt.c
index 5675977cffa..44f15b442d2 100644
--- a/src/amd/vulkan/radv_pipeline_rt.c
+++ b/src/amd/vulkan/radv_pipeline_rt.c
@@ -788,7 +788,7 @@ radv_rt_pipeline_create(VkDevice _device, VkPipelineCache 
_cache, const VkRayTra
 
    bool keep_executable_info = radv_pipeline_capture_shaders(device, 
pipeline->base.base.create_flags);
 
-   radv_hash_rt_shaders(device, pipeline->sha1, pCreateInfo, &key, 
pipeline->groups);
+   radv_hash_rt_shaders(device, pipeline->sha1, stages, pCreateInfo, 
pipeline->groups);
    pipeline->base.base.pipeline_hash = *(uint64_t *)pipeline->sha1;
 
    bool cache_hit = false;
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 9f08b2abbd9..814c1ec1867 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -2015,10 +2015,10 @@ void radv_hash_shaders(const struct radv_device 
*device, unsigned char *hash, co
                        uint32_t stage_count, const struct radv_pipeline_layout 
*layout,
                        const struct radv_pipeline_key *key);
 
-void radv_hash_rt_stages(struct mesa_sha1 *ctx, const 
VkPipelineShaderStageCreateInfo *stages, unsigned stage_count);
-
+struct radv_ray_tracing_stage;
 void radv_hash_rt_shaders(const struct radv_device *device, unsigned char 
*hash,
-                          const VkRayTracingPipelineCreateInfoKHR 
*pCreateInfo, const struct radv_pipeline_key *key,
+                          const struct radv_ray_tracing_stage *stages,
+                          const VkRayTracingPipelineCreateInfoKHR *pCreateInfo,
                           const struct radv_ray_tracing_group *groups);
 
 bool radv_enable_rt(const struct radv_physical_device *pdevice, bool 
rt_pipelines);

Reply via email to