Mesa (master): pan/bi: ADD packing for CONVERT

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


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

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Mon Apr 13 17:32:58 2020 -0400

pan/bi: ADD packing for CONVERT

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

---

 src/panfrost/bifrost/bi_pack.c | 25 ++++++++++++++++++++-----
 src/panfrost/bifrost/bifrost.h |  2 ++
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c
index dc304f3d7d9..d42b6d9fbd8 100644
--- a/src/panfrost/bifrost/bi_pack.c
+++ b/src/panfrost/bifrost/bi_pack.c
@@ -740,7 +740,7 @@ bi_pack_fma_csel(bi_instruction *ins, struct bi_registers *regs)
  */
 
 static unsigned
-bi_pack_fma_convert(bi_instruction *ins, struct bi_registers *regs)
+bi_pack_convert(bi_instruction *ins, struct bi_registers *regs, bool FMA)
 {
         nir_alu_type from_base = nir_alu_type_get_base_type(ins->src_types[0]);
         unsigned from_size = nir_alu_type_get_type_size(ins->src_types[0]);
@@ -758,13 +758,23 @@ bi_pack_fma_convert(bi_instruction *ins, struct bi_registers *regs)
         /* f32 to f16 is special */
         if (from_size == 32 && to_size == 16 && from_base == nir_type_float && to_base == from_base) {
                 /* TODO: second vectorized source? */
-                struct bifrost_fma_2src pack = {
+                struct bifrost_fma_2src pfma = {
                         .src0 = bi_get_src(ins, regs, 0, true),
                         .src1 = BIFROST_SRC_STAGE, /* 0 */
                         .op = BIFROST_FMA_FLOAT32_TO_16
                 };
 
-                RETURN_PACKED(pack);
+                struct bifrost_add_2src padd = {
+                        .src0 = bi_get_src(ins, regs, 0, true),
+                        .src1 = BIFROST_SRC_STAGE, /* 0 */
+                        .op = BIFROST_ADD_FLOAT32_TO_16
+                };
+
+                if (FMA) {
+                        RETURN_PACKED(pfma);
+                } else {
+                        RETURN_PACKED(padd);
+                }
         }
 
         /* Otherwise, figure out the mode */
@@ -822,7 +832,10 @@ bi_pack_fma_convert(bi_instruction *ins, struct bi_registers *regs)
                         op |= 0x100;
         }
 
-        return bi_pack_fma_1src(ins, regs, BIFROST_FMA_CONVERT | op);
+        if (FMA)
+                return bi_pack_fma_1src(ins, regs, BIFROST_FMA_CONVERT | op);
+        else
+                return bi_pack_add_1src(ins, regs, BIFROST_ADD_CONVERT | op);
 }
 
 static unsigned
@@ -838,7 +851,7 @@ bi_pack_fma(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs)
         case BI_BITWISE:
 		return BIFROST_FMA_NOP;
         case BI_CONVERT:
-		return bi_pack_fma_convert(bundle.fma, regs);
+		return bi_pack_convert(bundle.fma, regs, true);
         case BI_CSEL:
 		return bi_pack_fma_csel(bundle.fma, regs);
         case BI_FMA:
@@ -1101,7 +1114,9 @@ bi_pack_add(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs)
         case BI_BLEND:
                 return bi_pack_add_blend(clause, bundle.add, regs);
         case BI_BITWISE:
+                return BIFROST_ADD_NOP;
         case BI_CONVERT:
+		return bi_pack_convert(bundle.add, regs, false);
         case BI_DISCARD:
         case BI_FREXP:
         case BI_ISUB:
diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h
index 8700b18d436..5552dd92585 100644
--- a/src/panfrost/bifrost/bifrost.h
+++ b/src/panfrost/bifrost/bifrost.h
@@ -335,6 +335,7 @@ struct bifrost_shift_add {
 
 /* Two sources for vectorization */
 #define BIFROST_FMA_FLOAT32_TO_16 (0xdd000 >> 3)
+#define BIFROST_ADD_FLOAT32_TO_16 (0x0EC00 >> 3)
 
 enum bifrost_convert_mode {
         BIFROST_CONV_UNK0 = 0,
@@ -361,6 +362,7 @@ enum bifrost_convert_mode {
         ((is_unsigned & 1) | ((roundmode & 3) << 1) | ((swizzle & 3) << 3) | ((mode & 7) << 5))
 
 #define BIFROST_FMA_CONVERT (0xe0000)
+#define BIFROST_ADD_CONVERT (0x07800)
 
 enum bifrost_ldst_type {
         BIFROST_LDST_F16 = 0,



More information about the mesa-commit mailing list