Mesa (glsl2): ir_to_mesa: Fix binop_sqrt for multi-channel and negative source channels.

Eric Anholt anholt at kemper.freedesktop.org
Mon Jun 28 13:30:14 PDT 2010


Module: Mesa
Branch: glsl2
Commit: 8f62ad6d0ff3c11808739c74441f82f6f12485d6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8f62ad6d0ff3c11808739c74441f82f6f12485d6

Author: Eric Anholt <eric at anholt.net>
Date:   Mon Jun 28 13:01:49 2010 -0700

ir_to_mesa: Fix binop_sqrt for multi-channel and negative source channels.

Fixes glsl-fs-sqrt-branch.

---

 src/mesa/shader/ir_to_mesa.cpp |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp
index 9cf7839..d371e35 100644
--- a/src/mesa/shader/ir_to_mesa.cpp
+++ b/src/mesa/shader/ir_to_mesa.cpp
@@ -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]);



More information about the mesa-commit mailing list