agx: prepare for lower_wpos_center

required for correct sample shading in vk

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29607>
This commit is contained in:
Alyssa Rosenzweig 2024-06-06 12:25:44 -04:00 committed by Marge Bot
parent 55724ec9aa
commit ad85c043e7
2 changed files with 11 additions and 2 deletions

View File

@ -3299,7 +3299,6 @@ agx_preprocess_nir(nir_shader *nir, const nir_shader *libagx)
NIR_PASS(_, nir, nir_opt_sink, move_all);
NIR_PASS(_, nir, nir_opt_move, move_all);
NIR_PASS(_, nir, agx_nir_lower_shared_bitsize);
NIR_PASS(_, nir, nir_lower_frag_coord_to_pixel_coord);
}
void
@ -3325,6 +3324,7 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key,
bool needs_libagx = true /* TODO: Optimize */;
NIR_PASS(_, nir, nir_lower_frag_coord_to_pixel_coord);
NIR_PASS(_, nir, nir_lower_vars_to_ssa);
if (needs_libagx) {

View File

@ -25,7 +25,16 @@ lower(nir_builder *b, nir_intrinsic_instr *intr, void *data)
b->cursor = nir_before_instr(&intr->instr);
switch (intr->intrinsic) {
case nir_intrinsic_load_sample_pos: {
case nir_intrinsic_load_sample_pos:
case nir_intrinsic_load_sample_pos_or_center: {
/* Handle the center special case */
if (!b->shader->info.fs.uses_sample_shading) {
assert(intr->intrinsic == nir_intrinsic_load_sample_pos_or_center);
nir_def_rewrite_uses(&intr->def, nir_imm_vec2(b, 0.5, 0.5));
nir_instr_remove(&intr->instr);
return true;
}
/* Lower sample positions to decode the packed fixed-point register:
*
* uint32_t packed = load_sample_positions();