mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-09 12:00:05 +00:00
Types: Fix #1290: Rationalize and correct "mixed" style array dimensioning.
There a couple functional problems, which when reduced down also led to some good simplifications and rationalization. So, this commit: - corrects "mixed" functionality: int[A] f[B] -> f[B][A] - correct multi-identifier decls: int[A] f[B], g[C] -> f and g are independently sized. - increases symmetry between different places in the code that do this - makes fewer ways to do the same thing; several methods are just gone now - makes more clear when something is copied or shared
This commit is contained in:
parent
1c3ab274b1
commit
859b0342b8
@ -2607,8 +2607,8 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
|
|||||||
// Use a dummy glslang type for querying internal strides of
|
// Use a dummy glslang type for querying internal strides of
|
||||||
// arrays of arrays, but using just a one-dimensional array.
|
// arrays of arrays, but using just a one-dimensional array.
|
||||||
glslang::TType simpleArrayType(type, 0); // deference type of the array
|
glslang::TType simpleArrayType(type, 0); // deference type of the array
|
||||||
while (simpleArrayType.getArraySizes().getNumDims() > 1)
|
while (simpleArrayType.getArraySizes()->getNumDims() > 1)
|
||||||
simpleArrayType.getArraySizes().dereference();
|
simpleArrayType.getArraySizes()->dereference();
|
||||||
|
|
||||||
// Will compute the higher-order strides here, rather than making a whole
|
// Will compute the higher-order strides here, rather than making a whole
|
||||||
// pile of types and doing repetitive recursion on their contents.
|
// pile of types and doing repetitive recursion on their contents.
|
||||||
|
@ -19,6 +19,7 @@ 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
|
||||||
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: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
|
||||||
ERROR: 0:39: 'arrays of arrays' : not supported with this profile: none
|
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: 'arrays of arrays' : not supported with this profile: none
|
||||||
@ -78,7 +79,7 @@ ERROR: 0:192: 'assign' : l-value required (can't modify a const)
|
|||||||
ERROR: 0:195: 'gl_ModelViewMatrix' : identifiers starting with "gl_" are reserved
|
ERROR: 0:195: 'gl_ModelViewMatrix' : identifiers starting with "gl_" are reserved
|
||||||
ERROR: 0:200: 'token pasting (##)' : not supported for this version or the enabled extensions
|
ERROR: 0:200: 'token pasting (##)' : not supported for this version or the enabled extensions
|
||||||
ERROR: 0:203: 'token pasting (##)' : not supported for this version or the enabled extensions
|
ERROR: 0:203: 'token pasting (##)' : not supported for this version or the enabled extensions
|
||||||
ERROR: 79 compilation errors. No code generated.
|
ERROR: 80 compilation errors. No code generated.
|
||||||
|
|
||||||
|
|
||||||
Shader version: 120
|
Shader version: 120
|
||||||
|
@ -26,6 +26,7 @@ ERROR: 0:101: 'arrays of arrays' : not supported for this version or the enabled
|
|||||||
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
|
||||||
|
ERROR: 0:103: 'arrays of arrays' : not supported for this version or the enabled extensions
|
||||||
ERROR: 0:100: 'arrays of arrays' : not supported for this version or the enabled extensions
|
ERROR: 0:100: 'arrays of arrays' : not supported for this version or the enabled extensions
|
||||||
ERROR: 0:100: 'array-of-array of block' : not supported with this profile: es
|
ERROR: 0:100: 'array-of-array of block' : not supported with this profile: es
|
||||||
ERROR: 0:111: 'variable indexing fragment shader output array' : not supported with this profile: es
|
ERROR: 0:111: 'variable indexing fragment shader output array' : not supported with this profile: es
|
||||||
@ -44,7 +45,7 @@ ERROR: 0:157: 'invariant' : can only apply to an output
|
|||||||
ERROR: 0:158: 'invariant' : can only apply to an output
|
ERROR: 0:158: 'invariant' : can only apply to an output
|
||||||
ERROR: 0:160: 'imageBuffer' : Reserved word.
|
ERROR: 0:160: 'imageBuffer' : Reserved word.
|
||||||
ERROR: 0:160: '' : syntax error, unexpected IMAGEBUFFER, expecting COMMA or SEMICOLON
|
ERROR: 0:160: '' : syntax error, unexpected IMAGEBUFFER, expecting COMMA or SEMICOLON
|
||||||
ERROR: 45 compilation errors. No code generated.
|
ERROR: 46 compilation errors. No code generated.
|
||||||
|
|
||||||
|
|
||||||
Shader version: 300
|
Shader version: 300
|
||||||
@ -392,7 +393,7 @@ ERROR: node is still EOpNull!
|
|||||||
0:? 'sc' ( out lowp 3-component vector of float)
|
0:? 'sc' ( out lowp 3-component vector of float)
|
||||||
0:? 'sf' ( out lowp float)
|
0:? 'sf' ( out lowp float)
|
||||||
0:? 'arrayedSampler' ( uniform 5-element array of lowp sampler2D)
|
0:? 'arrayedSampler' ( uniform 5-element array of lowp sampler2D)
|
||||||
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:? 'multiInst' (layout( column_major shared) uniform 2-element array of 3-element array of block{layout( column_major shared) uniform 3-element array of 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:? '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:? 'st1' ( uniform structure{ global mediump int i, global lowp sampler2D s})
|
||||||
0:? 'st2' ( uniform structure{ global mediump int i, global lowp sampler2D s})
|
0:? 'st2' ( uniform structure{ global mediump int i, global lowp sampler2D s})
|
||||||
@ -623,7 +624,7 @@ ERROR: node is still EOpNull!
|
|||||||
0:? 'sc' ( out lowp 3-component vector of float)
|
0:? 'sc' ( out lowp 3-component vector of float)
|
||||||
0:? 'sf' ( out lowp float)
|
0:? 'sf' ( out lowp float)
|
||||||
0:? 'arrayedSampler' ( uniform 5-element array of lowp sampler2D)
|
0:? 'arrayedSampler' ( uniform 5-element array of lowp sampler2D)
|
||||||
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:? 'multiInst' (layout( column_major shared) uniform 2-element array of 3-element array of block{layout( column_major shared) uniform 3-element array of 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:? '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:? 'st1' ( uniform structure{ global mediump int i, global lowp sampler2D s})
|
||||||
0:? 'st2' ( uniform structure{ global mediump int i, global lowp sampler2D s})
|
0:? 'st2' ( uniform structure{ global mediump int i, global lowp sampler2D s})
|
||||||
|
68
Test/baseResults/mixedArrayDecls.frag.out
Executable file
68
Test/baseResults/mixedArrayDecls.frag.out
Executable file
@ -0,0 +1,68 @@
|
|||||||
|
mixedArrayDecls.frag
|
||||||
|
ERROR: 0:30: '' : syntax error, unexpected LEFT_PAREN, expecting COMMA or SEMICOLON
|
||||||
|
ERROR: 1 compilation errors. No code generated.
|
||||||
|
|
||||||
|
|
||||||
|
Shader version: 450
|
||||||
|
ERROR: node is still EOpNull!
|
||||||
|
0:16 Function Definition: foo(i1[14][15][6]; ( global 14-element array of 15-element array of 6-element array of int)
|
||||||
|
0:16 Function Parameters:
|
||||||
|
0:16 'p' ( in 14-element array of 15-element array of 6-element array of int)
|
||||||
|
0:16 Sequence
|
||||||
|
0:16 Branch: Return with expression
|
||||||
|
0:16 'p' ( in 14-element array of 15-element array of 6-element array of int)
|
||||||
|
0:18 Function Definition: main( ( global void)
|
||||||
|
0:18 Function Parameters:
|
||||||
|
0:20 Sequence
|
||||||
|
0:20 direct index ( temp 14-element array of int)
|
||||||
|
0:20 'g' ( global unsized 4-element array of 14-element array of int)
|
||||||
|
0:20 Constant:
|
||||||
|
0:20 3 (const int)
|
||||||
|
0:21 direct index ( temp 14-element array of int)
|
||||||
|
0:21 'h' ( global unsized 3-element array of 14-element array of int)
|
||||||
|
0:21 Constant:
|
||||||
|
0:21 2 (const int)
|
||||||
|
0:24 Function Definition: bar( ( global 4-element array of 3-element array of 2-element array of float)
|
||||||
|
0:24 Function Parameters:
|
||||||
|
0:? Sequence
|
||||||
|
0:24 Branch: Return with expression
|
||||||
|
0:24 'a' ( temp 4-element array of 3-element array of 2-element array of float)
|
||||||
|
0:? Linker Objects
|
||||||
|
0:? 's' ( global structure{ global 2-element array of 3-element array of int a, global 5-element array of 3-element array of int b})
|
||||||
|
0:? 'c' ( global 4-element array of 5-element array of int)
|
||||||
|
0:? 'd' ( global 8-element array of 5-element array of int)
|
||||||
|
0:? 'e' ( global 11-element array of 9-element array of int)
|
||||||
|
0:? 'f' ( global 13-element array of 9-element array of int)
|
||||||
|
0:? 'g' ( global unsized 4-element array of 14-element array of int)
|
||||||
|
0:? 'h' ( global unsized 3-element array of 14-element array of int)
|
||||||
|
0:? 'inbinst' ( in 4-element array of 5-element array of 6-element array of block{ in 8-element array of 9-element array of 7-element array of float f})
|
||||||
|
0:? 'barm' ( global 4-element array of 3-element array of 2-element array of float)
|
||||||
|
|
||||||
|
|
||||||
|
Linked fragment stage:
|
||||||
|
|
||||||
|
|
||||||
|
Shader version: 450
|
||||||
|
ERROR: node is still EOpNull!
|
||||||
|
0:18 Function Definition: main( ( global void)
|
||||||
|
0:18 Function Parameters:
|
||||||
|
0:20 Sequence
|
||||||
|
0:20 direct index ( temp 14-element array of int)
|
||||||
|
0:20 'g' ( global 4-element array of 14-element array of int)
|
||||||
|
0:20 Constant:
|
||||||
|
0:20 3 (const int)
|
||||||
|
0:21 direct index ( temp 14-element array of int)
|
||||||
|
0:21 'h' ( global 3-element array of 14-element array of int)
|
||||||
|
0:21 Constant:
|
||||||
|
0:21 2 (const int)
|
||||||
|
0:? Linker Objects
|
||||||
|
0:? 's' ( global structure{ global 2-element array of 3-element array of int a, global 5-element array of 3-element array of int b})
|
||||||
|
0:? 'c' ( global 4-element array of 5-element array of int)
|
||||||
|
0:? 'd' ( global 8-element array of 5-element array of int)
|
||||||
|
0:? 'e' ( global 11-element array of 9-element array of int)
|
||||||
|
0:? 'f' ( global 13-element array of 9-element array of int)
|
||||||
|
0:? 'g' ( global 4-element array of 14-element array of int)
|
||||||
|
0:? 'h' ( global 3-element array of 14-element array of int)
|
||||||
|
0:? 'inbinst' ( in 4-element array of 5-element array of 6-element array of block{ in 8-element array of 9-element array of 7-element array of float f})
|
||||||
|
0:? 'barm' ( global 4-element array of 3-element array of 2-element array of float)
|
||||||
|
|
30
Test/mixedArrayDecls.frag
Normal file
30
Test/mixedArrayDecls.frag
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#version 450
|
||||||
|
|
||||||
|
struct S {
|
||||||
|
int[3] a[2], b[5];
|
||||||
|
};
|
||||||
|
|
||||||
|
S s;
|
||||||
|
|
||||||
|
int[5] c[4], d[8];
|
||||||
|
int[9] e[], f[];
|
||||||
|
int e[11][9];
|
||||||
|
int f[13][9];
|
||||||
|
|
||||||
|
int[14] g[], h[];
|
||||||
|
|
||||||
|
int [14][15][6] foo(int[6] p[14][15]) { return p; }
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
g[3];
|
||||||
|
h[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
float[4][3][2] bar() { float[3][2] a[4]; return a; }
|
||||||
|
|
||||||
|
in inbname {
|
||||||
|
float[7] f[8][9];
|
||||||
|
} inbinst[4][5][6];
|
||||||
|
|
||||||
|
float[3][2] barm[4]() { float[3][2] a[4]; return a; } // ERROR
|
@ -1315,31 +1315,9 @@ public:
|
|||||||
|
|
||||||
void makeVector() { vector1 = true; }
|
void makeVector() { vector1 = true; }
|
||||||
|
|
||||||
// Merge type from parent, where a parentType is at the beginning of a declaration,
|
|
||||||
// establishing some characteristics for all subsequent names, while this type
|
|
||||||
// is on the individual names.
|
|
||||||
void mergeType(const TPublicType& parentType)
|
|
||||||
{
|
|
||||||
// arrayness is currently the only child aspect that has to be preserved
|
|
||||||
basicType = parentType.basicType;
|
|
||||||
vectorSize = parentType.vectorSize;
|
|
||||||
matrixCols = parentType.matrixCols;
|
|
||||||
matrixRows = parentType.matrixRows;
|
|
||||||
vector1 = false; // TPublicType is only GLSL which so far has no vec1
|
|
||||||
qualifier = parentType.qualifier;
|
|
||||||
sampler = parentType.sampler;
|
|
||||||
if (parentType.arraySizes)
|
|
||||||
newArraySizes(*parentType.arraySizes);
|
|
||||||
if (parentType.userDef) {
|
|
||||||
structure = parentType.userDef->getWritableStruct();
|
|
||||||
setTypeName(parentType.userDef->getTypeName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void hideMember() { basicType = EbtVoid; vectorSize = 1; }
|
virtual void hideMember() { basicType = EbtVoid; vectorSize = 1; }
|
||||||
virtual bool hiddenMember() const { return basicType == EbtVoid; }
|
virtual bool hiddenMember() const { return basicType == EbtVoid; }
|
||||||
|
|
||||||
virtual void setTypeName(const TString& n) { typeName = NewPoolTString(n.c_str()); }
|
|
||||||
virtual void setFieldName(const TString& n) { fieldName = NewPoolTString(n.c_str()); }
|
virtual void setFieldName(const TString& n) { fieldName = NewPoolTString(n.c_str()); }
|
||||||
virtual const TString& getTypeName() const
|
virtual const TString& getTypeName() const
|
||||||
{
|
{
|
||||||
@ -1369,7 +1347,7 @@ public:
|
|||||||
virtual bool isArrayOfArrays() const { return arraySizes != nullptr && arraySizes->getNumDims() > 1; }
|
virtual bool isArrayOfArrays() const { return arraySizes != nullptr && arraySizes->getNumDims() > 1; }
|
||||||
virtual int getImplicitArraySize() const { return arraySizes->getImplicitSize(); }
|
virtual int getImplicitArraySize() const { return arraySizes->getImplicitSize(); }
|
||||||
virtual const TArraySizes* getArraySizes() const { return arraySizes; }
|
virtual const TArraySizes* getArraySizes() const { return arraySizes; }
|
||||||
virtual TArraySizes& getArraySizes() { assert(arraySizes != nullptr); return *arraySizes; }
|
virtual TArraySizes* getArraySizes() { return arraySizes; }
|
||||||
|
|
||||||
virtual bool isScalar() const { return ! isVector() && ! isMatrix() && ! isStruct() && ! isArray(); }
|
virtual bool isScalar() const { return ! isVector() && ! isMatrix() && ! isStruct() && ! isArray(); }
|
||||||
virtual bool isScalarOrVec1() const { return isScalar() || vector1; }
|
virtual bool isScalarOrVec1() const { return isScalar() || vector1; }
|
||||||
@ -1503,22 +1481,33 @@ public:
|
|||||||
assert(type.arraySizes != nullptr);
|
assert(type.arraySizes != nullptr);
|
||||||
*arraySizes = *type.arraySizes;
|
*arraySizes = *type.arraySizes;
|
||||||
}
|
}
|
||||||
void newArraySizes(const TArraySizes& s)
|
void copyArraySizes(const 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;
|
||||||
*arraySizes = s;
|
*arraySizes = s;
|
||||||
}
|
}
|
||||||
|
void transferArraySizes(TArraySizes* s)
|
||||||
|
{
|
||||||
|
// For setting an already allocated set of sizes that this type can use
|
||||||
|
// (no copy made).
|
||||||
|
arraySizes = s;
|
||||||
|
}
|
||||||
void clearArraySizes()
|
void clearArraySizes()
|
||||||
{
|
{
|
||||||
arraySizes = 0;
|
arraySizes = nullptr;
|
||||||
}
|
}
|
||||||
void addArrayOuterSizes(const TArraySizes& s)
|
|
||||||
|
// Add inner array sizes, to any existing sizes, via copy; the
|
||||||
|
// sizes passed in can still be reused for other purposes.
|
||||||
|
void copyArrayInnerSizes(const TArraySizes* s)
|
||||||
{
|
{
|
||||||
if (arraySizes == nullptr)
|
if (s != nullptr) {
|
||||||
newArraySizes(s);
|
if (arraySizes == nullptr)
|
||||||
else
|
copyArraySizes(*s);
|
||||||
arraySizes->addOuterSizes(s);
|
else
|
||||||
|
arraySizes->addInnerSizes(*s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void changeOuterArraySize(int s) { arraySizes->changeOuterSize(s); }
|
void changeOuterArraySize(int s) { arraySizes->changeOuterSize(s); }
|
||||||
void setImplicitArraySize(int s) { arraySizes->setImplicitSize(s); }
|
void setImplicitArraySize(int s) { arraySizes->setImplicitSize(s); }
|
||||||
|
@ -130,10 +130,10 @@ struct TSmallArrayVector {
|
|||||||
sizes->push_back(pair);
|
sizes->push_back(pair);
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_front(const TSmallArrayVector& newDims)
|
void push_back(const TSmallArrayVector& newDims)
|
||||||
{
|
{
|
||||||
alloc();
|
alloc();
|
||||||
sizes->insert(sizes->begin(), newDims.sizes->begin(), newDims.sizes->end());
|
sizes->insert(sizes->end(), newDims.sizes->begin(), newDims.sizes->end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void pop_front()
|
void pop_front()
|
||||||
@ -252,6 +252,7 @@ struct TArraySizes {
|
|||||||
void addInnerSize(int s) { addInnerSize((unsigned)s, nullptr); }
|
void addInnerSize(int s) { addInnerSize((unsigned)s, nullptr); }
|
||||||
void addInnerSize(int s, TIntermTyped* n) { sizes.push_back((unsigned)s, n); }
|
void addInnerSize(int s, TIntermTyped* n) { sizes.push_back((unsigned)s, n); }
|
||||||
void addInnerSize(TArraySize pair) { sizes.push_back(pair.size, pair.node); }
|
void addInnerSize(TArraySize pair) { sizes.push_back(pair.size, pair.node); }
|
||||||
|
void addInnerSizes(const TArraySizes& s) { sizes.push_back(s.sizes); }
|
||||||
void changeOuterSize(int s) { sizes.changeFront((unsigned)s); }
|
void changeOuterSize(int s) { sizes.changeFront((unsigned)s); }
|
||||||
int getImplicitSize() const { return (int)implicitArraySize; }
|
int getImplicitSize() const { return (int)implicitArraySize; }
|
||||||
void setImplicitSize(int s) { implicitArraySize = s; }
|
void setImplicitSize(int s) { implicitArraySize = s; }
|
||||||
@ -288,7 +289,6 @@ struct TArraySizes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isImplicit() const { return getOuterSize() == UnsizedArraySize || isInnerImplicit(); }
|
bool isImplicit() const { return getOuterSize() == UnsizedArraySize || isInnerImplicit(); }
|
||||||
void addOuterSizes(const TArraySizes& s) { sizes.push_front(s.sizes); }
|
|
||||||
void dereference() { sizes.pop_front(); }
|
void dereference() { sizes.pop_front(); }
|
||||||
void copyDereferenced(const TArraySizes& rhs)
|
void copyDereferenced(const TArraySizes& rhs)
|
||||||
{
|
{
|
||||||
|
@ -7981,9 +7981,9 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
|||||||
if (version == 100 || IncludeLegacy(version, profile, spvVersion) || (! ForwardCompatibility && profile != EEsProfile && version < 420)) {
|
if (version == 100 || IncludeLegacy(version, profile, spvVersion) || (! ForwardCompatibility && profile != EEsProfile && version < 420)) {
|
||||||
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.addInnerSize(resources.maxDrawBuffers);
|
arraySizes->addInnerSize(resources.maxDrawBuffers);
|
||||||
fragData.newArraySizes(arraySizes);
|
fragData.transferArraySizes(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);
|
||||||
}
|
}
|
||||||
|
@ -2393,10 +2393,11 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
|
|||||||
// Types have to match, but we're still making the type.
|
// Types have to match, but we're still making the type.
|
||||||
// Finish making the type, and the comparison is done later
|
// Finish making the type, and the comparison is done later
|
||||||
// when checking for conversion.
|
// when checking for conversion.
|
||||||
TArraySizes& arraySizes = type.getArraySizes();
|
TArraySizes& arraySizes = *type.getArraySizes();
|
||||||
|
|
||||||
// At least the dimensionalities have to match.
|
// At least the dimensionalities have to match.
|
||||||
if (! function[0].type->isArray() || arraySizes.getNumDims() != function[0].type->getArraySizes().getNumDims() + 1) {
|
if (! function[0].type->isArray() ||
|
||||||
|
arraySizes.getNumDims() != function[0].type->getArraySizes()->getNumDims() + 1) {
|
||||||
error(loc, "array constructor argument not correct type to construct array element", "constructor", "");
|
error(loc, "array constructor argument not correct type to construct array element", "constructor", "");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2406,7 +2407,7 @@ bool TParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node, T
|
|||||||
// That means we need to adopt (from the first argument) the other array sizes into the type.
|
// That means we need to adopt (from the first argument) the other array sizes into the type.
|
||||||
for (int d = 1; d < arraySizes.getNumDims(); ++d) {
|
for (int d = 1; d < arraySizes.getNumDims(); ++d) {
|
||||||
if (arraySizes.getDimSize(d) == UnsizedArraySize) {
|
if (arraySizes.getDimSize(d) == UnsizedArraySize) {
|
||||||
arraySizes.setDimSize(d, function[0].type->getArraySizes().getDimSize(d - 1));
|
arraySizes.setDimSize(d, function[0].type->getArraySizes()->getDimSize(d - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3155,8 +3156,11 @@ void TParseContext::arraySizesCheck(const TSourceLoc& loc, const TQualifier& qua
|
|||||||
arraySizeRequiredCheck(loc, *arraySizes);
|
arraySizeRequiredCheck(loc, *arraySizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TParseContext::arrayOfArrayVersionCheck(const TSourceLoc& loc)
|
void TParseContext::arrayOfArrayVersionCheck(const TSourceLoc& loc, const TArraySizes* sizes)
|
||||||
{
|
{
|
||||||
|
if (sizes == nullptr || sizes->getNumDims() == 1)
|
||||||
|
return;
|
||||||
|
|
||||||
const char* feature = "arrays of arrays";
|
const char* feature = "arrays of arrays";
|
||||||
|
|
||||||
requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, feature);
|
requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, feature);
|
||||||
@ -3164,36 +3168,6 @@ void TParseContext::arrayOfArrayVersionCheck(const TSourceLoc& loc)
|
|||||||
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 430, nullptr, feature);
|
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 430, nullptr, feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TParseContext::arrayDimCheck(const TSourceLoc& loc, const TArraySizes* sizes1, const TArraySizes* sizes2)
|
|
||||||
{
|
|
||||||
if ((sizes1 && sizes2) ||
|
|
||||||
(sizes1 && sizes1->getNumDims() > 1) ||
|
|
||||||
(sizes2 && sizes2->getNumDims() > 1))
|
|
||||||
arrayOfArrayVersionCheck(loc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TParseContext::arrayDimCheck(const TSourceLoc& loc, const TType* type, const TArraySizes* sizes2)
|
|
||||||
{
|
|
||||||
// skip checking for multiple dimensions on the type; it was caught earlier
|
|
||||||
if ((type && type->isArray() && sizes2) ||
|
|
||||||
(sizes2 && sizes2->getNumDims() > 1))
|
|
||||||
arrayOfArrayVersionCheck(loc);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Merge array dimensions listed in 'sizes' onto the type's array dimensions.
|
|
||||||
//
|
|
||||||
// From the spec: "vec4[2] a[3]; // size-3 array of size-2 array of vec4"
|
|
||||||
//
|
|
||||||
// That means, the 'sizes' go in front of the 'type' as outermost sizes.
|
|
||||||
// 'type' is the type part of the declaration (to the left)
|
|
||||||
// 'sizes' is the arrayness tagged on the identifier (to the right)
|
|
||||||
//
|
|
||||||
void TParseContext::arrayDimMerge(TType& type, const TArraySizes* sizes)
|
|
||||||
{
|
|
||||||
if (sizes != nullptr)
|
|
||||||
type.addArrayOuterSizes(*sizes);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Do all the semantic checking for declaring or redeclaring an array, with and
|
// Do all the semantic checking for declaring or redeclaring an array, with and
|
||||||
// without a size, and make the right changes to the symbol table.
|
// without a size, and make the right changes to the symbol table.
|
||||||
@ -3680,7 +3654,7 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT
|
|||||||
else if (type.isArray()) {
|
else if (type.isArray()) {
|
||||||
if (type.isExplicitlySizedArray() && arraySizes->getOuterSize() == UnsizedArraySize)
|
if (type.isExplicitlySizedArray() && arraySizes->getOuterSize() == UnsizedArraySize)
|
||||||
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.getArraySizes() != *arraySizes)
|
else if (type.isExplicitlySizedArray() && *type.getArraySizes() != *arraySizes)
|
||||||
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->getOuterSize() != UnsizedArraySize)
|
else if (type.isImplicitlySizedArray() && arraySizes->getOuterSize() != UnsizedArraySize)
|
||||||
type.changeOuterArraySize(arraySizes->getOuterSize());
|
type.changeOuterArraySize(arraySizes->getOuterSize());
|
||||||
@ -4621,7 +4595,8 @@ void TParseContext::layoutObjectCheck(const TSourceLoc& loc, const TSymbol& symb
|
|||||||
// they are not allowed on block members. For arrayed interfaces (those generally having an
|
// they are not allowed on block members. For arrayed interfaces (those generally having an
|
||||||
// extra level of arrayness due to interface expansion), the outer array is stripped before
|
// extra level of arrayness due to interface expansion), the outer array is stripped before
|
||||||
// applying this rule."
|
// applying this rule."
|
||||||
void TParseContext::layoutMemberLocationArrayCheck(const TSourceLoc& loc, bool memberWithLocation, TArraySizes* arraySizes)
|
void TParseContext::layoutMemberLocationArrayCheck(const TSourceLoc& loc, bool memberWithLocation,
|
||||||
|
TArraySizes* arraySizes)
|
||||||
{
|
{
|
||||||
if (memberWithLocation && arraySizes != nullptr) {
|
if (memberWithLocation && arraySizes != nullptr) {
|
||||||
if (arraySizes->getNumDims() > (currentBlockQualifier.isArrayedIo(language) ? 1 : 0))
|
if (arraySizes->getNumDims() > (currentBlockQualifier.isArrayedIo(language) ? 1 : 0))
|
||||||
@ -5325,15 +5300,15 @@ void TParseContext::declareTypeDefaults(const TSourceLoc& loc, const TPublicType
|
|||||||
// 'publicType' is the type part of the declaration (to the left)
|
// 'publicType' is the type part of the declaration (to the left)
|
||||||
// 'arraySizes' is the arrayness tagged on the identifier (to the right)
|
// 'arraySizes' is the arrayness tagged on the identifier (to the right)
|
||||||
//
|
//
|
||||||
TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& identifier, const TPublicType& publicType, TArraySizes* arraySizes, TIntermTyped* initializer)
|
TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& identifier, const TPublicType& publicType,
|
||||||
|
TArraySizes* arraySizes, TIntermTyped* initializer)
|
||||||
{
|
{
|
||||||
TType type(publicType); // shallow copy; 'type' shares the arrayness and structure definition with 'publicType'
|
// Make a fresh type that combines the characteristics from the individual
|
||||||
if (type.isImplicitlySizedArray()) {
|
// identifier syntax and the declaration-type syntax.
|
||||||
// Because "int[] a = int[2](...), b = int[3](...)" makes two arrays a and b
|
TType type(publicType);
|
||||||
// of different sizes, for this case sharing the shallow copy of arrayness
|
type.transferArraySizes(arraySizes);
|
||||||
// with the publicType oversubscribes it, so get a deep copy of the arrayness.
|
type.copyArrayInnerSizes(publicType.arraySizes);
|
||||||
type.newArraySizes(*publicType.arraySizes);
|
arrayOfArrayVersionCheck(loc, type.getArraySizes());
|
||||||
}
|
|
||||||
|
|
||||||
if (voidErrorCheck(loc, identifier, type.getBasicType()))
|
if (voidErrorCheck(loc, identifier, type.getBasicType()))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -5360,15 +5335,9 @@ TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& iden
|
|||||||
inheritGlobalDefaults(type.getQualifier());
|
inheritGlobalDefaults(type.getQualifier());
|
||||||
|
|
||||||
// Declare the variable
|
// Declare the variable
|
||||||
if (arraySizes || type.isArray()) {
|
if (type.isArray()) {
|
||||||
// Arrayness is potentially coming both from the type and from the
|
|
||||||
// variable: "int[] a[];" or just one or the other.
|
|
||||||
// Merge it all to the type, so all arrayness is part of the type.
|
|
||||||
arrayDimCheck(loc, &type, arraySizes);
|
|
||||||
arrayDimMerge(type, arraySizes);
|
|
||||||
|
|
||||||
// Check that implicit sizing is only where allowed.
|
// Check that implicit sizing is only where allowed.
|
||||||
arraySizesCheck(loc, type.getQualifier(), &type.getArraySizes(), initializer != nullptr, false);
|
arraySizesCheck(loc, type.getQualifier(), type.getArraySizes(), initializer != nullptr, false);
|
||||||
|
|
||||||
if (! arrayQualifierError(loc, type.getQualifier()) && ! arrayError(loc, type))
|
if (! arrayQualifierError(loc, type.getQualifier()) && ! arrayError(loc, type))
|
||||||
declareArray(loc, identifier, type, symbol);
|
declareArray(loc, identifier, type, symbol);
|
||||||
@ -5509,8 +5478,10 @@ TIntermNode* TParseContext::executeInitializer(const TSourceLoc& loc, TIntermTyp
|
|||||||
variable->getType().getArraySizes()->getNumDims()) {
|
variable->getType().getArraySizes()->getNumDims()) {
|
||||||
// adopt unsized sizes from the initializer's sizes
|
// adopt unsized sizes from the initializer's sizes
|
||||||
for (int d = 1; d < variable->getType().getArraySizes()->getNumDims(); ++d) {
|
for (int d = 1; d < variable->getType().getArraySizes()->getNumDims(); ++d) {
|
||||||
if (variable->getType().getArraySizes()->getDimSize(d) == UnsizedArraySize)
|
if (variable->getType().getArraySizes()->getDimSize(d) == UnsizedArraySize) {
|
||||||
variable->getWritableType().getArraySizes().setDimSize(d, initializer->getType().getArraySizes()->getDimSize(d));
|
variable->getWritableType().getArraySizes()->setDimSize(d,
|
||||||
|
initializer->getType().getArraySizes()->getDimSize(d));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5621,16 +5592,16 @@ TIntermTyped* TParseContext::convertInitializerList(const TSourceLoc& loc, const
|
|||||||
// Later on, initializer execution code will deal with array size logic.
|
// Later on, initializer execution code will deal with array size logic.
|
||||||
TType arrayType;
|
TType arrayType;
|
||||||
arrayType.shallowCopy(type); // sharing struct stuff is fine
|
arrayType.shallowCopy(type); // sharing struct stuff is fine
|
||||||
arrayType.newArraySizes(*type.getArraySizes()); // but get a fresh copy of the array information, to edit below
|
arrayType.copyArraySizes(*type.getArraySizes()); // but get a fresh copy of the array information, to edit below
|
||||||
|
|
||||||
// edit array sizes to fill in unsized dimensions
|
// edit array sizes to fill in unsized dimensions
|
||||||
arrayType.changeOuterArraySize((int)initList->getSequence().size());
|
arrayType.changeOuterArraySize((int)initList->getSequence().size());
|
||||||
TIntermTyped* firstInit = initList->getSequence()[0]->getAsTyped();
|
TIntermTyped* firstInit = initList->getSequence()[0]->getAsTyped();
|
||||||
if (arrayType.isArrayOfArrays() && firstInit->getType().isArray() &&
|
if (arrayType.isArrayOfArrays() && firstInit->getType().isArray() &&
|
||||||
arrayType.getArraySizes().getNumDims() == firstInit->getType().getArraySizes()->getNumDims() + 1) {
|
arrayType.getArraySizes()->getNumDims() == firstInit->getType().getArraySizes()->getNumDims() + 1) {
|
||||||
for (int d = 1; d < arrayType.getArraySizes().getNumDims(); ++d) {
|
for (int d = 1; d < arrayType.getArraySizes()->getNumDims(); ++d) {
|
||||||
if (arrayType.getArraySizes().getDimSize(d) == UnsizedArraySize)
|
if (arrayType.getArraySizes()->getDimSize(d) == UnsizedArraySize)
|
||||||
arrayType.getArraySizes().setDimSize(d, firstInit->getType().getArraySizes()->getDimSize(d - 1));
|
arrayType.getArraySizes()->setDimSize(d, firstInit->getType().getArraySizes()->getDimSize(d - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5944,13 +5915,14 @@ TIntermTyped* TParseContext::constructAggregate(TIntermNode* node, const TType&
|
|||||||
//
|
//
|
||||||
// Do everything needed to add an interface block.
|
// Do everything needed to add an interface block.
|
||||||
//
|
//
|
||||||
void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, const TString* instanceName, TArraySizes* arraySizes)
|
void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, const TString* instanceName,
|
||||||
|
TArraySizes* arraySizes)
|
||||||
{
|
{
|
||||||
blockStageIoCheck(loc, currentBlockQualifier);
|
blockStageIoCheck(loc, currentBlockQualifier);
|
||||||
blockQualifierCheck(loc, currentBlockQualifier, instanceName != nullptr);
|
blockQualifierCheck(loc, currentBlockQualifier, instanceName != nullptr);
|
||||||
if (arraySizes) {
|
if (arraySizes != nullptr) {
|
||||||
arraySizesCheck(loc, currentBlockQualifier, arraySizes, false, false);
|
arraySizesCheck(loc, currentBlockQualifier, arraySizes, false, false);
|
||||||
arrayDimCheck(loc, arraySizes, 0);
|
arrayOfArrayVersionCheck(loc, arraySizes);
|
||||||
if (arraySizes->getNumDims() > 1)
|
if (arraySizes->getNumDims() > 1)
|
||||||
requireProfile(loc, ~EEsProfile, "array-of-array of block");
|
requireProfile(loc, ~EEsProfile, "array-of-array of block");
|
||||||
}
|
}
|
||||||
@ -5967,7 +5939,7 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
|
|||||||
if ((currentBlockQualifier.storage == EvqUniform || currentBlockQualifier.storage == EvqBuffer) && (memberQualifier.isInterpolation() || memberQualifier.isAuxiliary()))
|
if ((currentBlockQualifier.storage == EvqUniform || currentBlockQualifier.storage == EvqBuffer) && (memberQualifier.isInterpolation() || memberQualifier.isAuxiliary()))
|
||||||
error(memberLoc, "member of uniform or buffer block cannot have an auxiliary or interpolation qualifier", memberType.getFieldName().c_str(), "");
|
error(memberLoc, "member of uniform or buffer block cannot have an auxiliary or interpolation qualifier", memberType.getFieldName().c_str(), "");
|
||||||
if (memberType.isArray())
|
if (memberType.isArray())
|
||||||
arraySizesCheck(memberLoc, currentBlockQualifier, &memberType.getArraySizes(), false, member == typeList.size() - 1);
|
arraySizesCheck(memberLoc, currentBlockQualifier, memberType.getArraySizes(), false, member == typeList.size() - 1);
|
||||||
if (memberQualifier.hasOffset()) {
|
if (memberQualifier.hasOffset()) {
|
||||||
if (spvVersion.spv == 0) {
|
if (spvVersion.spv == 0) {
|
||||||
requireProfile(memberLoc, ~EEsProfile, "offset on block member");
|
requireProfile(memberLoc, ~EEsProfile, "offset on block member");
|
||||||
@ -6089,8 +6061,8 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
|
|||||||
//
|
//
|
||||||
|
|
||||||
TType blockType(&typeList, *blockName, currentBlockQualifier);
|
TType blockType(&typeList, *blockName, currentBlockQualifier);
|
||||||
if (arraySizes)
|
if (arraySizes != nullptr)
|
||||||
blockType.newArraySizes(*arraySizes);
|
blockType.transferArraySizes(arraySizes);
|
||||||
else
|
else
|
||||||
ioArrayCheck(loc, blockType, instanceName ? *instanceName : *blockName);
|
ioArrayCheck(loc, blockType, instanceName ? *instanceName : *blockName);
|
||||||
|
|
||||||
|
@ -341,10 +341,7 @@ public:
|
|||||||
void arraySizeRequiredCheck(const TSourceLoc&, const TArraySizes&);
|
void arraySizeRequiredCheck(const TSourceLoc&, const TArraySizes&);
|
||||||
void structArrayCheck(const TSourceLoc&, const TType& structure);
|
void structArrayCheck(const TSourceLoc&, const TType& structure);
|
||||||
void arraySizesCheck(const TSourceLoc&, const TQualifier&, TArraySizes*, bool initializer, bool lastMember);
|
void arraySizesCheck(const TSourceLoc&, const TQualifier&, TArraySizes*, bool initializer, bool lastMember);
|
||||||
void arrayOfArrayVersionCheck(const TSourceLoc&);
|
void arrayOfArrayVersionCheck(const TSourceLoc&, const TArraySizes*);
|
||||||
void arrayDimCheck(const TSourceLoc&, const TArraySizes* sizes1, const TArraySizes* sizes2);
|
|
||||||
void arrayDimCheck(const TSourceLoc&, const TType*, const TArraySizes*);
|
|
||||||
void arrayDimMerge(TType& type, const TArraySizes* sizes);
|
|
||||||
bool voidErrorCheck(const TSourceLoc&, const TString&, TBasicType);
|
bool voidErrorCheck(const TSourceLoc&, const TString&, TBasicType);
|
||||||
void boolCheck(const TSourceLoc&, const TIntermTyped*);
|
void boolCheck(const TSourceLoc&, const TIntermTyped*);
|
||||||
void boolCheck(const TSourceLoc&, const TPublicType&);
|
void boolCheck(const TSourceLoc&, const TPublicType&);
|
||||||
|
@ -934,13 +934,15 @@ parameter_declarator
|
|||||||
parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type");
|
parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type");
|
||||||
parseContext.arraySizeRequiredCheck($1.loc, *$1.arraySizes);
|
parseContext.arraySizeRequiredCheck($1.loc, *$1.arraySizes);
|
||||||
}
|
}
|
||||||
parseContext.arrayDimCheck($2.loc, $1.arraySizes, $3.arraySizes);
|
TType* type = new TType($1);
|
||||||
|
type->transferArraySizes($3.arraySizes);
|
||||||
|
type->copyArrayInnerSizes($1.arraySizes);
|
||||||
|
|
||||||
|
parseContext.arrayOfArrayVersionCheck($2.loc, type->getArraySizes());
|
||||||
parseContext.arraySizeRequiredCheck($3.loc, *$3.arraySizes);
|
parseContext.arraySizeRequiredCheck($3.loc, *$3.arraySizes);
|
||||||
parseContext.reservedErrorCheck($2.loc, *$2.string);
|
parseContext.reservedErrorCheck($2.loc, *$2.string);
|
||||||
|
|
||||||
TParameter param = { $2.string, new TType($1)};
|
TParameter param = { $2.string, type };
|
||||||
parseContext.arrayDimMerge(*param.type, $3.arraySizes);
|
|
||||||
|
|
||||||
$$.loc = $2.loc;
|
$$.loc = $2.loc;
|
||||||
$$.param = param;
|
$$.param = param;
|
||||||
@ -1075,7 +1077,7 @@ fully_specified_type
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($2.arraySizes && parseContext.arrayQualifierError($2.loc, $1.qualifier))
|
if ($2.arraySizes && parseContext.arrayQualifierError($2.loc, $1.qualifier))
|
||||||
$2.arraySizes = 0;
|
$2.arraySizes = nullptr;
|
||||||
|
|
||||||
parseContext.checkNoShaderLayouts($2.loc, $1.shaderQualifiers);
|
parseContext.checkNoShaderLayouts($2.loc, $1.shaderQualifiers);
|
||||||
$2.shaderQualifiers.merge($1.shaderQualifiers);
|
$2.shaderQualifiers.merge($1.shaderQualifiers);
|
||||||
@ -1352,7 +1354,7 @@ type_specifier
|
|||||||
$$.qualifier.precision = parseContext.getDefaultPrecision($$);
|
$$.qualifier.precision = parseContext.getDefaultPrecision($$);
|
||||||
}
|
}
|
||||||
| type_specifier_nonarray array_specifier {
|
| type_specifier_nonarray array_specifier {
|
||||||
parseContext.arrayDimCheck($2.loc, $2.arraySizes, 0);
|
parseContext.arrayOfArrayVersionCheck($2.loc, $2.arraySizes);
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
$$.qualifier.precision = parseContext.getDefaultPrecision($$);
|
$$.qualifier.precision = parseContext.getDefaultPrecision($$);
|
||||||
$$.arraySizes = $2.arraySizes;
|
$$.arraySizes = $2.arraySizes;
|
||||||
@ -3110,8 +3112,12 @@ struct_declaration
|
|||||||
parseContext.precisionQualifierCheck($1.loc, $1.basicType, $1.qualifier);
|
parseContext.precisionQualifierCheck($1.loc, $1.basicType, $1.qualifier);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < $$->size(); ++i) {
|
for (unsigned int i = 0; i < $$->size(); ++i) {
|
||||||
parseContext.arrayDimCheck($1.loc, (*$$)[i].type, $1.arraySizes);
|
TType type($1);
|
||||||
(*$$)[i].type->mergeType($1);
|
type.setFieldName((*$$)[i].type->getFieldName());
|
||||||
|
type.transferArraySizes((*$$)[i].type->getArraySizes());
|
||||||
|
type.copyArrayInnerSizes($1.arraySizes);
|
||||||
|
parseContext.arrayOfArrayVersionCheck((*$$)[i].loc, type.getArraySizes());
|
||||||
|
(*$$)[i].type->shallowCopy(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| type_qualifier type_specifier struct_declarator_list SEMICOLON {
|
| type_qualifier type_specifier struct_declarator_list SEMICOLON {
|
||||||
@ -3131,8 +3137,12 @@ struct_declaration
|
|||||||
parseContext.precisionQualifierCheck($2.loc, $2.basicType, $2.qualifier);
|
parseContext.precisionQualifierCheck($2.loc, $2.basicType, $2.qualifier);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < $$->size(); ++i) {
|
for (unsigned int i = 0; i < $$->size(); ++i) {
|
||||||
parseContext.arrayDimCheck($1.loc, (*$$)[i].type, $2.arraySizes);
|
TType type($2);
|
||||||
(*$$)[i].type->mergeType($2);
|
type.setFieldName((*$$)[i].type->getFieldName());
|
||||||
|
type.transferArraySizes((*$$)[i].type->getArraySizes());
|
||||||
|
type.copyArrayInnerSizes($2.arraySizes);
|
||||||
|
parseContext.arrayOfArrayVersionCheck((*$$)[i].loc, type.getArraySizes());
|
||||||
|
(*$$)[i].type->shallowCopy(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -3154,12 +3164,12 @@ struct_declarator
|
|||||||
$$.type->setFieldName(*$1.string);
|
$$.type->setFieldName(*$1.string);
|
||||||
}
|
}
|
||||||
| IDENTIFIER array_specifier {
|
| IDENTIFIER array_specifier {
|
||||||
parseContext.arrayDimCheck($1.loc, $2.arraySizes, 0);
|
parseContext.arrayOfArrayVersionCheck($1.loc, $2.arraySizes);
|
||||||
|
|
||||||
$$.type = new TType(EbtVoid);
|
$$.type = new TType(EbtVoid);
|
||||||
$$.loc = $1.loc;
|
$$.loc = $1.loc;
|
||||||
$$.type->setFieldName(*$1.string);
|
$$.type->setFieldName(*$1.string);
|
||||||
$$.type->newArraySizes(*$2.arraySizes);
|
$$.type->transferArraySizes($2.arraySizes);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,8 @@
|
|||||||
/* A Bison parser, made by GNU Bison 3.0.4. */
|
/* A Bison parser, made by GNU Bison 3.0. */
|
||||||
|
|
||||||
/* Bison interface for Yacc-like parsers in C
|
/* Bison interface for Yacc-like parsers in C
|
||||||
|
|
||||||
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
|
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -437,7 +437,7 @@ extern int yydebug;
|
|||||||
|
|
||||||
/* Value type. */
|
/* Value type. */
|
||||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||||
|
typedef union YYSTYPE YYSTYPE;
|
||||||
union YYSTYPE
|
union YYSTYPE
|
||||||
{
|
{
|
||||||
#line 70 "MachineIndependent/glslang.y" /* yacc.c:1909 */
|
#line 70 "MachineIndependent/glslang.y" /* yacc.c:1909 */
|
||||||
@ -477,8 +477,6 @@ union YYSTYPE
|
|||||||
|
|
||||||
#line 479 "MachineIndependent/glslang_tab.cpp.h" /* yacc.c:1909 */
|
#line 479 "MachineIndependent/glslang_tab.cpp.h" /* yacc.c:1909 */
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef union YYSTYPE YYSTYPE;
|
|
||||||
# define YYSTYPE_IS_TRIVIAL 1
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
# define YYSTYPE_IS_DECLARED 1
|
# define YYSTYPE_IS_DECLARED 1
|
||||||
#endif
|
#endif
|
||||||
|
@ -199,6 +199,7 @@ INSTANTIATE_TEST_CASE_P(
|
|||||||
"loopsArtificial.frag",
|
"loopsArtificial.frag",
|
||||||
"matrix.frag",
|
"matrix.frag",
|
||||||
"matrix2.frag",
|
"matrix2.frag",
|
||||||
|
"mixedArrayDecls.frag",
|
||||||
"newTexture.frag",
|
"newTexture.frag",
|
||||||
"Operations.frag",
|
"Operations.frag",
|
||||||
"overlongLiteral.frag",
|
"overlongLiteral.frag",
|
||||||
|
@ -436,28 +436,20 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList)
|
|||||||
if (declaredType.getQualifier().storage == EvqTemporary && parseContext.symbolTable.atGlobalLevel())
|
if (declaredType.getQualifier().storage == EvqTemporary && parseContext.symbolTable.atGlobalLevel())
|
||||||
declaredType.getQualifier().storage = EvqUniform;
|
declaredType.getQualifier().storage = EvqUniform;
|
||||||
|
|
||||||
|
// recognize array_specifier
|
||||||
|
TArraySizes* arraySizes = nullptr;
|
||||||
|
acceptArraySpecifier(arraySizes);
|
||||||
|
|
||||||
// We can handle multiple variables per type declaration, so
|
// We can handle multiple variables per type declaration, so
|
||||||
// the number of types can expand when arrayness is different.
|
// the number of types can expand when arrayness is different.
|
||||||
TType variableType;
|
TType variableType;
|
||||||
variableType.shallowCopy(declaredType);
|
variableType.shallowCopy(declaredType);
|
||||||
|
|
||||||
// recognize array_specifier
|
// In the most general case, arrayness is potentially coming both from the
|
||||||
TArraySizes* arraySizes = nullptr;
|
// declared type and from the variable: "int[] a[];" or just one or the other.
|
||||||
acceptArraySpecifier(arraySizes);
|
// Merge it all to the variableType, so all arrayness is part of the variableType.
|
||||||
|
variableType.transferArraySizes(arraySizes);
|
||||||
// Fix arrayness in the variableType
|
variableType.copyArrayInnerSizes(declaredType.getArraySizes());
|
||||||
if (declaredType.isImplicitlySizedArray()) {
|
|
||||||
// Because "int[] a = int[2](...), b = int[3](...)" makes two arrays a and b
|
|
||||||
// of different sizes, for this case sharing the shallow copy of arrayness
|
|
||||||
// with the parseType oversubscribes it, so get a deep copy of the arrayness.
|
|
||||||
variableType.newArraySizes(declaredType.getArraySizes());
|
|
||||||
}
|
|
||||||
if (arraySizes || variableType.isArray()) {
|
|
||||||
// In the most general case, arrayness is potentially coming both from the
|
|
||||||
// declared type and from the variable: "int[] a[];" or just one or the other.
|
|
||||||
// Merge it all to the variableType, so all arrayness is part of the variableType.
|
|
||||||
parseContext.arrayDimMerge(variableType, arraySizes);
|
|
||||||
}
|
|
||||||
|
|
||||||
// samplers accept immediate sampler state
|
// samplers accept immediate sampler state
|
||||||
if (variableType.getBasicType() == EbtSampler) {
|
if (variableType.getBasicType() == EbtSampler) {
|
||||||
@ -487,8 +479,7 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList)
|
|||||||
else if (variableType.getBasicType() == EbtBlock) {
|
else if (variableType.getBasicType() == EbtBlock) {
|
||||||
if (expressionNode)
|
if (expressionNode)
|
||||||
parseContext.error(idToken.loc, "buffer aliasing not yet supported", "block initializer", "");
|
parseContext.error(idToken.loc, "buffer aliasing not yet supported", "block initializer", "");
|
||||||
parseContext.declareBlock(idToken.loc, variableType, fullName,
|
parseContext.declareBlock(idToken.loc, variableType, fullName);
|
||||||
variableType.isArray() ? &variableType.getArraySizes() : nullptr);
|
|
||||||
parseContext.declareStructBufferCounter(idToken.loc, variableType, *fullName);
|
parseContext.declareStructBufferCounter(idToken.loc, variableType, *fullName);
|
||||||
} else {
|
} else {
|
||||||
if (variableType.getQualifier().storage == EvqUniform && ! variableType.containsOpaque()) {
|
if (variableType.getQualifier().storage == EvqUniform && ! variableType.containsOpaque()) {
|
||||||
@ -1036,7 +1027,7 @@ bool HlslGrammar::acceptTessellationPatchTemplateType(TType& type)
|
|||||||
|
|
||||||
TArraySizes* arraySizes = new TArraySizes;
|
TArraySizes* arraySizes = new TArraySizes;
|
||||||
arraySizes->addInnerSize(size->getAsConstantUnion()->getConstArray()[0].getIConst());
|
arraySizes->addInnerSize(size->getAsConstantUnion()->getConstArray()[0].getIConst());
|
||||||
type.newArraySizes(*arraySizes);
|
type.transferArraySizes(arraySizes);
|
||||||
type.getQualifier().builtIn = patchType;
|
type.getQualifier().builtIn = patchType;
|
||||||
|
|
||||||
if (! acceptTokenClass(EHTokRightAngle)) {
|
if (! acceptTokenClass(EHTokRightAngle)) {
|
||||||
@ -2295,9 +2286,9 @@ bool HlslGrammar::acceptStructBufferType(TType& type)
|
|||||||
|
|
||||||
// Create an unsized array out of that type.
|
// Create an unsized array out of that type.
|
||||||
// TODO: does this work if it's already an array type?
|
// TODO: does this work if it's already an array type?
|
||||||
TArraySizes unsizedArray;
|
TArraySizes* unsizedArray = new TArraySizes;
|
||||||
unsizedArray.addInnerSize(UnsizedArraySize);
|
unsizedArray->addInnerSize(UnsizedArraySize);
|
||||||
templateType->newArraySizes(unsizedArray);
|
templateType->transferArraySizes(unsizedArray);
|
||||||
templateType->getQualifier().storage = storage;
|
templateType->getQualifier().storage = storage;
|
||||||
|
|
||||||
// field name is canonical for all structbuffers
|
// field name is canonical for all structbuffers
|
||||||
@ -2395,7 +2386,7 @@ bool HlslGrammar::acceptStructDeclarationList(TTypeList*& typeList, TIntermNode*
|
|||||||
TArraySizes* arraySizes = nullptr;
|
TArraySizes* arraySizes = nullptr;
|
||||||
acceptArraySpecifier(arraySizes);
|
acceptArraySpecifier(arraySizes);
|
||||||
if (arraySizes)
|
if (arraySizes)
|
||||||
typeList->back().type->newArraySizes(*arraySizes);
|
typeList->back().type->transferArraySizes(arraySizes);
|
||||||
|
|
||||||
acceptPostDecls(member.type->getQualifier());
|
acceptPostDecls(member.type->getQualifier());
|
||||||
|
|
||||||
@ -2583,7 +2574,7 @@ bool HlslGrammar::acceptParameterDeclaration(TFunction& function)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
type->newArraySizes(*arraySizes);
|
type->transferArraySizes(arraySizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// post_decls
|
// post_decls
|
||||||
@ -2954,7 +2945,7 @@ bool HlslGrammar::acceptUnaryExpression(TIntermTyped*& node)
|
|||||||
TArraySizes* arraySizes = nullptr;
|
TArraySizes* arraySizes = nullptr;
|
||||||
acceptArraySpecifier(arraySizes);
|
acceptArraySpecifier(arraySizes);
|
||||||
if (arraySizes != nullptr)
|
if (arraySizes != nullptr)
|
||||||
castType.newArraySizes(*arraySizes);
|
castType.transferArraySizes(arraySizes);
|
||||||
TSourceLoc loc = token.loc;
|
TSourceLoc loc = token.loc;
|
||||||
if (acceptTokenClass(EHTokRightParen)) {
|
if (acceptTokenClass(EHTokRightParen)) {
|
||||||
// We've matched "(type)" now, get the expression to cast
|
// We've matched "(type)" now, get the expression to cast
|
||||||
|
@ -1105,7 +1105,7 @@ void HlslParseContext::splitBuiltIn(const TString& baseName, const TType& member
|
|||||||
TVariable* ioVar = makeInternalVariable(baseName + "." + memberType.getFieldName(), memberType);
|
TVariable* ioVar = makeInternalVariable(baseName + "." + memberType.getFieldName(), memberType);
|
||||||
|
|
||||||
if (arraySizes != nullptr && !memberType.isArray())
|
if (arraySizes != nullptr && !memberType.isArray())
|
||||||
ioVar->getWritableType().newArraySizes(*arraySizes);
|
ioVar->getWritableType().copyArraySizes(*arraySizes);
|
||||||
|
|
||||||
splitBuiltIns[tInterstageIoData(memberType.getQualifier().builtIn, outerQualifier.storage)] = ioVar;
|
splitBuiltIns[tInterstageIoData(memberType.getQualifier().builtIn, outerQualifier.storage)] = ioVar;
|
||||||
if (!isClipOrCullDistance(ioVar->getType()))
|
if (!isClipOrCullDistance(ioVar->getType()))
|
||||||
@ -1301,7 +1301,7 @@ int HlslParseContext::flattenStruct(const TVariable& variable, const TType& type
|
|||||||
name + "." + dereferencedType.getFieldName(),
|
name + "." + dereferencedType.getFieldName(),
|
||||||
linkage, outerQualifier,
|
linkage, outerQualifier,
|
||||||
builtInArraySizes == nullptr && dereferencedType.isArray()
|
builtInArraySizes == nullptr && dereferencedType.isArray()
|
||||||
? &dereferencedType.getArraySizes()
|
? dereferencedType.getArraySizes()
|
||||||
: builtInArraySizes);
|
: builtInArraySizes);
|
||||||
flattenData.offsets[pos++] = mpos;
|
flattenData.offsets[pos++] = mpos;
|
||||||
}
|
}
|
||||||
@ -1512,9 +1512,9 @@ void HlslParseContext::fixBuiltInIoType(TType& type)
|
|||||||
// Alter or set array size as needed.
|
// Alter or set array size as needed.
|
||||||
if (requiredArraySize > 0) {
|
if (requiredArraySize > 0) {
|
||||||
if (!type.isArray() || type.getOuterArraySize() != requiredArraySize) {
|
if (!type.isArray() || type.getOuterArraySize() != requiredArraySize) {
|
||||||
TArraySizes arraySizes;
|
TArraySizes* arraySizes = new TArraySizes;
|
||||||
arraySizes.addInnerSize(requiredArraySize);
|
arraySizes->addInnerSize(requiredArraySize);
|
||||||
type.newArraySizes(arraySizes);
|
type.transferArraySizes(arraySizes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2273,9 +2273,9 @@ void HlslParseContext::remapEntryPointIO(TFunction& function, TVariable*& return
|
|||||||
outputType.shallowCopy(function.getType());
|
outputType.shallowCopy(function.getType());
|
||||||
|
|
||||||
// vertices has necessarily already been set when handling entry point attributes.
|
// vertices has necessarily already been set when handling entry point attributes.
|
||||||
TArraySizes arraySizes;
|
TArraySizes* arraySizes = new TArraySizes;
|
||||||
arraySizes.addInnerSize(intermediate.getVertices());
|
arraySizes->addInnerSize(intermediate.getVertices());
|
||||||
outputType.newArraySizes(arraySizes);
|
outputType.transferArraySizes(arraySizes);
|
||||||
|
|
||||||
clearUniformInputOutput(function.getWritableType().getQualifier());
|
clearUniformInputOutput(function.getWritableType().getQualifier());
|
||||||
returnValue = makeIoVariable("@entryPointOutput", outputType, EvqVaryingOut);
|
returnValue = makeIoVariable("@entryPointOutput", outputType, EvqVaryingOut);
|
||||||
@ -2512,11 +2512,11 @@ TIntermAggregate* HlslParseContext::assignClipCullDistance(const TSourceLoc& loc
|
|||||||
clipCullType.getQualifier() = clipCullNode->getType().getQualifier();
|
clipCullType.getQualifier() = clipCullNode->getType().getQualifier();
|
||||||
|
|
||||||
// Create required array dimension
|
// Create required array dimension
|
||||||
TArraySizes arraySizes;
|
TArraySizes* arraySizes = new TArraySizes;
|
||||||
if (isImplicitlyArrayed)
|
if (isImplicitlyArrayed)
|
||||||
arraySizes.addInnerSize(requiredOuterArraySize);
|
arraySizes->addInnerSize(requiredOuterArraySize);
|
||||||
arraySizes.addInnerSize(requiredInnerArraySize);
|
arraySizes->addInnerSize(requiredInnerArraySize);
|
||||||
clipCullType.newArraySizes(arraySizes);
|
clipCullType.transferArraySizes(arraySizes);
|
||||||
|
|
||||||
// Obtain symbol name: we'll use that for the symbol we introduce.
|
// Obtain symbol name: we'll use that for the symbol we introduce.
|
||||||
TIntermSymbol* sym = clipCullNode->getAsSymbolNode();
|
TIntermSymbol* sym = clipCullNode->getAsSymbolNode();
|
||||||
@ -3612,9 +3612,9 @@ TIntermConstantUnion* HlslParseContext::getSamplePosArray(int count)
|
|||||||
TType retType(EbtFloat, EvqConst, 2);
|
TType retType(EbtFloat, EvqConst, 2);
|
||||||
|
|
||||||
if (numSamples != 1) {
|
if (numSamples != 1) {
|
||||||
TArraySizes arraySizes;
|
TArraySizes* arraySizes = new TArraySizes;
|
||||||
arraySizes.addInnerSize(numSamples);
|
arraySizes->addInnerSize(numSamples);
|
||||||
retType.newArraySizes(arraySizes);
|
retType.transferArraySizes(arraySizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new TIntermConstantUnion(*values, retType);
|
return new TIntermConstantUnion(*values, retType);
|
||||||
@ -4311,9 +4311,9 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
|
|||||||
// we construct an array from the separate args.
|
// we construct an array from the separate args.
|
||||||
if (hasOffset4) {
|
if (hasOffset4) {
|
||||||
TType arrayType(EbtInt, EvqTemporary, 2);
|
TType arrayType(EbtInt, EvqTemporary, 2);
|
||||||
TArraySizes arraySizes;
|
TArraySizes* arraySizes = new TArraySizes;
|
||||||
arraySizes.addInnerSize(4);
|
arraySizes->addInnerSize(4);
|
||||||
arrayType.newArraySizes(arraySizes);
|
arrayType.transferArraySizes(arraySizes);
|
||||||
|
|
||||||
TIntermAggregate* initList = new TIntermAggregate(EOpNull);
|
TIntermAggregate* initList = new TIntermAggregate(EOpNull);
|
||||||
|
|
||||||
@ -6343,11 +6343,11 @@ bool HlslParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node
|
|||||||
// Types have to match, but we're still making the type.
|
// Types have to match, but we're still making the type.
|
||||||
// Finish making the type, and the comparison is done later
|
// Finish making the type, and the comparison is done later
|
||||||
// when checking for conversion.
|
// when checking for conversion.
|
||||||
TArraySizes& arraySizes = type.getArraySizes();
|
TArraySizes& arraySizes = *type.getArraySizes();
|
||||||
|
|
||||||
// At least the dimensionalities have to match.
|
// At least the dimensionalities have to match.
|
||||||
if (! function[0].type->isArray() ||
|
if (! function[0].type->isArray() ||
|
||||||
arraySizes.getNumDims() != function[0].type->getArraySizes().getNumDims() + 1) {
|
arraySizes.getNumDims() != function[0].type->getArraySizes()->getNumDims() + 1) {
|
||||||
error(loc, "array constructor argument not correct type to construct array element", "constructor", "");
|
error(loc, "array constructor argument not correct type to construct array element", "constructor", "");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -6357,7 +6357,7 @@ bool HlslParseContext::constructorError(const TSourceLoc& loc, TIntermNode* node
|
|||||||
// That means we need to adopt (from the first argument) the other array sizes into the type.
|
// That means we need to adopt (from the first argument) the other array sizes into the type.
|
||||||
for (int d = 1; d < arraySizes.getNumDims(); ++d) {
|
for (int d = 1; d < arraySizes.getNumDims(); ++d) {
|
||||||
if (arraySizes.getDimSize(d) == UnsizedArraySize) {
|
if (arraySizes.getDimSize(d) == UnsizedArraySize) {
|
||||||
arraySizes.setDimSize(d, function[0].type->getArraySizes().getDimSize(d - 1));
|
arraySizes.setDimSize(d, function[0].type->getArraySizes()->getDimSize(d - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6621,20 +6621,6 @@ void HlslParseContext::structArrayCheck(const TSourceLoc& /*loc*/, const TType&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge array dimensions listed in 'sizes' onto the type's array dimensions.
|
|
||||||
//
|
|
||||||
// From the spec: "vec4[2] a[3]; // size-3 array of size-2 array of vec4"
|
|
||||||
//
|
|
||||||
// That means, the 'sizes' go in front of the 'type' as outermost sizes.
|
|
||||||
// 'type' is the type part of the declaration (to the left)
|
|
||||||
// 'sizes' is the arrayness tagged on the identifier (to the right)
|
|
||||||
//
|
|
||||||
void HlslParseContext::arrayDimMerge(TType& type, const TArraySizes* sizes)
|
|
||||||
{
|
|
||||||
if (sizes)
|
|
||||||
type.addArrayOuterSizes(*sizes);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Do all the semantic checking for declaring or redeclaring an array, with and
|
// Do all the semantic checking for declaring or redeclaring an array, with and
|
||||||
// without a size, and make the right changes to the symbol table.
|
// without a size, and make the right changes to the symbol table.
|
||||||
@ -7946,8 +7932,10 @@ TIntermNode* HlslParseContext::executeInitializer(const TSourceLoc& loc, TInterm
|
|||||||
variable->getType().getArraySizes()->getNumDims()) {
|
variable->getType().getArraySizes()->getNumDims()) {
|
||||||
// adopt unsized sizes from the initializer's sizes
|
// adopt unsized sizes from the initializer's sizes
|
||||||
for (int d = 1; d < variable->getType().getArraySizes()->getNumDims(); ++d) {
|
for (int d = 1; d < variable->getType().getArraySizes()->getNumDims(); ++d) {
|
||||||
if (variable->getType().getArraySizes()->getDimSize(d) == UnsizedArraySize)
|
if (variable->getType().getArraySizes()->getDimSize(d) == UnsizedArraySize) {
|
||||||
variable->getWritableType().getArraySizes().setDimSize(d, initializer->getType().getArraySizes()->getDimSize(d));
|
variable->getWritableType().getArraySizes()->setDimSize(d,
|
||||||
|
initializer->getType().getArraySizes()->getDimSize(d));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8034,7 +8022,7 @@ TIntermTyped* HlslParseContext::convertInitializerList(const TSourceLoc& loc, co
|
|||||||
// Later on, initializer execution code will deal with array size logic.
|
// Later on, initializer execution code will deal with array size logic.
|
||||||
TType arrayType;
|
TType arrayType;
|
||||||
arrayType.shallowCopy(type); // sharing struct stuff is fine
|
arrayType.shallowCopy(type); // sharing struct stuff is fine
|
||||||
arrayType.newArraySizes(*type.getArraySizes()); // but get a fresh copy of the array information, to edit below
|
arrayType.copyArraySizes(*type.getArraySizes()); // but get a fresh copy of the array information, to edit below
|
||||||
|
|
||||||
// edit array sizes to fill in unsized dimensions
|
// edit array sizes to fill in unsized dimensions
|
||||||
if (type.isImplicitlySizedArray())
|
if (type.isImplicitlySizedArray())
|
||||||
@ -8044,10 +8032,10 @@ TIntermTyped* HlslParseContext::convertInitializerList(const TSourceLoc& loc, co
|
|||||||
if (arrayType.isArrayOfArrays() && initList->getSequence().size() > 0) {
|
if (arrayType.isArrayOfArrays() && initList->getSequence().size() > 0) {
|
||||||
TIntermTyped* firstInit = initList->getSequence()[0]->getAsTyped();
|
TIntermTyped* firstInit = initList->getSequence()[0]->getAsTyped();
|
||||||
if (firstInit->getType().isArray() &&
|
if (firstInit->getType().isArray() &&
|
||||||
arrayType.getArraySizes().getNumDims() == firstInit->getType().getArraySizes()->getNumDims() + 1) {
|
arrayType.getArraySizes()->getNumDims() == firstInit->getType().getArraySizes()->getNumDims() + 1) {
|
||||||
for (int d = 1; d < arrayType.getArraySizes().getNumDims(); ++d) {
|
for (int d = 1; d < arrayType.getArraySizes()->getNumDims(); ++d) {
|
||||||
if (arrayType.getArraySizes().getDimSize(d) == UnsizedArraySize)
|
if (arrayType.getArraySizes()->getDimSize(d) == UnsizedArraySize)
|
||||||
arrayType.getArraySizes().setDimSize(d, firstInit->getType().getArraySizes()->getDimSize(d - 1));
|
arrayType.getArraySizes()->setDimSize(d, firstInit->getType().getArraySizes()->getDimSize(d - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8539,7 +8527,7 @@ TIntermTyped* HlslParseContext::constructAggregate(TIntermNode* node, const TTyp
|
|||||||
//
|
//
|
||||||
// Do everything needed to add an interface block.
|
// Do everything needed to add an interface block.
|
||||||
//
|
//
|
||||||
void HlslParseContext::declareBlock(const TSourceLoc& loc, TType& type, const TString* instanceName, TArraySizes* arraySizes)
|
void HlslParseContext::declareBlock(const TSourceLoc& loc, TType& type, const TString* instanceName)
|
||||||
{
|
{
|
||||||
assert(type.getWritableStruct() != nullptr);
|
assert(type.getWritableStruct() != nullptr);
|
||||||
|
|
||||||
@ -8667,8 +8655,8 @@ void HlslParseContext::declareBlock(const TSourceLoc& loc, TType& type, const TS
|
|||||||
const TString& interfaceName = (instanceName && !instanceName->empty()) ? *instanceName : type.getTypeName();
|
const TString& interfaceName = (instanceName && !instanceName->empty()) ? *instanceName : type.getTypeName();
|
||||||
|
|
||||||
TType blockType(&typeList, interfaceName, type.getQualifier());
|
TType blockType(&typeList, interfaceName, type.getQualifier());
|
||||||
if (arraySizes)
|
if (type.isArray())
|
||||||
blockType.newArraySizes(*arraySizes);
|
blockType.transferArraySizes(type.getArraySizes());
|
||||||
|
|
||||||
// Add the variable, as anonymous or named instanceName.
|
// Add the variable, as anonymous or named instanceName.
|
||||||
// Make an anonymous variable if no name was provided.
|
// Make an anonymous variable if no name was provided.
|
||||||
|
@ -126,7 +126,6 @@ public:
|
|||||||
void arraySizeCheck(const TSourceLoc&, TIntermTyped* expr, TArraySize&);
|
void arraySizeCheck(const TSourceLoc&, TIntermTyped* expr, TArraySize&);
|
||||||
void arraySizeRequiredCheck(const TSourceLoc&, const TArraySizes&);
|
void arraySizeRequiredCheck(const TSourceLoc&, const TArraySizes&);
|
||||||
void structArrayCheck(const TSourceLoc&, const TType& structure);
|
void structArrayCheck(const TSourceLoc&, const TType& structure);
|
||||||
void arrayDimMerge(TType& type, const TArraySizes* sizes);
|
|
||||||
bool voidErrorCheck(const TSourceLoc&, const TString&, TBasicType);
|
bool voidErrorCheck(const TSourceLoc&, const TString&, TBasicType);
|
||||||
void globalQualifierFix(const TSourceLoc&, TQualifier&);
|
void globalQualifierFix(const TSourceLoc&, TQualifier&);
|
||||||
bool structQualifierErrorCheck(const TSourceLoc&, const TPublicType& pType);
|
bool structQualifierErrorCheck(const TSourceLoc&, const TPublicType& pType);
|
||||||
@ -154,7 +153,7 @@ public:
|
|||||||
TIntermTyped* convertArray(TIntermTyped*, const TType&);
|
TIntermTyped* convertArray(TIntermTyped*, const TType&);
|
||||||
TIntermTyped* constructAggregate(TIntermNode*, const TType&, int, const TSourceLoc&);
|
TIntermTyped* constructAggregate(TIntermNode*, const TType&, int, const TSourceLoc&);
|
||||||
TIntermTyped* constructBuiltIn(const TType&, TOperator, TIntermTyped*, const TSourceLoc&, bool subset);
|
TIntermTyped* constructBuiltIn(const TType&, TOperator, TIntermTyped*, const TSourceLoc&, bool subset);
|
||||||
void declareBlock(const TSourceLoc&, TType&, const TString* instanceName = 0, TArraySizes* arraySizes = 0);
|
void declareBlock(const TSourceLoc&, TType&, const TString* instanceName = 0);
|
||||||
void declareStructBufferCounter(const TSourceLoc& loc, const TType& bufferType, const TString& name);
|
void declareStructBufferCounter(const TSourceLoc& loc, const TType& bufferType, const TString& name);
|
||||||
void fixBlockLocations(const TSourceLoc&, TQualifier&, TTypeList&, bool memberWithLocation, bool memberWithoutLocation);
|
void fixBlockLocations(const TSourceLoc&, TQualifier&, TTypeList&, bool memberWithLocation, bool memberWithoutLocation);
|
||||||
void fixBlockXfbOffsets(TQualifier&, TTypeList&);
|
void fixBlockXfbOffsets(TQualifier&, TTypeList&);
|
||||||
|
Loading…
Reference in New Issue
Block a user