[Mesa-dev] [PATCH 07/16] glsl: Add saturate to get_range

Thomas Helland thomashelland90 at gmail.com
Sun Nov 16 17:51:52 PST 2014


We can use the intersection function to reduce the range
even further if the operand has bounds between 0.0 and 1.0.
---
 src/glsl/opt_minmax.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/glsl/opt_minmax.cpp b/src/glsl/opt_minmax.cpp
index 341006e..b925aaa 100644
--- a/src/glsl/opt_minmax.cpp
+++ b/src/glsl/opt_minmax.cpp
@@ -292,6 +292,13 @@ 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]);
+         // We can get the intersection here to limit the range even more
+         return range_intersection(r0, minmax_range(low, high));
+
       default:
          break;
       }
-- 
2.0.3



More information about the mesa-dev mailing list