From 74e1802f5dd8921750851abc6128e4073602d405 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 20 Jul 2010 01:06:33 -0700 Subject: glsl2: Extend ir_constant to store constant arrays, and generate them. Since GLSL permits arrays of structures, we need to store each element as an ir_constant*, not just ir_constant_data. Fixes parser tests const-array-01.frag, const-array-03.frag, const-array-04.frag, const-array-05.frag, though 03 and 04 generate the wrong code. --- src/glsl/ir_clone.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/glsl/ir_clone.cpp') diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index f7e8794728..a3e4a3ae31 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -337,6 +337,17 @@ ir_constant::clone(struct hash_table *ht) const return c; } + case GLSL_TYPE_ARRAY: { + ir_constant *c = new(ctx) ir_constant; + + c->type = this->type; + c->array_elements = talloc_array(c, ir_constant *, this->type->length); + for (unsigned i = 0; i < this->type->length; i++) { + c->array_elements[i] = this->array_elements[i]->clone(NULL); + } + return c; + } + default: assert(!"Should not get here."); break; return NULL; -- cgit v1.2.3