Mesa (master): glsl: Implement saturate as ir_unop_saturate

Abdiel Janulgue abj at kemper.freedesktop.org
Sun Aug 31 18:04:53 UTC 2014


Module: Mesa
Branch: master
Commit: cbd0d643a30901dabc5b3cc84121bafe16f8fc6f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cbd0d643a30901dabc5b3cc84121bafe16f8fc6f

Author: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
Date:   Fri Jun 20 16:55:03 2014 -0700

glsl: Implement saturate as ir_unop_saturate

Now that we have the ir_unop_saturate implemented as a single
instruction, generate the correct simplified expression.

Reviewed-by: Matt Turner <mattst88 at gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>

---

 src/glsl/ir_builder.cpp |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/glsl/ir_builder.cpp b/src/glsl/ir_builder.cpp
index f039414..a2f6f29 100644
--- a/src/glsl/ir_builder.cpp
+++ b/src/glsl/ir_builder.cpp
@@ -271,11 +271,7 @@ clamp(operand a, operand b, operand c)
 ir_expression *
 saturate(operand a)
 {
-   void *mem_ctx = ralloc_parent(a.val);
-
-   return expr(ir_binop_max,
-	       expr(ir_binop_min, a, new(mem_ctx) ir_constant(1.0f)),
-	       new(mem_ctx) ir_constant(0.0f));
+   return expr(ir_unop_saturate, a);
 }
 
 ir_expression *




More information about the mesa-commit mailing list