[Mesa-dev] [PATCH 07/22] glsl: Add saturate to get_range
Thomas Helland
thomashelland90 at gmail.com
Sat Jan 3 11:18:12 PST 2015
We can use the intersection function to reduce the range
even further if the operand has bounds between 0.0 and 1.0.
v2: Rewrite as suggested by Ian.
Put in alphabetic order.
---
src/glsl/opt_minmax.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/glsl/opt_minmax.cpp b/src/glsl/opt_minmax.cpp
index ffdf203..8fee0aa 100644
--- a/src/glsl/opt_minmax.cpp
+++ b/src/glsl/opt_minmax.cpp
@@ -308,6 +308,11 @@ get_range(ir_rvalue *rval)
low = new(mem_ctx) ir_constant(0.0f);
return minmax_range(low, high);
+ case ir_unop_saturate:
+ r0 = minmax_range(new(mem_ctx) ir_constant(0.0f),
+ new(mem_ctx) ir_constant(1.0f));
+ return range_intersection(get_range(expr->operands[0]), r0);
+
case ir_unop_sin:
case ir_unop_sin_reduced:
case ir_unop_cos:
--
2.2.1
More information about the mesa-dev
mailing list