diff options
author | Eric Anholt <[email protected]> | 2016-11-15 12:54:26 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2016-11-29 08:38:59 -0800 |
commit | d4c20e82ae34b105fb2d06c8c412656aba2ca1b9 (patch) | |
tree | 353ef165ca46bb0ec7dbe3a500926c50350b6309 /src/gallium/drivers/vc4/vc4_qir.c | |
parent | 314f0c57e4c00b0a5cb544fa43e356c1069acd8f (diff) |
vc4: Restructure texture insts as ALU ops with tex_[strb] as the dst.
For now we're still just generating MOVs, but this will let us fold into
other ops in the future. No difference on shader-db.
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_qir.c')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_qir.c | 72 |
1 files changed, 65 insertions, 7 deletions
diff --git a/src/gallium/drivers/vc4/vc4_qir.c b/src/gallium/drivers/vc4/vc4_qir.c index 2c9119d9ccf..7c556a98ea2 100644 --- a/src/gallium/drivers/vc4/vc4_qir.c +++ b/src/gallium/drivers/vc4/vc4_qir.c @@ -75,11 +75,6 @@ static const struct qir_op_info qir_op_info[] = { [QOP_FRAG_Z] = { "frag_z", 1, 0 }, [QOP_FRAG_W] = { "frag_w", 1, 0 }, - [QOP_TEX_S] = { "tex_s", 0, 2, true }, - [QOP_TEX_T] = { "tex_t", 0, 2, true }, - [QOP_TEX_R] = { "tex_r", 0, 2, true }, - [QOP_TEX_B] = { "tex_b", 0, 2, true }, - [QOP_TEX_DIRECT] = { "tex_direct", 0, 2, true }, [QOP_TEX_RESULT] = { "tex_result", 1, 0, true }, [QOP_THRSW] = { "thrsw", 0, 0, true }, @@ -104,12 +99,37 @@ qir_get_op_name(enum qop qop) } int -qir_get_nsrc(struct qinst *inst) +qir_get_non_sideband_nsrc(struct qinst *inst) { assert(qir_op_info[inst->op].name); return qir_op_info[inst->op].nsrc; } +int +qir_get_nsrc(struct qinst *inst) +{ + assert(qir_op_info[inst->op].name); + + int nsrc = qir_get_non_sideband_nsrc(inst); + + /* Normal (non-direct) texture coordinate writes also implicitly load + * a uniform for the texture parameters. + */ + if (qir_is_tex(inst) && inst->dst.file != QFILE_TEX_S_DIRECT) + nsrc++; + + return nsrc; +} + +/* The sideband uniform for textures gets stored after the normal ALU + * arguments. + */ +int +qir_get_tex_uniform_src(struct qinst *inst) +{ + return qir_get_nsrc(inst) - 1; +} + /** * Returns whether the instruction has any side effects that must be * preserved. @@ -122,6 +142,11 @@ qir_has_side_effects(struct vc4_compile *c, struct qinst *inst) case QFILE_TLB_COLOR_WRITE: case QFILE_TLB_COLOR_WRITE_MS: case QFILE_TLB_STENCIL_SETUP: + case QFILE_TEX_S_DIRECT: + case QFILE_TEX_S: + case QFILE_TEX_T: + case QFILE_TEX_R: + case QFILE_TEX_B: return true; default: break; @@ -206,7 +231,30 @@ qir_is_raw_mov(struct qinst *inst) bool qir_is_tex(struct qinst *inst) { - return inst->op >= QOP_TEX_S && inst->op <= QOP_TEX_DIRECT; + switch (inst->dst.file) { + case QFILE_TEX_S_DIRECT: + case QFILE_TEX_S: + case QFILE_TEX_T: + case QFILE_TEX_R: + case QFILE_TEX_B: + return true; + default: + return false; + } +} + +bool +qir_has_implicit_tex_uniform(struct qinst *inst) +{ + switch (inst->dst.file) { + case QFILE_TEX_S: + case QFILE_TEX_T: + case QFILE_TEX_R: + case QFILE_TEX_B: + return true; + default: + return false; + } } bool @@ -298,6 +346,11 @@ qir_print_reg(struct vc4_compile *c, struct qreg reg, bool write) [QFILE_FRAG_Y] = "frag_y", [QFILE_FRAG_REV_FLAG] = "frag_rev_flag", [QFILE_QPU_ELEMENT] = "elem", + [QFILE_TEX_S_DIRECT] = "tex_s_direct", + [QFILE_TEX_S] = "tex_s", + [QFILE_TEX_T] = "tex_t", + [QFILE_TEX_R] = "tex_r", + [QFILE_TEX_B] = "tex_b", }; switch (reg.file) { @@ -330,6 +383,11 @@ qir_print_reg(struct vc4_compile *c, struct qreg reg, bool write) case QFILE_TLB_COLOR_WRITE_MS: case QFILE_TLB_Z_WRITE: case QFILE_TLB_STENCIL_SETUP: + case QFILE_TEX_S_DIRECT: + case QFILE_TEX_S: + case QFILE_TEX_T: + case QFILE_TEX_R: + case QFILE_TEX_B: fprintf(stderr, "%s", files[reg.file]); break; |