From f14beeb4ceeb4b7a07f989f6702aa317c9d7289a Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 4 Nov 2020 08:22:53 -0500 Subject: [PATCH] pan/bi: Infer z/stencil flags from sources passed Signed-off-by: Alyssa Rosenzweig Part-of: --- 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 3c474fa..880eb91 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 9adaa8f..1121de7 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 -- 2.7.4