glsl2: Add ir_unop_fract as an expression type.

Most backends will prefer seeing this to seeing (a - floor(a)), so
represent it explicitly.
This commit is contained in:
Eric Anholt
2010-07-01 10:37:11 -07:00
parent 5e4dd061d1
commit d925c91730
6 changed files with 33 additions and 8 deletions

View File

@@ -187,6 +187,24 @@ ir_constant_visitor::visit(ir_expression *ir)
}
break;
case ir_unop_fract:
for (c = 0; c < ir->operands[0]->type->components(); c++) {
switch (ir->type->base_type) {
case GLSL_TYPE_UINT:
data.u[c] = 0;
break;
case GLSL_TYPE_INT:
data.i[c] = 0;
break;
case GLSL_TYPE_FLOAT:
data.f[c] = op[0]->value.f[c] - floor(op[0]->value.f[c]);
break;
default:
assert(0);
}
}
break;
case ir_unop_neg:
for (c = 0; c < ir->operands[0]->type->components(); c++) {
switch (ir->type->base_type) {