summaryrefslogtreecommitdiff
path: root/src/glsl/ir_constant_expression.cpp
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2010-07-20 03:08:32 -0700
committerKenneth Graunke <kenneth@whitecape.org>2010-07-21 16:38:33 -0700
commit9a6d40fbfb679f01412c1fcc9d767c20a22246d8 (patch)
tree6a3fec95f2015a1b27a40560a9316fd865646459 /src/glsl/ir_constant_expression.cpp
parenta096fa747611472965cf0f953bfe2757fc80383c (diff)
ir_constant_expression: Add support for array == and !=.
Piglit parser tests const-array-03.frag and const-array-04.frag now generate the correct code.
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 d72a57c66a..5bef17c755 100644
--- a/src/glsl/ir_constant_expression.cpp
+++ b/src/glsl/ir_constant_expression.cpp
@@ -73,6 +73,22 @@ ir_expression::constant_expression_value()
components = op[1]->type->components();
}
+ void *ctx = talloc_parent(this);
+
+ /* Handle array operations here, rather than below. */
+ if (op[0]->type->is_array()) {
+ assert(op[1] != NULL && op[1]->type->is_array());
+ switch (this->operation) {
+ case ir_binop_equal:
+ return new(ctx) ir_constant(op[0]->has_value(op[1]));
+ case ir_binop_nequal:
+ return new(ctx) ir_constant(!op[0]->has_value(op[1]));
+ default:
+ break;
+ }
+ return NULL;
+ }
+
switch (this->operation) {
case ir_unop_logic_not:
assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
@@ -616,7 +632,6 @@ ir_expression::constant_expression_value()
return NULL;
}
- void *ctx = talloc_parent(this);
return new(ctx) ir_constant(this->type, &data);
}