Mesa (master): vc4: Redo VPM reads as a read file.

Eric Anholt anholt at kemper.freedesktop.org
Sat Jan 10 20:01:33 UTC 2015


Module: Mesa
Branch: master
Commit: a58ae83882b3ad3ecb53271f42cf1fd8f9c2907c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a58ae83882b3ad3ecb53271f42cf1fd8f9c2907c

Author: Eric Anholt <eric at anholt.net>
Date:   Sat Jan 10 14:07:12 2015 +1300

vc4: Redo VPM reads as a read file.

This will let us do copy propagation of the VPM reads.

---

 src/gallium/drivers/vc4/vc4_opt_copy_propagation.c |    7 ++++---
 src/gallium/drivers/vc4/vc4_program.c              |    9 ++++-----
 src/gallium/drivers/vc4/vc4_qir.c                  |    4 +++-
 src/gallium/drivers/vc4/vc4_qir.h                  |    2 --
 src/gallium/drivers/vc4/vc4_qpu_emit.c             |   10 +++++-----
 5 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/gallium/drivers/vc4/vc4_opt_copy_propagation.c b/src/gallium/drivers/vc4/vc4_opt_copy_propagation.c
index 5ead378..07e1cb1 100644
--- a/src/gallium/drivers/vc4/vc4_opt_copy_propagation.c
+++ b/src/gallium/drivers/vc4/vc4_opt_copy_propagation.c
@@ -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];
                 }
         }
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index e362dcd..56cd5c2 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -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++;
         }
 }
diff --git a/src/gallium/drivers/vc4/vc4_qir.c b/src/gallium/drivers/vc4/vc4_qir.c
index 5f3b8dd..4f73932 100644
--- a/src/gallium/drivers/vc4/vc4_qir.c
+++ b/src/gallium/drivers/vc4/vc4_qir.c
@@ -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)
diff --git a/src/gallium/drivers/vc4/vc4_qir.h b/src/gallium/drivers/vc4/vc4_qir.h
index d8f9bab..0c2bca9 100644
--- a/src/gallium/drivers/vc4/vc4_qir.h
+++ b/src/gallium/drivers/vc4/vc4_qir.h
@@ -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)
diff --git a/src/gallium/drivers/vc4/vc4_qpu_emit.c b/src/gallium/drivers/vc4/vc4_qpu_emit.c
index 857d56e..f3f50ec 100644
--- a/src/gallium/drivers/vc4/vc4_qpu_emit.c
+++ b/src/gallium/drivers/vc4/vc4_qpu_emit.c
@@ -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:




More information about the mesa-commit mailing list