From 359ba659036d0294cdc791b1ab28d6e8f7a00144 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Sat, 1 Feb 2025 20:10:43 +0100 Subject: [PATCH] nir/lower_poly_line_smooth: support partial store_output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RADV needs this to skip if there is no alpha component Reviewed-by: Samuel Pitoiset Reviewed-by: Marek Olšák Acked-by: Erik Faye-Lund Part-of: --- src/compiler/nir/nir_lower_poly_line_smooth.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compiler/nir/nir_lower_poly_line_smooth.c b/src/compiler/nir/nir_lower_poly_line_smooth.c index 4fcca5cfab6..037e0b3656c 100644 --- a/src/compiler/nir/nir_lower_poly_line_smooth.c +++ b/src/compiler/nir/nir_lower_poly_line_smooth.c @@ -26,7 +26,7 @@ /** * This NIR lowers pass for polygon and line smoothing by modifying the alpha - * value of fragment outputs using the sample coverage mask. + * value of the first fragment output using the sample coverage mask. */ static bool @@ -43,12 +43,12 @@ lower_polylinesmooth(nir_builder *b, nir_instr *instr, void *data) return false; int location = nir_intrinsic_io_semantics(intr).location; + int alpha_comp = 3 - nir_intrinsic_component(intr); if ((location != FRAG_RESULT_COLOR && location != FRAG_RESULT_DATA0) || - nir_intrinsic_src_type(intr) != nir_type_float32) + nir_intrinsic_src_type(intr) != nir_type_float32 || + !(nir_intrinsic_write_mask(intr) & BITFIELD_BIT(alpha_comp))) return false; - assert(intr->num_components == 4); - b->cursor = nir_before_instr(&intr->instr); nir_def *coverage = nir_load_sample_mask_in(b); @@ -59,11 +59,11 @@ lower_polylinesmooth(nir_builder *b, nir_instr *instr, void *data) coverage = nir_fmul_imm(b, coverage, 1.0 / *num_smooth_aa_sample); nir_def *smooth_enabled = nir_load_poly_line_smooth_enabled(b); - nir_def *alpha = nir_channel(b, intr->src[0].ssa, 3); + nir_def *alpha = nir_channel(b, intr->src[0].ssa, alpha_comp); nir_def *smooth_alpha = nir_fmul(b, alpha, coverage); nir_def *new_alpha = nir_bcsel(b, smooth_enabled, smooth_alpha, alpha); - nir_def *new_src = nir_vector_insert_imm(b, intr->src[0].ssa, new_alpha, 3); + nir_def *new_src = nir_vector_insert_imm(b, intr->src[0].ssa, new_alpha, alpha_comp); nir_src_rewrite(&intr->src[0], new_src); return true;