Mesa (master): pan/bit: Add BI_CONVERT tests

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Apr 13 22:48:21 UTC 2020


Module: Mesa
Branch: master
Commit: 2513d0257c7698b1686fe26aa5db8b7b2969d845
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2513d0257c7698b1686fe26aa5db8b7b2969d845

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Mon Apr 13 18:19:41 2020 -0400

pan/bit: Add BI_CONVERT tests

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4539>

---

 src/panfrost/bifrost/test/bi_test_pack.c | 66 ++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/src/panfrost/bifrost/test/bi_test_pack.c b/src/panfrost/bifrost/test/bi_test_pack.c
index ef8e32a9929..03c88d7dd91 100644
--- a/src/panfrost/bifrost/test/bi_test_pack.c
+++ b/src/panfrost/bifrost/test/bi_test_pack.c
@@ -286,6 +286,58 @@ bit_special_helper(struct panfrost_device *dev,
         }
 }
 
+static void
+bit_convert_helper(struct panfrost_device *dev, unsigned from_size,
+                unsigned to_size, unsigned cx, unsigned cy, bool FMA,
+                enum bifrost_roundmode roundmode,
+                uint32_t *input, enum bit_debug debug)
+{
+        bi_instruction ins = {
+                .type = BI_CONVERT,
+                .dest = BIR_INDEX_REGISTER | 0,
+                .writemask = 0xF,
+                .src = { BIR_INDEX_REGISTER | 0 }
+        };
+
+        nir_alu_type Ts[3] = { nir_type_float, nir_type_uint, nir_type_int };
+
+        for (unsigned from_base = 0; from_base < 3; ++from_base) {
+                for (unsigned to_base = 0; to_base < 3; ++to_base) {
+                        /* Discard invalid combinations.. */
+                        if ((from_size == to_size) && (from_base == to_base))
+                                continue;
+
+                        /* Can't switch signedness */
+                        if (from_base && to_base)
+                                continue;
+
+                        /* No F16_TO_I32, etc */
+                        if (from_size != to_size && from_base == 0 && to_base)
+                                continue;
+
+                        if (from_size != to_size && from_base && to_base == 0)
+                                continue;
+
+                        /* No need, just ignore the upper half */
+                        if (from_size > to_size && from_base == to_base && from_base)
+                                continue;
+
+                        ins.dest_type = Ts[to_base] | to_size;
+                        ins.src_types[0] = Ts[from_base] | from_size;
+                        ins.roundmode = roundmode;
+                        ins.swizzle[0][0] = cx;
+                        ins.swizzle[0][1] = cy;
+
+                        if (!bit_test_single(dev, &ins, input, FMA, debug)) {
+                                fprintf(stderr, "FAIL: convert.%u-%u.%u-%u.%u%u\n",
+                                                from_base, from_size,
+                                                to_base, to_size,
+                                                cx, cy);
+                        }
+                }
+        }
+}
+
 void
 bit_packing(struct panfrost_device *dev, enum bit_debug debug)
 {
@@ -324,4 +376,18 @@ bit_packing(struct panfrost_device *dev, enum bit_debug debug)
 
                 bit_special_helper(dev, sz, input, debug);
         }
+
+        for (unsigned rm = 0; rm < 4; ++rm) {
+                bit_convert_helper(dev, 32, 32, 0, 0, false, rm, (uint32_t *) input32, debug);
+
+                for (unsigned c = 0; c < 2; ++c)
+                        bit_convert_helper(dev, 32, 16, c, 0, false, rm, (uint32_t *) input32, debug);
+
+                bit_convert_helper(dev, 16, 32, 0, 0, false, rm, (uint32_t *) input16, debug);
+
+                for (unsigned c = 0; c < 4; ++c)
+                        bit_convert_helper(dev, 16, 16, c & 1, c >> 1, false, rm, (uint32_t *) input16, debug);
+        }
+
+
 }



More information about the mesa-commit mailing list