summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2010-08-31 05:38:50 +0200
committerMarek Olšák <[email protected]>2010-08-31 06:36:52 +0200
commit4f189b3bf57a6500953dac49105f160af5fa6468 (patch)
tree6e406eb6f33443db25d95b6f7808c19fcaedd97b
parent2619b1c96feed72444499021d8a870eab1c37e00 (diff)
ir_to_mesa: use RSQ+MUL instead of RSQ+RCP for SQRT
sqrt(x) = 1/rsq(x) = x*rsq(x) This optimization already was in the old GLSL compiler. Acked on irc by Eric Anholt.
-rw-r--r--src/mesa/program/ir_to_mesa.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index af6d7345a54..516c991855d 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -880,8 +880,9 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
break;
case ir_unop_sqrt:
+ /* sqrt(x) = x * rsq(x). */
ir_to_mesa_emit_scalar_op1(ir, OPCODE_RSQ, result_dst, op[0]);
- ir_to_mesa_emit_scalar_op1(ir, OPCODE_RCP, result_dst, result_src);
+ ir_to_mesa_emit_op2(ir, OPCODE_MUL, result_dst, result_src, op[0]);
/* 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);