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>
This commit is contained in:

committed by
Marge Bot

parent
368100d71c
commit
801922cbe6
@@ -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);
|
||||
|
||||
bytes[i] = bi_byte(bi_extract(b, src[i], chan >> 2), chan & 3);
|
||||
/* 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);
|
||||
}
|
||||
|
||||
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;
|
||||
|
Reference in New Issue
Block a user