glsl: Add constant evaluation of ir_unop_saturate

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>
This commit is contained in:
Abdiel Janulgue 2014-06-12 13:53:40 -07:00
parent a5f02b6696
commit 4c0ccfc5b3

View 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];