diff options
author | Eric Anholt <eric@anholt.net> | 2010-04-06 10:53:57 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2010-04-06 11:42:34 -0700 |
commit | af18641f0a9f717fdeab8d3e94c1df93b48c4d30 (patch) | |
tree | 32a485e2f5836519473b80d3a736e8aeb52c17f3 | |
parent | 326c676236e6a3c90db63e4d0c893aa4f9c21876 (diff) |
Add float/int conversion to ir_constant_expression.cpp.
Gives CorrectParse2.frag one more constant folding.
-rw-r--r-- | ir_constant_expression.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 9c98ceb66c..e1073cde1c 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -153,6 +153,26 @@ ir_constant_visitor::visit(ir_expression *ir) for (c = 0; c < ir->operands[0]->type->components(); c++) b[c] = !op[0]->value.b[c]; break; + + case ir_unop_f2i: + assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); + type = ir->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + i[c] = op[0]->value.f[c]; + } + break; + case ir_unop_i2f: + assert(op[0]->type->base_type == GLSL_TYPE_UINT || + op[0]->type->base_type == GLSL_TYPE_INT); + type = ir->type; + for (c = 0; c < ir->operands[0]->type->components(); c++) { + if (op[0]->type->base_type == GLSL_TYPE_INT) + f[c] = op[0]->value.i[c]; + else + f[c] = op[0]->value.u[c]; + } + break; + case ir_binop_add: if (ir->operands[0]->type == ir->operands[1]->type) { type = ir->operands[0]->type; |