From a58ae83882b3ad3ecb53271f42cf1fd8f9c2907c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 10 Jan 2015 14:07:12 +1300 Subject: [PATCH] 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 5ead3787ac5..07e1cb14b0d 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 e362dcdf6ca..56cd5c27d7b 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 5f3b8ddc445..4f73932e233 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 d8f9babef4c..0c2bca93d8b 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 857d56e0f44..f3f50ec68f8 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: -- 2.30.2