diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2014-02-21 15:23:42 -0800 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2014-02-21 22:51:33 -0800 |
commit | 760c6777a0530b4894dec564cdf218f5364b4df1 (patch) | |
tree | 60653a63ab875866553104482ac7a3e4808360f7 /src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | |
parent | 326fc60ee9457d17fb97a7f49c977743426b0859 (diff) | |
download | external_mesa3d-760c6777a0530b4894dec564cdf218f5364b4df1.zip external_mesa3d-760c6777a0530b4894dec564cdf218f5364b4df1.tar.gz external_mesa3d-760c6777a0530b4894dec564cdf218f5364b4df1.tar.bz2 |
i965/fs: Drop the emit(fs_inst) overload.
Using this emit function implicitly creates three copies, which
is pointlessly inefficient.
1. Code creates the original instruction.
2. Calling emit(fs_inst) copies it into the function.
3. It then allocates a new fs_inst and copies it into that.
The second could be eliminated by changing the signature to
fs_inst(const fs_inst &)
but that wouldn't eliminate the third. Making callers heap allocate the
instruction and call emit(fs_inst *) allows us to just use the original
one, with no extra copies, and isn't much more of a burden.
Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_fs_visitor.cpp')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 9a0090d..9b090be 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -743,8 +743,8 @@ fs_visitor::visit(ir_expression *ir) packed_consts.type = result.type; fs_reg const_offset_reg = fs_reg(const_offset->value.u[0] & ~15); - emit(fs_inst(FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD, - packed_consts, surf_index, const_offset_reg)); + emit(new(mem_ctx) fs_inst(FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD, + packed_consts, surf_index, const_offset_reg)); for (int i = 0; i < ir->type->vector_elements; i++) { packed_consts.set_smear(const_offset->value.u[0] % 16 / 4 + i); @@ -2399,9 +2399,10 @@ fs_visitor::emit_untyped_atomic(unsigned atomic_op, unsigned surf_index, } /* Emit the instruction. */ - fs_inst inst(SHADER_OPCODE_UNTYPED_ATOMIC, dst, atomic_op, surf_index); - inst.base_mrf = 0; - inst.mlen = mlen; + fs_inst *inst = new(mem_ctx) fs_inst(SHADER_OPCODE_UNTYPED_ATOMIC, dst, + atomic_op, surf_index); + inst->base_mrf = 0; + inst->mlen = mlen; emit(inst); } @@ -2432,22 +2433,14 @@ fs_visitor::emit_untyped_surface_read(unsigned surf_index, fs_reg dst, mlen += operand_len; /* Emit the instruction. */ - fs_inst inst(SHADER_OPCODE_UNTYPED_SURFACE_READ, dst, surf_index); - inst.base_mrf = 0; - inst.mlen = mlen; + fs_inst *inst = new(mem_ctx) + fs_inst(SHADER_OPCODE_UNTYPED_SURFACE_READ, dst, surf_index); + inst->base_mrf = 0; + inst->mlen = mlen; emit(inst); } fs_inst * -fs_visitor::emit(fs_inst inst) -{ - fs_inst *list_inst = new(mem_ctx) fs_inst; - *list_inst = inst; - emit(list_inst); - return list_inst; -} - -fs_inst * fs_visitor::emit(fs_inst *inst) { if (force_uncompressed_stack > 0) |