radv/rt: Hash the pipeline key
authorKonstantin Seurer <konstantin.seurer@gmail.com>
Sat, 10 Dec 2022 12:13:09 +0000 (13:13 +0100)
committerMarge Bot <emma+marge@anholt.net>
Mon, 12 Dec 2022 18:18:32 +0000 (18:18 +0000)
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20243>

src/amd/vulkan/radv_pipeline_cache.c
src/amd/vulkan/radv_pipeline_rt.c
src/amd/vulkan/radv_private.h

index 081ce4d..14acb69 100644 (file)
@@ -153,7 +153,7 @@ radv_hash_shaders(unsigned char *hash, const struct radv_pipeline_stage *stages,
 
 void
 radv_hash_rt_shaders(unsigned char *hash, const VkRayTracingPipelineCreateInfoKHR *pCreateInfo,
-                     uint32_t flags)
+                     const struct radv_pipeline_key *key, uint32_t flags)
 {
    RADV_FROM_HANDLE(radv_pipeline_layout, layout, pCreateInfo->layout);
    struct mesa_sha1 ctx;
@@ -162,6 +162,8 @@ radv_hash_rt_shaders(unsigned char *hash, const VkRayTracingPipelineCreateInfoKH
    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;
index f9c8cbf..d11b299 100644 (file)
@@ -272,7 +272,6 @@ radv_rt_pipeline_create(VkDevice _device, VkPipelineCache _cache,
       goto fail;
    }
 
-   radv_hash_rt_shaders(hash, &local_create_info, radv_get_hash_flags(device, keep_statistic_info));
    struct vk_shader_module module = {.base.type = VK_OBJECT_TYPE_SHADER_MODULE};
 
    VkPipelineShaderStageCreateInfo stage = {
@@ -301,6 +300,9 @@ radv_rt_pipeline_create(VkDevice _device, VkPipelineCache _cache,
    struct radv_pipeline_key key = radv_generate_rt_pipeline_key(rt_pipeline, pCreateInfo->flags);
    UNUSED gl_shader_stage last_vgt_api_stage = MESA_SHADER_NONE;
 
+   radv_hash_rt_shaders(hash, &local_create_info, &key,
+                        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
     * generating the nir. */
    result = radv_create_shaders(
index 795eb5d..0d43cb6 100644 (file)
@@ -1965,7 +1965,7 @@ void radv_hash_shaders(unsigned char *hash, const struct radv_pipeline_stage *st
                        const struct radv_pipeline_key *key, uint32_t flags);
 
 void radv_hash_rt_shaders(unsigned char *hash, const VkRayTracingPipelineCreateInfoKHR *pCreateInfo,
-                          uint32_t flags);
+                          const struct radv_pipeline_key *key, uint32_t flags);
 
 uint32_t radv_get_hash_flags(const struct radv_device *device, bool stats);