diff options
author | Rob Clark <[email protected]> | 2019-03-19 13:30:03 -0400 |
---|---|---|
committer | Rob Clark <[email protected]> | 2019-03-21 09:13:05 -0400 |
commit | bcd81d238797fdccaae0e94444162f1a1769a89e (patch) | |
tree | 34b2504fccf70de9cc7e56c2c126c6d84c821083 /src/freedreno/ir3/ir3_cp.c | |
parent | 1443694ee5a063936afc5f273d75294ea77c0bc7 (diff) |
freedreno/ir3: optimize sam.s2en to sam
Detect when sampler/texture idx are immediate and switch to non s2en
encoding.
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/freedreno/ir3/ir3_cp.c')
-rw-r--r-- | src/freedreno/ir3/ir3_cp.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/freedreno/ir3/ir3_cp.c b/src/freedreno/ir3/ir3_cp.c index bbc85b12198..28ba43f09ee 100644 --- a/src/freedreno/ir3/ir3_cp.c +++ b/src/freedreno/ir3/ir3_cp.c @@ -613,6 +613,34 @@ instr_cp(struct ir3_cp_ctx *ctx, struct ir3_instruction *instr) break; } } + + /* Handle converting a sam.s2en (taking samp/tex idx params via + * register) into a normal sam (encoding immediate samp/tex idx) + * if they are immediate. This saves some instructions and regs + * in the common case where we know samp/tex at compile time: + */ + if (is_tex(instr) && (instr->flags & IR3_INSTR_S2EN) && + !(ir3_shader_debug & IR3_DBG_FORCES2EN)) { + /* The first src will be a fan-in (collect), if both of it's + * two sources are mov from imm, then we can + */ + struct ir3_instruction *samp_tex = ssa(instr->regs[1]); + + debug_assert(samp_tex->opc == OPC_META_FI); + + struct ir3_instruction *samp = ssa(samp_tex->regs[1]); + struct ir3_instruction *tex = ssa(samp_tex->regs[2]); + + if ((samp->opc == OPC_MOV) && + (samp->regs[1]->flags & IR3_REG_IMMED) && + (tex->opc == OPC_MOV) && + (tex->regs[1]->flags & IR3_REG_IMMED)) { + instr->flags &= ~IR3_INSTR_S2EN; + instr->cat5.samp = samp->regs[1]->iim_val; + instr->cat5.tex = tex->regs[1]->iim_val; + instr->regs[1]->instr = NULL; + } + } } void |