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

Author: Bas Nieuwenhuizen <[email protected]>
Date:   Sat Feb 18 23:32:30 2023 +0100

radv: Add helper to hash stages.

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

---

 src/amd/vulkan/radv_pipeline_cache.c | 50 ++++++++++++++++++++----------------
 src/amd/vulkan/radv_private.h        |  3 +++
 2 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/src/amd/vulkan/radv_pipeline_cache.c 
b/src/amd/vulkan/radv_pipeline_cache.c
index dba7143546b..d3c125ca8cc 100644
--- a/src/amd/vulkan/radv_pipeline_cache.c
+++ b/src/amd/vulkan/radv_pipeline_cache.c
@@ -148,41 +148,47 @@ radv_hash_shaders(unsigned char *hash, const struct 
radv_pipeline_stage *stages,
 }
 
 void
-radv_hash_rt_shaders(unsigned char *hash, const 
VkRayTracingPipelineCreateInfoKHR *pCreateInfo,
-                     const struct radv_pipeline_key *key, uint32_t flags)
+radv_hash_rt_stages(struct mesa_sha1 *ctx, const 
VkPipelineShaderStageCreateInfo *stages,
+                    unsigned stage_count)
 {
-   RADV_FROM_HANDLE(radv_pipeline_layout, layout, pCreateInfo->layout);
-   struct mesa_sha1 ctx;
+   for (unsigned i = 0; i < stage_count; ++i) {
+      RADV_FROM_HANDLE(vk_shader_module, module, stages[i].module);
+      const VkSpecializationInfo *spec_info = stages[i].pSpecializationInfo;
 
-   _mesa_sha1_init(&ctx);
-   if (layout)
-      _mesa_sha1_update(&ctx, layout->sha1, sizeof(layout->sha1));
-
-   _mesa_sha1_update(&ctx, key, sizeof(*key));
-
-   for (uint32_t i = 0; i < pCreateInfo->stageCount; ++i) {
-      RADV_FROM_HANDLE(vk_shader_module, module, 
pCreateInfo->pStages[i].module);
-      const VkSpecializationInfo *spec_info = 
pCreateInfo->pStages[i].pSpecializationInfo;
-
-      const VkPipelineShaderStageModuleIdentifierCreateInfoEXT *iinfo =
-         vk_find_struct_const(pCreateInfo->pStages[i].pNext,
-               PIPELINE_SHADER_STAGE_MODULE_IDENTIFIER_CREATE_INFO_EXT);
+      const VkPipelineShaderStageModuleIdentifierCreateInfoEXT *iinfo = 
vk_find_struct_const(
+         stages[i].pNext, 
PIPELINE_SHADER_STAGE_MODULE_IDENTIFIER_CREATE_INFO_EXT);
 
       if (module) {
-         _mesa_sha1_update(&ctx, module->sha1, sizeof(module->sha1));
+         _mesa_sha1_update(ctx, module->sha1, sizeof(module->sha1));
       } else {
          assert(iinfo);
          assert(iinfo->identifierSize <= 
VK_MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT);
-         _mesa_sha1_update(&ctx, iinfo->pIdentifier, iinfo->identifierSize);
+         _mesa_sha1_update(ctx, iinfo->pIdentifier, iinfo->identifierSize);
       }
 
-      _mesa_sha1_update(&ctx, pCreateInfo->pStages[i].pName, 
strlen(pCreateInfo->pStages[i].pName));
+      _mesa_sha1_update(ctx, stages[i].pName, strlen(stages[i].pName));
       if (spec_info && spec_info->mapEntryCount) {
-         _mesa_sha1_update(&ctx, spec_info->pMapEntries,
+         _mesa_sha1_update(ctx, spec_info->pMapEntries,
                            spec_info->mapEntryCount * sizeof 
spec_info->pMapEntries[0]);
-         _mesa_sha1_update(&ctx, spec_info->pData, spec_info->dataSize);
+         _mesa_sha1_update(ctx, spec_info->pData, spec_info->dataSize);
       }
    }
+}
+
+void
+radv_hash_rt_shaders(unsigned char *hash, const 
VkRayTracingPipelineCreateInfoKHR *pCreateInfo,
+                     const struct radv_pipeline_key *key, uint32_t flags)
+{
+   RADV_FROM_HANDLE(radv_pipeline_layout, layout, pCreateInfo->layout);
+   struct mesa_sha1 ctx;
+
+   _mesa_sha1_init(&ctx);
+   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->groupCount; i++) {
       _mesa_sha1_update(&ctx, &pCreateInfo->pGroups[i].type,
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index a11cc80af01..c0a2e22b856 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -1992,6 +1992,9 @@ void radv_hash_shaders(unsigned char *hash, const struct 
radv_pipeline_stage *st
                        uint32_t stage_count, const struct radv_pipeline_layout 
*layout,
                        const struct radv_pipeline_key *key, uint32_t flags);
 
+void radv_hash_rt_stages(struct mesa_sha1 *ctx, const 
VkPipelineShaderStageCreateInfo *stages,
+                         unsigned stage_count);
+
 void radv_hash_rt_shaders(unsigned char *hash, const 
VkRayTracingPipelineCreateInfoKHR *pCreateInfo,
                           const struct radv_pipeline_key *key, uint32_t flags);
 

Reply via email to