pco: support flat interpolation varyings

Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Frank Binns <frank.binns@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33998>
This commit is contained in:
Simon Perretta 2024-12-01 00:05:12 +00:00 committed by Marge Bot
parent c386c2f9e8
commit 410bba0463
3 changed files with 33 additions and 6 deletions

View file

@ -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 */

View file

@ -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 {

View file

@ -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,