summaryrefslogtreecommitdiffstats
path: root/src/glsl/ir_constant_expression.cpp
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2010-07-21 18:04:22 -0700
committerKenneth Graunke <[email protected]>2010-07-28 15:46:27 -0700
commit0b6ef6ef6e1930b6ec03dae7ace53372bb239981 (patch)
tree24ed7b067b82ce4e7ec76e1b4fce3a90f021e757 /src/glsl/ir_constant_expression.cpp
parent2eaf31642c83086b06dce057997ae4bc4b1bce2c (diff)
ir_constant_expression: Add support for the "equal" builtin.
Diffstat (limited to 'src/glsl/ir_constant_expression.cpp')
-rw-r--r--src/glsl/ir_constant_expression.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
index 52f53d9ff48..e6f9558b62d 100644
--- a/src/glsl/ir_constant_expression.cpp
+++ b/src/glsl/ir_constant_expression.cpp
@@ -864,7 +864,22 @@ ir_call::constant_expression_value()
} else if (strcmp(callee, "dot") == 0) {
expr = new(mem_ctx) ir_expression(ir_binop_dot, type, op[0], op[1]);
} else if (strcmp(callee, "equal") == 0) {
- return NULL; /* FINISHME: implement this */
+ assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
+ for (unsigned c = 0; c < op[0]->type->components(); c++) {
+ switch (op[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ data.b[c] = op[0]->value.u[c] == op[1]->value.u[c];
+ break;
+ case GLSL_TYPE_INT:
+ data.b[c] = op[0]->value.i[c] == op[1]->value.i[c];
+ break;
+ case GLSL_TYPE_FLOAT:
+ data.b[c] = op[0]->value.f[c] == op[1]->value.f[c];
+ break;
+ default:
+ assert(!"Should not get here.");
+ }
+ }
} else if (strcmp(callee, "exp") == 0) {
expr = new(mem_ctx) ir_expression(ir_unop_exp, type, op[0], NULL);
} else if (strcmp(callee, "exp2") == 0) {