From 410bba04635b51ceb05e7a27afcc8337bedf8e68 Mon Sep 17 00:00:00 2001 From: Simon Perretta Date: Sun, 1 Dec 2024 00:05:12 +0000 Subject: [PATCH] pco: support flat interpolation varyings Signed-off-by: Simon Perretta Acked-by: Frank Binns Part-of: --- src/imagination/include/hwdef/rogue_hw_defs.h | 8 ++++++- src/imagination/pco/pco_nir.c | 22 ++++++++++++++----- src/imagination/pco/pco_trans_nir.c | 9 ++++++++ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/imagination/include/hwdef/rogue_hw_defs.h b/src/imagination/include/hwdef/rogue_hw_defs.h index dfa47fef968..e6c51311cef 100644 --- a/src/imagination/include/hwdef/rogue_hw_defs.h +++ b/src/imagination/include/hwdef/rogue_hw_defs.h @@ -165,6 +165,12 @@ #define ROGUE_USRM_LINE_SIZE_PER_INSTANCE \ (ROGUE_PDS_US_TEMP_ALLOCATION_GRANULARITY * ROGUE_USRM_LINE_SIZE) -#define ROGUE_USC_COEFFICIENT_SET_SIZE 4U +enum { + ROGUE_USC_COEFFICIENT_SET_A = 0, + ROGUE_USC_COEFFICIENT_SET_B, + ROGUE_USC_COEFFICIENT_SET_C, + ROGUE_USC_COEFFICIENT_SET_PAD, + ROGUE_USC_COEFFICIENT_SET_SIZE, +}; #endif /* ROGUE_HW_DEFS_H */ diff --git a/src/imagination/pco/pco_nir.c b/src/imagination/pco/pco_nir.c index 38bd9576c87..d6a243d0b15 100644 --- a/src/imagination/pco/pco_nir.c +++ b/src/imagination/pco/pco_nir.c @@ -168,21 +168,33 @@ static uint8_t vectorize_filter(const nir_instr *instr, UNUSED const void *data) } /** - * \brief Filters for a varying position load_input in frag shaders. + * \brief Filter for fragment shader inputs that need to be scalar. * * \param[in] instr Instruction. * \param[in] data User data. * \return True if the instruction was found. */ -static bool frag_pos_filter(const nir_instr *instr, UNUSED const void *data) +static bool frag_in_scalar_filter(const nir_instr *instr, const void *data) { assert(instr->type == nir_instr_type_intrinsic); + nir_shader *nir = (nir_shader *)data; nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr); if (intr->intrinsic != nir_intrinsic_load_input) return false; - return nir_intrinsic_io_semantics(intr).location == VARYING_SLOT_POS; + gl_varying_slot location = nir_intrinsic_io_semantics(intr).location; + if (location == VARYING_SLOT_POS) + return true; + + nir_variable *var = + nir_find_variable_with_location(nir, nir_var_shader_in, location); + assert(var); + + if (var->data.interpolation == INTERP_MODE_FLAT) + return true; + + return false; } /** @@ -285,8 +297,8 @@ void pco_lower_nir(pco_ctx *ctx, nir_shader *nir, pco_data *data) nir, nir_lower_io_to_scalar, nir_var_shader_in, - frag_pos_filter, - NULL); + frag_in_scalar_filter, + nir); } do { diff --git a/src/imagination/pco/pco_trans_nir.c b/src/imagination/pco/pco_trans_nir.c index 15394bc308f..5a70cfd5948 100644 --- a/src/imagination/pco/pco_trans_nir.c +++ b/src/imagination/pco/pco_trans_nir.c @@ -355,6 +355,15 @@ trans_load_input_fs(trans_ctx *tctx, nir_intrinsic_instr *intr, pco_ref dest) .itr_mode = itr_mode); } + case INTERP_MODE_FLAT: { + pco_ref coeff_c = + pco_ref_hwreg(coeffs_index + ROGUE_USC_COEFFICIENT_SET_C, + PCO_REG_CLASS_COEFF); + + assert(chans == 1); + return pco_mov(&tctx->b, dest, coeff_c); + } + case INTERP_MODE_NOPERSPECTIVE: return usc_itrsmp_enhanced ? pco_ditr(&tctx->b, dest,