From e0603a441e05bc5df3f3edefd0d0412a8bd52d1c Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Mon, 6 Jul 2015 19:08:03 -0600 Subject: [PATCH] Front-end: move to rational internal array-of-array interfaces and design. (A-of-A is not yet implemented though.) --- SPIRV/GlslangToSpv.cpp | 2 +- Test/baseResults/120.vert.out | 1 + Test/baseResults/300.frag.out | 1 + Test/baseResults/310.frag.out | 1 + Test/baseResults/310.vert.out | 1 + Test/baseResults/310AofA.vert.out | 1 + Test/baseResults/450.vert.out | 1 + Test/baseResults/specExamples.frag.out | 1 + Test/baseResults/specExamples.vert.out | 1 + glslang/CMakeLists.txt | 1 + glslang/Include/Types.h | 49 ++---- glslang/Include/arrays.h | 174 +++++++++++++++++++++ glslang/MachineIndependent/Initialize.cpp | 2 +- glslang/MachineIndependent/ParseHelper.cpp | 36 +++-- glslang/MachineIndependent/ParseHelper.h | 2 +- glslang/MachineIndependent/SymbolTable.cpp | 4 +- glslang/MachineIndependent/glslang.y | 22 +-- 17 files changed, 236 insertions(+), 64 deletions(-) create mode 100644 glslang/Include/arrays.h diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 302d850f..5fba7d38 100644 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -2469,7 +2469,7 @@ spv::Id TGlslangToSpvTraverser::createSpvConstant(const glslang::TType& glslangT if (glslangType.isArray()) { glslang::TType elementType; - elementType.shallowCopy(glslangType); // TODO: desktop arrays of arrays functionality will need a deeper copy to avoid modifying the original + elementType.deepCopy(glslangType); elementType.dereference(); for (int i = 0; i < glslangType.getArraySize(); ++i) spvConsts.push_back(createSpvConstant(elementType, consts, nextConst)); diff --git a/Test/baseResults/120.vert.out b/Test/baseResults/120.vert.out index 7b58c8bc..8db27da2 100644 --- a/Test/baseResults/120.vert.out +++ b/Test/baseResults/120.vert.out @@ -17,6 +17,7 @@ ERROR: 0:34: '.' : cannot apply to an array: flizbit ERROR: 0:34: 'f' : can't use function syntax on variable ERROR: 0:34: 'a4' : redefinition ERROR: 0:35: 'arrays of arrays' : not supported with this profile: none +WARNING: 0:35: 'Not supported yet.' : arrays of arrays ERROR: 0:36: 'arrays of arrays' : not supported with this profile: none ERROR: 0:37: 'arrays of arrays' : not supported with this profile: none ERROR: 0:38: 'arrays of arrays' : not supported with this profile: none diff --git a/Test/baseResults/300.frag.out b/Test/baseResults/300.frag.out index 73939d00..cfe171ba 100644 --- a/Test/baseResults/300.frag.out +++ b/Test/baseResults/300.frag.out @@ -21,6 +21,7 @@ ERROR: 0:85: 'double vector' : not supported with this profile: es ERROR: 0:86: 'dvec4' : Reserved word. ERROR: 0:86: 'double vector' : not supported with this profile: es ERROR: 0:101: 'arrays of arrays' : not supported for this version or the enabled extensions +WARNING: 0:101: 'Not supported yet.' : arrays of arrays ERROR: 0:102: 'arrays of arrays' : not supported for this version or the enabled extensions ERROR: 0:102: 'arrays of arrays' : not supported for this version or the enabled extensions ERROR: 0:103: 'arrays of arrays' : not supported for this version or the enabled extensions diff --git a/Test/baseResults/310.frag.out b/Test/baseResults/310.frag.out index 09c54fcb..0764d550 100644 --- a/Test/baseResults/310.frag.out +++ b/Test/baseResults/310.frag.out @@ -36,6 +36,7 @@ ERROR: 0:111: '' : image variables not declared 'writeonly' must have a format l ERROR: 0:112: 'out' : cannot be a matrix ERROR: 0:114: 'in' : cannot be bool ERROR: 0:115: 'sampler2D' : sampler/image types can only be used in uniform variables or function parameters: ino +WARNING: 0:117: 'Not supported yet.' : arrays of arrays ERROR: 0:117: 'fragment-shader array-of-array input' : not supported with this profile: es ERROR: 0:120: 'fragment-shader array-of-struct input' : not supported with this profile: es ERROR: 0:121: 'fragment-shader array-of-struct input' : not supported with this profile: es diff --git a/Test/baseResults/310.vert.out b/Test/baseResults/310.vert.out index ff579124..fb9f0f30 100644 --- a/Test/baseResults/310.vert.out +++ b/Test/baseResults/310.vert.out @@ -9,6 +9,7 @@ ERROR: 0:58: 'sampler/image' : type requires declaration of default precision qu ERROR: 0:67: 'textureSamples' : no matching overloaded function found ERROR: 0:72: 'out' : cannot be bool ERROR: 0:73: 'sampler2D' : sampler/image types can only be used in uniform variables or function parameters: outo +WARNING: 0:75: 'Not supported yet.' : arrays of arrays ERROR: 0:75: 'vertex-shader array-of-array output' : not supported with this profile: es ERROR: 0:78: 'vertex-shader array-of-struct output' : not supported with this profile: es ERROR: 0:79: 'vertex-shader array-of-struct output' : not supported with this profile: es diff --git a/Test/baseResults/310AofA.vert.out b/Test/baseResults/310AofA.vert.out index 63598fcf..a8de634e 100644 --- a/Test/baseResults/310AofA.vert.out +++ b/Test/baseResults/310AofA.vert.out @@ -1,5 +1,6 @@ 310AofA.vert Warning, version 310 is not yet complete; most version-specific features are present, but some are missing. +WARNING: 0:8: 'Not supported yet.' : arrays of arrays Shader version: 310 0:? Sequence diff --git a/Test/baseResults/450.vert.out b/Test/baseResults/450.vert.out index 44aff420..aecef87c 100644 --- a/Test/baseResults/450.vert.out +++ b/Test/baseResults/450.vert.out @@ -2,6 +2,7 @@ Warning, version 450 is not yet complete; most version-specific features are present, but some are missing. ERROR: 0:12: 'out' : cannot be bool ERROR: 0:13: 'sampler2D' : sampler/image types can only be used in uniform variables or function parameters: outo +WARNING: 0:15: 'Not supported yet.' : arrays of arrays ERROR: 2 compilation errors. No code generated. diff --git a/Test/baseResults/specExamples.frag.out b/Test/baseResults/specExamples.frag.out index 94eb75f0..bf3ae550 100644 --- a/Test/baseResults/specExamples.frag.out +++ b/Test/baseResults/specExamples.frag.out @@ -17,6 +17,7 @@ ERROR: 0:102: 'color' : redefinition ERROR: 0:112: 'redeclaration' : all redeclarations must use the same depth layout on gl_FragDepth 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 +WARNING: 0:146: 'Not supported yet.' : arrays of arrays ERROR: 0:150: 'constructor' : constructing from a non-dereferenced array 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' diff --git a/Test/baseResults/specExamples.vert.out b/Test/baseResults/specExamples.vert.out index 80fe6e8c..80e4929a 100644 --- a/Test/baseResults/specExamples.vert.out +++ b/Test/baseResults/specExamples.vert.out @@ -35,6 +35,7 @@ ERROR: 0:134: '' : function does not return a value: funcA ERROR: 0:136: '' : function does not return a value: funcB ERROR: 0:153: '' : function does not return a value: func3 ERROR: 0:170: 'coherent' : argument cannot drop memory qualifier when passed to formal parameter +WARNING: 0:192: 'Not supported yet.' : arrays of arrays ERROR: 0:192: 'constructor' : constructing from a non-dereferenced array ERROR: 0:193: 'constructor' : constructing from a non-dereferenced array ERROR: 0:194: 'constructor' : constructing from a non-dereferenced array diff --git a/glslang/CMakeLists.txt b/glslang/CMakeLists.txt index c8fbea67..947cc7ea 100644 --- a/glslang/CMakeLists.txt +++ b/glslang/CMakeLists.txt @@ -42,6 +42,7 @@ set(SOURCES set(HEADERS Public/ShaderLang.h + Include/Arrays.h Include/BaseTypes.h Include/Common.h Include/ConstantUnion.h diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h index 085ac4e7..1e8b24c3 100644 --- a/glslang/Include/Types.h +++ b/glslang/Include/Types.h @@ -40,6 +40,7 @@ #include "../Include/Common.h" #include "../Include/BaseTypes.h" #include "../Public/ShaderLang.h" +#include "arrays.h" namespace glslang { @@ -168,29 +169,6 @@ typedef TVector TTypeList; typedef TVector TIdentifierList; -// -// TODO: memory: TArraySizes can be replaced by something smaller. -// Almost all arrays could be handled by two sizes each fitting -// in 16 bits, needing a real vector only in the cases where there -// are more than 3 sizes or a size needing more than 16 bits. -// -// The type is a pointer, so that it can be non-allocated and zero -// for the vast majority of non-array types. Note that means if it -// is used, it will be containing at least one size. - -struct TArraySizes { - POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator()) - - TArraySizes() : implicitArraySize(1) { } - int getSize() { return sizes.front(); } // TArraySizes only exists if there is at least one dimension - void setSize(int s) { sizes.push_back(s); } - bool isArrayOfArrays() { return sizes.size() > 1; } -protected: - TVector sizes; - friend class TType; - int implicitArraySize; // for tracking maximum referenced index, before an explicit size is given -}; - // // Following are a series of helper enums for managing layouts and qualifiers, // used for TPublicType, TType, others. @@ -962,7 +940,7 @@ public: vectorSize = copyOf.vectorSize; matrixCols = copyOf.matrixCols; matrixRows = copyOf.matrixRows; - arraySizes = copyOf.arraySizes; + arraySizes = copyOf.arraySizes; // copying the pointer only, not the contents structure = copyOf.structure; fieldName = copyOf.fieldName; typeName = copyOf.typeName; @@ -1064,9 +1042,9 @@ public: virtual int getVectorSize() const { return vectorSize; } virtual int getMatrixCols() const { return matrixCols; } virtual int getMatrixRows() const { return matrixRows; } - virtual int getArraySize() const { return arraySizes->sizes.front(); } - virtual bool isArrayOfArrays() const { return arraySizes && arraySizes->isArrayOfArrays(); } - virtual int getImplicitArraySize () const { return arraySizes->implicitArraySize; } + virtual int getArraySize() const { return arraySizes->getOuterSize(); } + virtual bool isArrayOfArrays() const { return arraySizes && arraySizes->getNumDims() > 1; } + virtual int getImplicitArraySize() const { return arraySizes->getImplicitSize(); } virtual bool isScalar() const { return vectorSize == 1 && ! isStruct() && ! isArray(); } virtual bool isVector() const { return vectorSize > 1; } @@ -1147,17 +1125,20 @@ public: { // For when we may already be sharing existing array descriptors, // keeping the pointers the same, just updating the contents. + assert(arraySizes != nullptr); + assert(type.arraySizes != nullptr); *arraySizes = *type.arraySizes; } void setArraySizes(TArraySizes* s) { // For setting a fresh new set of array sizes, not yet worrying about sharing. arraySizes = new TArraySizes; + assert(s != nullptr); *arraySizes = *s; } void setArraySizes(const TType& type) { setArraySizes(type.arraySizes); } - void changeArraySize(int s) { arraySizes->sizes.front() = s; } - void setImplicitArraySize (int s) { arraySizes->implicitArraySize = s; } + void changeArraySize(int s) { arraySizes->changeOuterSize(s); } + void setImplicitArraySize (int s) { arraySizes->setImplicitSize(s); } // Recursively make the implicit array size the explicit array size, through the type tree. void adoptImplicitArraySizes() @@ -1265,12 +1246,12 @@ public: p += snprintf(p, end - p, "writeonly "); p += snprintf(p, end - p, "%s ", getStorageQualifierString()); if (arraySizes) { - if (arraySizes->sizes.front() == 0) { + if (arraySizes->getOuterSize() == 0) { p += snprintf(p, end - p, "implicitly-sized array of "); } else { - for(int i = 0; i < (int)arraySizes->sizes.size() ; ++i) { + for(int i = 0; i < (int)arraySizes->getNumDims() ; ++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]); + p += snprintf(p, end - p, "%d-element array of ", (*arraySizes)[i]); } } } @@ -1395,7 +1376,7 @@ public: bool sameArrayness(const TType& right) const { return ((arraySizes == 0 && right.arraySizes == 0) || - (arraySizes && right.arraySizes && arraySizes->sizes == right.arraySizes->sizes)); + (arraySizes && right.arraySizes && *arraySizes == *right.arraySizes)); } // See if two type's elements match in all ways except basic type @@ -1433,7 +1414,7 @@ protected: TSampler sampler; TQualifier qualifier; - TArraySizes* arraySizes; // 0 unless this is an array; can be shared across types + TArraySizes* arraySizes; // 0 unless an array; can be shared across types TTypeList* structure; // 0 unless this is a struct; can be shared across types TString *fieldName; // for structure field names TString *typeName; // for structure type name diff --git a/glslang/Include/arrays.h b/glslang/Include/arrays.h new file mode 100644 index 00000000..5cc89c7f --- /dev/null +++ b/glslang/Include/arrays.h @@ -0,0 +1,174 @@ +// +//Copyright (C) 2002-2005 3Dlabs Inc. Ltd. +//Copyright (C) 2012-2013 LunarG, Inc. +// +//All rights reserved. +// +//Redistribution and use in source and binary forms, with or without +//modification, are permitted provided that the following conditions +//are met: +// +// Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// +// Neither the name of 3Dlabs Inc. Ltd. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +//POSSIBILITY OF SUCH DAMAGE. +// + +// +// Implement types for tracking GLSL arrays, arrays of arrays, etc. +// + +#ifndef _ARRAYS_INCLUDED +#define _ARRAYS_INCLUDED + +namespace glslang { + +// +// TSmallArrayVector is used as the container for the set of sizes in TArraySizes. +// It has generic-container semantics, while TArraySizes has array-of-array semantics. +// +struct TSmallArrayVector { + // + // TODO: memory: TSmallArrayVector is intended to be smaller. + // Almost all arrays could be handled by two sizes each fitting + // in 16 bits, needing a real vector only in the cases where there + // are more than 3 sizes or a size needing more than 16 bits. + // + POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator()) + + TSmallArrayVector() : sizes(0) { } + virtual ~TSmallArrayVector() { dealloc(); } + + // For breaking into two non-shared copies, independently modifiable. + TSmallArrayVector& operator=(const TSmallArrayVector& from) + { + if (from.sizes == nullptr) + sizes = nullptr; + else { + alloc(); + *sizes = *from.sizes; + } + + return *this; + } + + int size() + { + if (sizes == nullptr) + return 0; + return (int)sizes->size(); + } + + unsigned int front() + { + assert(sizes != nullptr && sizes->size() > 0); + return sizes->front(); + } + + void changeFront(unsigned int s) + { + assert(sizes != nullptr); + sizes->front() = s; + } + + void push_back(unsigned int e) + { + alloc(); + sizes->push_back(e); + } + + unsigned int operator[](int i) + { + assert(sizes && (int)sizes->size() > i); + return (*sizes)[i]; + } + + bool operator==(const TSmallArrayVector& rhs) + { + if (sizes == nullptr && rhs.sizes == nullptr) + return true; + if (sizes == nullptr || rhs.sizes == nullptr) + return false; + return *sizes == *rhs.sizes; + } + +protected: + TSmallArrayVector(const TSmallArrayVector&); + + void alloc() + { + if (sizes == nullptr) + sizes = new TVector; + } + void dealloc() + { + delete sizes; + } + + TVector* sizes; // will either hold such a pointer, or in the future, hold the two array sizes +}; + +// +// Represent an array, or array of arrays, to arbitrary depth. This is not +// done through a hierarchy of types, but localized into this single cumulative object. +// +// The arrayness in TTtype is a pointer, so that it can be non-allocated and zero +// for the vast majority of types that are non-array types. +// +struct TArraySizes { + POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator()) + + TArraySizes() : implicitArraySize(1) { } + + // For breaking into two non-shared copies, independently modifiable. + TArraySizes& operator=(const TArraySizes& from) + { + implicitArraySize = from.implicitArraySize; + sizes = from.sizes; + + return *this; + } + + // translate from array-of-array semantics to container semantics + int getNumDims() { return sizes.size(); } + int getOuterSize() { return sizes.front(); } + void setOuterSize(int s) { sizes.push_back((unsigned)s); } + void changeOuterSize(int s) { sizes.changeFront((unsigned)s); } + int getImplicitSize() { return (int)implicitArraySize; } + void setImplicitSize(int s) { implicitArraySize = s; } + int operator[](int i) { return sizes[i]; } + bool operator==(const TArraySizes& rhs) { return sizes == rhs.sizes; } + +protected: + TSmallArrayVector sizes; + + TArraySizes(const TArraySizes&); + + // for tracking maximum referenced index, before an explicit size is given + // applies only to the outer-most dimension + int implicitArraySize; +}; + +} // end namespace glslang + +#endif // _ARRAYS_INCLUDED_ diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp index 57b6f354..396a9f67 100644 --- a/glslang/MachineIndependent/Initialize.cpp +++ b/glslang/MachineIndependent/Initialize.cpp @@ -3250,7 +3250,7 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb TPrecisionQualifier pq = profile == EEsProfile ? EpqMedium : EpqNone; TType fragData(EbtFloat, EvqFragColor, pq, 4); TArraySizes* arraySizes = new TArraySizes; - arraySizes->setSize(resources.maxDrawBuffers); + arraySizes->setOuterSize(resources.maxDrawBuffers); fragData.setArraySizes(arraySizes); symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData)); SpecialQualifier("gl_FragData", EvqFragColor, EbvFragData, symbolTable); diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 48b63af0..e71564c3 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -2500,26 +2500,34 @@ void TParseContext::arrayUnsizedCheck(TSourceLoc loc, const TQualifier& qualifie arraySizeRequiredCheck(loc, size); } -void TParseContext::arrayDimError(TSourceLoc loc) +void TParseContext::arrayOfArrayVersionCheck(TSourceLoc loc) { - requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, "arrays of arrays"); - profileRequires(loc, ECoreProfile | ECompatibilityProfile, 430, nullptr, "arrays of arrays"); - profileRequires(loc, EEsProfile, 310, nullptr, "arrays of arrays"); + const char* feature = "arrays of arrays"; + + requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, feature); + profileRequires(loc, EEsProfile, 310, nullptr, feature); + profileRequires(loc, ECoreProfile | ECompatibilityProfile, 430, nullptr, feature); + + static int once = false; + if (! once) { + warn(loc, feature, "Not supported yet.", ""); + once = true; + } } void TParseContext::arrayDimCheck(TSourceLoc loc, TArraySizes* sizes1, TArraySizes* sizes2) { if ((sizes1 && sizes2) || - (sizes1 && sizes1->isArrayOfArrays()) || - (sizes2 && sizes2->isArrayOfArrays())) - arrayDimError(loc); + (sizes1 && sizes1->getNumDims() > 1) || + (sizes2 && sizes2->getNumDims() > 1)) + arrayOfArrayVersionCheck(loc); } void TParseContext::arrayDimCheck(TSourceLoc loc, const TType* type, TArraySizes* sizes2) { if ((type && type->isArray() && sizes2) || - (sizes2 && sizes2->isArrayOfArrays())) - arrayDimError(loc); + (sizes2 && sizes2->getNumDims() > 1)) + arrayOfArrayVersionCheck(loc); } // @@ -2913,12 +2921,12 @@ void TParseContext::redeclareBuiltinBlock(TSourceLoc loc, TTypeList& newTypeList if (type.isArray() != (arraySizes != 0)) error(loc, "cannot change arrayness of redeclared block", blockName.c_str(), ""); else if (type.isArray()) { - if (type.isExplicitlySizedArray() && arraySizes->getSize() == 0) + if (type.isExplicitlySizedArray() && arraySizes->getOuterSize() == 0) error(loc, "block already declared with size, can't redeclare as implicitly-sized", blockName.c_str(), ""); - else if (type.isExplicitlySizedArray() && type.getArraySize() != arraySizes->getSize()) + else if (type.isExplicitlySizedArray() && type.getArraySize() != arraySizes->getOuterSize()) error(loc, "cannot change array size of redeclared block", blockName.c_str(), ""); - else if (type.isImplicitlySizedArray() && arraySizes->getSize() > 0) - type.changeArraySize(arraySizes->getSize()); + else if (type.isImplicitlySizedArray() && arraySizes->getOuterSize() > 0) + type.changeArraySize(arraySizes->getOuterSize()); } symbolTable.insert(*block); @@ -4560,7 +4568,7 @@ void TParseContext::declareBlock(TSourceLoc loc, TTypeList& typeList, const TStr { blockStageIoCheck(loc, currentBlockQualifier); if (arraySizes) - arrayUnsizedCheck(loc, currentBlockQualifier, arraySizes->getSize(), false); + arrayUnsizedCheck(loc, currentBlockQualifier, arraySizes->getOuterSize(), false); arrayDimCheck(loc, arraySizes, 0); // fix and check for member storage qualifiers and types that don't belong within a block diff --git a/glslang/MachineIndependent/ParseHelper.h b/glslang/MachineIndependent/ParseHelper.h index 7035b202..cac1da8c 100644 --- a/glslang/MachineIndependent/ParseHelper.h +++ b/glslang/MachineIndependent/ParseHelper.h @@ -129,7 +129,7 @@ public: void arraySizeRequiredCheck(TSourceLoc, int size); void structArrayCheck(TSourceLoc, const TType& structure); void arrayUnsizedCheck(TSourceLoc, const TQualifier&, int size, bool initializer); - void arrayDimError(TSourceLoc); + void arrayOfArrayVersionCheck(TSourceLoc); void arrayDimCheck(TSourceLoc, TArraySizes* sizes1, TArraySizes* sizes2); void arrayDimCheck(TSourceLoc, const TType*, TArraySizes*); bool voidErrorCheck(TSourceLoc, const TString&, TBasicType); diff --git a/glslang/MachineIndependent/SymbolTable.cpp b/glslang/MachineIndependent/SymbolTable.cpp index 8ec7f539..e07a9848 100644 --- a/glslang/MachineIndependent/SymbolTable.cpp +++ b/glslang/MachineIndependent/SymbolTable.cpp @@ -112,8 +112,8 @@ void TType::buildMangledName(TString& mangledName) if (arraySizes) { const int maxSize = 11; char buf[maxSize]; - for (int i = 0; i < (int)arraySizes->sizes.size(); ++i) { - snprintf(buf, maxSize, "%d", arraySizes->sizes[i]); + for (int i = 0; i < arraySizes->getNumDims(); ++i) { + snprintf(buf, maxSize, "%d", (*arraySizes)[i]); mangledName += '['; mangledName += buf; mangledName += ']'; diff --git a/glslang/MachineIndependent/glslang.y b/glslang/MachineIndependent/glslang.y index 91830efc..25eba7df 100644 --- a/glslang/MachineIndependent/glslang.y +++ b/glslang/MachineIndependent/glslang.y @@ -795,7 +795,7 @@ function_header GetStorageQualifierString($1.qualifier.storage), ""); } if ($1.arraySizes) - parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->getSize()); + parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->getOuterSize()); // Add the function as a prototype after parsing it (we do not support recursion) TFunction *function; @@ -811,7 +811,7 @@ parameter_declarator if ($1.arraySizes) { parseContext.profileRequires($1.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type"); parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type"); - parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->getSize()); + parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->getOuterSize()); } if ($1.basicType == EbtVoid) { parseContext.error($2.loc, "illegal use of type 'void'", $2.string->c_str(), ""); @@ -826,11 +826,11 @@ parameter_declarator if ($1.arraySizes) { parseContext.profileRequires($1.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type"); parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type"); - parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->getSize()); + parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->getOuterSize()); } parseContext.arrayDimCheck($2.loc, $1.arraySizes, $3.arraySizes); - parseContext.arraySizeRequiredCheck($3.loc, $3.arraySizes->getSize()); + parseContext.arraySizeRequiredCheck($3.loc, $3.arraySizes->getOuterSize()); parseContext.reservedErrorCheck($2.loc, *$2.string); $1.arraySizes = $3.arraySizes; @@ -890,7 +890,7 @@ parameter_type_specifier TParameter param = { 0, new TType($1) }; $$.param = param; if ($1.arraySizes) - parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->getSize()); + parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->getOuterSize()); } ; @@ -1237,7 +1237,7 @@ array_specifier : LEFT_BRACKET RIGHT_BRACKET { $$.loc = $1.loc; $$.arraySizes = new TArraySizes; - $$.arraySizes->setSize(0); + $$.arraySizes->setOuterSize(0); } | LEFT_BRACKET constant_expression RIGHT_BRACKET { $$.loc = $1.loc; @@ -1245,18 +1245,18 @@ array_specifier int size; parseContext.arraySizeCheck($2->getLoc(), $2, size); - $$.arraySizes->setSize(size); + $$.arraySizes->setOuterSize(size); } | array_specifier LEFT_BRACKET RIGHT_BRACKET { $$ = $1; - $$.arraySizes->setSize(0); + $$.arraySizes->setOuterSize(0); } | array_specifier LEFT_BRACKET constant_expression RIGHT_BRACKET { $$ = $1; int size; parseContext.arraySizeCheck($3->getLoc(), $3, size); - $$.arraySizes->setSize(size); + $$.arraySizes->setOuterSize(size); } ; @@ -1959,7 +1959,7 @@ struct_declaration parseContext.profileRequires($1.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type"); parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type"); if (parseContext.profile == EEsProfile) - parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->getSize()); + parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->getOuterSize()); } $$ = $2; @@ -1978,7 +1978,7 @@ struct_declaration parseContext.profileRequires($2.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type"); parseContext.profileRequires($2.loc, EEsProfile, 300, 0, "arrayed type"); if (parseContext.profile == EEsProfile) - parseContext.arraySizeRequiredCheck($2.loc, $2.arraySizes->getSize()); + parseContext.arraySizeRequiredCheck($2.loc, $2.arraySizes->getOuterSize()); } $$ = $3;