nir/lower_aaline: fix for scalarized outputs

this otherwise was broken

cc: mesa-stable

Acked-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28753>
(cherry picked from commit e28061c502)
This commit is contained in:
Mike Blumenkrantz 2024-04-15 13:21:51 -04:00 committed by Eric Engestrom
parent b47ea93f86
commit d4c791ec63
2 changed files with 10 additions and 6 deletions

View file

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

View file

@ -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;
}