pan/bi: Add preliminary LOAD_UNIFORM implementation
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 6 Mar 2020 14:52:09 +0000 (09:52 -0500)
committerMarge Bot <eric+marge@anholt.net>
Sat, 7 Mar 2020 00:37:39 +0000 (00:37 +0000)
Lots of things are missing (indirect access, UBOs) but we have this
stubbed out for now.

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

src/panfrost/bifrost/bi_print.c
src/panfrost/bifrost/bi_tables.c
src/panfrost/bifrost/bifrost_compile.c
src/panfrost/bifrost/compiler.h

index 9bdb84e1a4d14b2b1b40565327c70c87bf985bae..863e894606c087c576eaf8873d2bc1ee4a91aa7a 100644 (file)
@@ -122,6 +122,7 @@ bi_class_name(enum bi_class cl)
         case BI_FMA: return "fma";
         case BI_FREXP: return "frexp";
         case BI_LOAD: return "load";
+        case BI_LOAD_UNIFORM: return "load_uniform";
         case BI_LOAD_ATTR: return "load_attr";
         case BI_LOAD_VAR: return "load_var";
         case BI_LOAD_VAR_ADDRESS: return "load_var_address";
@@ -290,7 +291,7 @@ bi_print_instruction(bi_instruction *ins, FILE *fp)
 
         if (ins->type == BI_MINMAX)
                 fprintf(fp, "%s", bi_minmax_mode_name(ins->minmax));
-        else if (ins->type == BI_LOAD_ATTR || ins->type == BI_LOAD_VAR_ADDRESS)
+        else if (ins->type == BI_LOAD_ATTR || ins->type == BI_LOAD_VAR_ADDRESS || ins->type == BI_LOAD_UNIFORM)
                 bi_print_load(&ins->load, fp);
         else if (ins->type == BI_LOAD_VAR)
                 bi_print_load_vary(&ins->load_vary, fp);
index 3239e5670f600dc68d28e2b108695a13a1aea06a..06430d0912bb31f349a63deb0a51bf063ba45cc4 100644 (file)
@@ -39,6 +39,7 @@ unsigned bi_class_props[BI_NUM_CLASSES] = {
         [BI_FMA]               = BI_ROUNDMODE | BI_SCHED_FMA,
         [BI_FREXP]             = BI_SCHED_ALL,
         [BI_LOAD]              = BI_SCHED_HI_LATENCY,
+        [BI_LOAD_UNIFORM]      = BI_SCHED_HI_LATENCY,
         [BI_LOAD_ATTR]                 = BI_SCHED_HI_LATENCY,
         [BI_LOAD_VAR]          = BI_SCHED_HI_LATENCY,
         [BI_LOAD_VAR_ADDRESS]  = BI_SCHED_HI_LATENCY,
index c48a3d37d4dfc70c1af45481f5d45f5dc9deb0f9..3aedcd063fc87f64d3326dc6222a5673d5c3392d 100644 (file)
@@ -165,6 +165,24 @@ bi_emit_st_vary(bi_context *ctx, nir_intrinsic_instr *instr)
         bi_emit(ctx, st);
 }
 
+static void
+bi_emit_ld_uniform(bi_context *ctx, nir_intrinsic_instr *instr)
+{
+        /* TODO: Indirect access */
+
+        bi_instruction ld = {
+                .type = BI_LOAD_UNIFORM,
+                .load = bi_direct_load_for_instr(instr),
+                .dest = bir_dest_index(&instr->dest),
+                .dest_type = nir_intrinsic_type(instr),
+                .src = {
+                        BIR_INDEX_ZERO /* TODO: UBOs */
+                }
+        };
+
+        bi_emit(ctx, ld);
+}
+
 static void
 emit_intrinsic(bi_context *ctx, nir_intrinsic_instr *instr)
 {
@@ -192,6 +210,11 @@ emit_intrinsic(bi_context *ctx, nir_intrinsic_instr *instr)
                 else
                         unreachable("Unsupported shader stage");
                 break;
+
+        case nir_intrinsic_load_uniform:
+                bi_emit_ld_uniform(ctx, instr);
+                break;
+
         default:
                 /* todo */
                 break;
index 18127bacfd8e6dbedbbc58cc07f5a9b92c1948b3..de417fb8e3eb4a0c393884373dac7734fa513406 100644 (file)
@@ -59,6 +59,7 @@ enum bi_class {
         BI_FMA,
         BI_FREXP,
         BI_LOAD,
+        BI_LOAD_UNIFORM,
         BI_LOAD_ATTR,
         BI_LOAD_VAR,
         BI_LOAD_VAR_ADDRESS,
@@ -112,12 +113,12 @@ extern unsigned bi_class_props[BI_NUM_CLASSES];
 /* It can't get any worse than csel4... can it? */
 #define BIR_SRC_COUNT 4
 
-/* Class-specific data for BI_LD_ATTR, BI_LD_VAR_ADDR */
+/* Class-specific data for BI_LOAD, BI_LD_ATTR, BI_LD_VAR_ADDR */
 struct bi_load {
-        /* Note: no indirects here */
+        /* Note: LD_ATTR does not support indirects */
         unsigned location;
 
-        /* Only for BI_LD_ATTR. But number of vector channels */
+        /* Number of vector channels */
         unsigned channels;
 };