Module: Mesa Branch: main Commit: 28e330c24536d353ec25be7b78ce20c7770d1e23 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=28e330c24536d353ec25be7b78ce20c7770d1e23
Author: Samuel Pitoiset <samuel.pitoi...@gmail.com> Date: Tue Jan 9 14:27:16 2024 +0100 radv: add radv_shader_stage_key to radv_shader_stage For storing the per-stage key information like robustness etc. This will fit well with ESO as well. For pipelines, they are copied from radv_pipeline_key, similarly to the radv_pipeline_layout/radv_shader_layout pair. This will also allow us to kill radv_pipeline_key for compute/rt pipelines. Signed-off-by: Samuel Pitoiset <samuel.pitoi...@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27007> --- src/amd/vulkan/nir/radv_nir_rt_shader.c | 2 +- src/amd/vulkan/radv_pipeline.c | 11 ++++++++++- src/amd/vulkan/radv_pipeline_compute.c | 2 +- src/amd/vulkan/radv_pipeline_graphics.c | 11 +++++++---- src/amd/vulkan/radv_pipeline_rt.c | 5 +++-- src/amd/vulkan/radv_private.h | 6 +++++- 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/amd/vulkan/nir/radv_nir_rt_shader.c b/src/amd/vulkan/nir/radv_nir_rt_shader.c index d78dfecbae3..f22d15dc07b 100644 --- a/src/amd/vulkan/nir/radv_nir_rt_shader.c +++ b/src/amd/vulkan/nir/radv_nir_rt_shader.c @@ -813,7 +813,7 @@ radv_parse_rt_stage(struct radv_device *device, const VkPipelineShaderStageCreat { struct radv_shader_stage rt_stage; - radv_pipeline_stage_init(sinfo, pipeline_layout, &rt_stage); + radv_pipeline_stage_init(sinfo, pipeline_layout, key, &rt_stage); nir_shader *shader = radv_shader_spirv_to_nir(device, &rt_stage, key, false); diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index e14b7a75d06..4eac4fbf839 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -212,9 +212,17 @@ 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, struct radv_shader_stage *out_stage) + const struct radv_pipeline_layout *pipeline_layout, + const struct radv_pipeline_key *pipeline_key, struct radv_shader_stage *out_stage) { const VkShaderModuleCreateInfo *minfo = vk_find_struct_const(sinfo->pNext, SHADER_MODULE_CREATE_INFO); const VkPipelineShaderStageModuleIdentifierCreateInfoEXT *iinfo = @@ -245,6 +253,7 @@ 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 e4ab79c48c7..1255e935b1f 100644 --- a/src/amd/vulkan/radv_pipeline_compute.c +++ b/src/amd/vulkan/radv_pipeline_compute.c @@ -202,7 +202,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, &cs_stage); + radv_pipeline_stage_init(pStage, pipeline_layout, pipeline_key, &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 66c10fc9322..3235ebca881 100644 --- a/src/amd/vulkan/radv_pipeline_graphics.c +++ b/src/amd/vulkan/radv_pipeline_graphics.c @@ -2291,6 +2291,7 @@ radv_pipeline_retain_shaders(struct radv_retained_shaders *retained_shaders, str static void radv_pipeline_import_retained_shaders(const struct radv_device *device, struct radv_graphics_pipeline *pipeline, + const struct radv_pipeline_key *pipeline_key, struct radv_graphics_lib_pipeline *lib, struct radv_shader_stage *stages) { struct radv_retained_shaders *retained_shaders = &lib->retained_shaders; @@ -2304,7 +2305,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, &stages[s]); + radv_pipeline_stage_init(sinfo, &lib->layout, pipeline_key, &stages[s]); } /* Import the NIR shaders (after SPIRV->NIR). */ @@ -2326,6 +2327,7 @@ radv_pipeline_import_retained_shaders(const struct radv_device *device, struct r 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; @@ -2335,6 +2337,7 @@ radv_pipeline_import_retained_shaders(const struct radv_device *device, struct r static void radv_pipeline_load_retained_shaders(const struct radv_device *device, struct radv_graphics_pipeline *pipeline, + const struct radv_pipeline_key *pipeline_key, const VkGraphicsPipelineCreateInfo *pCreateInfo, struct radv_shader_stage *stages) { const VkPipelineLibraryCreateInfoKHR *libs_info = @@ -2353,7 +2356,7 @@ radv_pipeline_load_retained_shaders(const struct radv_device *device, struct rad RADV_FROM_HANDLE(radv_pipeline, pipeline_lib, libs_info->pLibraries[i]); struct radv_graphics_lib_pipeline *gfx_pipeline_lib = radv_pipeline_to_graphics_lib(pipeline_lib); - radv_pipeline_import_retained_shaders(device, pipeline, gfx_pipeline_lib, stages); + radv_pipeline_import_retained_shaders(device, pipeline, pipeline_key, gfx_pipeline_lib, stages); } } @@ -2624,10 +2627,10 @@ 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, &stages[stage]); + radv_pipeline_stage_init(sinfo, pipeline_layout, pipeline_key, &stages[stage]); } - radv_pipeline_load_retained_shaders(device, pipeline, pCreateInfo, stages); + radv_pipeline_load_retained_shaders(device, pipeline, pipeline_key, pCreateInfo, stages); if (radv_should_compute_pipeline_hash(device, pipeline, fast_linking_enabled)) { radv_hash_shaders(device, hash, stages, MESA_VULKAN_SHADER_STAGES, pipeline_layout, pipeline_key); diff --git a/src/amd/vulkan/radv_pipeline_rt.c b/src/amd/vulkan/radv_pipeline_rt.c index 44f15b442d2..86da0d27f94 100644 --- a/src/amd/vulkan/radv_pipeline_rt.c +++ b/src/amd/vulkan/radv_pipeline_rt.c @@ -286,7 +286,7 @@ radv_init_rt_stage_hashes(struct radv_device *device, const VkRayTracingPipeline for (uint32_t idx = 0; idx < pCreateInfo->stageCount; idx++) { struct radv_shader_stage stage; - radv_pipeline_stage_init(&pCreateInfo->pStages[idx], pipeline_layout, &stage); + radv_pipeline_stage_init(&pCreateInfo->pStages[idx], pipeline_layout, key, &stage); radv_hash_shaders(device, stages[idx].sha1, &stage, 1, NULL, key); } @@ -515,7 +515,7 @@ 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, stage); + radv_pipeline_stage_init(&pCreateInfo->pStages[i], pipeline_layout, key, stage); /* precompile the shader */ stage->nir = radv_parse_rt_stage(device, &pCreateInfo->pStages[i], key, pipeline_layout); @@ -624,6 +624,7 @@ radv_rt_compile_shaders(struct radv_device *device, struct vk_pipeline_cache *ca }; 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, key, 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 3c70729ff21..32fc29632e0 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, - struct radv_shader_stage *out_stage); + const struct radv_pipeline_key *pipeline_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, @@ -2266,6 +2266,7 @@ struct radv_shader_stage { struct radv_shader_info info; struct radv_shader_args args; + struct radv_shader_stage_key key; VkPipelineCreationFeedback feedback; @@ -2275,6 +2276,9 @@ 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) {