glslang parser: Arrays-of-arrays name-mangling and error messages (lots of A-of-A stuff to come a bit later). This patch from Google, David Neto <dneto@google.com>.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31137 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2015-05-11 16:16:49 +00:00
parent f75276ba5c
commit af9ab5f743
12 changed files with 102 additions and 22 deletions

14
Test/310AofA.vert Normal file
View File

@ -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);
}

View 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
ERROR: 0:40: 'constructor' : array constructor needs one argument per array element
ERROR: 0:40: 'arrays of arrays' : not supported with this profile: none
ERROR: 0:40: '=' : cannot convert from 'const float' to 'temp 2-element array of float'
ERROR: 0:40: '=' : cannot convert from 'const float' to 'temp 2-element array of 3-element array of float'
ERROR: 0:41: 'arrays of arrays' : not supported with this profile: none
ERROR: 0:41: 'constructor' : array constructor needs one argument per array element
ERROR: 0:41: 'arrays of arrays' : not supported with this profile: none
ERROR: 0:41: '=' : cannot convert from 'const float' to 'temp 2-element array of float'
ERROR: 0:41: '=' : cannot convert from 'const float' to 'temp 2-element array of 3-element array of float'
ERROR: 0:50: 'arrays of arrays' : not supported with this profile: none
ERROR: 0:51: 'arrays of arrays' : not supported with this profile: none
ERROR: 0:52: 'arrays of arrays' : not supported with this profile: none

View File

@ -389,7 +389,7 @@ ERROR: node is still EOpNull!
0:? 'sc' (out lowp 3-component vector of float)
0:? 'sf' (out lowp float)
0:? 'arrayedSampler' (uniform 5-element array of lowp sampler2D)
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})
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})
0:? 'colors' (out 4-element array of lowp 4-component vector of float)
0:? 'st1' (uniform structure{global mediump int i, global lowp sampler2D s})
0:? 'st2' (uniform structure{global mediump int i, global lowp sampler2D s})
@ -745,7 +745,7 @@ ERROR: node is still EOpNull!
0:? 'sc' (out lowp 3-component vector of float)
0:? 'sf' (out lowp float)
0:? 'arrayedSampler' (uniform 5-element array of lowp sampler2D)
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})
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})
0:? 'colors' (out 4-element array of lowp 4-component vector of float)
0:? 'st1' (uniform structure{global mediump int i, global lowp sampler2D s})
0:? 'st2' (uniform structure{global mediump int i, global lowp sampler2D s})

View File

@ -294,7 +294,7 @@ ERROR: node is still EOpNull!
0:? 'inb' (smooth in bool)
0:? 'ino' (smooth in highp sampler2D)
0:? 'ina' (smooth in 4-element array of mediump float)
0:? 'inaa' (smooth in 4-element array of mediump float)
0:? 'inaa' (smooth in 4-element array of 2-element array of mediump float)
0:? 'ins' (smooth in structure{global mediump float f})
0:? 'inasa' (smooth in 4-element array of structure{global mediump float f})
0:? 'insa' (smooth in 4-element array of structure{global mediump float f})
@ -556,7 +556,7 @@ ERROR: node is still EOpNull!
0:? 'inb' (smooth in bool)
0:? 'ino' (smooth in highp sampler2D)
0:? 'ina' (smooth in 4-element array of mediump float)
0:? 'inaa' (smooth in 4-element array of mediump float)
0:? 'inaa' (smooth in 4-element array of 2-element array of mediump float)
0:? 'ins' (smooth in structure{global mediump float f})
0:? 'inasa' (smooth in 4-element array of structure{global mediump float f})
0:? 'insa' (smooth in 4-element array of structure{global mediump float f})

View File

@ -179,7 +179,7 @@ ERROR: node is still EOpNull!
0:? 'outb' (smooth out bool)
0:? 'outo' (smooth out highp sampler2D)
0:? 'outa' (smooth out 4-element array of highp float)
0:? 'outaa' (smooth out 4-element array of highp float)
0:? 'outaa' (smooth out 4-element array of 2-element array of highp float)
0:? 'outs' (smooth out structure{global highp float f})
0:? 'outasa' (smooth out 4-element array of structure{global highp float f})
0:? 'outsa' (smooth out 4-element array of structure{global highp float f})
@ -354,7 +354,7 @@ ERROR: node is still EOpNull!
0:? 'outb' (smooth out bool)
0:? 'outo' (smooth out highp sampler2D)
0:? 'outa' (smooth out 4-element array of highp float)
0:? 'outaa' (smooth out 4-element array of highp float)
0:? 'outaa' (smooth out 4-element array of 2-element array of highp float)
0:? 'outs' (smooth out structure{global highp float f})
0:? 'outasa' (smooth out 4-element array of structure{global highp float f})
0:? 'outsa' (smooth out 4-element array of structure{global highp float f})

