glsl: Implement saturate as ir_unop_saturate
authorAbdiel Janulgue <abdiel.janulgue@linux.intel.com>
Fri, 20 Jun 2014 23:55:03 +0000 (16:55 -0700)
committerAbdiel Janulgue <abdiel.janulgue@linux.intel.com>
Sun, 31 Aug 2014 18:04:08 +0000 (21:04 +0300)
Now that we have the ir_unop_saturate implemented as a single
instruction, generate the correct simplified expression.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
src/glsl/ir_builder.cpp

index f03941443e09822eccc1b55c6db531880cbef769..a2f6f2967d1c9fbeb63814dbb8c02dd277b920a7 100644 (file)
@@ -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 *