From af9ab5f743fc97d3170addd77a6e381ebea023e8 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Mon, 11 May 2015 16:16:49 +0000 Subject: [PATCH] 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 . git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31137 e7fa87d3-cd2b-0410-9028-fcbf551c1848 --- Test/310AofA.vert | 14 +++++++ Test/baseResults/120.vert.out | 4 +- Test/baseResults/300.frag.out | 4 +- Test/baseResults/310.frag.out | 4 +- Test/baseResults/310.vert.out | 4 +- Test/baseResults/310AofA.vert.out | 59 ++++++++++++++++++++++++++++++ Test/baseResults/450.vert.out | 4 +- Test/baseResults/specExamples.frag.out | 2 +- Test/testlist | 1 + glslang/Include/Types.h | 10 +++-- glslang/MachineIndependent/Initialize.cpp | 8 ++-- glslang/MachineIndependent/SymbolTable.cpp | 10 +++-- 12 files changed, 102 insertions(+), 22 deletions(-) create mode 100644 Test/310AofA.vert create mode 100644 Test/baseResults/310AofA.vert.out diff --git a/Test/310AofA.vert b/Test/310AofA.vert new file mode 100644 index 0000000..eb68d89 --- /dev/null +++ b/Test/310AofA.vert @@ -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); +} diff --git a/Test/baseResults/120.vert.out b/Test/baseResults/120.vert.out index a5b1638..6cc6fa3 100644 --- a/Test/baseResults/120.vert.out +++ b/Test/baseResults/120.vert.out @@ -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 diff --git a/Test/baseResults/300.frag.out b/Test/baseResults/300.frag.out index 02d5836..1c0d0fa 100644 --- a/Test/baseResults/300.frag.out +++ b/Test/baseResults/300.frag.out @@ -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}) diff --git a/Test/baseResults/310.frag.out b/Test/baseResults/310.frag.out index cba86bb..eeac76d 100644 --- a/Test/baseResults/310.frag.out +++ b/Test/baseResults/310.frag.out @@ -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}) diff --git a/Test/baseResults/310.vert.out b/Test/baseResults/310.vert.out index 8f3b682..5bc03f7 100644 --- a/Test/baseResults/310.vert.out +++ b/Test/baseResults/310.vert.out @@ -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}) diff --git a/Test/baseResults/310AofA.vert.out b/Test/baseResults/310AofA.vert.out new file mode 100644 index 0000000..ef63fd2 --- /dev/null +++ b/Test/baseResults/310AofA.vert.out @@ -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) + diff --git a/Test/baseResults/450.vert.out b/Test/baseResults/450.vert.out index 5298360..09b3bfd 100644 --- a/Test/baseResults/450.vert.out +++ b/Test/baseResults/450.vert.out @@ -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}) diff --git a/Test/baseResults/specExamples.frag.out b/Test/baseResults/specExamples.frag.out index 7857d11..5c5560e 100644 --- a/Test/baseResults/specExamples.frag.out +++ b/Test/baseResults/specExamples.frag.out @@ -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 diff --git a/Test/testlist b/Test/testlist index d87689c..85b5ba3 100644 --- a/Test/testlist +++ b/Test/testlist @@ -40,6 +40,7 @@ comment.frag 310.vert 310.frag 310implicitSizeArrayError.vert +310AofA.vert 330.frag 330comp.frag constErrors.frag diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h index b76e2d5..b02b708 100644 --- a/glslang/Include/Types.h +++ b/glslang/Include/Types.h @@ -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()); diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 2cab878..2735a9f 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -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); diff --git a/glslang/MachineIndependent/SymbolTable.cpp b/glslang/MachineIndependent/SymbolTable.cpp index f1479a5..8ec7f53 100644 --- a/glslang/MachineIndependent/SymbolTable.cpp +++ b/glslang/MachineIndependent/SymbolTable.cpp @@ -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 += ']'; + } } } -- 2.7.4