glsl: Add constant evaluation of ir_unop_saturate
authorAbdiel Janulgue <abdiel.janulgue@linux.intel.com>
Thu, 12 Jun 2014 20:53:40 +0000 (13:53 -0700)
committerAbdiel Janulgue <abdiel.janulgue@linux.intel.com>
Sun, 31 Aug 2014 18:04:08 +0000 (21:04 +0300)
v2: Use CLAMP macro (Ian Romanick)

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

index 96060217c97246a4553532e2943df96a5908c8f8..1e8b3a3ccedbd609038743892fa804259ee96373 100644 (file)
@@ -1469,6 +1469,12 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
       }
       break;
 
+   case ir_unop_saturate:
+      for (unsigned c = 0; c < components; c++) {
+         data.f[c] = CLAMP(op[0]->value.f[c], 0.0f, 1.0f);
+      }
+      break;
+
    case ir_triop_bitfield_extract: {
       int offset = op[1]->value.i[0];
       int bits = op[2]->value.i[0];