summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2010-07-08 23:11:14 -0700
committerKenneth Graunke <[email protected]>2010-07-14 15:50:27 -0700
commit14b7b2660c771aa090477c11f85da998ec3d2570 (patch)
tree18ab799cef17bcf81954587b057e98fca55407e6
parent5e840dba4412b33ae49289efd357a60098ac2611 (diff)
ir_constant_expression: Add support for ir_unop_sign.
-rw-r--r--src/glsl/ir_constant_expression.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
index 06d7dd8fbe0..5ba6264dd65 100644
--- a/src/glsl/ir_constant_expression.cpp
+++ b/src/glsl/ir_constant_expression.cpp
@@ -262,6 +262,24 @@ ir_constant_visitor::visit(ir_expression *ir)
}
break;
+ case ir_unop_sign:
+ for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) {
+ switch (ir->type->base_type) {
+ case GLSL_TYPE_UINT:
+ data.u[c] = op[0]->value.i[c] > 0;
+ break;
+ case GLSL_TYPE_INT:
+ data.i[c] = (op[0]->value.i[c] > 0) - (op[0]->value.i[c] < 0);
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.f[c] = float((op[0]->value.f[c] > 0)-(op[0]->value.f[c] < 0));
+ break;
+ default:
+ assert(0);
+ }
+ }
+ break;
+
case ir_unop_rcp:
assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) {