radv: switch to nir_intrinsic_load_input_attachment_coord
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35556>
This commit is contained in:
Samuel Pitoiset 2025-06-17 11:23:19 +02:00 committed by Marge Bot
parent df55ea8c51
commit 59dfa8c2f5
4 changed files with 33 additions and 2 deletions

View file

@ -48,6 +48,8 @@ bool radv_nir_lower_primitive_shading_rate(nir_shader *nir, enum amd_gfx_level g
bool radv_nir_lower_fs_intrinsics(nir_shader *nir, const struct radv_shader_stage *fs_stage,
const struct radv_graphics_state_key *gfx_state);
bool radv_nir_lower_fs_input_attachment(nir_shader *nir);
bool radv_nir_lower_fs_barycentric(nir_shader *shader, const struct radv_graphics_state_key *gfx_state,
unsigned rast_prim);

View file

@ -125,3 +125,31 @@ radv_nir_lower_fs_intrinsics(nir_shader *nir, const struct radv_shader_stage *fs
struct ctx ctx = { .fs_stage = fs_stage, .gfx_state = gfx_state };
return nir_shader_intrinsics_pass(nir, pass, nir_metadata_none, &ctx);
}
static bool
lower_load_input_attachment(nir_builder *b, nir_intrinsic_instr *intrin, void *state)
{
switch (intrin->intrinsic) {
case nir_intrinsic_load_input_attachment_coord: {
b->cursor = nir_before_instr(&intrin->instr);
nir_def *pos = nir_f2i32(b, nir_load_frag_coord(b));
nir_def *layer = nir_load_layer_id(b);
nir_def *coord = nir_vec3(b, nir_channel(b, pos, 0), nir_channel(b, pos, 1), layer);
nir_def_replace(&intrin->def, coord);
return true;
}
default:
return false;
}
}
bool
radv_nir_lower_fs_input_attachment(nir_shader *nir)
{
if (!nir->info.fs.uses_fbfetch_output)
return false;
return nir_shader_intrinsics_pass(nir, lower_load_input_attachment, nir_metadata_control_flow, NULL);
}

View file

@ -2763,6 +2763,8 @@ radv_graphics_shaders_compile(struct radv_device *device, struct vk_pipeline_cac
if (!gfx_state->ps.has_epilog)
radv_nir_remap_color_attachment(stages[MESA_SHADER_FRAGMENT].nir, gfx_state);
NIR_PASS(update_info, stages[MESA_SHADER_FRAGMENT].nir, radv_nir_lower_fs_input_attachment);
NIR_PASS(update_info, stages[MESA_SHADER_FRAGMENT].nir, nir_opt_frag_coord_to_pixel_coord);
if (update_info)
nir_shader_gather_info(stages[MESA_SHADER_FRAGMENT].nir,

View file

@ -454,8 +454,7 @@ radv_shader_spirv_to_nir(struct radv_device *device, const struct radv_shader_st
if (nir->info.stage == MESA_SHADER_FRAGMENT)
NIR_PASS(_, nir, nir_lower_input_attachments,
&(nir_input_attachment_options){
.use_fragcoord_sysval = true,
.use_layer_id_sysval = true,
.use_ia_coord_intrin = true,
});
nir_remove_dead_variables_options dead_vars_opts = {