[Mesa-dev] [PATCH] i965/nir: Don't emit a copy after a texture instruction if it's not needed
Jason Ekstrand
jason at jlekstrand.net
Wed Mar 18 21:43:26 PDT 2015
Shader-db results on HSW:
total instructions in shared programs: 4112172 -> 4111347 (-0.02%)
instructions in affected programs: 18265 -> 17440 (-4.52%)
helped: 137
HURT: 0
GAINED: 0
LOST: 0
---
src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index 42c50cb..625a5ae 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -1895,9 +1895,20 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr)
is_cube_array, is_rect, sampler, sampler_reg, texunit);
fs_reg dest = get_nir_dest(instr->dest);
- dest.type = this->result.type;
- unsigned num_components = nir_tex_instr_dest_size(instr);
- emit_percomp(MOV(dest, this->result), (1 << num_components) - 1);
+
+ fs_inst *inst = (fs_inst *) this->instructions.get_tail();
+ if (inst->is_tex() && alloc.sizes[inst->dst.reg] <= alloc.sizes[dest.reg]) {
+ // The last instruction is the actual texture operation and we have
+ // enough space in the NIR dest register. Just smash the destination
+ // with the register from the NIR dest.
+ assert(inst->dst.file == GRF && dest.file == GRF);
+ assert(dest.reg_offset == 0);
+ inst->dst.reg = dest.reg;
+ } else {
+ dest.type = this->result.type;
+ unsigned num_components = nir_tex_instr_dest_size(instr);
+ emit_percomp(MOV(dest, this->result), (1 << num_components) - 1);
+ }
}
void
--
2.3.2
More information about the mesa-dev
mailing list