[Mesa-dev] [PATCH 15/22] glsl: Add ir_triop_lrp to get_range v2

Thomas Helland thomashelland90 at gmail.com
Sat Jan 3 14:25:30 PST 2015


V2: Fix the logic so we don't emit bogus results.
    Fix the comments (spotted by Matt)

---
Now, when we do the correct thing, we no longer get a
reduction in instructions on that one Brutal Legend shader.

 src/glsl/opt_minmax.cpp | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/glsl/opt_minmax.cpp b/src/glsl/opt_minmax.cpp
index 8d63d96..d2e685b 100644
--- a/src/glsl/opt_minmax.cpp
+++ b/src/glsl/opt_minmax.cpp
@@ -457,6 +457,22 @@ get_range(ir_rvalue *rval)
          // Get the range of the addition of op0*op1 and op2
          return resolv_add_range(r0, r1);
 
+      case ir_triop_lrp:
+         r0 = get_range(expr->operands[2]);
+
+         // Get the range of (1-a)
+         r1 = resolv_add_range(get_range(new(mem_ctx) ir_constant(1.0f)),
+               get_range(neg(expr->operands[2])->as_rvalue()));
+
+         // Get the range of (1-a)*x
+         r1 = resolv_mul_range(r1, get_range(expr->operands[0]));
+
+         // Get the range of a*y
+         r0 = resolv_mul_range(r0, get_range(expr->operands[1]));
+
+         // Add the two parts together
+         return resolv_add_range(r0, r1);
+
       default:
          break;
       }
-- 
2.2.1



More information about the mesa-dev mailing list