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>
This commit is contained in:
Kenneth Graunke
2014-02-21 15:23:42 -08:00
committed by Matt Turner
parent 326fc60ee9
commit 760c6777a0
3 changed files with 17 additions and 25 deletions
+7 -7
View File
@@ -642,8 +642,8 @@ fs_visitor::emit_shader_time_write(enum shader_time_shader_type type,
else
payload = fs_reg(this, glsl_type::uint_type);
emit(fs_inst(SHADER_OPCODE_SHADER_TIME_ADD,
fs_reg(), payload, offset, value));
emit(new(mem_ctx) fs_inst(SHADER_OPCODE_SHADER_TIME_ADD,
fs_reg(), payload, offset, value));
}
void
@@ -672,32 +672,32 @@ fs_visitor::fail(const char *format, ...)
fs_inst *
fs_visitor::emit(enum opcode opcode)
{
return emit(fs_inst(opcode));
return emit(new(mem_ctx) fs_inst(opcode));
}
fs_inst *
fs_visitor::emit(enum opcode opcode, fs_reg dst)
{
return emit(fs_inst(opcode, dst));
return emit(new(mem_ctx) fs_inst(opcode, dst));
}
fs_inst *
fs_visitor::emit(enum opcode opcode, fs_reg dst, fs_reg src0)
{
return emit(fs_inst(opcode, dst, src0));
return emit(new(mem_ctx) fs_inst(opcode, dst, src0));
}
fs_inst *
fs_visitor::emit(enum opcode opcode, fs_reg dst, fs_reg src0, fs_reg src1)
{
return emit(fs_inst(opcode, dst, src0, src1));
return emit(new(mem_ctx) fs_inst(opcode, dst, src0, src1));
}
fs_inst *
fs_visitor::emit(enum opcode opcode, fs_reg dst,
fs_reg src0, fs_reg src1, fs_reg src2)
{
return emit(fs_inst(opcode, dst, src0, src1, src2));
return emit(new(mem_ctx) fs_inst(opcode, dst, src0, src1, src2));
}
void
-1
View File
@@ -284,7 +284,6 @@ public:
bool can_do_source_mods(fs_inst *inst);
fs_inst *emit(fs_inst inst);
fs_inst *emit(fs_inst *inst);
void emit(exec_list list);
+10 -17
View File
@@ -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,21 +2433,13 @@ 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)
{