egl/wayland: add missing newline between functions
[mesa.git] / src / compiler / glsl / link_uniform_block_active_visitor.cpp
index df8b221af921faf9337b1cedbe25fff402bc1d43..7f12353bb20f35e37c284785379df45b353d9829 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "link_uniform_block_active_visitor.h"
 #include "program.h"
+#include "linker_util.h"
 
 static link_uniform_block_active *
 process_block(void *mem_ctx, struct hash_table *ht, ir_variable *var)
@@ -40,7 +41,7 @@ process_block(void *mem_ctx, struct hash_table *ht, ir_variable *var)
     */
    if (existing_block == NULL) {
       link_uniform_block_active *const b =
-        rzalloc(mem_ctx, struct link_uniform_block_active);
+         rzalloc(mem_ctx, struct link_uniform_block_active);
 
       b->type = block_type;
       b->has_instance_name = var->is_interface_instance();
@@ -58,13 +59,13 @@ process_block(void *mem_ctx, struct hash_table *ht, ir_variable *var)
       return b;
    } else {
       link_uniform_block_active *const b =
-        (link_uniform_block_active *) existing_block->data;
+         (link_uniform_block_active *) existing_block->data;
 
       if (b->type != block_type
-         || b->has_instance_name != var->is_interface_instance())
-        return NULL;
+          || b->has_instance_name != var->is_interface_instance())
+         return NULL;
       else
-        return b;
+         return b;
    }
 
    assert(!"Should not get here.");
@@ -89,8 +90,8 @@ process_block(void *mem_ctx, struct hash_table *ht, ir_variable *var)
  *   }
  *
  * There are only 2 active blocks above but for the sake of indirect indexing
- * and not over complicating the code we will end up with a count of 8.
- * Here each dimension has 2 different indices counted so we end up with 2*2*2
+ * and not over complicating the code we will end up with a count of 8.  Here
+ * each dimension has 2 different indices counted so we end up with 2*2*2
  */
 static struct uniform_block_array_elements **
 process_arrays(void *mem_ctx, ir_dereference_array *ir,
@@ -102,13 +103,15 @@ process_arrays(void *mem_ctx, ir_dereference_array *ir,
       if (*ub_array_ptr == NULL) {
          *ub_array_ptr = rzalloc(mem_ctx, struct uniform_block_array_elements);
          (*ub_array_ptr)->ir = ir;
+         (*ub_array_ptr)->aoa_size =
+                      ir->array->type->arrays_of_arrays_size();
       }
 
       struct uniform_block_array_elements *ub_array = *ub_array_ptr;
       ir_constant *c = ir->array_index->as_constant();
       if (c) {
-         /* Index is a constant, so mark just that element used,
-          * if not already.
+         /* Index is a constant, so mark just that element used, if not
+          * already.
           */
          const unsigned idx = c->get_uint_component(0);
 
@@ -131,9 +134,7 @@ process_arrays(void *mem_ctx, ir_dereference_array *ir,
             ub_array->num_array_elements++;
          }
       } else {
-         /* The array index is not a constant,
-          * so mark the entire array used.
-          */
+         /* The array index is not a constant, so mark the entire array used. */
          assert(ir->array->type->is_array());
          if (ub_array->num_array_elements < ir->array->type->length) {
             ub_array->num_array_elements = ir->array->type->length;
@@ -147,6 +148,7 @@ process_arrays(void *mem_ctx, ir_dereference_array *ir,
             }
          }
       }
+
       return &ub_array->array;
    } else {
       return &block->array;
@@ -170,8 +172,7 @@ link_uniform_block_active_visitor::visit(ir_variable *var)
    if (var->get_interface_type_packing() == GLSL_INTERFACE_PACKING_PACKED)
       return visit_continue;
 
-   /* Process the block.  Bail if there was an error.
-    */
+   /* Process the block.  Bail if there was an error. */
    link_uniform_block_active *const b =
       process_block(this->mem_ctx, this->ht, var);
    if (b == NULL) {
@@ -200,6 +201,7 @@ link_uniform_block_active_visitor::visit(ir_variable *var)
                                              (*ub_array)->array_elements,
                                              unsigned,
                                              (*ub_array)->num_array_elements);
+      (*ub_array)->aoa_size = type->arrays_of_arrays_size();
 
       for (unsigned i = 0; i < (*ub_array)->num_array_elements; i++) {
          (*ub_array)->array_elements[i] = i;
@@ -236,14 +238,13 @@ link_uniform_block_active_visitor::visit_enter(ir_dereference_array *ir)
        || !var->is_interface_instance())
       return visit_continue;
 
-   /* Process the block.  Bail if there was an error.
-    */
+   /* Process the block.  Bail if there was an error. */
    link_uniform_block_active *const b =
       process_block(this->mem_ctx, this->ht, var);
    if (b == NULL) {
       linker_error(prog,
-                  "uniform block `%s' has mismatching definitions",
-                  var->get_interface_type()->name);
+                   "uniform block `%s' has mismatching definitions",
+                   var->get_interface_type()->name);
       this->success = false;
       return visit_stop;
    }
@@ -253,9 +254,9 @@ link_uniform_block_active_visitor::visit_enter(ir_dereference_array *ir)
    assert(b->has_instance_name);
    assert(b->type != NULL);
 
-   /* If the block array was declared with a shared or
-    * std140 layout qualifier, all its instances have been already marked
-    * as used in link_uniform_block_active_visitor::visit(ir_variable *).
+   /* If the block array was declared with a shared or std140 layout
+    * qualifier, all its instances have been already marked as used in
+    * link_uniform_block_active_visitor::visit(ir_variable *).
     */
    if (var->get_interface_type_packing() == GLSL_INTERFACE_PACKING_PACKED) {
       b->var = var;
@@ -275,14 +276,13 @@ link_uniform_block_active_visitor::visit(ir_dereference_variable *ir)
 
    assert(!var->is_interface_instance() || !var->type->is_array());
 
-   /* Process the block.  Bail if there was an error.
-    */
+   /* Process the block.  Bail if there was an error. */
    link_uniform_block_active *const b =
       process_block(this->mem_ctx, this->ht, var);
    if (b == NULL) {
       linker_error(this->prog,
-                  "uniform block `%s' has mismatching definitions",
-                  var->get_interface_type()->name);
+                   "uniform block `%s' has mismatching definitions",
+                   var->get_interface_type()->name);
       this->success = false;
       return visit_stop;
    }