ir_constant_expression: Add support for ir_unop_trunc.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 9 Jul 2010 06:21:36 +0000 (23:21 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 14 Jul 2010 22:50:28 +0000 (15:50 -0700)
This uses a C99 function.

src/glsl/ir_constant_expression.cpp

index 292461e5eb7bd8843292355beac7a466ba792884..09bc5b6bbff0125736767844ef4c3b81972f3abf 100644 (file)
@@ -206,6 +206,13 @@ ir_constant_visitor::visit(ir_expression *ir)
       }
       break;
 
+   case ir_unop_trunc:
+      assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
+      for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) {
+        data.f[c] = truncf(op[0]->value.f[c]);
+      }
+      break;
+
    case ir_unop_fract:
       for (unsigned c = 0; c < ir->operands[0]->type->components(); c++) {
         switch (ir->type->base_type) {