From d4c791ec6383bbc8296629aec4b63a032bf853a8 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 15 Apr 2024 13:21:51 -0400 Subject: [PATCH] nir/lower_aaline: fix for scalarized outputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this otherwise was broken cc: mesa-stable Acked-by: Marek Olšák Part-of: (cherry picked from commit e28061c5021b7902b39d8e93ae0e2d12682b1fbe) --- .pick_status.json | 2 +- src/gallium/auxiliary/nir/nir_draw_helpers.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 93fe2144c19..15c81a36a42 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -64,7 +64,7 @@ "description": "nir/lower_aaline: fix for scalarized outputs", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/auxiliary/nir/nir_draw_helpers.c b/src/gallium/auxiliary/nir/nir_draw_helpers.c index 630f37b97e7..646746f5274 100644 --- a/src/gallium/auxiliary/nir/nir_draw_helpers.c +++ b/src/gallium/auxiliary/nir/nir_draw_helpers.c @@ -177,6 +177,9 @@ lower_aaline_instr(nir_builder *b, nir_instr *instr, void *data) return false; if (var->data.location < FRAG_RESULT_DATA0 && var->data.location != FRAG_RESULT_COLOR) return false; + uint32_t mask = nir_intrinsic_write_mask(intrin) << var->data.location_frac; + if (!(mask & BITFIELD_BIT(3))) + return false; nir_def *out_input = intrin->src[1].ssa; b->cursor = nir_before_instr(instr); @@ -223,12 +226,13 @@ lower_aaline_instr(nir_builder *b, nir_instr *instr, void *data) tmp = nir_fmul(b, nir_channel(b, tmp, 0), nir_fmin(b, nir_channel(b, tmp, 1), max)); - tmp = nir_fmul(b, nir_channel(b, out_input, 3), tmp); + tmp = nir_fmul(b, nir_channel(b, out_input, out_input->num_components - 1), tmp); - nir_def *out = nir_vec4(b, nir_channel(b, out_input, 0), - nir_channel(b, out_input, 1), - nir_channel(b, out_input, 2), - tmp); + nir_def *components[4]; + for (unsigned i = 0; i < out_input->num_components - 1; i++) + components[i] = nir_channel(b, out_input, i); + components[out_input->num_components - 1] = tmp; + nir_def *out = nir_vec(b, components, out_input->num_components); nir_src_rewrite(&intrin->src[1], out); return true; }