Mesa (master): glsl: update types for unsized arrays of members

Timothy Arceri tarceri at kemper.freedesktop.org
Sat Jul 4 07:13:23 UTC 2015


Module: Mesa
Branch: master
Commit: 939dc2850645786b4ff76aa162e44eb9f77be805
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=939dc2850645786b4ff76aa162e44eb9f77be805

Author: Timothy Arceri <t_arceri at yahoo.com.au>
Date:   Sat Mar 14 12:40:20 2015 +1100

glsl: update types for unsized arrays of members

Assigns a new array type based on the max access of
unsized array members. This is to support arrays of arrays.

Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>

---

 src/glsl/linker.cpp |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 71a45e8..8d4b40e 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1250,8 +1250,7 @@ public:
                resize_interface_members(var->type->fields.array,
                                         var->get_max_ifc_array_access());
             var->change_interface_type(new_type);
-            var->type =
-               glsl_type::get_array_instance(new_type, var->type->length);
+            var->type = update_interface_members_array(var->type, new_type);
          }
       } else if (const glsl_type *ifc_type = var->get_interface_type()) {
          /* Store a pointer to the variable in the unnamed_interfaces
@@ -1299,6 +1298,21 @@ private:
       }
    }
 
+   static const glsl_type *
+   update_interface_members_array(const glsl_type *type,
+                                  const glsl_type *new_interface_type)
+   {
+      const glsl_type *element_type = type->fields.array;
+      if (element_type->is_array()) {
+         const glsl_type *new_array_type =
+            update_interface_members_array(element_type, new_interface_type);
+         return glsl_type::get_array_instance(new_array_type, type->length);
+      } else {
+         return glsl_type::get_array_instance(new_interface_type,
+                                              type->length);
+      }
+   }
+
    /**
     * Determine whether the given interface type contains unsized arrays (if
     * it doesn't, array_sizing_visitor doesn't need to process it).




More information about the mesa-commit mailing list