broadcom/vc5: Add support for loading varyings in V3D 4.1.
authorEric Anholt <eric@anholt.net>
Thu, 11 Jan 2018 19:53:13 +0000 (11:53 -0800)
committerEric Anholt <eric@anholt.net>
Sat, 13 Jan 2018 05:57:21 +0000 (21:57 -0800)
The LDVARY signal now writes an arbitrary register, so I took out the
magic src register file and replaced it with an instruction with LDVARY
set so we have somewhere to hang a QFILE_TEMP destination for register
allocation.

src/broadcom/compiler/nir_to_vir.c
src/broadcom/compiler/v3d_compiler.h
src/broadcom/compiler/vir.c
src/broadcom/compiler/vir_dump.c
src/broadcom/compiler/vir_opt_dead_code.c
src/broadcom/compiler/vir_to_qpu.c

index 8f37e3b3e3f8e7c186bade72b5b67b1fa26e7e0e..955083b717d01fbf4ffc9b47651b2e12c3d73e09 100644 (file)
@@ -395,9 +395,20 @@ static struct qreg
 emit_fragment_varying(struct v3d_compile *c, nir_variable *var,
                       uint8_t swizzle)
 {
-        struct qreg vary = vir_reg(QFILE_VARY, ~0);
+        struct qreg r3 = vir_reg(QFILE_MAGIC, V3D_QPU_WADDR_R3);
         struct qreg r5 = vir_reg(QFILE_MAGIC, V3D_QPU_WADDR_R5);
 
+        struct qreg vary;
+        if (c->devinfo->ver >= 41) {
+                struct qinst *ldvary = vir_add_inst(V3D_QPU_A_NOP, c->undef,
+                                                    c->undef, c->undef);
+                ldvary->qpu.sig.ldvary = true;
+                vary = vir_emit_def(c, ldvary);
+        } else {
+                vir_NOP(c)->qpu.sig.ldvary = true;
+                vary = r3;
+        }
+
         /* For gl_PointCoord input or distance along a line, we'll be called
          * with no nir_variable, and we don't count toward VPM size so we
          * don't track an input slot.
index 1de0bfc1abd48e303ed98d287f7c02f2ff87bb46..cccb54184a55e660526975982ed56424a27c6e86 100644 (file)
@@ -73,7 +73,6 @@ enum qfile {
          * or physical registers later.
          */
         QFILE_TEMP,
-        QFILE_VARY,
         QFILE_UNIF,
         QFILE_TLB,
         QFILE_TLBU,
index 94593e3f6c7a899013532409d3007c902cde6304..7ea431036eff06e2e35ca707b7e2bc672b4cc9f1 100644 (file)
@@ -110,6 +110,7 @@ vir_has_side_effects(struct v3d_compile *c, struct qinst *inst)
         }
 
         if (inst->qpu.sig.ldtmu ||
+            inst->qpu.sig.ldvary ||
             inst->qpu.sig.wrtmuc ||
             inst->qpu.sig.thrsw) {
                 return true;
@@ -210,7 +211,6 @@ vir_writes_r3(const struct v3d_device_info *devinfo, struct qinst *inst)
 {
         for (int i = 0; i < vir_get_nsrc(inst); i++) {
                 switch (inst->src[i].file) {
-                case QFILE_VARY:
                 case QFILE_VPM:
                         return true;
                 default:
index cdb1928ed006de58ab0150528d324d2d2c6be9cf..ef860cbb5c1c4f537e5117ebc48753cd8a6d9433 100644 (file)
@@ -29,7 +29,6 @@ vir_print_reg(struct v3d_compile *c, struct qreg reg)
 {
         static const char *files[] = {
                 [QFILE_TEMP] = "t",
-                [QFILE_VARY] = "v",
                 [QFILE_UNIF] = "u",
                 [QFILE_TLB] = "tlb",
                 [QFILE_TLBU] = "tlbu",
index 9e0ef20b6dbeae0decf8052e9a92b3929c828d46..1f9e504e6be579db82239fb08ff8961354ea952e 100644 (file)
@@ -78,12 +78,6 @@ has_nonremovable_reads(struct v3d_compile *c, struct qinst *inst)
                         if (total_size == 1)
                                 return true;
                 }
-
-                /* Dead code removal of varyings is tricky, so just assert
-                 * that it all happened at the NIR level.
-                 */
-                if (inst->src[i].file == QFILE_VARY)
-                        return true;
         }
 
         return false;
index 9229fa5ba47122acf8aae657156266e6633d5b99..432f156218ca5c772e14412a3f463d0db53d9308 100644 (file)
@@ -189,12 +189,6 @@ v3d_generate_code_block(struct v3d_compile *c,
 
                                 src[i] = qpu_acc(5);
                                 break;
-                        case QFILE_VARY:
-                                temp = new_qpu_nop_before(qinst);
-                                temp->qpu.sig.ldvary = true;
-
-                                src[i] = qpu_acc(3);
-                                break;
                         case QFILE_SMALL_IMM:
                                 abort(); /* XXX */
 #if 0
@@ -255,7 +249,6 @@ v3d_generate_code_block(struct v3d_compile *c,
                         dst = qpu_magic(V3D_QPU_WADDR_TLBU);
                         break;
 
-                case QFILE_VARY:
                 case QFILE_UNIF:
                 case QFILE_SMALL_IMM:
                 case QFILE_LOAD_IMM: