mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 17:40:11 +01:00
ir_to_mesa: Try to avoid emitting a MOV_SAT to saturate an expression tree.
Fixes a regression in codegen quality for ff_fragment_shader conversion to GLSL -- glean texCombine produces 7.5% fewer Mesa IR instructions.
This commit is contained in:
parent
6bd5f43f21
commit
62722d90af
1 changed files with 24 additions and 4 deletions
|
|
@ -915,10 +915,30 @@ ir_to_mesa_visitor::try_emit_sat(ir_expression *ir)
|
||||||
sat_src->accept(this);
|
sat_src->accept(this);
|
||||||
src_reg src = this->result;
|
src_reg src = this->result;
|
||||||
|
|
||||||
this->result = get_temp(ir->type);
|
/* If we generated an expression instruction into a temporary in
|
||||||
ir_to_mesa_instruction *inst;
|
* processing the saturate's operand, apply the saturate to that
|
||||||
inst = emit(ir, OPCODE_MOV, dst_reg(this->result), src);
|
* instruction. Otherwise, generate a MOV to do the saturate.
|
||||||
inst->saturate = true;
|
*
|
||||||
|
* Note that we have to be careful to only do this optimization if
|
||||||
|
* the instruction in question was what generated src->result. For
|
||||||
|
* example, ir_dereference_array might generate a MUL instruction
|
||||||
|
* to create the reladdr, and return us a src reg using that
|
||||||
|
* reladdr. That MUL result is not the value we're trying to
|
||||||
|
* saturate.
|
||||||
|
*/
|
||||||
|
ir_expression *sat_src_expr = sat_src->as_expression();
|
||||||
|
ir_to_mesa_instruction *new_inst;
|
||||||
|
new_inst = (ir_to_mesa_instruction *)this->instructions.get_tail();
|
||||||
|
if (sat_src_expr && (sat_src_expr->operation == ir_binop_mul ||
|
||||||
|
sat_src_expr->operation == ir_binop_add ||
|
||||||
|
sat_src_expr->operation == ir_binop_dot)) {
|
||||||
|
new_inst->saturate = true;
|
||||||
|
} else {
|
||||||
|
this->result = get_temp(ir->type);
|
||||||
|
ir_to_mesa_instruction *inst;
|
||||||
|
inst = emit(ir, OPCODE_MOV, dst_reg(this->result), src);
|
||||||
|
inst->saturate = true;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue