From 2aa416976528e7b17d8f7848b9597148c39fa097 Mon Sep 17 00:00:00 2001 From: Simon Perretta Date: Mon, 23 Feb 2026 09:12:21 +0000 Subject: [PATCH] pco: reserve additional outputs for trilinear sampled coeffs Sampling coeffs with trilinear filtering will output 2x sets of data. Whether bilinear or trilinear filtering is in use can't be determined without checking state words, so unconditionally reserve 2x to avoid clobbering output regs. Fixes: 7df32ba09d3 ("pco: initial texture/sampler compiler support") Signed-off-by: Simon Perretta Acked-by: Frank Binns Tested-by: Icenowy Zheng (cherry picked from commit af1669d9e25a346104d061ec05e89bd6a5a80c40) Part-of: --- .pick_status.json | 2 +- src/compiler/nir/nir_intrinsics.py | 3 ++- src/imagination/pco/pco_trans_nir.c | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 28a22ece7aa..1bebb7da3b1 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1214,7 +1214,7 @@ "description": "pco: reserve additional outputs for trilinear sampled coeffs", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "7df32ba09d3bdc7f20ec2f632af181824e0f90a6", "notes": null diff --git a/src/compiler/nir/nir_intrinsics.py b/src/compiler/nir/nir_intrinsics.py index 5c4b63bb580..ccb377beeec 100644 --- a/src/compiler/nir/nir_intrinsics.py +++ b/src/compiler/nir/nir_intrinsics.py @@ -2859,7 +2859,8 @@ intrinsic("smp_pco", src_comp=[16, 4, 4], dest_comp=0, indices=[SMP_FLAGS_PCO, R # smp_coeffs_pco(data, tex_state, smp_state) # Returns the calculated sampling coefficients for the given data and state words. -intrinsic("smp_coeffs_pco", src_comp=[16, 4, 4], dest_comp=8, indices=[SMP_FLAGS_PCO, RANGE], bit_sizes=[32]) +# Actually outputs 7/14 components, but NIR doesn't support those for num_components, so fake it as 16 for now. +intrinsic("smp_coeffs_pco", src_comp=[16, 4, 4], dest_comp=16, indices=[SMP_FLAGS_PCO, RANGE], bit_sizes=[32]) # smp_raw_pco(data, tex_state, smp_state) # Returns the raw sampling data for the given data and state words. diff --git a/src/imagination/pco/pco_trans_nir.c b/src/imagination/pco/pco_trans_nir.c index 6c5dabea9cd..9d7459494eb 100644 --- a/src/imagination/pco/pco_trans_nir.c +++ b/src/imagination/pco/pco_trans_nir.c @@ -1710,8 +1710,11 @@ static pco_instr *lower_smp(trans_ctx *tctx, enum pco_sb_mode sb_mode = PCO_SB_MODE_NONE; switch (intr->intrinsic) { case nir_intrinsic_smp_coeffs_pco: - /* Shrink the destination to its actual size. */ - *dest = pco_ref_chans(*dest, ROGUE_SMP_COEFF_COUNT); + /* Shrink the destination to its actual size. + * Trilinear filtering will produce two sets of coeffs; + * reserve both just in case so that we don't clobber output regs. + */ + *dest = pco_ref_chans(*dest, ROGUE_SMP_COEFF_COUNT * 2u); chans = 1; /* Chans must be 1 for coeff mode. */ sb_mode = PCO_SB_MODE_COEFFS;