Mesa (master): glsl: Add constant evaluation of ir_unop_saturate

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


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

Author: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
Date:   Thu Jun 12 13:53:40 2014 -0700

glsl: Add constant evaluation of ir_unop_saturate

v2: Use CLAMP macro (Ian Romanick)

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

---

 src/glsl/ir_constant_expression.cpp |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
index 9606021..1e8b3a3 100644
--- a/src/glsl/ir_constant_expression.cpp
+++ b/src/glsl/ir_constant_expression.cpp
@@ -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];




More information about the mesa-commit mailing list