pan/bi: Pack LD_ATTR
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Sat, 21 Mar 2020 19:25:54 +0000 (15:25 -0400)
committerMarge Bot <eric+marge@anholt.net>
Sun, 22 Mar 2020 03:32:35 +0000 (03:32 +0000)
Also requires the usual R61/62 games.

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

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

index 556ed68961f87a910e949460e54f3a2d68ceeb86..9941b27d61480f83f0b353cad5a80b4eccbdfec6 100644 (file)
@@ -119,7 +119,7 @@ bi_assign_uniform_constant_single(
                 return assigned;
 
         bi_foreach_src(ins, s) {
-                if (s == 0 && ins->type == BI_LOAD_VAR_ADDRESS) continue;
+                if (s == 0 && (ins->type == BI_LOAD_VAR_ADDRESS || ins->type == BI_LOAD_ATTR)) continue;
 
                 if (ins->src[s] & BIR_INDEX_CONSTANT) {
                         /* TODO: lo/hi matching? */
@@ -593,6 +593,25 @@ bi_pack_add_ld_var_addr(bi_clause *clause, bi_instruction *ins, struct bi_regist
         RETURN_PACKED(pack);
 }
 
+static unsigned
+bi_pack_add_ld_attr(bi_clause *clause, bi_instruction *ins, struct bi_registers *regs)
+{
+        /* Only direct loads supported */
+        assert(ins->src[0] == BIR_INDEX_CONSTANT);
+
+        struct bifrost_ld_attr pack = {
+                .src0 = bi_get_src(ins, regs, 1, false),
+                .src1 = bi_get_src(ins, regs, 2, false),
+                .location = ins->constant.u64,
+                .channels = MALI_POSITIVE(bi_load32_components(ins)),
+                .type = bi_pack_ldst_type(ins->dest_type),
+                .op = BIFROST_ADD_OP_LD_ATTR
+        };
+
+        bi_write_data_register(clause, ins);
+        RETURN_PACKED(pack);
+}
+
 static unsigned
 bi_pack_add_st_vary(bi_clause *clause, bi_instruction *ins, struct bi_registers *regs)
 {
@@ -667,10 +686,10 @@ bi_pack_add(bi_clause *clause, bi_bundle bundle, struct bi_registers *regs)
         case BI_ISUB:
         case BI_LOAD:
                 return BIFROST_ADD_NOP;
+        case BI_LOAD_ATTR:
+                return bi_pack_add_ld_attr(clause, bundle.add, regs);
         case BI_LOAD_UNIFORM:
                 return bi_pack_add_ld_ubo(clause, bundle.add, regs);
-        case BI_LOAD_ATTR:
-                return BIFROST_ADD_NOP;
         case BI_LOAD_VAR:
                 return bi_pack_add_ld_vary(clause, bundle.add, regs);
         case BI_LOAD_VAR_ADDRESS:
index 6ee9291ca7b1915f6e0a91fffbc75cf8819f769a..7b8854f56f3eb8c2c3b25ac3473add31de995f83 100644 (file)
@@ -280,6 +280,8 @@ struct bifrost_ld_var_addr {
         unsigned op : 7;
 } __attribute__((packed));
 
+#define BIFROST_ADD_OP_LD_ATTR (0x08000 >> 12)
+
 struct bifrost_ld_attr {
         unsigned src0 : 3;
         unsigned src1 : 3;
index 3d7bbfbba6314b0766bc0c93922a04e2ba9804cc..f3f5f08f11df95f4230c654f7c2082d413554c92 100644 (file)
@@ -167,16 +167,23 @@ bi_emit_frag_out(bi_context *ctx, nir_intrinsic_instr *instr)
         bi_schedule_barrier(ctx);
 }
 
+static bi_instruction
+bi_load_with_r61(enum bi_class T, nir_intrinsic_instr *instr)
+{
+        bi_instruction ld = bi_load(T, instr);
+        ld.src[1] = BIR_INDEX_REGISTER | 61; /* TODO: RA */
+        ld.src[2] = BIR_INDEX_REGISTER | 62;
+        ld.src[3] = 0;
+        ld.src_types[1] = nir_type_uint32;
+        ld.src_types[2] = nir_type_uint32;
+        ld.src_types[3] = nir_intrinsic_type(instr);
+        return ld;
+}
+
 static void
 bi_emit_st_vary(bi_context *ctx, nir_intrinsic_instr *instr)
 {
-        bi_instruction address = bi_load(BI_LOAD_VAR_ADDRESS, instr);
-        address.src[1] = BIR_INDEX_REGISTER | 61; /* TODO: RA */
-        address.src[2] = BIR_INDEX_REGISTER | 62;
-        address.src[3] = 0;
-        address.src_types[1] = nir_type_uint32;
-        address.src_types[2] = nir_type_uint32;
-        address.src_types[3] = nir_intrinsic_type(instr);
+        bi_instruction address = bi_load_with_r61(BI_LOAD_VAR_ADDRESS, instr);
         address.dest = bi_make_temp(ctx);
         address.dest_type = nir_type_uint32;
         address.writemask = (1 << 12) - 1;
@@ -259,7 +266,7 @@ emit_intrinsic(bi_context *ctx, nir_intrinsic_instr *instr)
                 if (ctx->stage == MESA_SHADER_FRAGMENT)
                         bi_emit_ld_vary(ctx, instr);
                 else if (ctx->stage == MESA_SHADER_VERTEX)
-                        bi_emit(ctx, bi_load(BI_LOAD_ATTR, instr));
+                        bi_emit(ctx, bi_load_with_r61(BI_LOAD_ATTR, instr));
                 else {
                         unreachable("Unsupported shader stage");
                 }