radv/rt: Hash stages using radv_hash_shaders
authorKonstantin Seurer <konstantin.seurer@gmail.com>
Tue, 20 Jun 2023 14:52:50 +0000 (16:52 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 28 Jun 2023 19:45:25 +0000 (19:45 +0000)
The hash also depends on the radv_pipeline_key as well as the flags. The
pipeline layout will also play a role when we implement inline
descriptor sets and push constants.

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

src/amd/vulkan/radv_pipeline_rt.c

index 46c225d..1b7b5b3 100644 (file)
@@ -183,16 +183,17 @@ radv_rt_fill_group_info(struct radv_device *device, const VkRayTracingPipelineCr
 }
 
 static void
-radv_rt_fill_stage_info(const VkRayTracingPipelineCreateInfoKHR *pCreateInfo, struct radv_ray_tracing_stage *stages)
+radv_rt_fill_stage_info(struct radv_device *device, const VkRayTracingPipelineCreateInfoKHR *pCreateInfo,
+                        struct radv_ray_tracing_stage *stages, const struct radv_pipeline_key *key)
 {
    uint32_t idx;
    for (idx = 0; idx < pCreateInfo->stageCount; idx++) {
       stages[idx].stage = vk_to_mesa_shader_stage(pCreateInfo->pStages[idx].stage);
 
-      struct mesa_sha1 ctx;
-      _mesa_sha1_init(&ctx);
-      radv_hash_rt_stages(&ctx, pCreateInfo->pStages + idx, 1);
-      _mesa_sha1_final(&ctx, stages[idx].sha1);
+      struct radv_pipeline_stage stage;
+      radv_pipeline_stage_init(&pCreateInfo->pStages[idx], &stage, stages[idx].stage);
+
+      radv_hash_shaders(stages[idx].sha1, &stage, 1, NULL, key, radv_get_hash_flags(device, false));
    }
 
    if (pCreateInfo->pLibraryInfo) {
@@ -548,13 +549,13 @@ radv_rt_pipeline_create(VkDevice _device, VkPipelineCache _cache, const VkRayTra
    pipeline->stages = stages;
    pipeline->groups = groups;
 
-   radv_rt_fill_stage_info(pCreateInfo, stages);
+   struct radv_pipeline_key key = radv_generate_pipeline_key(device, &pipeline->base.base, pCreateInfo->flags);
+
+   radv_rt_fill_stage_info(device, pCreateInfo, stages, &key);
    result = radv_rt_fill_group_info(device, pCreateInfo, stages, pipeline->groups);
    if (result != VK_SUCCESS)
       goto fail;
 
-   struct radv_pipeline_key key = radv_generate_pipeline_key(device, &pipeline->base.base, pCreateInfo->flags);
-
    radv_hash_rt_shaders(pipeline->sha1, pCreateInfo, &key, pipeline->groups,
                         radv_get_hash_flags(device, keep_statistic_info));
    pipeline->base.base.pipeline_hash = *(uint64_t *)pipeline->sha1;