[Mesa-dev] [PATCH 5/6] glsl: Add saturate to get_range
Thomas Helland
thomashelland90 at gmail.com
Wed Oct 29 18:11:20 PDT 2014
Also, if the operand has bounds between 0.0 and 1.0
then copy that range up.
Signed-off-by: Thomas Helland <thomashelland90 at gmail.com>
---
src/glsl/opt_minmax.cpp | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/glsl/opt_minmax.cpp b/src/glsl/opt_minmax.cpp
index 0b9ddc2..4088c80 100644
--- a/src/glsl/opt_minmax.cpp
+++ b/src/glsl/opt_minmax.cpp
@@ -293,6 +293,20 @@ get_range(ir_rvalue *rval)
low = new(mem_ctx) ir_constant(-1.0f);
return minmax_range(low, high);
+ case ir_unop_saturate:
+ high = new(mem_ctx) ir_constant(1.0f);
+ low = new(mem_ctx) ir_constant(0.0f);
+ r0 = get_range(expr->operands[0]);
+ // Operand has lower bounds between 0.0 - 1.0 gives us new lower bounds
+ if (r0.low && compare_components(r0.low, low) > EQUAL &&
+ compare_components(r0.low, high) < EQUAL)
+ low = r0.low;
+ // Operand has upper bounds between 0.0 - 1.0 gives us new lower bounds
+ if (r0.high && compare_components(r0.high, low) > EQUAL &&
+ compare_components(r0.high, high) < EQUAL)
+ high = r0.high;
+ return minmax_range(low, high);
+
default:
break;
}
--
2.0.3
More information about the mesa-dev
mailing list