pan/bit: Factor out identity swizzle helper
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 4 May 2020 18:13:29 +0000 (14:13 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 4 May 2020 18:45:15 +0000 (18:45 +0000)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4890>

src/panfrost/bifrost/test/bi_test_pack.c

index 2f02db12c9b43e69923ef790a785910cbe6cd74f..832eddaa1637627edfa225deb0938048afa7ed29 100644 (file)
@@ -516,20 +516,24 @@ bit_constant_helper(struct panfrost_device *dev,
         }
 }
 
+static void
+bit_swizzle_identity(bi_instruction *ins, unsigned args, unsigned size)
+{
+        for (unsigned i = 0; i < 2; ++i) {
+                for (unsigned j = 0; j < (32 / size); ++j)
+                        ins->swizzle[i][j] = j;
+        }
+}
+
 static void
 bit_bitwise_helper(struct panfrost_device *dev, uint32_t *input, unsigned size, enum bit_debug debug)
 {
         bi_instruction ins = bit_ins(BI_BITWISE, 3, nir_type_uint, size);
+        bit_swizzle_identity(&ins, 2, size);
 
         /* TODO: shifts */
         ins.src[2] = BIR_INDEX_ZERO;
 
-        /* Force identity swizzle -- bitwise is not swizzleable */
-        for (unsigned i = 0; i < 2; ++i) {
-                for (unsigned j = 0; j < (32 / size); ++j)
-                        ins.swizzle[i][j] = j;
-        }
-
         for (unsigned op = BI_BITWISE_AND; op <= BI_BITWISE_XOR; ++op) {
                 ins.op.bitwise = op;