[Mesa-dev] [PATCH 2/3] glsl: Optimize clamp(x, 0.0, b), where b < 1.0 as saturate(min(x, b))
Abdiel Janulgue
abdiel.janulgue at linux.intel.com
Mon Jun 23 22:32:29 PDT 2014
Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
---
src/glsl/opt_algebraic.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index 8d7609d..0d694b6 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -589,6 +589,10 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
/* Found a min (max(x, 0), 1.0) */
if (outer_const->is_one() && inner_val_a->is_zero())
return saturate(inner_val_b);
+
+ /* Found a min (max(x, 0.0) b), where b < 1.0 */
+ if ((outer_const->get_float_component(0) < 1.0f) && inner_val_b->is_zero())
+ return saturate(expr(ir_binop_min, inner_val_a, outer_const));
}
}
--
1.9.1
More information about the mesa-dev
mailing list