pan/bi: Rework blend descriptor access handling
authorBoris Brezillon <boris.brezillon@collabora.com>
Mon, 12 Oct 2020 09:19:45 +0000 (11:19 +0200)
committerBoris Brezillon <boris.brezillon@collabora.com>
Thu, 15 Oct 2020 06:05:23 +0000 (08:05 +0200)
The current logic assumes blend descriptors are always retrieved from
the blend descriptor slots present in the FAU RAM, but this assumption
no longer stands when we add blend shaders to the mix. In that case we
need to use an 'opaque blend' whose descriptor is passed through
embedded constants.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7151>

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

index 1d33bed..310216f 100644 (file)
@@ -124,12 +124,6 @@ bi_assign_fau_idx_single(bi_registers *regs,
         if (!ins)
                 return assigned;
 
-        if (ins->type == BI_BLEND) {
-                assert(!assigned);
-                regs->fau_idx = 0x8;
-                return true;
-        }
-
         if (ins->type == BI_BRANCH && clause->branch_constant) {
                 /* By convention branch constant is last */
                 unsigned idx = clause->constant_count - 1;
@@ -186,6 +180,18 @@ bi_assign_fau_idx_single(bi_registers *regs,
                         assigned = true;
                 } else if (ins->src[s] & BIR_INDEX_ZERO && fast_zero) {
                         ins->src[s] = BIR_INDEX_PASS | BIFROST_SRC_STAGE;
+                } else if (ins->src[s] & BIR_INDEX_BLEND) {
+                        unsigned rt = ins->blend_location;
+
+                        assert(rt <= 7);
+                        assert((ins->src[s] & ~BIR_SPECIAL) == BIFROST_SRC_FAU_HI ||
+                               (ins->src[s] & ~BIR_SPECIAL) == BIFROST_SRC_FAU_LO);
+                        ins->src[s] = BIR_INDEX_PASS | (ins->src[s] & ~BIR_SPECIAL);
+                        if (assigned && regs->fau_idx != (8 | rt))
+                                unreachable("Mismatched FAU index");
+
+                        regs->fau_idx = 8 | rt;
+                        assigned = true;
                 } else if (s & BIR_INDEX_UNIFORM) {
                         unreachable("Push uniforms not implemented yet");
                 }
index 509f9a3..17a9d6c 100644 (file)
@@ -158,8 +158,8 @@ bi_emit_frag_out(bi_context *ctx, nir_intrinsic_instr *instr)
                         pan_src_index(&instr->src[0]),
                         BIR_INDEX_REGISTER | 60 /* Can this be arbitrary? */,
                         /* Blend descriptor */
-                        BIR_INDEX_PASS | BIFROST_SRC_FAU_LO,
-                        BIR_INDEX_PASS | BIFROST_SRC_FAU_HI,
+                        BIR_INDEX_BLEND | BIFROST_SRC_FAU_LO,
+                        BIR_INDEX_BLEND | BIFROST_SRC_FAU_HI,
                 },
                 .src_types = {
                         nir_intrinsic_src_type(instr),
index bfc58ae..350a0d4 100644 (file)
@@ -514,11 +514,13 @@ bi_remove_instruction(bi_instruction *ins)
 #define BIR_INDEX_CONSTANT (1 << 29)
 #define BIR_INDEX_ZERO     (1 << 28)
 #define BIR_INDEX_PASS     (1 << 27)
+#define BIR_INDEX_BLEND    (1 << 26)
 
 /* Keep me synced please so we can check src & BIR_SPECIAL */
 
-#define BIR_SPECIAL        ((BIR_INDEX_REGISTER | BIR_INDEX_UNIFORM) | \
-        (BIR_INDEX_CONSTANT | BIR_INDEX_ZERO | BIR_INDEX_PASS))
+#define BIR_SPECIAL        (BIR_INDEX_REGISTER | BIR_INDEX_UNIFORM | \
+                            BIR_INDEX_CONSTANT | BIR_INDEX_ZERO | \
+                            BIR_INDEX_PASS | BIR_INDEX_BLEND)
 
 static inline unsigned
 bi_max_temp(bi_context *ctx)