pan/bi: Properly handle large 8-bit vectors in bi_alu_src_index()

Previously, we used bi_src_index() directly and ignored the offset we
took all that care to calculate at the top of the function.  For most
cases, this is fine since the offset is 0.  But if we ever have an i8v8,
or larger, this doesn't work.  It's not really more work to handle this
case.  All we have to do is use the offset and &3 the swizzle.  It just
means we can't have false code sharing with the bi_make_vec_to() case.

Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Reviewed-by: Christoph Pillmayer <christoph.pillmayer@arm.com>
Reviewed-by: Lorenzo Rossi <lorenzo.rossi@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40576>
This commit is contained in:
Faith Ekstrand 2026-03-24 09:53:03 -04:00 committed by Marge Bot
parent 9950a98d5e
commit 0b029f319f

View file

@ -2567,6 +2567,18 @@ bi_alu_src_index(bi_builder *b, nir_alu_src src, unsigned comps)
} else if (bitsize == 8 && comps == 1) {
idx.swizzle = BI_SWIZZLE_B0000 + (src.swizzle[0] & 3);
} else if (bitsize == 8) {
if (comps == 2 || comps == 4) {
unsigned c[4] = {0};
for (unsigned i = 0; i < comps; ++i)
c[i] = src.swizzle[i] & 3;
enum bi_swizzle swizzle;
if (bi_byte_swizzle_from_nir_swizzle(c, comps, &swizzle)) {
idx.swizzle = swizzle;
return idx;
}
}
/* XXX: Use optimized swizzle when posisble */
bi_index unoffset_srcs[NIR_MAX_VEC_COMPONENTS] = {bi_null()};
unsigned channels[NIR_MAX_VEC_COMPONENTS] = {0};
@ -2576,15 +2588,6 @@ bi_alu_src_index(bi_builder *b, nir_alu_src src, unsigned comps)
channels[i] = src.swizzle[i];
}
if (comps == 2 || comps == 4) {
enum bi_swizzle swizzle;
if (bi_byte_swizzle_from_nir_swizzle(channels, comps, &swizzle)) {
bi_index ret = bi_src_index(&src.src);
ret.swizzle = swizzle;
return ret;
}
}
bi_index temp = bi_temp(b->shader);
bi_make_vec_to(b, temp, unoffset_srcs, channels, comps, bitsize);