vc4: Redo VPM reads as a read file.
authorEric Anholt <eric@anholt.net>
Sat, 10 Jan 2015 01:07:12 +0000 (14:07 +1300)
committerEric Anholt <eric@anholt.net>
Sat, 10 Jan 2015 01:35:24 +0000 (14:35 +1300)
This will let us do copy propagation of the VPM reads.

src/gallium/drivers/vc4/vc4_opt_copy_propagation.c
src/gallium/drivers/vc4/vc4_program.c
src/gallium/drivers/vc4/vc4_qir.c
src/gallium/drivers/vc4/vc4_qir.h
src/gallium/drivers/vc4/vc4_qpu_emit.c

index 5ead3787ac5bd592ebe8d9313c604c388c065d86..07e1cb14b0d8636359ae5323d324e7d402c83156 100644 (file)
@@ -87,9 +87,10 @@ qir_opt_copy_propagation(struct vc4_compile *c)
 
                 if (inst->op == QOP_MOV &&
                     inst->dst.file == QFILE_TEMP &&
-                    (inst->src[0].file != QFILE_TEMP ||
-                     (defs[inst->src[0].index]->op != QOP_TEX_RESULT &&
-                      defs[inst->src[0].index]->op != QOP_TLB_COLOR_READ))) {
+                    inst->src[0].file != QFILE_VPM &&
+                    !(inst->src[0].file == QFILE_TEMP &&
+                      (defs[inst->src[0].index]->op == QOP_TEX_RESULT ||
+                       defs[inst->src[0].index]->op == QOP_TLB_COLOR_READ))) {
                         movs[inst->dst.index] = inst->src[0];
                 }
         }
index e362dcdf6ca5655887e24bf9d4ca3d0e873b9f9c..56cd5c27d7bbd45af9a45812024557ff675155e9 100644 (file)
@@ -1080,7 +1080,8 @@ emit_vertex_input(struct vc4_compile *c, int attr)
         struct qreg vpm_reads[4];
 
         for (int i = 0; i < align(attr_size, 4) / 4; i++) {
-                vpm_reads[i] = qir_VPM_READ(c);
+                struct qreg vpm = { QFILE_VPM, attr * 4 + i };
+                vpm_reads[i] = qir_MOV(c, vpm);
                 c->num_inputs++;
         }
 
@@ -1933,10 +1934,8 @@ emit_stub_vpm_read(struct vc4_compile *c)
                 return;
 
         for (int i = 0; i < 4; i++) {
-                qir_emit(c, qir_inst(QOP_VPM_READ,
-                                     qir_get_temp(c),
-                                     c->undef,
-                                     c->undef));
+                struct qreg vpm = { QFILE_VPM, 0 };
+                (void)qir_MOV(c, vpm);
                 c->num_inputs++;
         }
 }
index 5f3b8ddc4456279cc59f9d283919c5b8b9de091f..4f73932e233f8d08dd31314a30ed3888ae4423be 100644 (file)
@@ -79,7 +79,6 @@ static const struct qir_op_info qir_op_info[] = {
         [QOP_PACK_8C_F] = { "pack_8c_f", 1, 2, false, true },
         [QOP_PACK_8D_F] = { "pack_8d_f", 1, 2, false, true },
         [QOP_PACK_SCALED] = { "pack_scaled", 1, 2, false, true },
-        [QOP_VPM_READ] = { "vpm_read", 0, 1, true },
         [QOP_TLB_DISCARD_SETUP] = { "discard", 0, 1, true },
         [QOP_TLB_STENCIL_SETUP] = { "tlb_stencil_setup", 0, 1, true },
         [QOP_TLB_Z_WRITE] = { "tlb_z", 0, 1, true },
@@ -152,6 +151,9 @@ qir_has_side_effects(struct vc4_compile *c, struct qinst *inst)
                     c->input_semantics[inst->src[i].index].semantic == 0xff) {
                         return true;
                 }
+
+                if (inst->src[i].file == QFILE_VPM)
+                        return true;
         }
 
         if (inst->dst.file == QFILE_VPM)
index d8f9babef4ce4457eb3f212bb8931b2730043e3c..0c2bca93d8bc0f9ec4a534345fc0f968e51a3d1d 100644 (file)
@@ -105,7 +105,6 @@ enum qop {
         QOP_PACK_8B_F,
         QOP_PACK_8C_F,
         QOP_PACK_8D_F,
-        QOP_VPM_READ,
         QOP_TLB_DISCARD_SETUP,
         QOP_TLB_STENCIL_SETUP,
         QOP_TLB_Z_WRITE,
@@ -495,7 +494,6 @@ QIR_ALU0(FRAG_W)
 QIR_ALU0(FRAG_REV_FLAG)
 QIR_ALU0(TEX_RESULT)
 QIR_ALU0(TLB_COLOR_READ)
-QIR_ALU0(VPM_READ)
 QIR_NODST_1(TLB_Z_WRITE)
 QIR_NODST_1(TLB_DISCARD_SETUP)
 QIR_NODST_1(TLB_STENCIL_SETUP)
index 857d56e0f442d3710355cf8e567fe48dd065ad41..f3f50ec68f8feb7b98e135af7038bcc33d52f9b8 100644 (file)
@@ -147,6 +147,7 @@ vc4_generate_code(struct vc4_context *vc4, struct vc4_compile *c)
         uint32_t inputs_remaining = c->num_inputs;
         uint32_t vpm_read_fifo_count = 0;
         uint32_t vpm_read_offset = 0;
+        int last_vpm_read_index = -1;
         bool written_r3 = false;
         bool needs_restore;
         /* Map from the QIR ops enum order to QPU unpack bits. */
@@ -250,7 +251,10 @@ vc4_generate_code(struct vc4_context *vc4, struct vc4_compile *c)
                                 assert(src[i].addr <= 47);
                                 break;
                         case QFILE_VPM:
-                                assert(!"not reached");
+                                assert((int)qinst->src[i].index >=
+                                       last_vpm_read_index);
+                                last_vpm_read_index = qinst->src[i].index;
+                                src[i] = qpu_ra(QPU_R_VPM);
                                 break;
                         }
                 }
@@ -314,10 +318,6 @@ vc4_generate_code(struct vc4_context *vc4, struct vc4_compile *c)
 
                         break;
 
-                case QOP_VPM_READ:
-                        queue(c, qpu_a_MOV(dst, qpu_ra(QPU_R_VPM)));
-                        break;
-
                 case QOP_RCP:
                 case QOP_RSQ:
                 case QOP_EXP2: