radv: Hash pipeline libraries separately
authorFriedrich Vock <friedrich.vock@gmx.de>
Mon, 13 Mar 2023 20:16:47 +0000 (21:16 +0100)
committerMarge Bot <emma+marge@anholt.net>
Wed, 26 Apr 2023 02:48:29 +0000 (02:48 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22686>

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

index 8ae1494..dceed6a 100644 (file)
@@ -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 |
index 2bc06c9..f9d1327 100644 (file)
@@ -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
index 35c2296..91a20bf 100644 (file)
@@ -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[];
 };