diff options
author | Abdiel Janulgue <[email protected]> | 2014-06-16 12:28:00 -0700 |
---|---|---|
committer | Abdiel Janulgue <[email protected]> | 2014-08-31 21:04:09 +0300 |
commit | cbd225057ad6df7ac3f8c982ecec64ec4658013c (patch) | |
tree | 4504a3cefe9ade58d94b1acabed02e03f9f20e53 | |
parent | b2c0c35907eb5f0b271b3d5a9799539a53cdfe20 (diff) |
i965/fs: Refactor try_emit_saturate
v3: Since the fs backend can emit saturate as a separate instruction, there is
no need to detect for min/max instructions and to rewrite the instruction tree
accordingly. On the other hand, we don't need to emit a separate saturated
mov either when the expression generating src can do saturate directly.
v4: Add can_do_saturate() check before enabling saturate modifer (Ken)
Reviewed-by: Matt Turner <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Signed-off-by: Abdiel Janulgue <[email protected]>
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 7ceca0eb304..24d6bcea476 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -267,17 +267,14 @@ fs_visitor::emit_minmax(enum brw_conditional_mod conditionalmod, const fs_reg &d } } -/* Instruction selection: Produce a MOV.sat instead of - * MIN(MAX(val, 0), 1) when possible. - */ bool fs_visitor::try_emit_saturate(ir_expression *ir) { - ir_rvalue *sat_val = ir->as_rvalue_to_saturate(); - - if (!sat_val) + if (ir->operation != ir_unop_saturate) return false; + ir_rvalue *sat_val = ir->operands[0]; + fs_inst *pre_inst = (fs_inst *) this->instructions.get_tail(); sat_val->accept(this); @@ -285,21 +282,17 @@ fs_visitor::try_emit_saturate(ir_expression *ir) fs_inst *last_inst = (fs_inst *) this->instructions.get_tail(); - /* If the last instruction from our accept() didn't generate our - * src, generate a saturated MOV + /* If the last instruction from our accept() generated our + * src, just set the saturate flag instead of emmitting a separate mov. */ fs_inst *modify = get_instruction_generating_reg(pre_inst, last_inst, src); - if (!modify || modify->regs_written != 1) { - this->result = fs_reg(this, ir->type); - fs_inst *inst = emit(MOV(this->result, src)); - inst->saturate = true; - } else { + if (modify && modify->regs_written == 1 && modify->can_do_saturate()) { modify->saturate = true; this->result = src; + return true; } - - return true; + return false; } bool |