glsl: create type name for arrays of arrays
authorTimothy Arceri <t_arceri@yahoo.com.au>
Thu, 23 Jan 2014 12:21:02 +0000 (23:21 +1100)
committerTimothy Arceri <t_arceri@yahoo.com.au>
Thu, 23 Jan 2014 12:37:36 +0000 (23:37 +1100)
We need to insert outermost dimensions in the correct spot otherwise
 the dimension order will be backwards

Signed-off-by: Timothy Arceri <t_arceri@yahoo.com.au>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/glsl/glsl_types.cpp

index f9bb0cfc75493cc3d7efe3c01fdae09f47ce1401..1b0b3ef883dac0a8b0ba972deef97ce457d92c69 100644 (file)
@@ -300,8 +300,20 @@ glsl_type::glsl_type(const glsl_type *array, unsigned length) :
 
    if (length == 0)
       snprintf(n, name_length, "%s[]", array->name);
-   else
-      snprintf(n, name_length, "%s[%u]", array->name, length);
+   else {
+      /* insert outermost dimensions in the correct spot
+       * otherwise the dimension order will be backwards
+       */
+      const char *pos = strchr(array->name, '[');
+      if (pos) {
+         int idx = pos - array->name;
+         snprintf(n, idx+1, "%s", array->name);
+         snprintf(n + idx, name_length - idx, "[%u]%s",
+                  length, array->name + idx);
+      } else {
+         snprintf(n, name_length, "%s[%u]", array->name, length);
+      }
+   }
 
    this->name = n;
 }