glslang parser: Arrays-of-arrays name-mangling and error messages (lots of A-of-A...
authorJohn Kessenich <cepheus@frii.com>
Mon, 11 May 2015 16:16:49 +0000 (16:16 +0000)
committerJohn Kessenich <cepheus@frii.com>
Mon, 11 May 2015 16:16:49 +0000 (16:16 +0000)
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31137 e7fa87d3-cd2b-0410-9028-fcbf551c1848

12 files changed:
Test/310AofA.vert [new file with mode: 0644]
Test/baseResults/120.vert.out
Test/baseResults/300.frag.out
Test/baseResults/310.frag.out
Test/baseResults/310.vert.out
Test/baseResults/310AofA.vert.out [new file with mode: 0644]
Test/baseResults/450.vert.out
Test/baseResults/specExamples.frag.out
Test/testlist
glslang/Include/Types.h
glslang/MachineIndependent/Initialize.cpp
glslang/MachineIndependent/SymbolTable.cpp

diff --git a/Test/310AofA.vert b/Test/310AofA.vert
new file mode 100644 (file)
index 0000000..eb68d89
--- /dev/null
@@ -0,0 +1,14 @@
+#version 310 es
+
+// Check name mangling of functions with parameters that are multi-dimensional arrays.
+
+#define NX 2
+#define NY 3
+#define NZ 4
+void f(bool a, float b, uint[4] c, int[NY][NX] d) {
+}
+
+void main() {
+  int[NY][NX] d;
+  f(false, 12.1, uint[NZ](uint(0),uint(1),uint(1),uint(2)), d);
+}
index a5b1638..6cc6fa3 100644 (file)
@@ -24,11 +24,11 @@ ERROR: 0:39: 'arrays of arrays' : not supported with this profile: none
 ERROR: 0:40: 'arrays of arrays' : not supported with this profile: none\r
 ERROR: 0:40: 'constructor' : array constructor needs one argument per array element \r
 ERROR: 0:40: 'arrays of arrays' : not supported with this profile: none\r
-ERROR: 0:40: '=' :  cannot convert from 'const float' to 'temp 2-element array of float'\r
+ERROR: 0:40: '=' :  cannot convert from 'const float' to 'temp 2-element array of 3-element array of float'\r
 ERROR: 0:41: 'arrays of arrays' : not supported with this profile: none\r
 ERROR: 0:41: 'constructor' : array constructor needs one argument per array element \r
 ERROR: 0:41: 'arrays of arrays' : not supported with this profile: none\r
-ERROR: 0:41: '=' :  cannot convert from 'const float' to 'temp 2-element array of float'\r
+ERROR: 0:41: '=' :  cannot convert from 'const float' to 'temp 2-element array of 3-element array of float'\r
 ERROR: 0:50: 'arrays of arrays' : not supported with this profile: none\r
 ERROR: 0:51: 'arrays of arrays' : not supported with this profile: none\r
 ERROR: 0:52: 'arrays of arrays' : not supported with this profile: none\r
index 02d5836..1c0d0fa 100644 (file)
@@ -389,7 +389,7 @@ ERROR: node is still EOpNull!
 0:?     'sc' (out lowp 3-component vector of float)\r
 0:?     'sf' (out lowp float)\r
 0:?     'arrayedSampler' (uniform 5-element array of lowp sampler2D)\r
-0:?     'multiInst' (layout(column_major shared ) uniform 2-element array of block{layout(column_major shared ) uniform 2-element array of mediump int a, layout(column_major shared ) uniform 2-element array of mediump int b, layout(column_major shared ) uniform 2-element array of mediump int c})\r
+0:?     'multiInst' (layout(column_major shared ) uniform 2-element array of 3-element array of block{layout(column_major shared ) uniform 2-element array of mediump int a, layout(column_major shared ) uniform 2-element array of 3-element array of mediump int b, layout(column_major shared ) uniform 2-element array of 3-element array of mediump int c})\r
 0:?     'colors' (out 4-element array of lowp 4-component vector of float)\r
 0:?     'st1' (uniform structure{global mediump int i, global lowp sampler2D s})\r
 0:?     'st2' (uniform structure{global mediump int i, global lowp sampler2D s})\r
@@ -745,7 +745,7 @@ ERROR: node is still EOpNull!
 0:?     'sc' (out lowp 3-component vector of float)\r
 0:?     'sf' (out lowp float)\r
 0:?     'arrayedSampler' (uniform 5-element array of lowp sampler2D)\r
-0:?     'multiInst' (layout(column_major shared ) uniform 2-element array of block{layout(column_major shared ) uniform 2-element array of mediump int a, layout(column_major shared ) uniform 2-element array of mediump int b, layout(column_major shared ) uniform 2-element array of mediump int c})\r
+0:?     'multiInst' (layout(column_major shared ) uniform 2-element array of 3-element array of block{layout(column_major shared ) uniform 2-element array of mediump int a, layout(column_major shared ) uniform 2-element array of 3-element array of mediump int b, layout(column_major shared ) uniform 2-element array of 3-element array of mediump int c})\r
 0:?     'colors' (out 4-element array of lowp 4-component vector of float)\r
 0:?     'st1' (uniform structure{global mediump int i, global lowp sampler2D s})\r
 0:?     'st2' (uniform structure{global mediump int i, global lowp sampler2D s})\r
index cba86bb..eeac76d 100644 (file)
@@ -294,7 +294,7 @@ ERROR: node is still EOpNull!
 0:?     'inb' (smooth in bool)\r
 0:?     'ino' (smooth in highp sampler2D)\r
 0:?     'ina' (smooth in 4-element array of mediump float)\r
-0:?     'inaa' (smooth in 4-element array of mediump float)\r
+0:?     'inaa' (smooth in 4-element array of 2-element array of mediump float)\r
 0:?     'ins' (smooth in structure{global mediump float f})\r
 0:?     'inasa' (smooth in 4-element array of structure{global mediump float f})\r
 0:?     'insa' (smooth in 4-element array of structure{global mediump float f})\r
@@ -556,7 +556,7 @@ ERROR: node is still EOpNull!
 0:?     'inb' (smooth in bool)\r
 0:?     'ino' (smooth in highp sampler2D)\r
 0:?     'ina' (smooth in 4-element array of mediump float)\r
-0:?     'inaa' (smooth in 4-element array of mediump float)\r
+0:?     'inaa' (smooth in 4-element array of 2-element array of mediump float)\r
 0:?     'ins' (smooth in structure{global mediump float f})\r
 0:?     'inasa' (smooth in 4-element array of structure{global mediump float f})\r
 0:?     'insa' (smooth in 4-element array of structure{global mediump float f})\r
index 8f3b682..5bc03f7 100644 (file)
@@ -179,7 +179,7 @@ ERROR: node is still EOpNull!
 0:?     'outb' (smooth out bool)\r
 0:?     'outo' (smooth out highp sampler2D)\r
 0:?     'outa' (smooth out 4-element array of highp float)\r
-0:?     'outaa' (smooth out 4-element array of highp float)\r
+0:?     'outaa' (smooth out 4-element array of 2-element array of highp float)\r
 0:?     'outs' (smooth out structure{global highp float f})\r
 0:?     'outasa' (smooth out 4-element array of structure{global highp float f})\r
 0:?     'outsa' (smooth out 4-element array of structure{global highp float f})\r
@@ -354,7 +354,7 @@ ERROR: node is still EOpNull!
 0:?     'outb' (smooth out bool)\r
 0:?     'outo' (smooth out highp sampler2D)\r
 0:?     'outa' (smooth out 4-element array of highp float)\r
-0:?     'outaa' (smooth out 4-element array of highp float)\r
+0:?     'outaa' (smooth out 4-element array of 2-element array of highp float)\r
 0:?     'outs' (smooth out structure{global highp float f})\r
 0:?     'outasa' (smooth out 4-element array of structure{global highp float f})\r
 0:?     'outsa' (smooth out 4-element array of structure{global highp float f})\r
diff --git a/Test/baseResults/310AofA.vert.out b/Test/baseResults/310AofA.vert.out
new file mode 100644 (file)
index 0000000..ef63fd2
--- /dev/null
@@ -0,0 +1,59 @@
+310mangle.vert\r
+Warning, version 310 is not yet complete; most version-specific features are present, but some are missing.\r
+\r
+Shader version: 310\r
+0:? Sequence\r
+0:8  Function Definition: f(b1;f1;u1[4];i1[3][2]; (global void)\r
+0:8    Function Parameters: \r
+0:8      'a' (in bool)\r
+0:8      'b' (in highp float)\r
+0:8      'c' (in 4-element array of highp uint)\r
+0:8      'd' (in 3-element array of 2-element array of highp int)\r
+0:11  Function Definition: main( (global void)\r
+0:11    Function Parameters: \r
+0:?     Sequence\r
+0:13      Function Call: f(b1;f1;u1[4];i1[3][2]; (global void)\r
+0:13        Constant:\r
+0:13          false (const bool)\r
+0:13        Constant:\r
+0:13          12.100000\r
+0:13        Constant:\r
+0:13          0 (const uint)\r
+0:13          1 (const uint)\r
+0:13          1 (const uint)\r
+0:13          2 (const uint)\r
+0:13        'd' (temp 3-element array of 2-element array of highp int)\r
+0:?   Linker Objects\r
+0:?     'gl_VertexID' (gl_VertexId highp int)\r
+0:?     'gl_InstanceID' (gl_InstanceId highp int)\r
+\r
+\r
+Linked vertex stage:\r
+\r
+\r
+Shader version: 310\r
+0:? Sequence\r
+0:8  Function Definition: f(b1;f1;u1[4];i1[3][2]; (global void)\r
+0:8    Function Parameters: \r
+0:8      'a' (in bool)\r
+0:8      'b' (in highp float)\r
+0:8      'c' (in 4-element array of highp uint)\r
+0:8      'd' (in 3-element array of 2-element array of highp int)\r
+0:11  Function Definition: main( (global void)\r
+0:11    Function Parameters: \r
+0:?     Sequence\r
+0:13      Function Call: f(b1;f1;u1[4];i1[3][2]; (global void)\r
+0:13        Constant:\r
+0:13          false (const bool)\r
+0:13        Constant:\r
+0:13          12.100000\r
+0:13        Constant:\r
+0:13          0 (const uint)\r
+0:13          1 (const uint)\r
+0:13          1 (const uint)\r
+0:13          2 (const uint)\r
+0:13        'd' (temp 3-element array of 2-element array of highp int)\r
+0:?   Linker Objects\r
+0:?     'gl_VertexID' (gl_VertexId highp int)\r
+0:?     'gl_InstanceID' (gl_InstanceId highp int)\r
+\r
index 5298360..09b3bfd 100644 (file)
@@ -25,7 +25,7 @@ ERROR: node is still EOpNull!
 0:?     'outb' (smooth out bool)\r
 0:?     'outo' (smooth out sampler2D)\r
 0:?     'outa' (smooth out 4-element array of float)\r
-0:?     'outaa' (smooth out 4-element array of float)\r
+0:?     'outaa' (smooth out 4-element array of 2-element array of float)\r
 0:?     'outs' (smooth out structure{global float f})\r
 0:?     'outasa' (smooth out 4-element array of structure{global float f})\r
 0:?     'outsa' (smooth out 4-element array of structure{global float f})\r
@@ -58,7 +58,7 @@ ERROR: node is still EOpNull!
 0:?     'outb' (smooth out bool)\r
 0:?     'outo' (smooth out sampler2D)\r
 0:?     'outa' (smooth out 4-element array of float)\r
-0:?     'outaa' (smooth out 4-element array of float)\r
+0:?     'outaa' (smooth out 4-element array of 2-element array of float)\r
 0:?     'outs' (smooth out structure{global float f})\r
 0:?     'outasa' (smooth out 4-element array of structure{global float f})\r
 0:?     'outsa' (smooth out 4-element array of structure{global float f})\r
index 7857d11..5c5560e 100644 (file)
@@ -18,7 +18,7 @@ ERROR: 0:112: 'redeclaration' : all redeclarations must use the same depth layou
 ERROR: 0:118: 'redeclaration' : all redeclarations must use the same depth layout on gl_FragDepth\r
 ERROR: 0:121: 'redeclaration' : all redeclarations must use the same depth layout on gl_FragDepth\r
 ERROR: 0:150: 'constructor' : constructing from a non-dereferenced array \r
-ERROR: 0:150: '=' :  cannot convert from 'const float' to 'temp 3-element array of 4-component vector of float'\r
+ERROR: 0:150: '=' :  cannot convert from 'const float' to 'temp 3-element array of 2-element array of 4-component vector of float'\r
 ERROR: 0:152: 'constructor' :  cannot convert parameter 1 from 'const 2-element array of 4-component vector of float' to 'temp 4-component vector of float'\r
 ERROR: 0:172: 'x' : undeclared identifier \r
 ERROR: 0:172: '[]' : scalar integer expression required \r
index d87689c..85b5ba3 100644 (file)
@@ -40,6 +40,7 @@ comment.frag
 310.vert
 310.frag
 310implicitSizeArrayError.vert
+310AofA.vert
 330.frag
 330comp.frag
 constErrors.frag
index b76e2d5..b02b708 100644 (file)
@@ -1261,10 +1261,14 @@ public:
             p += snprintf(p, end - p, "writeonly ");
         p += snprintf(p, end - p, "%s ", getStorageQualifierString());
         if (arraySizes) {
-            if (arraySizes->sizes.front() == 0)
+            if (arraySizes->sizes.front() == 0) {
                 p += snprintf(p, end - p, "implicitly-sized array of ");
-            else
-                p += snprintf(p, end - p, "%d-element array of ", arraySizes->sizes.front());
+            } else {
+                for(int i = 0; i < (int)arraySizes->sizes.size() ; ++i) {
+//                    p += snprintf(p, end - p, "%s%d", (i == 0 ? "" : "x"), arraySizes->sizes[numDimensions-1-i]);
+                    p += snprintf(p, end - p, "%d-element array of ", arraySizes->sizes[i]);
+                }
+            }
         }
         if (qualifier.precision != EpqNone)
             p += snprintf(p, end - p, "%s ", getPrecisionQualifierString());
index 2cab878..2735a9f 100644 (file)
@@ -2543,12 +2543,12 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
     // compute
     if ((profile == EEsProfile && version >= 310) || (profile != EEsProfile && version >= 430)) {
         snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxComputeWorkGroupCount = ivec3(%d,%d,%d);", resources.maxComputeWorkGroupCountX,
-                                                                                                    resources.maxComputeWorkGroupCountY,
-                                                                                                    resources.maxComputeWorkGroupCountZ);                
+                                                                                                         resources.maxComputeWorkGroupCountY,
+                                                                                                         resources.maxComputeWorkGroupCountZ);                
         s.append(builtInConstant);
         snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxComputeWorkGroupSize = ivec3(%d,%d,%d);", resources.maxComputeWorkGroupSizeX,
-                                                                                                    resources.maxComputeWorkGroupSizeY,
-                                                                                                    resources.maxComputeWorkGroupSizeZ);
+                                                                                                        resources.maxComputeWorkGroupSizeY,
+                                                                                                        resources.maxComputeWorkGroupSizeZ);
         s.append(builtInConstant);
 
         snprintf(builtInConstant, maxSize, "const int gl_MaxComputeUniformComponents = %d;", resources.maxComputeUniformComponents);
index f1479a5..8ec7f53 100644 (file)
@@ -112,10 +112,12 @@ void TType::buildMangledName(TString& mangledName)
     if (arraySizes) {
         const int maxSize = 11;
         char buf[maxSize];
-        snprintf(buf, maxSize, "%d", arraySizes->sizes.front());
-        mangledName += '[';
-        mangledName += buf;
-        mangledName += ']';
+        for (int i = 0; i < (int)arraySizes->sizes.size(); ++i) {
+            snprintf(buf, maxSize, "%d", arraySizes->sizes[i]);
+            mangledName += '[';
+            mangledName += buf;
+            mangledName += ']';
+        }
     }
 }