View File

@ -0,0 +1,59 @@
310mangle.vert
Warning, version 310 is not yet complete; most version-specific features are present, but some are missing.
Shader version: 310
0:? Sequence
0:8 Function Definition: f(b1;f1;u1[4];i1[3][2]; (global void)
0:8 Function Parameters:
0:8 'a' (in bool)
0:8 'b' (in highp float)
0:8 'c' (in 4-element array of highp uint)
0:8 'd' (in 3-element array of 2-element array of highp int)
0:11 Function Definition: main( (global void)
0:11 Function Parameters:
0:? Sequence
0:13 Function Call: f(b1;f1;u1[4];i1[3][2]; (global void)
0:13 Constant:
0:13 false (const bool)
0:13 Constant:
0:13 12.100000
0:13 Constant:
0:13 0 (const uint)
0:13 1 (const uint)
0:13 1 (const uint)
0:13 2 (const uint)
0:13 'd' (temp 3-element array of 2-element array of highp int)
0:? Linker Objects
0:? 'gl_VertexID' (gl_VertexId highp int)
0:? 'gl_InstanceID' (gl_InstanceId highp int)
Linked vertex stage:
Shader version: 310
0:? Sequence
0:8 Function Definition: f(b1;f1;u1[4];i1[3][2]; (global void)
0:8 Function Parameters:
0:8 'a' (in bool)
0:8 'b' (in highp float)
0:8 'c' (in 4-element array of highp uint)
0:8 'd' (in 3-element array of 2-element array of highp int)
0:11 Function Definition: main( (global void)
0:11 Function Parameters:
0:? Sequence
0:13 Function Call: f(b1;f1;u1[4];i1[3][2]; (global void)
0:13 Constant:
0:13 false (const bool)
0:13 Constant:
0:13 12.100000
0:13 Constant:
0:13 0 (const uint)
0:13 1 (const uint)
0:13 1 (const uint)
0:13 2 (const uint)
0:13 'd' (temp 3-element array of 2-element array of highp int)
0:? Linker Objects
0:? 'gl_VertexID' (gl_VertexId highp int)
0:? 'gl_InstanceID' (gl_InstanceId highp int)

View File

@ -25,7 +25,7 @@ ERROR: node is still EOpNull!
0:? 'outb' (smooth out bool)
0:? 'outo' (smooth out sampler2D)
0:? 'outa' (smooth out 4-element array of float)
0:? 'outaa' (smooth out 4-element array of float)
0:? 'outaa' (smooth out 4-element array of 2-element array of float)
0:? 'outs' (smooth out structure{global float f})
0:? 'outasa' (smooth out 4-element array of structure{global float f})
0:? 'outsa' (smooth out 4-element array of structure{global float f})
@ -58,7 +58,7 @@ ERROR: node is still EOpNull!
0:? 'outb' (smooth out bool)
0:? 'outo' (smooth out sampler2D)
0:? 'outa' (smooth out 4-element array of float)
0:? 'outaa' (smooth out 4-element array of float)
0:? 'outaa' (smooth out 4-element array of 2-element array of float)
0:? 'outs' (smooth out structure{global float f})
0:? 'outasa' (smooth out 4-element array of structure{global float f})
0:? 'outsa' (smooth out 4-element array of structure{global float f})

View 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
ERROR: 0:121: 'redeclaration' : all redeclarations must use the same depth layout on gl_FragDepth
ERROR: 0:150: 'constructor' : constructing from a non-dereferenced array
ERROR: 0:150: '=' : cannot convert from 'const float' to 'temp 3-element array of 4-component vector of float'
ERROR: 0:150: '=' : cannot convert from 'const float' to 'temp 3-element array of 2-element array of 4-component vector of float'
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'
ERROR: 0:172: 'x' : undeclared identifier
ERROR: 0:172: '[]' : scalar integer expression required

View File

@ -40,6 +40,7 @@ comment.frag
310.vert
310.frag
310implicitSizeArrayError.vert
310AofA.vert
330.frag
330comp.frag
constErrors.frag

View 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());

View 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);

View 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 += ']';
}
}
}