Mesa (master): glsl: create type name for arrays of arrays

Timothy Arceri tarceri at kemper.freedesktop.org
Thu Jan 23 12:45:48 UTC 2014


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

Author: Timothy Arceri <t_arceri at yahoo.com.au>
Date:   Thu Jan 23 23:21:02 2014 +1100

glsl: create type name for arrays of arrays

We need to insert outermost dimensions in the correct spot otherwise
 the dimension order will be backwards

Signed-off-by: Timothy Arceri <t_arceri at yahoo.com.au>
Reviewed-by: Paul Berry <stereotype441 at gmail.com>

---

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

diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index f9bb0cf..1b0b3ef 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -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;
 }




More information about the mesa-commit mailing list