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.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27007>
This commit is contained in:
Samuel Pitoiset 2024-01-09 14:27:16 +01:00 committed by Marge Bot
parent cff2a3aafc
commit 28e330c245
6 changed files with 27 additions and 10 deletions

View file

@ -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);

View file

@ -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);
}

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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)
{