diff options
author | Eric Anholt <[email protected]> | 2016-05-05 18:04:14 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2016-05-06 10:25:55 -0700 |
commit | a1f698881e13a4993e958815b79f8150d48e2739 (patch) | |
tree | b672c8fd5640e76d0b3282abc345c6b46f04134f /src/gallium/drivers/vc4 | |
parent | 890dc19eeba10b4df9c658b524ce743cf4db6765 (diff) |
vc4: Add support for loading immediate values in QIR.
This will be used for resetting the uniform stream in the presence of
branching, but may also be useful as an optimization to reduce how many
uniforms we have to copy out per draw call (in exchange for increasing
icache pressure).
Diffstat (limited to 'src/gallium/drivers/vc4')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_qir.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_qir.h | 17 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_qir_validate.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_qpu_emit.c | 7 |
4 files changed, 32 insertions, 0 deletions
diff --git a/src/gallium/drivers/vc4/vc4_qir.c b/src/gallium/drivers/vc4/vc4_qir.c index 86a7ae023c1..b9676adb3af 100644 --- a/src/gallium/drivers/vc4/vc4_qir.c +++ b/src/gallium/drivers/vc4/vc4_qir.c @@ -81,6 +81,8 @@ static const struct qir_op_info qir_op_info[] = { [QOP_TEX_B] = { "tex_b", 0, 2 }, [QOP_TEX_DIRECT] = { "tex_direct", 0, 2 }, [QOP_TEX_RESULT] = { "tex_result", 1, 0, true }, + + [QOP_LOAD_IMM] = { "load_imm", 0, 1 }, }; static const char * @@ -244,6 +246,10 @@ qir_print_reg(struct vc4_compile *c, struct qreg reg, bool write) fprintf(stderr, "null"); break; + case QFILE_LOAD_IMM: + fprintf(stderr, "0x%08x (%f)", reg.index, uif(reg.index)); + break; + case QFILE_SMALL_IMM: if ((int)reg.index >= -16 && (int)reg.index <= 15) fprintf(stderr, "%d", reg.index); diff --git a/src/gallium/drivers/vc4/vc4_qir.h b/src/gallium/drivers/vc4/vc4_qir.h index d1263b64362..f541c754c88 100644 --- a/src/gallium/drivers/vc4/vc4_qir.h +++ b/src/gallium/drivers/vc4/vc4_qir.h @@ -62,6 +62,12 @@ enum qfile { QFILE_FRAG_REV_FLAG, /** + * Stores an immediate value in the index field that will be used + * directly by qpu_load_imm(). + */ + QFILE_LOAD_IMM, + + /** * Stores an immediate value in the index field that can be turned * into a small immediate field by qpu_encode_small_immediate(). */ @@ -147,6 +153,8 @@ enum qop { * the destination */ QOP_TEX_RESULT, + + QOP_LOAD_IMM, }; struct queued_qpu_inst { @@ -721,4 +729,13 @@ qir_VPM_WRITE(struct vc4_compile *c, struct qreg val) qir_MOV_dest(c, qir_reg(QFILE_VPM, 0), val); } +static inline struct qreg +qir_LOAD_IMM(struct vc4_compile *c, uint32_t val) +{ + struct qreg t = qir_get_temp(c); + qir_emit(c, qir_inst(QOP_LOAD_IMM, t, + qir_reg(QFILE_LOAD_IMM, val), c->undef)); + return t; +} + #endif /* VC4_QIR_H */ diff --git a/src/gallium/drivers/vc4/vc4_qir_validate.c b/src/gallium/drivers/vc4/vc4_qir_validate.c index f41cd634027..af2e3baf815 100644 --- a/src/gallium/drivers/vc4/vc4_qir_validate.c +++ b/src/gallium/drivers/vc4/vc4_qir_validate.c @@ -80,6 +80,7 @@ void qir_validate(struct vc4_compile *c) case QFILE_FRAG_Y: case QFILE_FRAG_REV_FLAG: case QFILE_SMALL_IMM: + case QFILE_LOAD_IMM: fail_instr(inst, "Bad dest file"); break; } @@ -96,6 +97,7 @@ void qir_validate(struct vc4_compile *c) case QFILE_VARY: case QFILE_UNIF: case QFILE_VPM: + case QFILE_LOAD_IMM: break; case QFILE_SMALL_IMM: diff --git a/src/gallium/drivers/vc4/vc4_qpu_emit.c b/src/gallium/drivers/vc4/vc4_qpu_emit.c index ecb70948ece..794757e6d18 100644 --- a/src/gallium/drivers/vc4/vc4_qpu_emit.c +++ b/src/gallium/drivers/vc4/vc4_qpu_emit.c @@ -267,6 +267,7 @@ vc4_generate_code(struct vc4_context *vc4, struct vc4_compile *c) int index = qinst->src[i].index; switch (qinst->src[i].file) { case QFILE_NULL: + case QFILE_LOAD_IMM: src[i] = qpu_rn(0); break; case QFILE_TEMP: @@ -351,6 +352,7 @@ vc4_generate_code(struct vc4_context *vc4, struct vc4_compile *c) case QFILE_VARY: case QFILE_UNIF: case QFILE_SMALL_IMM: + case QFILE_LOAD_IMM: case QFILE_FRAG_X: case QFILE_FRAG_Y: case QFILE_FRAG_REV_FLAG: @@ -390,6 +392,11 @@ vc4_generate_code(struct vc4_context *vc4, struct vc4_compile *c) break; + case QOP_LOAD_IMM: + assert(qinst->src[0].file == QFILE_LOAD_IMM); + queue(c, qpu_load_imm_ui(dst, qinst->src[0].index)); + break; + case QOP_MS_MASK: src[1] = qpu_ra(QPU_R_MS_REV_FLAGS); fixup_raddr_conflict(c, dst, &src[0], &src[1], |