glsl: Handle instance array declarations
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 22 Jan 2013 04:06:45 +0000 (23:06 -0500)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 25 Jan 2013 14:07:34 +0000 (09:07 -0500)
v2: Add a comment and an assertion about the array size in the
non-instance name case.  Suggested by Paul Berry.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/ast_to_hir.cpp

index 80a02e9da4e91d39fc13132b29e232b144af17f5..80dd86e78035a54e6a5124df4caf288b137ca990 100644 (file)
@@ -4273,14 +4273,30 @@ ast_uniform_block::hir(exec_list *instructions,
     *     field selector ( . ) operator (analogously to structures)."
     */
    if (this->instance_name) {
-      ir_variable *var = new(state) ir_variable(block_type,
-                                                this->instance_name,
-                                                ir_var_uniform);
+      ir_variable *var;
+
+      if (this->array_size != NULL) {
+         const glsl_type *block_array_type =
+            process_array_type(&loc, block_type, this->array_size, state);
+
+         var = new(state) ir_variable(block_array_type,
+                                      this->instance_name,
+                                      ir_var_uniform);
+      } else {
+         var = new(state) ir_variable(block_type,
+                                      this->instance_name,
+                                      ir_var_uniform);
+      }
 
       var->interface_type = block_type;
       state->symbols->add_variable(var);
       instructions->push_tail(var);
    } else {
+      /* In order to have an array size, the block must also be declared with
+       * an instane name.
+       */
+      assert(this->array_size == NULL);
+
       for (unsigned i = 0; i < num_variables; i++) {
          ir_variable *var =
             new(state) ir_variable(fields[i].type,