Commit ead86224 by John Kessenich

Non-functional. Rationalizations enabling future generalizations:

- Use much simpler method to update implicit array sizes. The previous overly complicated method was error prone. - Rationalize all use of unsized arrays. - Combine decorations when generating SPIR-V, to simplify adding extensions.
parent 2316924b
...@@ -854,9 +854,9 @@ Id Builder::makeFpConstant(Id type, double d, bool specConstant) ...@@ -854,9 +854,9 @@ Id Builder::makeFpConstant(Id type, double d, bool specConstant)
switch (getScalarTypeWidth(type)) { switch (getScalarTypeWidth(type)) {
case 16: case 16:
return makeFloat16Constant(d, specConstant); return makeFloat16Constant((float)d, specConstant);
case 32: case 32:
return makeFloatConstant(d, specConstant); return makeFloatConstant((float)d, specConstant);
case 64: case 64:
return makeDoubleConstant(d, specConstant); return makeDoubleConstant(d, specConstant);
default: default:
......
...@@ -104,3 +104,9 @@ void foo3() ...@@ -104,3 +104,9 @@ void foo3()
int[] i = int[](); // ERROR, need constructor arguments int[] i = int[](); // ERROR, need constructor arguments
float emptyA[]; float emptyA[];
float b = vec4(emptyA); // ERROR, array can't be a constructor argument float b = vec4(emptyA); // ERROR, array can't be a constructor argument
uniform sampler2D s2d[];
void foo4()
{
s2d[a]; // ERROR, can't variably index unsized array
}
...@@ -453,7 +453,7 @@ ERROR: 0:47: 'patch' : cannot use interpolation qualifiers with patch ...@@ -453,7 +453,7 @@ ERROR: 0:47: 'patch' : cannot use interpolation qualifiers with patch
ERROR: 0:48: 'patch' : cannot use interpolation qualifiers with patch ERROR: 0:48: 'patch' : cannot use interpolation qualifiers with patch
ERROR: 0:49: 'patch' : cannot use interpolation qualifiers with patch ERROR: 0:49: 'patch' : cannot use interpolation qualifiers with patch
ERROR: 0:50: '' : can only have one auxiliary qualifier (centroid, patch, and sample) ERROR: 0:50: '' : can only have one auxiliary qualifier (centroid, patch, and sample)
ERROR: 0:54: 'gl_PerVertex' : block already declared with size, can't redeclare as implicitly-sized ERROR: 0:54: 'gl_PerVertex' : block already declared with size, can't redeclare as unsized
ERROR: 0:59: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use ERROR: 0:59: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use
ERROR: 0:64: 'quads' : cannot apply to 'out' ERROR: 0:64: 'quads' : cannot apply to 'out'
ERROR: 0:64: 'cw' : can only apply to 'in' ERROR: 0:64: 'cw' : can only apply to 'in'
......
...@@ -25,7 +25,7 @@ ERROR: 0:53: 'noperspective' : not supported for this version or the enabled ext ...@@ -25,7 +25,7 @@ ERROR: 0:53: 'noperspective' : not supported for this version or the enabled ext
ERROR: 0:53: 'patch' : cannot use interpolation qualifiers with patch ERROR: 0:53: 'patch' : cannot use interpolation qualifiers with patch
ERROR: 0:54: 'sample' : Reserved word. ERROR: 0:54: 'sample' : Reserved word.
ERROR: 0:54: '' : can only have one auxiliary qualifier (centroid, patch, and sample) ERROR: 0:54: '' : can only have one auxiliary qualifier (centroid, patch, and sample)
ERROR: 0:58: 'gl_PerVertex' : block already declared with size, can't redeclare as implicitly-sized ERROR: 0:58: 'gl_PerVertex' : block already declared with size, can't redeclare as unsized
ERROR: 0:63: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use ERROR: 0:63: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use
ERROR: 0:68: 'quads' : cannot apply to 'out' ERROR: 0:68: 'quads' : cannot apply to 'out'
ERROR: 0:68: 'cw' : can only apply to 'in' ERROR: 0:68: 'cw' : can only apply to 'in'
......
...@@ -11,14 +11,14 @@ ERROR: node is still EOpNull! ...@@ -11,14 +11,14 @@ ERROR: node is still EOpNull!
0:7 move second child to first child ( temp highp int) 0:7 move second child to first child ( temp highp int)
0:7 'o' (layout( location=0) smooth out highp int) 0:7 'o' (layout( location=0) smooth out highp int)
0:7 direct index (layout( column_major shared) temp highp int) 0:7 direct index (layout( column_major shared) temp highp int)
0:7 a: direct index for structure (layout( column_major shared) uniform unsized 1-element array of highp int) 0:7 a: direct index for structure (layout( column_major shared) uniform unsized 3-element array of highp int)
0:7 'uni' (layout( binding=0 column_major shared) uniform block{layout( column_major shared) uniform unsized 1-element array of highp int a}) 0:7 'uni' (layout( binding=0 column_major shared) uniform block{layout( column_major shared) uniform unsized 3-element array of highp int a})
0:7 Constant: 0:7 Constant:
0:7 0 (const int) 0:7 0 (const int)
0:7 Constant: 0:7 Constant:
0:7 2 (const int) 0:7 2 (const int)
0:? Linker Objects 0:? Linker Objects
0:? 'uni' (layout( binding=0 column_major shared) uniform block{layout( column_major shared) uniform unsized 1-element array of highp int a}) 0:? 'uni' (layout( binding=0 column_major shared) uniform block{layout( column_major shared) uniform unsized 3-element array of highp int a})
0:? 'o' (layout( location=0) smooth out highp int) 0:? 'o' (layout( location=0) smooth out highp int)
0:? 'gl_VertexID' ( gl_VertexId highp int VertexId) 0:? 'gl_VertexID' ( gl_VertexId highp int VertexId)
0:? 'gl_InstanceID' ( gl_InstanceId highp int InstanceId) 0:? 'gl_InstanceID' ( gl_InstanceId highp int InstanceId)
...@@ -35,14 +35,14 @@ ERROR: node is still EOpNull! ...@@ -35,14 +35,14 @@ ERROR: node is still EOpNull!
0:7 move second child to first child ( temp highp int) 0:7 move second child to first child ( temp highp int)
0:7 'o' (layout( location=0) smooth out highp int) 0:7 'o' (layout( location=0) smooth out highp int)
0:7 direct index (layout( column_major shared) temp highp int) 0:7 direct index (layout( column_major shared) temp highp int)
0:7 a: direct index for structure (layout( column_major shared) uniform 1-element array of highp int) 0:7 a: direct index for structure (layout( column_major shared) uniform 3-element array of highp int)
0:7 'uni' (layout( binding=0 column_major shared) uniform block{layout( column_major shared) uniform 1-element array of highp int a}) 0:7 'uni' (layout( binding=0 column_major shared) uniform block{layout( column_major shared) uniform 3-element array of highp int a})
0:7 Constant: 0:7 Constant:
0:7 0 (const int) 0:7 0 (const int)
0:7 Constant: 0:7 Constant:
0:7 2 (const int) 0:7 2 (const int)
0:? Linker Objects 0:? Linker Objects
0:? 'uni' (layout( binding=0 column_major shared) uniform block{layout( column_major shared) uniform 1-element array of highp int a}) 0:? 'uni' (layout( binding=0 column_major shared) uniform block{layout( column_major shared) uniform 3-element array of highp int a})
0:? 'o' (layout( location=0) smooth out highp int) 0:? 'o' (layout( location=0) smooth out highp int)
0:? 'gl_VertexID' ( gl_VertexId highp int VertexId) 0:? 'gl_VertexID' ( gl_VertexId highp int VertexId)
0:? 'gl_InstanceID' ( gl_InstanceId highp int InstanceId) 0:? 'gl_InstanceID' ( gl_InstanceId highp int InstanceId)
......
...@@ -24,7 +24,7 @@ ERROR: 0:49: 'noperspective' : Reserved word. ...@@ -24,7 +24,7 @@ ERROR: 0:49: 'noperspective' : Reserved word.
ERROR: 0:49: 'noperspective' : not supported for this version or the enabled extensions ERROR: 0:49: 'noperspective' : not supported for this version or the enabled extensions
ERROR: 0:49: 'patch' : cannot use interpolation qualifiers with patch ERROR: 0:49: 'patch' : cannot use interpolation qualifiers with patch
ERROR: 0:50: '' : can only have one auxiliary qualifier (centroid, patch, and sample) ERROR: 0:50: '' : can only have one auxiliary qualifier (centroid, patch, and sample)
ERROR: 0:54: 'gl_PerVertex' : block already declared with size, can't redeclare as implicitly-sized ERROR: 0:54: 'gl_PerVertex' : block already declared with size, can't redeclare as unsized
ERROR: 0:59: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use ERROR: 0:59: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use
ERROR: 0:64: 'quads' : cannot apply to 'out' ERROR: 0:64: 'quads' : cannot apply to 'out'
ERROR: 0:64: 'cw' : can only apply to 'in' ERROR: 0:64: 'cw' : can only apply to 'in'
......
...@@ -11,7 +11,7 @@ ERROR: 0:47: 'patch' : cannot use interpolation qualifiers with patch ...@@ -11,7 +11,7 @@ ERROR: 0:47: 'patch' : cannot use interpolation qualifiers with patch
ERROR: 0:48: 'patch' : cannot use interpolation qualifiers with patch ERROR: 0:48: 'patch' : cannot use interpolation qualifiers with patch
ERROR: 0:49: 'patch' : cannot use interpolation qualifiers with patch ERROR: 0:49: 'patch' : cannot use interpolation qualifiers with patch
ERROR: 0:50: '' : can only have one auxiliary qualifier (centroid, patch, and sample) ERROR: 0:50: '' : can only have one auxiliary qualifier (centroid, patch, and sample)
ERROR: 0:54: 'gl_PerVertex' : block already declared with size, can't redeclare as implicitly-sized ERROR: 0:54: 'gl_PerVertex' : block already declared with size, can't redeclare as unsized
ERROR: 0:59: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use ERROR: 0:59: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use
ERROR: 0:64: 'quads' : cannot apply to 'out' ERROR: 0:64: 'quads' : cannot apply to 'out'
ERROR: 0:64: 'cw' : can only apply to 'in' ERROR: 0:64: 'cw' : can only apply to 'in'
......
...@@ -51,7 +51,7 @@ ERROR: 0:157: 'textureQueryLevels' : no matching overloaded function found ...@@ -51,7 +51,7 @@ ERROR: 0:157: 'textureQueryLevels' : no matching overloaded function found
ERROR: 0:157: 'assign' : cannot convert from ' const float' to ' temp int' ERROR: 0:157: 'assign' : cannot convert from ' const float' to ' temp int'
ERROR: 0:158: 'textureQueryLevels' : no matching overloaded function found ERROR: 0:158: 'textureQueryLevels' : no matching overloaded function found
ERROR: 0:158: 'assign' : cannot convert from ' const float' to ' temp int' ERROR: 0:158: 'assign' : cannot convert from ' const float' to ' temp int'
WARNING: 0:161: '[]' : assuming array size of one for compile-time checking of binding numbers for implicitly-sized array WARNING: 0:161: '[]' : assuming array size of one for compile-time checking of binding numbers for unsized array
ERROR: 51 compilation errors. No code generated. ERROR: 51 compilation errors. No code generated.
......
...@@ -33,13 +33,13 @@ ERROR: node is still EOpNull! ...@@ -33,13 +33,13 @@ ERROR: node is still EOpNull!
0:35 GroupMemoryBarrier ( global void) 0:35 GroupMemoryBarrier ( global void)
0:36 move second child to first child ( temp int) 0:36 move second child to first child ( temp int)
0:36 value: direct index for structure (layout( column_major shared) buffer int) 0:36 value: direct index for structure (layout( column_major shared) buffer int)
0:36 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer unsized 1-element array of float values}) 0:36 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer runtime-sized array of float values})
0:36 Constant: 0:36 Constant:
0:36 0 (const uint) 0:36 0 (const uint)
0:36 Convert float to int ( temp int) 0:36 Convert float to int ( temp int)
0:36 indirect index (layout( column_major shared) temp float) 0:36 indirect index (layout( column_major shared) temp float)
0:36 values: direct index for structure (layout( column_major shared) buffer unsized 1-element array of float) 0:36 values: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:36 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer unsized 1-element array of float values}) 0:36 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer runtime-sized array of float values})
0:36 Constant: 0:36 Constant:
0:36 1 (const uint) 0:36 1 (const uint)
0:36 'gl_LocalInvocationIndex' ( in uint LocalInvocationIndex) 0:36 'gl_LocalInvocationIndex' ( in uint LocalInvocationIndex)
...@@ -56,8 +56,8 @@ ERROR: node is still EOpNull! ...@@ -56,8 +56,8 @@ ERROR: node is still EOpNull!
0:65 Sequence 0:65 Sequence
0:65 move second child to first child ( temp float) 0:65 move second child to first child ( temp float)
0:65 direct index (layout( column_major shared) temp float) 0:65 direct index (layout( column_major shared) temp float)
0:65 values: direct index for structure (layout( column_major shared) buffer unsized 1-element array of float) 0:65 values: direct index for structure (layout( column_major shared) buffer unsized 3-element array of float)
0:65 'ro' (layout( column_major shared) readonly buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer unsized 1-element array of float values}) 0:65 'ro' (layout( column_major shared) readonly buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer unsized 3-element array of float values})
0:65 Constant: 0:65 Constant:
0:65 1 (const int) 0:65 1 (const int)
0:65 Constant: 0:65 Constant:
...@@ -65,8 +65,8 @@ ERROR: node is still EOpNull! ...@@ -65,8 +65,8 @@ ERROR: node is still EOpNull!
0:65 Constant: 0:65 Constant:
0:65 4.700000 0:65 4.700000
0:66 array length ( temp int) 0:66 array length ( temp int)
0:66 values: direct index for structure (layout( column_major shared) buffer unsized 1-element array of float) 0:66 values: direct index for structure (layout( column_major shared) buffer unsized 3-element array of float)
0:66 'ro' (layout( column_major shared) readonly buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer unsized 1-element array of float values}) 0:66 'ro' (layout( column_major shared) readonly buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer unsized 3-element array of float values})
0:66 Constant: 0:66 Constant:
0:66 1 (const int) 0:66 1 (const int)
0:67 Barrier ( global void) 0:67 Barrier ( global void)
...@@ -129,7 +129,7 @@ ERROR: node is still EOpNull! ...@@ -129,7 +129,7 @@ ERROR: node is still EOpNull!
0:? 4096 (const uint) 0:? 4096 (const uint)
0:? 'total' ( const int) 0:? 'total' ( const int)
0:? 66592 (const int) 0:? 66592 (const int)
0:? 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer unsized 1-element array of float values}) 0:? 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer runtime-sized array of float values})
0:? 'invalid' (layout( column_major shared) buffer block{layout( column_major shared) buffer unsized 1-element array of float values, layout( column_major shared) buffer int value}) 0:? 'invalid' (layout( column_major shared) buffer block{layout( column_major shared) buffer unsized 1-element array of float values, layout( column_major shared) buffer int value})
0:? 'v3' (layout( location=2) in 3-component vector of float) 0:? 'v3' (layout( location=2) in 3-component vector of float)
0:? 'f' ( in float) 0:? 'f' ( in float)
...@@ -140,7 +140,7 @@ ERROR: node is still EOpNull! ...@@ -140,7 +140,7 @@ ERROR: node is still EOpNull!
0:? 'arrX' ( global 2-element array of int) 0:? 'arrX' ( global 2-element array of int)
0:? 'arrY' ( global 1-element array of int) 0:? 'arrY' ( global 1-element array of int)
0:? 'arrZ' ( global 4096-element array of int) 0:? 'arrZ' ( global 4096-element array of int)
0:? 'ro' (layout( column_major shared) readonly buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer unsized 1-element array of float values}) 0:? 'ro' (layout( column_major shared) readonly buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer unsized 3-element array of float values})
0:? 'roll' ( uniform double) 0:? 'roll' ( uniform double)
0:? 'destTex' ( writeonly uniform image2D) 0:? 'destTex' ( writeonly uniform image2D)
0:? 'inbi' ( in block{ in int a}) 0:? 'inbi' ( in block{ in int a})
...@@ -165,13 +165,13 @@ ERROR: node is still EOpNull! ...@@ -165,13 +165,13 @@ ERROR: node is still EOpNull!
0:35 GroupMemoryBarrier ( global void) 0:35 GroupMemoryBarrier ( global void)
0:36 move second child to first child ( temp int) 0:36 move second child to first child ( temp int)
0:36 value: direct index for structure (layout( column_major shared) buffer int) 0:36 value: direct index for structure (layout( column_major shared) buffer int)
0:36 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer unsized 1-element array of float values}) 0:36 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer runtime-sized array of float values})
0:36 Constant: 0:36 Constant:
0:36 0 (const uint) 0:36 0 (const uint)
0:36 Convert float to int ( temp int) 0:36 Convert float to int ( temp int)
0:36 indirect index (layout( column_major shared) temp float) 0:36 indirect index (layout( column_major shared) temp float)
0:36 values: direct index for structure (layout( column_major shared) buffer unsized 1-element array of float) 0:36 values: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:36 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer unsized 1-element array of float values}) 0:36 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer runtime-sized array of float values})
0:36 Constant: 0:36 Constant:
0:36 1 (const uint) 0:36 1 (const uint)
0:36 'gl_LocalInvocationIndex' ( in uint LocalInvocationIndex) 0:36 'gl_LocalInvocationIndex' ( in uint LocalInvocationIndex)
...@@ -190,8 +190,8 @@ ERROR: node is still EOpNull! ...@@ -190,8 +190,8 @@ ERROR: node is still EOpNull!
0:? 4096 (const uint) 0:? 4096 (const uint)
0:? 'total' ( const int) 0:? 'total' ( const int)
0:? 66592 (const int) 0:? 66592 (const int)
0:? 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer unsized 1-element array of float values}) 0:? 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer runtime-sized array of float values})
0:? 'invalid' (layout( column_major shared) buffer block{layout( column_major shared) buffer unsized 1-element array of float values, layout( column_major shared) buffer int value}) 0:? 'invalid' (layout( column_major shared) buffer block{layout( column_major shared) buffer 1-element array of float values, layout( column_major shared) buffer int value})
0:? 'v3' (layout( location=2) in 3-component vector of float) 0:? 'v3' (layout( location=2) in 3-component vector of float)
0:? 'f' ( in float) 0:? 'f' ( in float)
0:? 'fo' ( out float) 0:? 'fo' ( out float)
...@@ -201,7 +201,7 @@ ERROR: node is still EOpNull! ...@@ -201,7 +201,7 @@ ERROR: node is still EOpNull!
0:? 'arrX' ( global 2-element array of int) 0:? 'arrX' ( global 2-element array of int)
0:? 'arrY' ( global 1-element array of int) 0:? 'arrY' ( global 1-element array of int)
0:? 'arrZ' ( global 4096-element array of int) 0:? 'arrZ' ( global 4096-element array of int)
0:? 'ro' (layout( column_major shared) readonly buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer unsized 1-element array of float values}) 0:? 'ro' (layout( column_major shared) readonly buffer block{layout( column_major shared) buffer int value, layout( column_major shared) buffer unsized 3-element array of float values})
0:? 'roll' ( uniform double) 0:? 'roll' ( uniform double)
0:? 'destTex' ( writeonly uniform image2D) 0:? 'destTex' ( writeonly uniform image2D)
0:? 'inbi' ( in block{ in int a}) 0:? 'inbi' ( in block{ in int a})
......
...@@ -2,7 +2,7 @@ array.frag ...@@ -2,7 +2,7 @@ array.frag
ERROR: 0:21: '[' : array index out of range '2' ERROR: 0:21: '[' : array index out of range '2'
ERROR: 0:27: '[' : array must be redeclared with a size before being indexed with a variable ERROR: 0:27: '[' : array must be redeclared with a size before being indexed with a variable
ERROR: 0:30: 'assign' : cannot convert from ' global 4-element array of float' to ' global 5-element array of float' ERROR: 0:30: 'assign' : cannot convert from ' global 4-element array of float' to ' global 5-element array of float'
ERROR: 0:31: 'assign' : cannot convert from ' global 4-element array of float' to ' global unsized 4-element array of float' ERROR: 0:31: 'assign' : cannot convert from ' global 4-element array of float' to ' global runtime-sized array of float'
ERROR: 0:33: 'foo' : no matching overloaded function found ERROR: 0:33: 'foo' : no matching overloaded function found
ERROR: 0:42: '[' : array index out of range '5' ERROR: 0:42: '[' : array index out of range '5'
ERROR: 0:45: '[' : array index out of range '1000' ERROR: 0:45: '[' : array index out of range '1000'
...@@ -25,7 +25,9 @@ ERROR: 0:101: '[' : array index out of range '5' ...@@ -25,7 +25,9 @@ ERROR: 0:101: '[' : array index out of range '5'
ERROR: 0:104: 'constructor' : array constructor must have at least one argument ERROR: 0:104: 'constructor' : array constructor must have at least one argument
ERROR: 0:104: '=' : cannot convert from ' const float' to ' global unsized 1-element array of int' ERROR: 0:104: '=' : cannot convert from ' const float' to ' global unsized 1-element array of int'
ERROR: 0:106: 'constructor' : array argument must be sized ERROR: 0:106: 'constructor' : array argument must be sized
ERROR: 26 compilation errors. No code generated. ERROR: 0:111: '[' : array must be redeclared with a size before being indexed with a variable
ERROR: 0:111: 'variable indexing sampler array' : not supported with this profile: none
ERROR: 28 compilation errors. No code generated.
Shader version: 130 Shader version: 130
...@@ -68,21 +70,21 @@ ERROR: node is still EOpNull! ...@@ -68,21 +70,21 @@ ERROR: node is still EOpNull!
0:21 4.000000 0:21 4.000000
0:24 move second child to first child ( temp float) 0:24 move second child to first child ( temp float)
0:24 direct index ( temp float) 0:24 direct index ( temp float)
0:24 'gu' ( global unsized 4-element array of float) 0:24 'gu' ( global runtime-sized array of float)
0:24 Constant: 0:24 Constant:
0:24 2 (const int) 0:24 2 (const int)
0:24 Constant: 0:24 Constant:
0:24 4.000000 0:24 4.000000
0:26 move second child to first child ( temp float) 0:26 move second child to first child ( temp float)
0:26 direct index ( temp float) 0:26 direct index ( temp float)
0:26 'gu' ( global unsized 4-element array of float) 0:26 'gu' ( global runtime-sized array of float)
0:26 Constant: 0:26 Constant:
0:26 3 (const int) 0:26 3 (const int)
0:26 Constant: 0:26 Constant:
0:26 3.000000 0:26 3.000000
0:27 move second child to first child ( temp float) 0:27 move second child to first child ( temp float)
0:27 indirect index ( temp float) 0:27 indirect index ( temp float)
0:27 'gu' ( global unsized 4-element array of float) 0:27 'gu' ( global runtime-sized array of float)
0:27 'a' ( uniform int) 0:27 'a' ( uniform int)
0:27 Constant: 0:27 Constant:
0:27 5.000000 0:27 5.000000
...@@ -91,7 +93,7 @@ ERROR: node is still EOpNull! ...@@ -91,7 +93,7 @@ ERROR: node is still EOpNull!
0:29 Function Call: foo(f1[5]; ( global 4-element array of float) 0:29 Function Call: foo(f1[5]; ( global 4-element array of float)
0:29 'g5' ( global 5-element array of float) 0:29 'g5' ( global 5-element array of float)
0:30 'g5' ( global 5-element array of float) 0:30 'g5' ( global 5-element array of float)
0:31 'gu' ( global unsized 4-element array of float) 0:31 'gu' ( global runtime-sized array of float)
0:33 Constant: 0:33 Constant:
0:33 0.000000 0:33 0.000000
0:34 Function Call: bar(f1[5]; ( global void) 0:34 Function Call: bar(f1[5]; ( global void)
...@@ -108,7 +110,7 @@ ERROR: node is still EOpNull! ...@@ -108,7 +110,7 @@ ERROR: node is still EOpNull!
0:36 true case 0:36 true case
0:37 move second child to first child ( temp float) 0:37 move second child to first child ( temp float)
0:37 direct index ( temp float) 0:37 direct index ( temp float)
0:37 'gu' ( global unsized 4-element array of float) 0:37 'gu' ( global runtime-sized array of float)
0:37 Constant: 0:37 Constant:
0:37 0 (const int) 0:37 0 (const int)
0:37 Constant: 0:37 Constant:
...@@ -264,8 +266,14 @@ ERROR: node is still EOpNull! ...@@ -264,8 +266,14 @@ ERROR: node is still EOpNull!
0:106 'b' ( global float) 0:106 'b' ( global float)
0:106 Constant: 0:106 Constant:
0:106 0.000000 0:106 0.000000
0:109 Function Definition: foo4( ( global void)
0:109 Function Parameters:
0:111 Sequence
0:111 indirect index ( temp sampler2D)
0:111 's2d' ( uniform runtime-sized array of sampler2D)
0:111 'a' ( uniform int)
0:? Linker Objects 0:? Linker Objects
0:? 'gu' ( global unsized 4-element array of float) 0:? 'gu' ( global runtime-sized array of float)
0:? 'g4' ( global 4-element array of float) 0:? 'g4' ( global 4-element array of float)
0:? 'g5' ( global 5-element array of float) 0:? 'g5' ( global 5-element array of float)
0:? 'a' ( uniform int) 0:? 'a' ( uniform int)
...@@ -275,6 +283,7 @@ ERROR: node is still EOpNull! ...@@ -275,6 +283,7 @@ ERROR: node is still EOpNull!
0:? 'i' ( global unsized 1-element array of int) 0:? 'i' ( global unsized 1-element array of int)
0:? 'emptyA' ( global unsized 1-element array of float) 0:? 'emptyA' ( global unsized 1-element array of float)
0:? 'b' ( global float) 0:? 'b' ( global float)
0:? 's2d' ( uniform runtime-sized array of sampler2D)
Linked fragment stage: Linked fragment stage:
...@@ -320,21 +329,21 @@ ERROR: node is still EOpNull! ...@@ -320,21 +329,21 @@ ERROR: node is still EOpNull!
0:21 4.000000 0:21 4.000000
0:24 move second child to first child ( temp float) 0:24 move second child to first child ( temp float)
0:24 direct index ( temp float) 0:24 direct index ( temp float)
0:24 'gu' ( global 4-element array of float) 0:24 'gu' ( global runtime-sized array of float)
0:24 Constant: 0:24 Constant:
0:24 2 (const int) 0:24 2 (const int)
0:24 Constant: 0:24 Constant:
0:24 4.000000 0:24 4.000000
0:26 move second child to first child ( temp float) 0:26 move second child to first child ( temp float)
0:26 direct index ( temp float) 0:26 direct index ( temp float)
0:26 'gu' ( global 4-element array of float) 0:26 'gu' ( global runtime-sized array of float)
0:26 Constant: 0:26 Constant:
0:26 3 (const int) 0:26 3 (const int)
0:26 Constant: 0:26 Constant:
0:26 3.000000 0:26 3.000000
0:27 move second child to first child ( temp float) 0:27 move second child to first child ( temp float)
0:27 indirect index ( temp float) 0:27 indirect index ( temp float)
0:27 'gu' ( global 4-element array of float) 0:27 'gu' ( global runtime-sized array of float)
0:27 'a' ( uniform int) 0:27 'a' ( uniform int)
0:27 Constant: 0:27 Constant:
0:27 5.000000 0:27 5.000000
...@@ -343,7 +352,7 @@ ERROR: node is still EOpNull! ...@@ -343,7 +352,7 @@ ERROR: node is still EOpNull!
0:29 Function Call: foo(f1[5]; ( global 4-element array of float) 0:29 Function Call: foo(f1[5]; ( global 4-element array of float)
0:29 'g5' ( global 5-element array of float) 0:29 'g5' ( global 5-element array of float)
0:30 'g5' ( global 5-element array of float) 0:30 'g5' ( global 5-element array of float)
0:31 'gu' ( global 4-element array of float) 0:31 'gu' ( global runtime-sized array of float)
0:33 Constant: 0:33 Constant:
0:33 0.000000 0:33 0.000000
0:34 Function Call: bar(f1[5]; ( global void) 0:34 Function Call: bar(f1[5]; ( global void)
...@@ -360,7 +369,7 @@ ERROR: node is still EOpNull! ...@@ -360,7 +369,7 @@ ERROR: node is still EOpNull!
0:36 true case 0:36 true case
0:37 move second child to first child ( temp float) 0:37 move second child to first child ( temp float)
0:37 direct index ( temp float) 0:37 direct index ( temp float)
0:37 'gu' ( global 4-element array of float) 0:37 'gu' ( global runtime-sized array of float)
0:37 Constant: 0:37 Constant:
0:37 0 (const int) 0:37 0 (const int)
0:37 Constant: 0:37 Constant:
...@@ -452,7 +461,7 @@ ERROR: node is still EOpNull! ...@@ -452,7 +461,7 @@ ERROR: node is still EOpNull!
0:106 Constant: 0:106 Constant:
0:106 0.000000 0:106 0.000000
0:? Linker Objects 0:? Linker Objects
0:? 'gu' ( global 4-element array of float) 0:? 'gu' ( global runtime-sized array of float)
0:? 'g4' ( global 4-element array of float) 0:? 'g4' ( global 4-element array of float)
0:? 'g5' ( global 5-element array of float) 0:? 'g5' ( global 5-element array of float)
0:? 'a' ( uniform int) 0:? 'a' ( uniform int)
...@@ -462,4 +471,5 @@ ERROR: node is still EOpNull! ...@@ -462,4 +471,5 @@ ERROR: node is still EOpNull!
0:? 'i' ( global 1-element array of int) 0:? 'i' ( global 1-element array of int)
0:? 'emptyA' ( global 1-element array of float) 0:? 'emptyA' ( global 1-element array of float)
0:? 'b' ( global float) 0:? 'b' ( global float)
0:? 's2d' ( uniform runtime-sized array of sampler2D)
...@@ -470,7 +470,7 @@ public: ...@@ -470,7 +470,7 @@ public:
// Drop just the storage qualification, which perhaps should // Drop just the storage qualification, which perhaps should
// never be done, as it is fundamentally inconsistent, but need to // never be done, as it is fundamentally inconsistent, but need to
// explore what downstream consumers need. // explore what downstream consumers need.
// E.g., in a deference, it is an inconsistency between: // E.g., in a dereference, it is an inconsistency between:
// A) partially dereferenced resource is still in the storage class it started in // A) partially dereferenced resource is still in the storage class it started in
// B) partially dereferenced resource is a new temporary object // B) partially dereferenced resource is a new temporary object
// If A, then nothing should change, if B, then everything should change, but this is half way. // If A, then nothing should change, if B, then everything should change, but this is half way.
...@@ -1354,9 +1354,11 @@ public: ...@@ -1354,9 +1354,11 @@ public:
virtual bool isVector() const { return vectorSize > 1 || vector1; } virtual bool isVector() const { return vectorSize > 1 || vector1; }
virtual bool isMatrix() const { return matrixCols ? true : false; } virtual bool isMatrix() const { return matrixCols ? true : false; }
virtual bool isArray() const { return arraySizes != nullptr; } virtual bool isArray() const { return arraySizes != nullptr; }
virtual bool isExplicitlySizedArray() const { return isArray() && getOuterArraySize() != UnsizedArraySize; } virtual bool isSizedArray() const { return isArray() && arraySizes->isSized(); }
virtual bool isImplicitlySizedArray() const { return isArray() && getOuterArraySize() == UnsizedArraySize && qualifier.storage != EvqBuffer; } virtual bool isUnsizedArray() const { return isArray() && !arraySizes->isSized(); }
virtual bool isRuntimeSizedArray() const { return isArray() && getOuterArraySize() == UnsizedArraySize && qualifier.storage == EvqBuffer; } virtual bool isArrayVariablyIndexed() const { assert(isArray()); return arraySizes->isVariablyIndexed(); }
virtual void setArrayVariablyIndexed() { assert(isArray()); arraySizes->setVariablyIndexed(); }
virtual void updateImplicitArraySize(int size) { assert(isArray()); arraySizes->updateImplicitSize(size); }
virtual bool isStruct() const { return structure != nullptr; } virtual bool isStruct() const { return structure != nullptr; }
virtual bool isFloatingDomain() const { return basicType == EbtFloat || basicType == EbtDouble || basicType == EbtFloat16; } virtual bool isFloatingDomain() const { return basicType == EbtFloat || basicType == EbtDouble || basicType == EbtFloat16; }
virtual bool isIntegerDomain() const virtual bool isIntegerDomain() const
...@@ -1414,10 +1416,10 @@ public: ...@@ -1414,10 +1416,10 @@ public:
return contains([this](const TType* t) { return t != this && t->isStruct(); } ); return contains([this](const TType* t) { return t != this && t->isStruct(); } );
} }
// Recursively check the structure for any implicitly-sized arrays, needed for triggering a copyUp(). // Recursively check the structure for any unsized arrays, needed for triggering a copyUp().
virtual bool containsImplicitlySizedArray() const virtual bool containsUnsizedArray() const
{ {
return contains([](const TType* t) { return t->isImplicitlySizedArray(); } ); return contains([](const TType* t) { return t->isUnsizedArray(); } );
} }
virtual bool containsOpaque() const virtual bool containsOpaque() const
...@@ -1510,16 +1512,22 @@ public: ...@@ -1510,16 +1512,22 @@ public:
} }
} }
void changeOuterArraySize(int s) { arraySizes->changeOuterSize(s); } void changeOuterArraySize(int s) { arraySizes->changeOuterSize(s); }
void setImplicitArraySize(int s) { arraySizes->setImplicitSize(s); }
// Recursively make the implicit array size the explicit array size, through the type tree. // Recursively make the implicit array size the explicit array size.
void adoptImplicitArraySizes() // Expicit arrays are compile-time or link-time sized, never run-time sized.
// Sometimes, policy calls for an array to be run-time sized even if it was
// never variably indexed: Don't turn a 'skipNonvariablyIndexed' array into
// an explicit array.
void adoptImplicitArraySizes(bool skipNonvariablyIndexed)
{ {
if (isImplicitlySizedArray()) if (isUnsizedArray() && !(skipNonvariablyIndexed || isArrayVariablyIndexed()))
changeOuterArraySize(getImplicitArraySize()); changeOuterArraySize(getImplicitArraySize());
if (isStruct()) { if (isStruct() && structure->size() > 0) {
for (int i = 0; i < (int)structure->size(); ++i) int lastMember = (int)structure->size() - 1;
(*structure)[i].type->adoptImplicitArraySizes(); for (int i = 0; i < lastMember; ++i)
(*structure)[i].type->adoptImplicitArraySizes(false);
// implement the "last member of an SSBO" policy
(*structure)[lastMember].type->adoptImplicitArraySizes(getQualifier().storage == EvqBuffer);
} }
} }
...@@ -1686,17 +1694,21 @@ public: ...@@ -1686,17 +1694,21 @@ public:
if (isArray()) { if (isArray()) {
for(int i = 0; i < (int)arraySizes->getNumDims(); ++i) { for(int i = 0; i < (int)arraySizes->getNumDims(); ++i) {
int size = arraySizes->getDimSize(i); int size = arraySizes->getDimSize(i);
if (size == UnsizedArraySize) { if (size == UnsizedArraySize && i == 0 && arraySizes->isVariablyIndexed())
appendStr(" unsized"); appendStr(" runtime-sized array of");
if (i == 0) { else {
if (size == UnsizedArraySize) {
appendStr(" unsized");
if (i == 0) {
appendStr(" ");
appendInt(arraySizes->getImplicitSize());
}
} else {
appendStr(" "); appendStr(" ");
appendInt(arraySizes->getImplicitSize()); appendInt(arraySizes->getDimSize(i));
} }
} else { appendStr("-element array of");
appendStr(" ");
appendInt(arraySizes->getDimSize(i));
} }
appendStr("-element array of");
} }
} }
if (qualifier.precision != EpqNone) { if (qualifier.precision != EpqNone) {
......
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
#ifndef _ARRAYS_INCLUDED #ifndef _ARRAYS_INCLUDED
#define _ARRAYS_INCLUDED #define _ARRAYS_INCLUDED
#include <algorithm>
namespace glslang { namespace glslang {
// This is used to mean there is no size yet (unsized), it is waiting to get a size from somewhere else. // This is used to mean there is no size yet (unsized), it is waiting to get a size from somewhere else.
...@@ -220,12 +222,13 @@ protected: ...@@ -220,12 +222,13 @@ protected:
struct TArraySizes { struct TArraySizes {
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator()) POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
TArraySizes() : implicitArraySize(1) { } TArraySizes() : implicitArraySize(1), variablyIndexed(false) { }
// For breaking into two non-shared copies, independently modifiable. // For breaking into two non-shared copies, independently modifiable.
TArraySizes& operator=(const TArraySizes& from) TArraySizes& operator=(const TArraySizes& from)
{ {
implicitArraySize = from.implicitArraySize; implicitArraySize = from.implicitArraySize;
variablyIndexed = from.variablyIndexed;
sizes = from.sizes; sizes = from.sizes;
return *this; return *this;
...@@ -254,9 +257,9 @@ struct TArraySizes { ...@@ -254,9 +257,9 @@ struct TArraySizes {
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 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 implicitArraySize; }
void setImplicitSize(int s) { implicitArraySize = s; } void updateImplicitSize(int s) { implicitArraySize = std::max(implicitArraySize, s); }
bool isInnerImplicit() const bool isInnerUnsized() const
{ {
for (int d = 1; d < sizes.size(); ++d) { for (int d = 1; d < sizes.size(); ++d) {
if (sizes.getDimSize(d) == (unsigned)UnsizedArraySize) if (sizes.getDimSize(d) == (unsigned)UnsizedArraySize)
...@@ -265,7 +268,7 @@ struct TArraySizes { ...@@ -265,7 +268,7 @@ struct TArraySizes {
return false; return false;
} }
bool clearInnerImplicit() bool clearInnerUnsized()
{ {
for (int d = 1; d < sizes.size(); ++d) { for (int d = 1; d < sizes.size(); ++d) {
if (sizes.getDimSize(d) == (unsigned)UnsizedArraySize) if (sizes.getDimSize(d) == (unsigned)UnsizedArraySize)
...@@ -288,7 +291,8 @@ struct TArraySizes { ...@@ -288,7 +291,8 @@ struct TArraySizes {
return sizes.getDimNode(0) != nullptr; return sizes.getDimNode(0) != nullptr;
} }
bool isImplicit() const { return getOuterSize() == UnsizedArraySize || isInnerImplicit(); } bool hasUnsized() const { return getOuterSize() == UnsizedArraySize || isInnerUnsized(); }
bool isSized() const { return getOuterSize() != UnsizedArraySize; }
void dereference() { sizes.pop_front(); } void dereference() { sizes.pop_front(); }
void copyDereferenced(const TArraySizes& rhs) void copyDereferenced(const TArraySizes& rhs)
{ {
...@@ -311,6 +315,9 @@ struct TArraySizes { ...@@ -311,6 +315,9 @@ struct TArraySizes {
return true; return true;
} }
void setVariablyIndexed() { variablyIndexed = true; }
bool isVariablyIndexed() const { return variablyIndexed; }
bool operator==(const TArraySizes& rhs) { return sizes == rhs.sizes; } bool operator==(const TArraySizes& rhs) { return sizes == rhs.sizes; }
bool operator!=(const TArraySizes& rhs) { return sizes != rhs.sizes; } bool operator!=(const TArraySizes& rhs) { return sizes != rhs.sizes; }
...@@ -319,9 +326,12 @@ protected: ...@@ -319,9 +326,12 @@ protected:
TArraySizes(const TArraySizes&); TArraySizes(const TArraySizes&);
// for tracking maximum referenced index, before an explicit size is given // For tracking maximum referenced compile-time constant index.
// applies only to the outer-most dimension // Applies only to the outer-most dimension. Potentially becomes
// the implicit size of the array, if not variably indexed and
// otherwise legal.
int implicitArraySize; int implicitArraySize;
bool variablyIndexed; // true if array is indexed with a non compile-time constant
}; };
} // end namespace glslang } // end namespace glslang
......
...@@ -729,7 +729,11 @@ enum TOperator { ...@@ -729,7 +729,11 @@ enum TOperator {
// Array operators // Array operators
// //
EOpArrayLength, // "Array" distinguishes from length(v) built-in function, but it applies to vectors and matrices as well. // Can apply to arrays, vectors, or matrices.
// Can be decomposed to a constant at compile time, but this does not always happen,
// due to link-time effects. So, consumer can expect either a link-time sized or
// run-time sized array.
EOpArrayLength,
// //
// Image operations // Image operations
......
...@@ -243,7 +243,7 @@ void TParseContextBase::checkIndex(const TSourceLoc& loc, const TType& type, int ...@@ -243,7 +243,7 @@ void TParseContextBase::checkIndex(const TSourceLoc& loc, const TType& type, int
error(loc, "", "[", "index out of range '%d'", index); error(loc, "", "[", "index out of range '%d'", index);
index = 0; index = 0;
} else if (type.isArray()) { } else if (type.isArray()) {
if (type.isExplicitlySizedArray() && index >= type.getOuterArraySize()) { if (type.isSizedArray() && index >= type.getOuterArraySize()) {
error(loc, "", "[", "array index out of range '%d'", index); error(loc, "", "[", "array index out of range '%d'", index);
index = type.getOuterArraySize() - 1; index = type.getOuterArraySize() - 1;
} }
......
...@@ -348,6 +348,7 @@ public: ...@@ -348,6 +348,7 @@ public:
void samplerCheck(const TSourceLoc&, const TType&, const TString& identifier, TIntermTyped* initializer); void samplerCheck(const TSourceLoc&, const TType&, const TString& identifier, TIntermTyped* initializer);
void atomicUintCheck(const TSourceLoc&, const TType&, const TString& identifier); void atomicUintCheck(const TSourceLoc&, const TType&, const TString& identifier);
void transparentOpaqueCheck(const TSourceLoc&, const TType&, const TString& identifier); void transparentOpaqueCheck(const TSourceLoc&, const TType&, const TString& identifier);
void memberQualifierCheck(glslang::TPublicType&);
void globalQualifierFixCheck(const TSourceLoc&, TQualifier&); void globalQualifierFixCheck(const TSourceLoc&, TQualifier&);
void globalQualifierTypeCheck(const TSourceLoc&, const TQualifier&, const TPublicType&); void globalQualifierTypeCheck(const TSourceLoc&, const TQualifier&, const TPublicType&);
bool structQualifierErrorCheck(const TSourceLoc&, const TPublicType& pType); bool structQualifierErrorCheck(const TSourceLoc&, const TPublicType& pType);
...@@ -360,7 +361,7 @@ public: ...@@ -360,7 +361,7 @@ public:
bool containsFieldWithBasicType(const TType& type ,TBasicType basicType); bool containsFieldWithBasicType(const TType& type ,TBasicType basicType);
TSymbol* redeclareBuiltinVariable(const TSourceLoc&, const TString&, const TQualifier&, const TShaderQualifiers&); TSymbol* redeclareBuiltinVariable(const TSourceLoc&, const TString&, const TQualifier&, const TShaderQualifiers&);
void redeclareBuiltinBlock(const TSourceLoc&, TTypeList& typeList, const TString& blockName, const TString* instanceName, TArraySizes* arraySizes); void redeclareBuiltinBlock(const TSourceLoc&, TTypeList& typeList, const TString& blockName, const TString* instanceName, TArraySizes* arraySizes);
void paramCheckFix(const TSourceLoc&, const TStorageQualifier&, TType& type); void paramCheckFixStorage(const TSourceLoc&, const TStorageQualifier&, TType& type);
void paramCheckFix(const TSourceLoc&, const TQualifier&, TType& type); void paramCheckFix(const TSourceLoc&, const TQualifier&, TType& type);
void nestedBlockCheck(const TSourceLoc&); void nestedBlockCheck(const TSourceLoc&);
void nestedStructCheck(const TSourceLoc&); void nestedStructCheck(const TSourceLoc&);
...@@ -408,7 +409,6 @@ public: ...@@ -408,7 +409,6 @@ public:
void wrapupSwitchSubsequence(TIntermAggregate* statements, TIntermNode* branchNode); void wrapupSwitchSubsequence(TIntermAggregate* statements, TIntermNode* branchNode);
TIntermNode* addSwitch(const TSourceLoc&, TIntermTyped* expression, TIntermAggregate* body); TIntermNode* addSwitch(const TSourceLoc&, TIntermTyped* expression, TIntermAggregate* body);
void updateImplicitArraySize(const TSourceLoc&, TIntermNode*, int index);
TAttributeType attributeFromName(const TString& name) const; TAttributeType attributeFromName(const TString& name) const;
TAttributes* makeAttributes(const TString& identifier) const; TAttributes* makeAttributes(const TString& identifier) const;
TAttributes* makeAttributes(const TString& identifier, TIntermNode* node) const; TAttributes* makeAttributes(const TString& identifier, TIntermNode* node) const;
......
...@@ -968,7 +968,7 @@ parameter_declaration ...@@ -968,7 +968,7 @@ parameter_declaration
$$ = $1; $$ = $1;
parseContext.parameterTypeCheck($1.loc, EvqIn, *$1.param.type); parseContext.parameterTypeCheck($1.loc, EvqIn, *$1.param.type);
parseContext.paramCheckFix($1.loc, EvqTemporary, *$$.param.type); parseContext.paramCheckFixStorage($1.loc, EvqTemporary, *$$.param.type);
parseContext.precisionQualifierCheck($$.loc, $$.param.type->getBasicType(), $$.param.type->getQualifier()); parseContext.precisionQualifierCheck($$.loc, $$.param.type->getBasicType(), $$.param.type->getQualifier());
} }
// //
...@@ -988,7 +988,7 @@ parameter_declaration ...@@ -988,7 +988,7 @@ parameter_declaration
$$ = $1; $$ = $1;
parseContext.parameterTypeCheck($1.loc, EvqIn, *$1.param.type); parseContext.parameterTypeCheck($1.loc, EvqIn, *$1.param.type);
parseContext.paramCheckFix($1.loc, EvqTemporary, *$$.param.type); parseContext.paramCheckFixStorage($1.loc, EvqTemporary, *$$.param.type);
parseContext.precisionQualifierCheck($$.loc, $$.param.type->getBasicType(), $$.param.type->getQualifier()); parseContext.precisionQualifierCheck($$.loc, $$.param.type->getBasicType(), $$.param.type->getQualifier());
} }
; ;
...@@ -3121,7 +3121,6 @@ struct_declaration ...@@ -3121,7 +3121,6 @@ struct_declaration
} }
} }
| type_qualifier type_specifier struct_declarator_list SEMICOLON { | type_qualifier type_specifier struct_declarator_list SEMICOLON {
parseContext.globalQualifierFixCheck($1.loc, $1.qualifier);
if ($2.arraySizes) { if ($2.arraySizes) {
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");
...@@ -3131,7 +3130,7 @@ struct_declaration ...@@ -3131,7 +3130,7 @@ struct_declaration
$$ = $3; $$ = $3;
parseContext.checkNoShaderLayouts($1.loc, $1.shaderQualifiers); parseContext.memberQualifierCheck($1);
parseContext.voidErrorCheck($2.loc, (*$3)[0].type->getFieldName(), $2.basicType); parseContext.voidErrorCheck($2.loc, (*$3)[0].type->getFieldName(), $2.basicType);
parseContext.mergeQualifiers($2.loc, $2.qualifier, $1.qualifier, true); parseContext.mergeQualifiers($2.loc, $2.qualifier, $1.qualifier, true);
parseContext.precisionQualifierCheck($2.loc, $2.basicType, $2.qualifier); parseContext.precisionQualifierCheck($2.loc, $2.basicType, $2.qualifier);
......
...@@ -268,10 +268,12 @@ void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& lin ...@@ -268,10 +268,12 @@ void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& lin
// Recursively merge the implicit array sizes through the objects' respective type trees. // Recursively merge the implicit array sizes through the objects' respective type trees.
void TIntermediate::mergeImplicitArraySizes(TType& type, const TType& unitType) void TIntermediate::mergeImplicitArraySizes(TType& type, const TType& unitType)
{ {
if (type.isImplicitlySizedArray() && unitType.isArray()) { if (type.isUnsizedArray() && unitType.isArray()) {
int newImplicitArraySize = unitType.isImplicitlySizedArray() ? unitType.getImplicitArraySize() : unitType.getOuterArraySize(); int newImplicitArraySize = unitType.isSizedArray() ? unitType.getOuterArraySize() :
if (newImplicitArraySize > type.getImplicitArraySize ()) unitType.getImplicitArraySize();
type.setImplicitArraySize(newImplicitArraySize); type.updateImplicitArraySize(type.getImplicitArraySize());
if (unitType.isArrayVariablyIndexed())
type.setArrayVariablyIndexed();
} }
// Type mismatches are caught and reported after this, just be careful for now. // Type mismatches are caught and reported after this, just be careful for now.
...@@ -511,7 +513,9 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled) ...@@ -511,7 +513,9 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
virtual void visitSymbol(TIntermSymbol* symbol) virtual void visitSymbol(TIntermSymbol* symbol)
{ {
// Implicitly size arrays. // Implicitly size arrays.
symbol->getWritableType().adoptImplicitArraySizes(); // If an unsized array is left as unsized, it effectively
// becomes run-time sized.
symbol->getWritableType().adoptImplicitArraySizes(false);
} }
} finalLinkTraverser; } finalLinkTraverser;
...@@ -766,7 +770,7 @@ int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& typ ...@@ -766,7 +770,7 @@ int TIntermediate::addUsedLocation(const TQualifier& qualifier, const TType& typ
int size; int size;
if (qualifier.isUniformOrBuffer()) { if (qualifier.isUniformOrBuffer()) {
if (type.isExplicitlySizedArray()) if (type.isSizedArray())
size = type.getCumulativeArraySize(); size = type.getCumulativeArraySize();
else else
size = 1; size = 1;
...@@ -914,12 +918,12 @@ int TIntermediate::computeTypeLocationSize(const TType& type, EShLanguage stage) ...@@ -914,12 +918,12 @@ int TIntermediate::computeTypeLocationSize(const TType& type, EShLanguage stage)
// consecutive locations..." // consecutive locations..."
if (type.isArray()) { if (type.isArray()) {
// TODO: perf: this can be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness // TODO: perf: this can be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness
// TODO: are there valid cases of having an unsized array with a location? If so, running this code too early.
TType elementType(type, 0); TType elementType(type, 0);
if (type.isImplicitlySizedArray()) { if (type.isSizedArray())
// TODO: are there valid cases of having an implicitly-sized array with a location? If so, running this code too early.
return computeTypeLocationSize(elementType, stage);
} else
return type.getOuterArraySize() * computeTypeLocationSize(elementType, stage); return type.getOuterArraySize() * computeTypeLocationSize(elementType, stage);
else
return computeTypeLocationSize(elementType, stage);
} }
// "The locations consumed by block and structure members are determined by applying the rules above // "The locations consumed by block and structure members are determined by applying the rules above
...@@ -971,11 +975,12 @@ int TIntermediate::computeTypeUniformLocationSize(const TType& type) ...@@ -971,11 +975,12 @@ int TIntermediate::computeTypeUniformLocationSize(const TType& type)
if (type.isArray()) { if (type.isArray()) {
// TODO: perf: this can be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness // TODO: perf: this can be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness
TType elementType(type, 0); TType elementType(type, 0);
if (type.isImplicitlySizedArray()) { if (type.isSizedArray()) {
return type.getOuterArraySize() * computeTypeUniformLocationSize(elementType);
} else {
// TODO: are there valid cases of having an implicitly-sized array with a location? If so, running this code too early. // TODO: are there valid cases of having an implicitly-sized array with a location? If so, running this code too early.
return computeTypeUniformLocationSize(elementType); return computeTypeUniformLocationSize(elementType);
} else }
return type.getOuterArraySize() * computeTypeUniformLocationSize(elementType);
} }
// "Each subsequent inner-most member or element gets incremental // "Each subsequent inner-most member or element gets incremental
...@@ -1036,7 +1041,7 @@ unsigned int TIntermediate::computeTypeXfbSize(const TType& type, bool& contains ...@@ -1036,7 +1041,7 @@ unsigned int TIntermediate::computeTypeXfbSize(const TType& type, bool& contains
if (type.isArray()) { if (type.isArray()) {
// TODO: perf: this can be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness // TODO: perf: this can be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness
assert(type.isExplicitlySizedArray()); assert(type.isSizedArray());
TType elementType(type, 0); TType elementType(type, 0);
return type.getOuterArraySize() * computeTypeXfbSize(elementType, containsDouble); return type.getOuterArraySize() * computeTypeXfbSize(elementType, containsDouble);
} }
......
...@@ -2569,8 +2569,8 @@ bool HlslGrammar::acceptParameterDeclaration(TFunction& function) ...@@ -2569,8 +2569,8 @@ bool HlslGrammar::acceptParameterDeclaration(TFunction& function)
TArraySizes* arraySizes = nullptr; TArraySizes* arraySizes = nullptr;
acceptArraySpecifier(arraySizes); acceptArraySpecifier(arraySizes);
if (arraySizes) { if (arraySizes) {
if (arraySizes->isImplicit()) { if (arraySizes->hasUnsized()) {
parseContext.error(token.loc, "function parameter array cannot be implicitly sized", "", ""); parseContext.error(token.loc, "function parameter requires array size", "[]", "");
return false; return false;
} }
......
...@@ -164,8 +164,6 @@ public: ...@@ -164,8 +164,6 @@ public:
void wrapupSwitchSubsequence(TIntermAggregate* statements, TIntermNode* branchNode); void wrapupSwitchSubsequence(TIntermAggregate* statements, TIntermNode* branchNode);
TIntermNode* addSwitch(const TSourceLoc&, TIntermTyped* expression, TIntermAggregate* body, const TAttributes&); TIntermNode* addSwitch(const TSourceLoc&, TIntermTyped* expression, TIntermAggregate* body, const TAttributes&);
void updateImplicitArraySize(const TSourceLoc&, TIntermNode*, int index);
void nestLooping() { ++loopNestingLevel; } void nestLooping() { ++loopNestingLevel; }
void unnestLooping() { --loopNestingLevel; } void unnestLooping() { --loopNestingLevel; }
void nestAnnotations() { ++annotationNestingLevel; } void nestAnnotations() { ++annotationNestingLevel; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment