summaryrefslogtreecommitdiff
path: root/src/glsl/ir_constant_expression.cpp
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2010-07-21 20:24:29 -0700
committerKenneth Graunke <kenneth@whitecape.org>2010-07-28 15:46:28 -0700
commitd60b2b03da30093ae85458f1d0be3cc5c33d992c (patch)
tree904fe89d68c8cd1706c514b8b4bb06fcee5b842d /src/glsl/ir_constant_expression.cpp
parent53f306d573ce6393062cf86d4fe31148eacc5e1e (diff)
ir_constant_expression: Add support for the "reflect" builtin.
Diffstat (limited to 'src/glsl/ir_constant_expression.cpp')
-rw-r--r--src/glsl/ir_constant_expression.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
index 809ea609a3..c8320814a3 100644
--- a/src/glsl/ir_constant_expression.cpp
+++ b/src/glsl/ir_constant_expression.cpp
@@ -1013,7 +1013,10 @@ ir_call::constant_expression_value()
for (unsigned c = 0; c < op[0]->type->components(); c++)
data.f[c] = M_PI/180.0 * op[0]->value.f[c];
} else if (strcmp(callee, "reflect") == 0) {
- return NULL; /* FINISHME: implement this */
+ assert(op[0]->type->is_float());
+ float dot_NI = dot(op[1], op[0]);
+ for (unsigned c = 0; c < op[0]->type->components(); c++)
+ data.f[c] = op[0]->value.f[c] - 2 * dot_NI * op[1]->value.f[c];
} else if (strcmp(callee, "refract") == 0) {
return NULL; /* FINISHME: implement this */
} else if (strcmp(callee, "sign") == 0) {