Front-end: move to rational internal array-of-array interfaces and design. (A-of-A is not yet implemented though.)
This commit is contained in:
parent
dcab977055
commit
e0603a441e
@ -2469,7 +2469,7 @@ spv::Id TGlslangToSpvTraverser::createSpvConstant(const glslang::TType& glslangT
|
|||||||
|
|
||||||
if (glslangType.isArray()) {
|
if (glslangType.isArray()) {
|
||||||
glslang::TType elementType;
|
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();
|
elementType.dereference();
|
||||||
for (int i = 0; i < glslangType.getArraySize(); ++i)
|
for (int i = 0; i < glslangType.getArraySize(); ++i)
|
||||||
spvConsts.push_back(createSpvConstant(elementType, consts, nextConst));
|
spvConsts.push_back(createSpvConstant(elementType, consts, nextConst));
|
||||||
|
@ -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: 'f' : can't use function syntax on variable
|
||||||
ERROR: 0:34: 'a4' : redefinition
|
ERROR: 0:34: 'a4' : redefinition
|
||||||
ERROR: 0:35: 'arrays of arrays' : not supported with this profile: none
|
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:36: 'arrays of arrays' : not supported with this profile: none
|
||||||
ERROR: 0:37: '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
|
ERROR: 0:38: 'arrays of arrays' : not supported with this profile: none
|
||||||
|
@ -21,6 +21,7 @@ ERROR: 0:85: 'double vector' : not supported with this profile: es
|
|||||||
ERROR: 0:86: 'dvec4' : Reserved word.
|
ERROR: 0:86: 'dvec4' : Reserved word.
|
||||||
ERROR: 0:86: 'double vector' : not supported with this profile: es
|
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
|
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: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
|
ERROR: 0:103: 'arrays of arrays' : not supported for this version or the enabled extensions
|
||||||
|
@ -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:112: 'out' : cannot be a matrix
|
||||||
ERROR: 0:114: 'in' : cannot be bool
|
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
|
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: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: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
|
ERROR: 0:121: 'fragment-shader array-of-struct input' : not supported with this profile: es
|
||||||
|
@ -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:67: 'textureSamples' : no matching overloaded function found
|
||||||
ERROR: 0:72: 'out' : cannot be bool
|
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
|
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: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: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
|
ERROR: 0:79: 'vertex-shader array-of-struct output' : not supported with this profile: es
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
310AofA.vert
|
310AofA.vert
|
||||||
Warning, version 310 is not yet complete; most version-specific features are present, but some are missing.
|
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
|
Shader version: 310
|
||||||
0:? Sequence
|
0:? Sequence
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
|
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:12: 'out' : cannot be bool
|
||||||
ERROR: 0:13: 'sampler2D' : sampler/image types can only be used in uniform variables or function parameters: outo
|
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.
|
ERROR: 2 compilation errors. No code generated.
|
||||||
|
|
||||||
|
|
||||||
|
@ -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: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: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: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: '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: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:152: 'constructor' : cannot convert parameter 1 from 'const 2-element array of 4-component vector of float' to 'temp 4-component vector of float'
|
||||||
|
@ -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:136: '' : function does not return a value: funcB
|
||||||
ERROR: 0:153: '' : function does not return a value: func3
|
ERROR: 0:153: '' : function does not return a value: func3
|
||||||
ERROR: 0:170: 'coherent' : argument cannot drop memory qualifier when passed to formal parameter
|
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:192: 'constructor' : constructing from a non-dereferenced array
|
||||||
ERROR: 0:193: '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
|
ERROR: 0:194: 'constructor' : constructing from a non-dereferenced array
|
||||||
|
@ -42,6 +42,7 @@ set(SOURCES
|
|||||||
|
|
||||||
set(HEADERS
|
set(HEADERS
|
||||||
Public/ShaderLang.h
|
Public/ShaderLang.h
|
||||||
|
Include/Arrays.h
|
||||||
Include/BaseTypes.h
|
Include/BaseTypes.h
|
||||||
Include/Common.h
|
Include/Common.h
|
||||||
Include/ConstantUnion.h
|
Include/ConstantUnion.h
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "../Include/Common.h"
|
#include "../Include/Common.h"
|
||||||
#include "../Include/BaseTypes.h"
|
#include "../Include/BaseTypes.h"
|
||||||
#include "../Public/ShaderLang.h"
|
#include "../Public/ShaderLang.h"
|
||||||
|
#include "arrays.h"
|
||||||
|
|
||||||
namespace glslang {
|
namespace glslang {
|
||||||
|
|
||||||
@ -168,29 +169,6 @@ typedef TVector<TTypeLoc> TTypeList;
|
|||||||
|
|
||||||
typedef TVector<TString*> TIdentifierList;
|
typedef TVector<TString*> 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<int> 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,
|
// Following are a series of helper enums for managing layouts and qualifiers,
|
||||||
// used for TPublicType, TType, others.
|
// used for TPublicType, TType, others.
|
||||||
@ -962,7 +940,7 @@ public:
|
|||||||
vectorSize = copyOf.vectorSize;
|
vectorSize = copyOf.vectorSize;
|
||||||
matrixCols = copyOf.matrixCols;
|
matrixCols = copyOf.matrixCols;
|
||||||
matrixRows = copyOf.matrixRows;
|
matrixRows = copyOf.matrixRows;
|
||||||
arraySizes = copyOf.arraySizes;
|
arraySizes = copyOf.arraySizes; // copying the pointer only, not the contents
|
||||||
structure = copyOf.structure;
|
structure = copyOf.structure;
|
||||||
fieldName = copyOf.fieldName;
|
fieldName = copyOf.fieldName;
|
||||||
typeName = copyOf.typeName;
|
typeName = copyOf.typeName;
|
||||||
@ -1064,9 +1042,9 @@ public:
|
|||||||
virtual int getVectorSize() const { return vectorSize; }
|
virtual int getVectorSize() const { return vectorSize; }
|
||||||
virtual int getMatrixCols() const { return matrixCols; }
|
virtual int getMatrixCols() const { return matrixCols; }
|
||||||
virtual int getMatrixRows() const { return matrixRows; }
|
virtual int getMatrixRows() const { return matrixRows; }
|
||||||
virtual int getArraySize() const { return arraySizes->sizes.front(); }
|
virtual int getArraySize() const { return arraySizes->getOuterSize(); }
|
||||||
virtual bool isArrayOfArrays() const { return arraySizes && arraySizes->isArrayOfArrays(); }
|
virtual bool isArrayOfArrays() const { return arraySizes && arraySizes->getNumDims() > 1; }
|
||||||
virtual int getImplicitArraySize () const { return arraySizes->implicitArraySize; }
|
virtual int getImplicitArraySize() const { return arraySizes->getImplicitSize(); }
|
||||||
|
|
||||||
virtual bool isScalar() const { return vectorSize == 1 && ! isStruct() && ! isArray(); }
|
virtual bool isScalar() const { return vectorSize == 1 && ! isStruct() && ! isArray(); }
|
||||||
virtual bool isVector() const { return vectorSize > 1; }
|
virtual bool isVector() const { return vectorSize > 1; }
|
||||||
@ -1147,17 +1125,20 @@ public:
|
|||||||
{
|
{
|
||||||
// For when we may already be sharing existing array descriptors,
|
// For when we may already be sharing existing array descriptors,
|
||||||
// keeping the pointers the same, just updating the contents.
|
// keeping the pointers the same, just updating the contents.
|
||||||
|
assert(arraySizes != nullptr);
|
||||||
|
assert(type.arraySizes != nullptr);
|
||||||
*arraySizes = *type.arraySizes;
|
*arraySizes = *type.arraySizes;
|
||||||
}
|
}
|
||||||
void setArraySizes(TArraySizes* s)
|
void setArraySizes(TArraySizes* s)
|
||||||
{
|
{
|
||||||
// For setting a fresh new set of array sizes, not yet worrying about sharing.
|
// For setting a fresh new set of array sizes, not yet worrying about sharing.
|
||||||
arraySizes = new TArraySizes;
|
arraySizes = new TArraySizes;
|
||||||
|
assert(s != nullptr);
|
||||||
*arraySizes = *s;
|
*arraySizes = *s;
|
||||||
}
|
}
|
||||||
void setArraySizes(const TType& type) { setArraySizes(type.arraySizes); }
|
void setArraySizes(const TType& type) { setArraySizes(type.arraySizes); }
|
||||||
void changeArraySize(int s) { arraySizes->sizes.front() = s; }
|
void changeArraySize(int s) { arraySizes->changeOuterSize(s); }
|
||||||
void setImplicitArraySize (int s) { arraySizes->implicitArraySize = s; }
|
void setImplicitArraySize (int s) { arraySizes->setImplicitSize(s); }
|
||||||
|
|
||||||
// Recursively make the implicit array size the explicit array size, through the type tree.
|
// Recursively make the implicit array size the explicit array size, through the type tree.
|
||||||
void adoptImplicitArraySizes()
|
void adoptImplicitArraySizes()
|
||||||
@ -1265,12 +1246,12 @@ public:
|
|||||||
p += snprintf(p, end - p, "writeonly ");
|
p += snprintf(p, end - p, "writeonly ");
|
||||||
p += snprintf(p, end - p, "%s ", getStorageQualifierString());
|
p += snprintf(p, end - p, "%s ", getStorageQualifierString());
|
||||||
if (arraySizes) {
|
if (arraySizes) {
|
||||||
if (arraySizes->sizes.front() == 0) {
|
if (arraySizes->getOuterSize() == 0) {
|
||||||
p += snprintf(p, end - p, "implicitly-sized array of ");
|
p += snprintf(p, end - p, "implicitly-sized array of ");
|
||||||
} else {
|
} 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, "%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
|
bool sameArrayness(const TType& right) const
|
||||||
{
|
{
|
||||||
return ((arraySizes == 0 && right.arraySizes == 0) ||
|
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
|
// See if two type's elements match in all ways except basic type
|
||||||
@ -1433,7 +1414,7 @@ protected:
|
|||||||
TSampler sampler;
|
TSampler sampler;
|
||||||
TQualifier qualifier;
|
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
|
TTypeList* structure; // 0 unless this is a struct; can be shared across types
|
||||||
TString *fieldName; // for structure field names
|
TString *fieldName; // for structure field names
|
||||||
TString *typeName; // for structure type name
|
TString *typeName; // for structure type name
|
||||||
|
174
glslang/Include/arrays.h
Normal file
174
glslang/Include/arrays.h
Normal file
@ -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<unsigned int>;
|
||||||
|
}
|
||||||
|
void dealloc()
|
||||||
|
{
|
||||||
|
delete sizes;
|
||||||
|
}
|
||||||
|
|
||||||
|
TVector<unsigned int>* 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_
|
@ -3250,7 +3250,7 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
|
|||||||
TPrecisionQualifier pq = profile == EEsProfile ? EpqMedium : EpqNone;
|
TPrecisionQualifier pq = profile == EEsProfile ? EpqMedium : EpqNone;
|
||||||
TType fragData(EbtFloat, EvqFragColor, pq, 4);
|
TType fragData(EbtFloat, EvqFragColor, pq, 4);
|
||||||
TArraySizes* arraySizes = new TArraySizes;
|
TArraySizes* arraySizes = new TArraySizes;
|
||||||
arraySizes->setSize(resources.maxDrawBuffers);
|
arraySizes->setOuterSize(resources.maxDrawBuffers);
|
||||||
fragData.setArraySizes(arraySizes);
|
fragData.setArraySizes(arraySizes);
|
||||||
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));
|
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));
|
||||||
SpecialQualifier("gl_FragData", EvqFragColor, EbvFragData, symbolTable);
|
SpecialQualifier("gl_FragData", EvqFragColor, EbvFragData, symbolTable);
|
||||||
|
@ -2500,26 +2500,34 @@ void TParseContext::arrayUnsizedCheck(TSourceLoc loc, const TQualifier& qualifie
|
|||||||
arraySizeRequiredCheck(loc, size);
|
arraySizeRequiredCheck(loc, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TParseContext::arrayDimError(TSourceLoc loc)
|
void TParseContext::arrayOfArrayVersionCheck(TSourceLoc loc)
|
||||||
{
|
{
|
||||||
requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, "arrays of arrays");
|
const char* feature = "arrays of arrays";
|
||||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 430, nullptr, "arrays of arrays");
|
|
||||||
profileRequires(loc, EEsProfile, 310, nullptr, "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)
|
void TParseContext::arrayDimCheck(TSourceLoc loc, TArraySizes* sizes1, TArraySizes* sizes2)
|
||||||
{
|
{
|
||||||
if ((sizes1 && sizes2) ||
|
if ((sizes1 && sizes2) ||
|
||||||
(sizes1 && sizes1->isArrayOfArrays()) ||
|
(sizes1 && sizes1->getNumDims() > 1) ||
|
||||||
(sizes2 && sizes2->isArrayOfArrays()))
|
(sizes2 && sizes2->getNumDims() > 1))
|
||||||
arrayDimError(loc);
|
arrayOfArrayVersionCheck(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TParseContext::arrayDimCheck(TSourceLoc loc, const TType* type, TArraySizes* sizes2)
|
void TParseContext::arrayDimCheck(TSourceLoc loc, const TType* type, TArraySizes* sizes2)
|
||||||
{
|
{
|
||||||
if ((type && type->isArray() && sizes2) ||
|
if ((type && type->isArray() && sizes2) ||
|
||||||
(sizes2 && sizes2->isArrayOfArrays()))
|
(sizes2 && sizes2->getNumDims() > 1))
|
||||||
arrayDimError(loc);
|
arrayOfArrayVersionCheck(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -2913,12 +2921,12 @@ void TParseContext::redeclareBuiltinBlock(TSourceLoc loc, TTypeList& newTypeList
|
|||||||
if (type.isArray() != (arraySizes != 0))
|
if (type.isArray() != (arraySizes != 0))
|
||||||
error(loc, "cannot change arrayness of redeclared block", blockName.c_str(), "");
|
error(loc, "cannot change arrayness of redeclared block", blockName.c_str(), "");
|
||||||
else if (type.isArray()) {
|
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(), "");
|
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(), "");
|
error(loc, "cannot change array size of redeclared block", blockName.c_str(), "");
|
||||||
else if (type.isImplicitlySizedArray() && arraySizes->getSize() > 0)
|
else if (type.isImplicitlySizedArray() && arraySizes->getOuterSize() > 0)
|
||||||
type.changeArraySize(arraySizes->getSize());
|
type.changeArraySize(arraySizes->getOuterSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
symbolTable.insert(*block);
|
symbolTable.insert(*block);
|
||||||
@ -4560,7 +4568,7 @@ void TParseContext::declareBlock(TSourceLoc loc, TTypeList& typeList, const TStr
|
|||||||
{
|
{
|
||||||
blockStageIoCheck(loc, currentBlockQualifier);
|
blockStageIoCheck(loc, currentBlockQualifier);
|
||||||
if (arraySizes)
|
if (arraySizes)
|
||||||
arrayUnsizedCheck(loc, currentBlockQualifier, arraySizes->getSize(), false);
|
arrayUnsizedCheck(loc, currentBlockQualifier, arraySizes->getOuterSize(), false);
|
||||||
arrayDimCheck(loc, arraySizes, 0);
|
arrayDimCheck(loc, arraySizes, 0);
|
||||||
|
|
||||||
// fix and check for member storage qualifiers and types that don't belong within a block
|
// fix and check for member storage qualifiers and types that don't belong within a block
|
||||||
|
@ -129,7 +129,7 @@ public:
|
|||||||
void arraySizeRequiredCheck(TSourceLoc, int size);
|
void arraySizeRequiredCheck(TSourceLoc, int size);
|
||||||
void structArrayCheck(TSourceLoc, const TType& structure);
|
void structArrayCheck(TSourceLoc, const TType& structure);
|
||||||
void arrayUnsizedCheck(TSourceLoc, const TQualifier&, int size, bool initializer);
|
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, TArraySizes* sizes1, TArraySizes* sizes2);
|
||||||
void arrayDimCheck(TSourceLoc, const TType*, TArraySizes*);
|
void arrayDimCheck(TSourceLoc, const TType*, TArraySizes*);
|
||||||
bool voidErrorCheck(TSourceLoc, const TString&, TBasicType);
|
bool voidErrorCheck(TSourceLoc, const TString&, TBasicType);
|
||||||
|
@ -112,8 +112,8 @@ void TType::buildMangledName(TString& mangledName)
|
|||||||
if (arraySizes) {
|
if (arraySizes) {
|
||||||
const int maxSize = 11;
|
const int maxSize = 11;
|
||||||
char buf[maxSize];
|
char buf[maxSize];
|
||||||
for (int i = 0; i < (int)arraySizes->sizes.size(); ++i) {
|
for (int i = 0; i < arraySizes->getNumDims(); ++i) {
|
||||||
snprintf(buf, maxSize, "%d", arraySizes->sizes[i]);
|
snprintf(buf, maxSize, "%d", (*arraySizes)[i]);
|
||||||
mangledName += '[';
|
mangledName += '[';
|
||||||
mangledName += buf;
|
mangledName += buf;
|
||||||
mangledName += ']';
|
mangledName += ']';
|
||||||
|
@ -795,7 +795,7 @@ function_header
|
|||||||
GetStorageQualifierString($1.qualifier.storage), "");
|
GetStorageQualifierString($1.qualifier.storage), "");
|
||||||
}
|
}
|
||||||
if ($1.arraySizes)
|
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)
|
// Add the function as a prototype after parsing it (we do not support recursion)
|
||||||
TFunction *function;
|
TFunction *function;
|
||||||
@ -811,7 +811,7 @@ parameter_declarator
|
|||||||
if ($1.arraySizes) {
|
if ($1.arraySizes) {
|
||||||
parseContext.profileRequires($1.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
|
parseContext.profileRequires($1.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
|
||||||
parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "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) {
|
if ($1.basicType == EbtVoid) {
|
||||||
parseContext.error($2.loc, "illegal use of type 'void'", $2.string->c_str(), "");
|
parseContext.error($2.loc, "illegal use of type 'void'", $2.string->c_str(), "");
|
||||||
@ -826,11 +826,11 @@ parameter_declarator
|
|||||||
if ($1.arraySizes) {
|
if ($1.arraySizes) {
|
||||||
parseContext.profileRequires($1.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
|
parseContext.profileRequires($1.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
|
||||||
parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "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.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);
|
parseContext.reservedErrorCheck($2.loc, *$2.string);
|
||||||
|
|
||||||
$1.arraySizes = $3.arraySizes;
|
$1.arraySizes = $3.arraySizes;
|
||||||
@ -890,7 +890,7 @@ parameter_type_specifier
|
|||||||
TParameter param = { 0, new TType($1) };
|
TParameter param = { 0, new TType($1) };
|
||||||
$$.param = param;
|
$$.param = param;
|
||||||
if ($1.arraySizes)
|
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 {
|
: LEFT_BRACKET RIGHT_BRACKET {
|
||||||
$$.loc = $1.loc;
|
$$.loc = $1.loc;
|
||||||
$$.arraySizes = new TArraySizes;
|
$$.arraySizes = new TArraySizes;
|
||||||
$$.arraySizes->setSize(0);
|
$$.arraySizes->setOuterSize(0);
|
||||||
}
|
}
|
||||||
| LEFT_BRACKET constant_expression RIGHT_BRACKET {
|
| LEFT_BRACKET constant_expression RIGHT_BRACKET {
|
||||||
$$.loc = $1.loc;
|
$$.loc = $1.loc;
|
||||||
@ -1245,18 +1245,18 @@ array_specifier
|
|||||||
|
|
||||||
int size;
|
int size;
|
||||||
parseContext.arraySizeCheck($2->getLoc(), $2, size);
|
parseContext.arraySizeCheck($2->getLoc(), $2, size);
|
||||||
$$.arraySizes->setSize(size);
|
$$.arraySizes->setOuterSize(size);
|
||||||
}
|
}
|
||||||
| array_specifier LEFT_BRACKET RIGHT_BRACKET {
|
| array_specifier LEFT_BRACKET RIGHT_BRACKET {
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
$$.arraySizes->setSize(0);
|
$$.arraySizes->setOuterSize(0);
|
||||||
}
|
}
|
||||||
| array_specifier LEFT_BRACKET constant_expression RIGHT_BRACKET {
|
| array_specifier LEFT_BRACKET constant_expression RIGHT_BRACKET {
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
|
|
||||||
int size;
|
int size;
|
||||||
parseContext.arraySizeCheck($3->getLoc(), $3, 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, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
|
||||||
parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type");
|
parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type");
|
||||||
if (parseContext.profile == EEsProfile)
|
if (parseContext.profile == EEsProfile)
|
||||||
parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->getSize());
|
parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->getOuterSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
@ -1978,7 +1978,7 @@ struct_declaration
|
|||||||
parseContext.profileRequires($2.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
|
parseContext.profileRequires($2.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
|
||||||
parseContext.profileRequires($2.loc, EEsProfile, 300, 0, "arrayed type");
|
parseContext.profileRequires($2.loc, EEsProfile, 300, 0, "arrayed type");
|
||||||
if (parseContext.profile == EEsProfile)
|
if (parseContext.profile == EEsProfile)
|
||||||
parseContext.arraySizeRequiredCheck($2.loc, $2.arraySizes->getSize());
|
parseContext.arraySizeRequiredCheck($2.loc, $2.arraySizes->getOuterSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
$$ = $3;
|
$$ = $3;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user