[Mesa-dev] [PATCH 01/19] glsl: calculate component size for arrays of arrays when varying packing disabled

Timothy Arceri t_arceri at yahoo.com.au
Sat Jun 20 05:32:58 PDT 2015


Signed-off-by: Timothy Arceri <t_arceri at yahoo.com.au>
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
 src/glsl/link_varyings.cpp | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index 7b2d4bd..6cb55b3 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -876,9 +876,18 @@ varying_matches::record(ir_variable *producer_var, ir_variable *consumer_var)
    this->matches[this->num_matches].packing_order
       = this->compute_packing_order(var);
    if (this->disable_varying_packing) {
-      unsigned slots = var->type->is_array()
-         ? (var->type->length * var->type->fields.array->matrix_columns)
-         : var->type->matrix_columns;
+      unsigned slots;
+      if (var->type->is_array()) {
+         const glsl_type *type = var->type;
+         slots = 1;
+         while (type->is_array()) {
+            slots *= type->length;
+            type = type->fields.array;
+         }
+         slots *= type->matrix_columns;
+      } else {
+         slots = var->type->matrix_columns;
+      }
       this->matches[this->num_matches].num_components = 4 * slots;
    } else {
       this->matches[this->num_matches].num_components
-- 
2.1.0



More information about the mesa-dev mailing list