pan/bi: Infer z/stencil flags from sources passed
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 4 Nov 2020 13:22:53 +0000 (08:22 -0500)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 4 Nov 2020 16:21:28 +0000 (11:21 -0500)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7446>

src/panfrost/bifrost/bi_pack_helpers.h
src/panfrost/bifrost/gen_pack.py

index 3c474fa..880eb91 100644 (file)
@@ -64,6 +64,19 @@ bi_get_src_reg_slot(bi_registers *regs, unsigned src)
                 unreachable("Tried to access register with no port");
 }
 
+/* Sources are usually strictly required, but in a few special cases they can
+ * be made optional with the value passed arbitrary. Check that here */
+
+static bool
+bi_src_nullable(bi_instruction *ins, unsigned s)
+{
+        /* Z/S flags inferred */
+        if (ins->type == BI_ZS_EMIT && s < 2)
+                return true;
+
+        return false;
+}
+
 static inline enum bifrost_packed_src
 bi_get_src(bi_instruction *ins, bi_registers *regs, unsigned s)
 {
@@ -73,6 +86,8 @@ bi_get_src(bi_instruction *ins, bi_registers *regs, unsigned s)
                 return bi_get_src_reg_slot(regs, src);
         else if (src & BIR_INDEX_PASS)
                 return src & ~BIR_INDEX_PASS;
+        else if (!src && bi_src_nullable(ins, s))
+                return BIFROST_SRC_STAGE;
         else {
 #ifndef NDEBUG
                 bi_print_instruction(ins, stderr);
index 9adaa8f..1121de7 100644 (file)
@@ -277,6 +277,10 @@ modifier_map = {
         "divzero": lambda a,b,c,d: '0',
         "sem": lambda a,b,c,d: '0', # IEEE 754 compliant NaN rules
 
+        # For +ZS_EMIT, infer modifiers from specified sources
+        "z": lambda a,b,c,d: '(ins->src[0] != 0)',
+        "stencil": lambda a,b,c,d: '(ins->src[1] != 0)',
+
         # We don't support these in the IR yet (TODO)
         "saturate": lambda a,b,c,d: '0', # clamp to min/max int
         "mask": lambda a,b,c,d: '0', # clz(~0) = ~0
@@ -302,8 +306,6 @@ modifier_map = {
         "subgroup": lambda a,b,c,d: '1', # CLPER subgroup4
         "inactive_result": lambda a,b,c,d: '0', # CLPER zero
         "threads": lambda a,b,c,d: '0', # IMULD odd
-        "stencil": lambda a,b,c,d: '1', # ZS_EMIT stencil
-        "z": lambda a,b,c,d: '1', # ZS_EMIT z
         "combine": lambda a,b,c,d: '0', # BRANCHC any
         "format": lambda a,b,c,d: '1', # LEA_TEX_IMM u32
         "test_mode": lambda a,b,c,d: '0', # JUMP_EX z