pan/bi: Track clause types during scheduling
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 18 Mar 2020 17:43:10 +0000 (13:43 -0400)
committerMarge Bot <eric+marge@anholt.net>
Thu, 19 Mar 2020 03:23:07 +0000 (03:23 +0000)
There's an easy mapping for this, so let's do it. Note we do this at
schedule-time instead of emit since we'll need to lookahead clause
types. The alternative is a prepass running after schedule but before
codegen, but there's no reason not to just stick it here when we're
preparing bi_clause in the first place.

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

src/panfrost/bifrost/bi_schedule.c

index 669b4019d5cc09d5189803c790dd9f384db0eeb7..4adab3bc60e77154cad69bb780b85fc626404be9 100644 (file)
 
 #include "compiler.h"
 
+/* Finds the clause type required or return none */
+
+static enum bifrost_clause_type
+bi_clause_type_for_ins(bi_instruction *ins)
+{
+        unsigned T = ins->type;
+
+        /* Only high latency ops impose clause types */
+        if (!(bi_class_props[T] & BI_SCHED_HI_LATENCY))
+                return BIFROST_CLAUSE_NONE;
+
+        switch (T) {
+        case BI_BRANCH:
+        case BI_DISCARD:
+                return BIFROST_CLAUSE_NONE;
+
+        case BI_LOAD_VAR:
+                return BIFROST_CLAUSE_LOAD_VARY;
+
+        case BI_LOAD_UNIFORM:
+        case BI_LOAD_ATTR:
+        case BI_LOAD_VAR_ADDRESS:
+                return BIFROST_CLAUSE_UBO;
+
+        case BI_TEX:
+                return BIFROST_CLAUSE_TEX;
+
+        case BI_LOAD:
+                return BIFROST_CLAUSE_SSBO_LOAD;
+
+        case BI_STORE:
+        case BI_STORE_VAR:
+                return BIFROST_CLAUSE_SSBO_STORE;
+
+        case BI_BLEND:
+                return BIFROST_CLAUSE_BLEND;
+
+        case BI_ATEST:
+                return BIFROST_CLAUSE_ATEST;
+
+        default:
+                unreachable("Invalid high-latency class");
+        }
+}
+
 /* Eventually, we'll need a proper scheduling, grouping instructions
  * into clauses and ordering/assigning grouped instructions to the
  * appropriate FMA/ADD slots. Right now we do the dumbest possible
@@ -70,6 +115,8 @@ bi_schedule(bi_context *ctx)
                         u->constant_count = 1;
                         u->constants[0] = ins->constant.u64;
 
+                        u->clause_type = bi_clause_type_for_ins(ins);
+
                         list_addtail(&u->link, &bblock->clauses);
                 }