Mesa (master): pan/bi: Infer z/stencil flags from sources passed

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Nov 4 16:45:35 UTC 2020


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

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Wed Nov  4 08:22:53 2020 -0500

pan/bi: Infer z/stencil flags from sources passed

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

---

 src/panfrost/bifrost/bi_pack_helpers.h | 15 +++++++++++++++
 src/panfrost/bifrost/gen_pack.py       |  6 ++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/panfrost/bifrost/bi_pack_helpers.h b/src/panfrost/bifrost/bi_pack_helpers.h
index 3c474fa9347..880eb91475f 100644
--- a/src/panfrost/bifrost/bi_pack_helpers.h
+++ b/src/panfrost/bifrost/bi_pack_helpers.h
@@ -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);
diff --git a/src/panfrost/bifrost/gen_pack.py b/src/panfrost/bifrost/gen_pack.py
index 9adaa8fcda9..1121de7a3b3 100644
--- a/src/panfrost/bifrost/gen_pack.py
+++ b/src/panfrost/bifrost/gen_pack.py
@@ -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



More information about the mesa-commit mailing list