diff --git a/src/amd/vulkan/nir/radv_nir_rt_shader.c b/src/amd/vulkan/nir/radv_nir_rt_shader.c index 9fb0b25abda..9fd49a1d26e 100644 --- a/src/amd/vulkan/nir/radv_nir_rt_shader.c +++ b/src/amd/vulkan/nir/radv_nir_rt_shader.c @@ -811,9 +811,10 @@ nir_shader * radv_parse_rt_stage(struct radv_device *device, const VkPipelineShaderStageCreateInfo *sinfo, const struct radv_pipeline_key *key, const struct radv_pipeline_layout *pipeline_layout) { + gl_shader_stage s = vk_to_mesa_shader_stage(sinfo->stage); struct radv_shader_stage rt_stage; - radv_pipeline_stage_init(sinfo, pipeline_layout, key, &rt_stage); + radv_pipeline_stage_init(sinfo, pipeline_layout, &key->stage_info[s], &rt_stage); nir_shader *shader = radv_shader_spirv_to_nir(device, &rt_stage, NULL, false); diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index 9af7c9fd4fb..7b52f989fbe 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -225,17 +225,10 @@ radv_generate_pipeline_key(const struct radv_device *device, const VkPipelineSha return key; } -void -radv_shader_stage_key_init(const struct radv_pipeline_key *pipeline_key, gl_shader_stage stage, - struct radv_shader_stage_key *stage_key) -{ - *stage_key = pipeline_key->stage_info[stage]; -} - void radv_pipeline_stage_init(const VkPipelineShaderStageCreateInfo *sinfo, const struct radv_pipeline_layout *pipeline_layout, - const struct radv_pipeline_key *pipeline_key, struct radv_shader_stage *out_stage) + const struct radv_shader_stage_key *stage_key, struct radv_shader_stage *out_stage) { const VkShaderModuleCreateInfo *minfo = vk_find_struct_const(sinfo->pNext, SHADER_MODULE_CREATE_INFO); const VkPipelineShaderStageModuleIdentifierCreateInfoEXT *iinfo = @@ -250,6 +243,7 @@ radv_pipeline_stage_init(const VkPipelineShaderStageCreateInfo *sinfo, out_stage->entrypoint = sinfo->pName; out_stage->spec_info = sinfo->pSpecializationInfo; out_stage->feedback.flags = VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT; + out_stage->key = *stage_key; if (sinfo->module != VK_NULL_HANDLE) { struct vk_shader_module *module = vk_shader_module_from_handle(sinfo->module); @@ -266,7 +260,6 @@ radv_pipeline_stage_init(const VkPipelineShaderStageCreateInfo *sinfo, } radv_shader_layout_init(pipeline_layout, out_stage->stage, &out_stage->layout); - radv_shader_stage_key_init(pipeline_key, out_stage->stage, &out_stage->key); vk_pipeline_hash_shader_stage(sinfo, NULL, out_stage->shader_sha1); } diff --git a/src/amd/vulkan/radv_pipeline_compute.c b/src/amd/vulkan/radv_pipeline_compute.c index 4c0e3a33db9..eec5937cf6f 100644 --- a/src/amd/vulkan/radv_pipeline_compute.c +++ b/src/amd/vulkan/radv_pipeline_compute.c @@ -199,7 +199,7 @@ radv_compute_pipeline_compile(struct radv_compute_pipeline *pipeline, struct rad int64_t pipeline_start = os_time_get_nano(); - radv_pipeline_stage_init(pStage, pipeline_layout, pipeline_key, &cs_stage); + radv_pipeline_stage_init(pStage, pipeline_layout, &pipeline_key->stage_info[MESA_SHADER_COMPUTE], &cs_stage); radv_hash_shaders(device, hash, &cs_stage, 1, pipeline_layout, pipeline_key); diff --git a/src/amd/vulkan/radv_pipeline_graphics.c b/src/amd/vulkan/radv_pipeline_graphics.c index a176a13cb6c..7367a73b08c 100644 --- a/src/amd/vulkan/radv_pipeline_graphics.c +++ b/src/amd/vulkan/radv_pipeline_graphics.c @@ -2320,7 +2320,7 @@ radv_pipeline_import_retained_shaders(const struct radv_device *device, struct r if (!(shader_stage_to_pipeline_library_flags(sinfo->stage) & lib->lib_flags)) continue; - radv_pipeline_stage_init(sinfo, &lib->layout, pipeline_key, &stages[s]); + radv_pipeline_stage_init(sinfo, &lib->layout, &pipeline_key->stage_info[s], &stages[s]); } /* Import the NIR shaders (after SPIRV->NIR). */ @@ -2339,10 +2339,10 @@ radv_pipeline_import_retained_shaders(const struct radv_device *device, struct r stages[s].stage = s; stages[s].nir = nir_deserialize(NULL, options, &blob_reader); stages[s].entrypoint = nir_shader_get_entrypoint(stages[s].nir)->function->name; + stages[s].key = pipeline_key->stage_info[s]; memcpy(stages[s].shader_sha1, retained_shaders->stages[s].shader_sha1, sizeof(stages[s].shader_sha1)); radv_shader_layout_init(&lib->layout, s, &stages[s].layout); - radv_shader_stage_key_init(pipeline_key, s, &stages[s].key); stages[s].feedback.flags |= VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT; @@ -2640,7 +2640,7 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline, const Vk if (!(shader_stage_to_pipeline_library_flags(sinfo->stage) & lib_flags)) continue; - radv_pipeline_stage_init(sinfo, pipeline_layout, pipeline_key, &stages[stage]); + radv_pipeline_stage_init(sinfo, pipeline_layout, &pipeline_key->stage_info[stage], &stages[stage]); } radv_pipeline_load_retained_shaders(device, pipeline, pipeline_key, pCreateInfo, stages); diff --git a/src/amd/vulkan/radv_pipeline_rt.c b/src/amd/vulkan/radv_pipeline_rt.c index b9ed9d43ce2..0eacd71d89f 100644 --- a/src/amd/vulkan/radv_pipeline_rt.c +++ b/src/amd/vulkan/radv_pipeline_rt.c @@ -283,8 +283,10 @@ radv_init_rt_stage_hashes(struct radv_device *device, const VkRayTracingPipeline RADV_FROM_HANDLE(radv_pipeline_layout, pipeline_layout, pCreateInfo->layout); for (uint32_t idx = 0; idx < pCreateInfo->stageCount; idx++) { + gl_shader_stage s = vk_to_mesa_shader_stage(pCreateInfo->pStages[idx].stage); struct radv_shader_stage stage; - radv_pipeline_stage_init(&pCreateInfo->pStages[idx], pipeline_layout, key, &stage); + + radv_pipeline_stage_init(&pCreateInfo->pStages[idx], pipeline_layout, &key->stage_info[s], &stage); radv_hash_shaders(device, stages[idx].sha1, &stage, 1, NULL, key); } @@ -512,7 +514,8 @@ radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *ca int64_t stage_start = os_time_get_nano(); struct radv_shader_stage *stage = &stages[i]; - radv_pipeline_stage_init(&pCreateInfo->pStages[i], pipeline_layout, key, stage); + gl_shader_stage s = vk_to_mesa_shader_stage(pCreateInfo->pStages[i].stage); + radv_pipeline_stage_init(&pCreateInfo->pStages[i], pipeline_layout, &key->stage_info[s], stage); /* precompile the shader */ stage->nir = radv_parse_rt_stage(device, &pCreateInfo->pStages[i], key, pipeline_layout); @@ -618,10 +621,10 @@ radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *ca struct radv_shader_stage traversal_stage = { .stage = MESA_SHADER_INTERSECTION, .nir = traversal_module.nir, + .key = key->stage_info[MESA_SHADER_INTERSECTION], }; vk_pipeline_hash_shader_stage(&pStage, NULL, traversal_stage.shader_sha1); radv_shader_layout_init(pipeline_layout, MESA_SHADER_INTERSECTION, &traversal_stage.layout); - radv_shader_stage_key_init(key, MESA_SHADER_INTERSECTION, &traversal_stage.key); result = radv_rt_nir_to_asm(device, cache, pCreateInfo, pipeline, false, &traversal_stage, NULL, NULL, &pipeline->base.base.shaders[MESA_SHADER_INTERSECTION]); ralloc_free(traversal_module.nir); diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index c51a600d5c4..1167b5a829d 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -2010,7 +2010,7 @@ struct radv_pipeline_key; struct radv_ray_tracing_group; void radv_pipeline_stage_init(const VkPipelineShaderStageCreateInfo *sinfo, const struct radv_pipeline_layout *layout, - const struct radv_pipeline_key *pipeline_key, struct radv_shader_stage *out_stage); + const struct radv_shader_stage_key *stage_key, struct radv_shader_stage *out_stage); void radv_hash_shaders(const struct radv_device *device, unsigned char *hash, const struct radv_shader_stage *stages, uint32_t stage_count, const struct radv_pipeline_layout *layout, @@ -2276,9 +2276,6 @@ struct radv_shader_stage { void radv_shader_layout_init(const struct radv_pipeline_layout *pipeline_layout, gl_shader_stage stage, struct radv_shader_layout *layout); -void radv_shader_stage_key_init(const struct radv_pipeline_key *pipeline_key, gl_shader_stage stage, - struct radv_shader_stage_key *stage_key); - static inline bool radv_is_last_vgt_stage(const struct radv_shader_stage *stage) {