summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorTimothy Arceri <t_arceri@yahoo.com.au>2014-01-23 23:21:02 +1100
committerTimothy Arceri <t_arceri@yahoo.com.au>2014-01-23 23:37:36 +1100
commit61a584609936940f69207dd520b5b4208810a9e7 (patch)
tree788814508be195f11b2e1c08cd1cadd4b24e2b86 /src/glsl
parent3d492f19f6e1a50a645cfa3b04d64808d44af5e3 (diff)
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@yahoo.com.au> Reviewed-by: Paul Berry <stereotype441@gmail.com>
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/glsl_types.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index f9bb0cfc754..1b0b3ef883d 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;
}