radv: move per-primitive fixup closer to radv_nir_lower_io

Ideally this would be in radv_nir_lower_io, but we need the information
about the previous stage.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40982>
This commit is contained in:
Georg Lehmann 2026-04-15 13:49:35 +02:00 committed by Marge Bot
parent 78e2bbc70f
commit 2a5823c988

View file

@ -1264,18 +1264,6 @@ radv_link_mesh(struct radv_shader_stage *mesh_stage, struct radv_shader_stage *f
{
assert(mesh_stage->nir->info.stage == MESA_SHADER_MESH);
if (fs_stage) {
assert(fs_stage->nir->info.stage == MESA_SHADER_FRAGMENT);
nir_foreach_shader_in_variable (var, fs_stage->nir) {
/* These variables are per-primitive when used with a mesh shader. */
if (var->data.location == VARYING_SLOT_PRIMITIVE_ID || var->data.location == VARYING_SLOT_VIEWPORT ||
var->data.location == VARYING_SLOT_LAYER) {
var->data.per_primitive = true;
}
}
}
/* Lower mesh shader draw ID to zero prevent app bugs from triggering undefined behaviour. */
if (mesh_stage->info.ms.has_task && BITSET_TEST(mesh_stage->nir->info.system_values_read, SYSTEM_VALUE_DRAW_ID))
radv_nir_lower_draw_id_to_zero(mesh_stage->nir);
@ -2644,6 +2632,19 @@ radv_graphics_shaders_compile(struct radv_device *device, struct vk_pipeline_cac
radv_foreach_stage (i, active_nir_stages) {
int64_t stage_start = os_time_get_nano();
if (i == MESA_SHADER_FRAGMENT && stages[MESA_SHADER_MESH].nir) {
nir_foreach_shader_in_variable (var, stages[i].nir) {
/* These variables are implicitly per-primitive when used with mesh->fragment stages
* and this can't be determined with only the FS.
* nir_opt_varyings relies on inputs and outputs agreeing on per-primitive.
*/
if (var->data.location == VARYING_SLOT_PRIMITIVE_ID || var->data.location == VARYING_SLOT_VIEWPORT ||
var->data.location == VARYING_SLOT_LAYER) {
var->data.per_primitive = true;
}
}
}
radv_nir_lower_io(device, stages[i].nir);
if (!stages[i].key.optimisations_disabled) {