diff options
author | Eric Anholt <eric@anholt.net> | 2010-07-06 17:11:03 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2010-07-06 18:49:24 -0700 |
commit | 2d1789e667c4180777829f96856daf91326721b9 (patch) | |
tree | a4a5b6a396269afd115149a0df049605ad2c03c6 /src/mesa/shader/ir_to_mesa.cpp | |
parent | ca088cc277ce9f986693c857f3961dc0e1a4d91c (diff) |
ir_to_mesa: Add support for conditional moves.
Nothing generates conditional moves yet.
Diffstat (limited to 'src/mesa/shader/ir_to_mesa.cpp')
-rw-r--r-- | src/mesa/shader/ir_to_mesa.cpp | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index e1b0397dde..021e270f18 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -286,6 +286,20 @@ ir_to_mesa_dst_reg_from_src(ir_to_mesa_src_reg reg) return dst_reg; } +inline ir_to_mesa_src_reg +ir_to_mesa_src_reg_from_dst(ir_to_mesa_dst_reg reg) +{ + ir_to_mesa_src_reg src_reg; + + src_reg.file = reg.file; + src_reg.index = reg.index; + src_reg.swizzle = SWIZZLE_XYZW; + src_reg.negate = 0; + src_reg.reladdr = 0; + + return src_reg; +} + /** * Emits Mesa scalar opcodes to produce unique answers across channels. * @@ -1192,14 +1206,22 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) assert(r.file != PROGRAM_UNDEFINED); if (ir->condition) { - ir_constant *condition_constant; + ir_to_mesa_src_reg condition; - condition_constant = ir->condition->constant_expression_value(); + ir->condition->accept(this); + condition = this->result; - assert(condition_constant && condition_constant->value.b[0]); + /* We use the OPCODE_CMP (a < 0 ? b : c) for conditional moves, + * and the condition we produced is 0.0 or 1.0. By flipping the + * sign, we can choose which value OPCODE_CMP produces without + * an extra computing the condition. + */ + condition.negate = ~condition.negate; + ir_to_mesa_emit_op3(ir, OPCODE_CMP, l, + condition, r, ir_to_mesa_src_reg_from_dst(l)); + } else { + ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r); } - - ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r); } |