pan/bi: Route through clause header
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 18 Mar 2020 16:18:30 +0000 (12:18 -0400)
committerMarge Bot <eric+marge@anholt.net>
Thu, 19 Mar 2020 03:23:07 +0000 (03:23 +0000)
We already track almost all the information we need, let's dump it onto
the wire now.

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

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

index 65218b2301079529e192f8ed2b3a0e0e7b1432c2..2f961650d3ed8ca2ded37a359d1507ee0e68eaee 100644 (file)
  * bits on the wire (as well as fixup branches) */
 
 static uint64_t
-bi_pack_header(bi_clause *clause, bi_clause *next)
+bi_pack_header(bi_clause *clause, bi_clause *next, bool is_fragment)
 {
         struct bifrost_header header = {
-                /* stub */
+                .back_to_back = clause->back_to_back,
                 .no_end_of_shader = (next != NULL),
+                .elide_writes = is_fragment,
+                .branch_cond = clause->branch_conditional,
+                .datareg_writebarrier = clause->data_register_write_barrier,
+                .datareg = clause->data_register,
+                .scoreboard_deps = clause->dependencies,
+                .scoreboard_index = clause->scoreboard_id,
+                .clause_type = clause->clause_type,
+                .next_clause_type = next ? next->clause_type : 0,
         };
 
         uint64_t u = 0;
@@ -384,7 +392,7 @@ bi_pack_fma(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs)
 }
 
 static unsigned
-bi_pack_add_ld_vary(bi_instruction *ins, struct bi_registers *regs)
+bi_pack_add_ld_vary(bi_clause *clause, bi_instruction *ins, struct bi_registers *regs)
 {
         unsigned size = nir_alu_type_get_type_size(ins->dest_type);
         assert(size == 32 || size == 16);
@@ -408,6 +416,10 @@ bi_pack_add_ld_vary(bi_instruction *ins, struct bi_registers *regs)
                 packed_addr = bi_get_src(ins, regs, 0, false) | 0b11000;
         }
 
+        /* The destination is thrown in the data register */
+        assert(ins->dest & BIR_INDEX_REGISTER);
+        clause->data_register = ins->dest & ~BIR_INDEX_REGISTER;
+
         assert(channels >= 1 && channels <= 4);
 
         struct bifrost_ld_var pack = {
@@ -445,7 +457,7 @@ bi_pack_add(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs)
         case BI_LOAD_ATTR:
                 return BIFROST_ADD_NOP;
         case BI_LOAD_VAR:
-                return bi_pack_add_ld_vary(bundle.add, regs);
+                return bi_pack_add_ld_vary(clause, bundle.add, regs);
         case BI_LOAD_VAR_ADDRESS:
         case BI_MINMAX:
         case BI_MOV:
@@ -492,9 +504,12 @@ bi_pack_clause(bi_context *ctx, bi_clause *clause, bi_clause *next,
         struct bi_packed_bundle ins_1 = bi_pack_bundle(clause, clause->bundles[0], clause->bundles[0], true);
         assert(clause->bundle_count == 1);
 
+        /* Used to decide if we elide writes */
+        bool is_fragment = ctx->stage == MESA_SHADER_FRAGMENT;
+
         struct bifrost_fmt1 quad_1 = {
                 .tag = BIFROST_FMT1_FINAL,
-                .header = bi_pack_header(clause, next),
+                .header = bi_pack_header(clause, next, is_fragment),
                 .ins_1 = ins_1.lo,
                 .ins_2 = ins_1.hi & ((1 << 11) - 1),
                 .ins_0 = (ins_1.hi >> 11) & 0b111,
index 2d3633502ec5d17f6bb4cf43bd6898f929a92fac..3c84c2671d52cc37782f6430c37e42bce8f9348a 100644 (file)
@@ -307,12 +307,18 @@ typedef struct {
         bool back_to_back;
         bool branch_conditional;
 
+        /* Assigned data register */
+        unsigned data_register;
+
         /* Corresponds to the usual bit but shifted by a clause */
         bool data_register_write_barrier;
 
         /* Constants read by this clause. ISA limit. */
         uint64_t constants[8];
         unsigned constant_count;
+
+        /* What type of high latency instruction is here, basically */
+        unsigned clause_type;
 } bi_clause;
 
 typedef struct bi_block {