pan/bit: Add constants test
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 15 Apr 2020 15:40:59 +0000 (11:40 -0400)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 17 Apr 2020 20:25:36 +0000 (16:25 -0400)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4615>

src/panfrost/bifrost/test/bi_test_pack.c

index ac0a80572db7a02c046436feb1d22280c1fe75f0..e127ea3b8de43247ad5ecf9c25ccf78df4ad70c0 100644 (file)
@@ -422,6 +422,33 @@ bit_convert_helper(struct panfrost_device *dev, unsigned from_size,
         }
 }
 
+static void
+bit_constant_helper(struct panfrost_device *dev,
+                uint32_t *input, enum bit_debug debug)
+{
+        enum bi_class C[3] = { BI_MOV, BI_ADD, BI_FMA };
+
+        for (unsigned doubled = 0; doubled < 2; ++doubled) {
+                for (unsigned count = 1; count <= 3; ++count) {
+                        bi_instruction ins = bit_ins(C[count - 1], count, nir_type_float, 32);
+
+                        ins.src[0] = BIR_INDEX_CONSTANT | 0;
+                        ins.src[1] = (count >= 2) ? BIR_INDEX_CONSTANT | (doubled ? 32 : 0) : 0;
+                        ins.src[2] = (count >= 3) ? BIR_INDEX_ZERO : 0;
+
+                        ins.constant.u64 = doubled ?
+                                0x3f800000ull | (0x3f000000ull << 32ull) :
+                                0x3f800000ull;
+
+                        if (!bit_test_single(dev, &ins, input, true, debug)) {
+                                fprintf(stderr, "FAIL: constants.%s.%u\n",
+                                                doubled ? "two" : "one",
+                                                count);
+                        }
+                }
+        }
+}
+
 void
 bit_packing(struct panfrost_device *dev, enum bit_debug debug)
 {
@@ -431,6 +458,8 @@ bit_packing(struct panfrost_device *dev, enum bit_debug debug)
         bit_generate_float4(input32);
         bit_generate_half8(input16);
 
+        bit_constant_helper(dev, (uint32_t *) input32, debug);
+
         for (unsigned sz = 16; sz <= 32; sz *= 2) {
                 uint32_t *input =
                         (sz == 16) ? (uint32_t *) input16 :