diff options
author | Mary Guillemard <mary.guillemard@collabora.com> | 2024-07-08 12:38:49 +0200 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2024-07-17 12:04:11 +0000 |
commit | 801922cbe6ba2d0ffe3a9f2f7357969bd11cc2d7 (patch) | |
tree | 6486bd26331b0e851d4e0434265e1678418d14cb /src | |
parent | 368100d71c9cc03536cdb637066062955b29b149 (diff) |
bi: Implement basic 8-bit vec support
Not the most efficient approach but functional.
Signed-off-by: Mary Guillemard <mary.guillemard@collabora.com>
Acked-by: Rebecca Mckeever <rebecca.mckeever@collabora.com>
Reviewed by: Eric R. Smith <eric.smith@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30088>
Diffstat (limited to 'src')
-rw-r--r-- | src/panfrost/compiler/bifrost_compile.c | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/src/panfrost/compiler/bifrost_compile.c b/src/panfrost/compiler/bifrost_compile.c index e25ca71f9b0..10088656e6f 100644 --- a/src/panfrost/compiler/bifrost_compile.c +++ b/src/panfrost/compiler/bifrost_compile.c @@ -647,8 +647,20 @@ bi_make_vec8_helper(bi_builder *b, bi_index *src, unsigned *channel, for (unsigned i = 0; i < count; ++i) { unsigned chan = channel ? channel[i] : 0; + unsigned lane = chan & 3; + bi_index raw_data = bi_extract(b, src[i], chan >> 2); + + /* On Bifrost, MKVEC.v4i8 cannot select b1 or b3 */ + if (b->shader->arch < 9 && lane != 0 && lane != 2) { + bytes[i] = bi_byte(bi_rshift_or(b, 32, raw_data, bi_zero(), + bi_imm_u8(lane * 8), false), + 0); + } else { + bytes[i] = bi_byte(raw_data, lane); + } - bytes[i] = bi_byte(bi_extract(b, src[i], chan >> 2), chan & 3); + assert(b->shader->arch >= 9 || bytes[i].swizzle == BI_SWIZZLE_B0000 || + bytes[i].swizzle == BI_SWIZZLE_B2222); } if (b->shader->arch >= 9) { @@ -1884,10 +1896,29 @@ bi_alu_src_index(bi_builder *b, nir_alu_src src, unsigned comps) unsigned c0 = src.swizzle[0] & 1; unsigned c1 = (comps > 1) ? src.swizzle[1] & 1 : c0; idx.swizzle = BI_SWIZZLE_H00 + c1 + (c0 << 1); - } else if (bitsize == 8) { - /* 8-bit vectors not yet supported */ - assert(comps == 1 && "8-bit vectors not supported"); + } else if (bitsize == 8 && comps == 1) { idx.swizzle = BI_SWIZZLE_B0000 + (src.swizzle[0] & 3); + } else if (bitsize == 8) { + /* XXX: Use optimized swizzle when posisble */ + bi_index unoffset_srcs[NIR_MAX_VEC_COMPONENTS] = {bi_null()}; + unsigned channels[NIR_MAX_VEC_COMPONENTS] = {0}; + + for (unsigned i = 0; i < comps; ++i) { + unoffset_srcs[i] = bi_src_index(&src.src); + channels[i] = src.swizzle[i]; + } + + bi_index temp = bi_temp(b->shader); + bi_make_vec_to(b, temp, unoffset_srcs, channels, comps, bitsize); + + static const enum bi_swizzle swizzle_lut[] = { + BI_SWIZZLE_B0000, BI_SWIZZLE_B0011, BI_SWIZZLE_H01, BI_SWIZZLE_H01}; + assert(comps - 1 < ARRAY_SIZE(swizzle_lut)); + + /* Assign a coherent swizzle for the vector */ + temp.swizzle = swizzle_lut[comps - 1]; + + return temp; } return idx; |