pan/bi: Add fp16 support for frcp/frsq
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 6 Apr 2020 14:36:10 +0000 (10:36 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 6 Apr 2020 19:41:56 +0000 (19:41 +0000)
More ops.

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

src/panfrost/bifrost/bi_pack.c
src/panfrost/bifrost/bifrost.h

index c6439c39e0c6a2b0a78c4cba85f9c331cbea64d4..81f149cf56280e8120e36d4f78237f05bb5c9e99 100644 (file)
@@ -989,11 +989,20 @@ static unsigned
 bi_pack_add_special(bi_instruction *ins, struct bi_registers *regs)
 {
         unsigned op = 0;
+        bool fp16 = ins->dest_type == nir_type_float16;
+        bool Y = ins->swizzle[0][0];
 
         if (ins->op.special == BI_SPECIAL_FRCP) {
-                op = BIFROST_ADD_OP_FRCP_FAST_F32;
+                op = fp16 ?
+                        (Y ? BIFROST_ADD_OP_FRCP_FAST_F16_Y :
+                        BIFROST_ADD_OP_FRCP_FAST_F16_X) :
+                        BIFROST_ADD_OP_FRCP_FAST_F32;
         } else {
-                op = BIFROST_ADD_OP_FRSQ_FAST_F32;
+                op = fp16 ?
+                        (Y ? BIFROST_ADD_OP_FRSQ_FAST_F16_Y :
+                        BIFROST_ADD_OP_FRSQ_FAST_F16_X) :
+                        BIFROST_ADD_OP_FRSQ_FAST_F32;
+
         }
 
         return bi_pack_add_1src(ins, regs, op);
index 31ea14db63c42d66c1ecfa18575083a078b980ac..602788a72259cd030ee3ce26364c3d62d95b6622 100644 (file)
@@ -111,7 +111,11 @@ struct bifrost_fma_2src {
 
 #define BIFROST_ADD_OP_BLEND (0x1952c)
 #define BIFROST_ADD_OP_FRCP_FAST_F32 (0x0cc00)
+#define BIFROST_ADD_OP_FRCP_FAST_F16_X (0x0ce10)
+#define BIFROST_ADD_OP_FRCP_FAST_F16_Y (0x0ce30)
 #define BIFROST_ADD_OP_FRSQ_FAST_F32 (0x0cc20)
+#define BIFROST_ADD_OP_FRSQ_FAST_F16_X (0x0ce50)
+#define BIFROST_ADD_OP_FRSQ_FAST_F16_Y (0x0ce70)
 
 struct bifrost_add_inst {
         unsigned src0 : 3;