summaryrefslogtreecommitdiff
path: root/src/glsl/ir_constant_expression.cpp
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2010-07-21 21:53:40 -0700
committerKenneth Graunke <kenneth@whitecape.org>2010-07-28 15:46:29 -0700
commitff58b7c9b6f513ed8bf57b3e4283b67b06fd9d34 (patch)
treeb46967d78f84749057bc5291f048a08a75fbebd6 /src/glsl/ir_constant_expression.cpp
parent3d5c2f0adbd72a68d4fe3900b0d3e267510950ef (diff)
ir_constant_expression: Add support for the "step" builtin.
Diffstat (limited to 'src/glsl/ir_constant_expression.cpp')
-rw-r--r--src/glsl/ir_constant_expression.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
index c939690129..5485d79a88 100644
--- a/src/glsl/ir_constant_expression.cpp
+++ b/src/glsl/ir_constant_expression.cpp
@@ -1045,7 +1045,11 @@ ir_call::constant_expression_value()
} else if (strcmp(callee, "sqrt") == 0) {
expr = new(mem_ctx) ir_expression(ir_unop_sqrt, type, op[0], NULL);
} else if (strcmp(callee, "step") == 0) {
- return NULL; /* FINISHME: implement this */
+ assert(op[0]->type->is_float() && op[1]->type->is_float());
+ /* op[0] (edge) may be either a scalar or a vector */
+ const unsigned c0_inc = op[0]->type->is_scalar() ? 0 : 1;
+ for (unsigned c = 0, c0 = 0; c < type->components(); c0 += c0_inc, c++)
+ data.f[c] = (op[1]->value.f[c] < op[0]->value.f[c0]) ? 0.0 : 1.0;
} else if (strcmp(callee, "tan") == 0) {
assert(op[0]->type->is_float());
for (unsigned c = 0; c < op[0]->type->components(); c++)