From: Alyssa Rosenzweig Date: Sat, 25 Apr 2020 00:52:40 +0000 (-0400) Subject: pan/bit: Add SELECT tests X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=64c33a459fa9a5c8b49a967c0fee75d5f80317d3;p=mesa.git pan/bit: Add SELECT tests Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/panfrost/bifrost/test/bi_test_pack.c b/src/panfrost/bifrost/test/bi_test_pack.c index 0486240f230..cdbb1a27edd 100644 --- a/src/panfrost/bifrost/test/bi_test_pack.c +++ b/src/panfrost/bifrost/test/bi_test_pack.c @@ -373,6 +373,36 @@ bit_reduce_helper(struct panfrost_device *dev, uint32_t *input, enum bit_debug d } } +static void +bit_select_helper(struct panfrost_device *dev, uint32_t *input, unsigned size, enum bit_debug debug) +{ + unsigned C = 32 / size; + bi_instruction ins = bit_ins(BI_SELECT, C, nir_type_uint, 32); + + for (unsigned c = 0; c < C; ++c) + ins.src_types[c] = nir_type_uint | size; + + if (size == 8) { + /* SCHEDULER: We can only read 3 registers at once. */ + ins.src[2] = ins.src[0]; + } + + /* Each argument has swizzle {lo, hi} so 2^C options */ + unsigned hi = (size == 16) ? 1 : 2; + + for (unsigned add = 0; add < ((size == 16) ? 2 : 1); ++add) { + for (unsigned swizzle = 0; swizzle < (1 << C); ++swizzle) { + for (unsigned i = 0; i < C; ++i) + ins.swizzle[i][0] = ((swizzle >> i) & 1) ? hi : 0; + + if (!bit_test_single(dev, &ins, input, !add, debug)) { + fprintf(stderr, "FAIL: select.%u.%u\n", + size, swizzle); + } + } + } +} + static void bit_convert_helper(struct panfrost_device *dev, unsigned from_size, unsigned to_size, unsigned cx, unsigned cy, bool FMA, @@ -511,4 +541,8 @@ bit_packing(struct panfrost_device *dev, enum bit_debug debug) memcpy(mscale_input, input32, sizeof(input32)); mscale_input[3] = 0x7; bit_fma_mscale_helper(dev, mscale_input, debug); + + for (unsigned sz = 8; sz <= 16; sz *= 2) { + bit_select_helper(dev, (uint32_t *) input32, 8, debug); + } }