mesa: fix code generation for ir_unop_sqrt
authorBrian Paul <brianp@vmware.com>
Thu, 2 Sep 2010 13:58:28 +0000 (07:58 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 2 Sep 2010 13:58:33 +0000 (07:58 -0600)
The CMP instruction needed to be flipped to properly handle
operand==0.

Fixes fd.o bug 29923.

src/mesa/program/ir_to_mesa.cpp

index b2ba9a2..f0e14b8 100644 (file)
@@ -1198,9 +1198,10 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
       /* sqrt(x) = x * rsq(x). */
       ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]);
       ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, result_src, op[0]);
-      /* For incoming channels < 0, set the result to 0. */
+      /* For incoming channels <= 0, set the result to 0. */
+      op[0].negate = ~op[0].negate;
       ir_to_mesa_emit_op3(ir, OPCODE_CMP, result_dst,
-                         op[0], src_reg_for_float(0.0), result_src);
+                         op[0], result_src, src_reg_for_float(0.0));
       break;
    case ir_unop_rsq:
       ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]);