summaryrefslogtreecommitdiffstats
path: root/src/glsl/ir_constant_expression.cpp
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2010-07-01 10:37:11 -0700
committerEric Anholt <[email protected]>2010-07-01 11:07:22 -0700
commitd925c9173009e9e5d48df30b30aaef22753183aa (patch)
treee42ee590b44d75b69fb67ee7de8b42ce05ee1c11 /src/glsl/ir_constant_expression.cpp
parent5e4dd061d17563828bcce5525400a0ce363aa15d (diff)
glsl2: Add ir_unop_fract as an expression type.
Most backends will prefer seeing this to seeing (a - floor(a)), so represent it explicitly.
Diffstat (limited to 'src/glsl/ir_constant_expression.cpp')
-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 c6348ac4347..548217cddd9 100644
--- a/src/glsl/ir_constant_expression.cpp
+++ b/src/glsl/ir_constant_expression.cpp
@@ -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) {