panfrost: add pass to lower noperspective varyings to a constant

This isn't hooked up yet, but should be a significant performance
improvement when available.

Signed-off-by: Benjamin Lee <benjamin.lee@collabora.com>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32127>
This commit is contained in:
Benjamin Lee
2024-11-15 20:57:01 -08:00
committed by Marge Bot
parent 30a288cdc9
commit 98de4f42ff
2 changed files with 30 additions and 0 deletions

View File

@@ -392,6 +392,8 @@ bool pan_nir_lower_image_ms(nir_shader *shader);
bool pan_nir_lower_frag_coord_zw(nir_shader *shader);
bool pan_nir_lower_noperspective_vs(nir_shader *shader);
bool pan_nir_lower_noperspective_fs(nir_shader *shader);
bool pan_nir_lower_static_noperspective(nir_shader *shader,
uint32_t noperspective_varyings);
bool pan_lower_helper_invocation(nir_shader *shader);
bool pan_lower_sample_pos(nir_shader *shader);

View File

@@ -290,3 +290,31 @@ pan_nir_lower_noperspective_fs(nir_shader *shader)
return true;
}
static bool
lower_static_noperspective(nir_builder *b, nir_intrinsic_instr *intrin,
void *data)
{
uint32_t *noperspective_varyings = data;
if (intrin->intrinsic != nir_intrinsic_load_noperspective_varyings_pan)
return false;
b->cursor = nir_after_instr(&intrin->instr);
nir_def *val = nir_imm_int(b, *noperspective_varyings);
nir_def_replace(&intrin->def, val);
return true;
}
/**
* Lower loads from the noperspective_varyings_pan sysval to a constant.
*/
bool
pan_nir_lower_static_noperspective(nir_shader *shader,
uint32_t noperspective_varyings)
{
return nir_shader_intrinsics_pass(shader, lower_static_noperspective,
nir_metadata_control_flow,
(void *)&noperspective_varyings);
}