summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/lower_instructions.cpp
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2017-03-17 14:58:22 +0100
committerSamuel Pitoiset <[email protected]>2017-03-22 22:02:12 +0100
commit737c734cd4851968542c58892e50c3afa55471ef (patch)
tree09c78c4876f1e5243a8b6e549234a770790097c8 /src/compiler/glsl/lower_instructions.cpp
parent448f4c0c891945ea3d440d26045db33580673db7 (diff)
glsl: lower sqrt(abs()) and inversesqrt(abs()) if requested
Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/glsl/lower_instructions.cpp')
-rw-r--r--src/compiler/glsl/lower_instructions.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/compiler/glsl/lower_instructions.cpp b/src/compiler/glsl/lower_instructions.cpp
index 729cb13f84f..697bb84344e 100644
--- a/src/compiler/glsl/lower_instructions.cpp
+++ b/src/compiler/glsl/lower_instructions.cpp
@@ -168,6 +168,7 @@ private:
void find_lsb_to_float_cast(ir_expression *ir);
void find_msb_to_float_cast(ir_expression *ir);
void imul_high_to_mul(ir_expression *ir);
+ void sqrt_to_abs_sqrt(ir_expression *ir);
ir_expression *_carry(operand a, operand b);
};
@@ -1582,6 +1583,13 @@ lower_instructions_visitor::imul_high_to_mul(ir_expression *ir)
}
}
+void
+lower_instructions_visitor::sqrt_to_abs_sqrt(ir_expression *ir)
+{
+ ir->operands[0] = new(ir) ir_expression(ir_unop_abs, ir->operands[0]);
+ this->progress = true;
+}
+
ir_visitor_status
lower_instructions_visitor::visit_leave(ir_expression *ir)
{
@@ -1719,6 +1727,12 @@ lower_instructions_visitor::visit_leave(ir_expression *ir)
imul_high_to_mul(ir);
break;
+ case ir_unop_rsq:
+ case ir_unop_sqrt:
+ if (lowering(SQRT_TO_ABS_SQRT))
+ sqrt_to_abs_sqrt(ir);
+ break;
+
default:
return visit_continue;
}