ir_to_mesa: Fix binop_sqrt for multi-channel and negative source channels.
authorEric Anholt <eric@anholt.net>
Mon, 28 Jun 2010 20:01:49 +0000 (13:01 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 28 Jun 2010 20:03:10 +0000 (13:03 -0700)
Fixes glsl-fs-sqrt-branch.

src/mesa/shader/ir_to_mesa.cpp

index 9cf783914849be749e8d8755c538932f75a1076c..d371e35f9cfc2b0594cec202b19f8637247a3759 100644 (file)
@@ -706,7 +706,10 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
       break;
    case ir_unop_sqrt:
       ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]);
-      ir_to_mesa_emit_op1(ir, OPCODE_RCP, result_dst, result_src);
+      ir_to_mesa_emit_scalar_op1(ir, OPCODE_RCP, result_dst, result_src);
+      /* For incoming channels < 0, set the result to 0. */
+      ir_to_mesa_emit_op3(ir, OPCODE_CMP, result_dst,
+                         op[0], src_reg_for_float(0.0), result_src);
       break;
    case ir_unop_rsq:
       ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]);