420Pack: Implement length() on vectors and matrices. Also, tweak line-continuation semantics to understand the extension.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@26601 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2014-05-10 22:24:50 +00:00
parent 7c257eb108
commit 0b9e112da6
14 changed files with 286 additions and 134 deletions

View File

@ -117,6 +117,9 @@ void bar235()
c = textureGrad(Isca, i, vec3(0.1), vec3(0.2));
}
int \
x; // ERROR until 420pack is turned on
#extension GL_ARB_shading_language_420pack : enable
const int ai[3] = { 10, 23, 32 };
@ -125,11 +128,19 @@ uniform layout(binding=0) sampler2D bounds;
void bar23444()
{
mat4x3 m43;
mat4x3 m43; \
float a1 = m43[3].y;
int a2 = m43.length(); // ERROR until shading_language_420pack is fully implemented
vec3 v3;
int a2 = m43.length();
a2 += m43[1].length();
a2 += v3.length();
const float b = 2 * a1;
a.x = gl_MinProgramTexelOffset + gl_MaxProgramTexelOffset; // ERROR until shading_language_420pack is fully implemented
a.x = gl_MinProgramTexelOffset + gl_MaxProgramTexelOffset;
bool boolb;
boolb.length(); // ERROR
m43[3][1].length(); // ERROR
v3.length; // ERROR
v3.length(b); // ERROR
}
in float gl_FogFragCoord;

View File

@ -83,4 +83,16 @@ out gl_PerVertex {
};
patch in vec4 patchIn; // ERROR
patch out vec4 patchOut; // ERROR
patch out vec4 patchOut; // ERROR
void bar23444()
{
mat4x3 m43; \
float a1 = m43[3].y;
vec3 v3;
int a2 = m43.length();
a2 += m43[1].length();
a2 += v3.length();
const float b = 2 * a1;
int a = gl_MinProgramTexelOffset + gl_MaxProgramTexelOffset;
}

View File

@ -11,9 +11,9 @@ ERROR: 0:21: 'assign' : l-value required (can't modify a const)
ERROR: 0:28: 'length' : array must be declared with a size before using this method
ERROR: 0:31: 'length' : incomplete method syntax
ERROR: 0:32: 'length' : method does not accept any arguments
ERROR: 0:33: 'flizbit' : only the length method is supported for array
ERROR: 0:33: 'flizbit' : does not apply to this type: 7-element array of float
ERROR: 0:33: '=' : cannot convert from '7-element array of float' to 'int'
ERROR: 0:34: 'flizbit' : only the length method is supported for array
ERROR: 0:34: 'flizbit' : does not apply to this type: 7-element array of float
ERROR: 0:34: 'f' : can't use function syntax on variable
ERROR: 0:34: 'a4' : redefinition
ERROR: 0:35: 'arrays of arrays' : not supported with this profile: none
@ -123,7 +123,7 @@ ERROR: node is still EOpNull!
0:32 move second child to first child (int)
0:32 'a3' (int)
0:32 Constant:
0:32 12 (const int)
0:32 1 (const int)
0:43 move second child to first child (float)
0:43 'gl_PointSize' (invariant gl_PointSize float)
0:43 Constant:
@ -442,7 +442,7 @@ ERROR: node is still EOpNull!
0:32 move second child to first child (int)
0:32 'a3' (int)
0:32 Constant:
0:32 12 (const int)
0:32 1 (const int)
0:43 move second child to first child (float)
0:43 'gl_PointSize' (invariant gl_PointSize float)
0:43 Constant:

View File

@ -13,17 +13,22 @@ ERROR: 0:81: 'textureGatherOffset(...)' : not supported for this version or the
ERROR: 0:84: 'textureGatherOffset(...)' : not supported for this version or the enabled extensions
ERROR: 0:85: 'textureGatherOffset(...)' : not supported for this version or the enabled extensions
WARNING: 0:88: '#extension' : extension is only partially supported: GL_ARB_gpu_shader5
WARNING: 0:120: '#extension' : extension is only partially supported: GL_ARB_shading_language_420pack
ERROR: 0:123: 'uniform block' : not supported for this version or the enabled extensions
ERROR: 0:130: '.' : field selection not allowed on matrix
ERROR: 0:130: 'm43' : can't use function syntax on variable
ERROR: 0:130: '=' : cannot convert from 'const float' to 'int'
ERROR: 0:132: 'gl_MinProgramTexelOffset' : undeclared identifier
ERROR: 0:132: 'gl_MaxProgramTexelOffset' : undeclared identifier
ERROR: 0:135: 'gl_FogFragCoord' : identifiers starting with "gl_" are reserved
ERROR: 0:140: 'int' : must be qualified as flat in
ERROR: 0:140: 'redeclaration' : cannot change the type of gl_FogFragCoord
ERROR: 21 compilation errors. No code generated.
ERROR: 0:120: 'line continuation' : not supported for this version or the enabled extensions
WARNING: 0:123: '#extension' : extension is only partially supported: GL_ARB_shading_language_420pack
ERROR: 0:126: 'uniform block' : not supported for this version or the enabled extensions
ERROR: 0:138: 'gl_MinProgramTexelOffset' : undeclared identifier
ERROR: 0:138: 'gl_MaxProgramTexelOffset' : undeclared identifier
ERROR: 0:140: 'length' : does not operate on this type: bool
ERROR: 0:140: 'boolb' : can't use function syntax on variable
ERROR: 0:141: 'length' : does not operate on this type: float
ERROR: 0:141: '' : function call, method, or subroutine call expected
ERROR: 0:141: '' : no matching overloaded function found
ERROR: 0:142: 'length' : incomplete method syntax
ERROR: 0:143: 'length' : method does not accept any arguments
ERROR: 0:146: 'gl_FogFragCoord' : identifiers starting with "gl_" are reserved
ERROR: 0:151: 'int' : must be qualified as flat in
ERROR: 0:151: 'redeclaration' : cannot change the type of gl_FogFragCoord
ERROR: 26 compilation errors. No code generated.
Shader version: 130
@ -300,34 +305,53 @@ ERROR: node is still EOpNull!
0:117 0.200000
0:117 0.200000
0:117 0.200000
0:126 Function Definition: bar23444( (void)
0:126 Function Parameters:
0:129 Function Definition: bar23444( (void)
0:129 Function Parameters:
0:? Sequence
0:129 Sequence
0:129 move second child to first child (float)
0:129 'a1' (float)
0:129 direct index (float)
0:129 direct index (3-component vector of float)
0:129 'm43' (4X3 matrix of float)
0:129 Constant:
0:129 3 (const int)
0:129 Constant:
0:129 1 (const int)
0:131 Sequence
0:131 move second child to first child (float)
0:131 'b' (const (read only) float)
0:131 component-wise multiply (float)
0:131 Constant:
0:131 2.000000
0:131 'a1' (float)
0:132 move second child to first child (float)
0:132 direct index (float)
0:132 'a' (3-component vector of float)
0:132 Constant:
0:132 0 (const int)
0:132 add (float)
0:132 'gl_MinProgramTexelOffset' (float)
0:132 'gl_MaxProgramTexelOffset' (float)
0:132 Sequence
0:132 move second child to first child (float)
0:132 'a1' (float)
0:132 direct index (float)
0:132 direct index (3-component vector of float)
0:132 'm43' (4X3 matrix of float)
0:132 Constant:
0:132 3 (const int)
0:132 Constant:
0:132 1 (const int)
0:134 Sequence
0:134 move second child to first child (int)
0:134 'a2' (int)
0:134 Constant:
0:134 4 (const int)
0:135 add second child into first child (int)
0:135 'a2' (int)
0:135 Constant:
0:135 3 (const int)
0:136 add second child into first child (int)
0:136 'a2' (int)
0:136 Constant:
0:136 3 (const int)
0:137 Sequence
0:137 move second child to first child (float)
0:137 'b' (const (read only) float)
0:137 component-wise multiply (float)
0:137 Constant:
0:137 2.000000
0:137 'a1' (float)
0:138 move second child to first child (float)
0:138 direct index (float)
0:138 'a' (3-component vector of float)
0:138 Constant:
0:138 0 (const int)
0:138 add (float)
0:138 'gl_MinProgramTexelOffset' (float)
0:138 'gl_MaxProgramTexelOffset' (float)
0:140 Constant:
0:140 0.000000
0:141 Constant:
0:141 0.000000
0:143 Constant:
0:143 1 (const int)
0:? Linker Objects
0:? 'a' (3-component vector of float)
0:? 'b' (float)
@ -349,6 +373,7 @@ ERROR: node is still EOpNull!
0:? 'Isca' (uniform isamplerCubeArray)
0:? 'Usca' (uniform usamplerCubeArray)
0:? 'Scas' (uniform samplerCubeArrayShadow)
0:? 'x' (int)
0:? 'ai' (const 3-element array of int)
0:? 10 (const int)
0:? 23 (const int)
@ -635,34 +660,53 @@ ERROR: node is still EOpNull!
0:117 0.200000
0:117 0.200000
0:117 0.200000
0:126 Function Definition: bar23444( (void)
0:126 Function Parameters:
0:129 Function Definition: bar23444( (void)
0:129 Function Parameters:
0:? Sequence
0:129 Sequence
0:129 move second child to first child (float)
0:129 'a1' (float)
0:129 direct index (float)
0:129 direct index (3-component vector of float)
0:129 'm43' (4X3 matrix of float)
0:129 Constant:
0:129 3 (const int)
0:129 Constant:
0:129 1 (const int)
0:131 Sequence
0:131 move second child to first child (float)
0:131 'b' (const (read only) float)
0:131 component-wise multiply (float)
0:131 Constant:
0:131 2.000000
0:131 'a1' (float)
0:132 move second child to first child (float)
0:132 direct index (float)
0:132 'a' (3-component vector of float)
0:132 Constant:
0:132 0 (const int)
0:132 add (float)
0:132 'gl_MinProgramTexelOffset' (float)
0:132 'gl_MaxProgramTexelOffset' (float)
0:132 Sequence
0:132 move second child to first child (float)
0:132 'a1' (float)
0:132 direct index (float)
0:132 direct index (3-component vector of float)
0:132 'm43' (4X3 matrix of float)
0:132 Constant:
0:132 3 (const int)
0:132 Constant:
0:132 1 (const int)
0:134 Sequence
0:134 move second child to first child (int)
0:134 'a2' (int)
0:134 Constant:
0:134 4 (const int)
0:135 add second child into first child (int)
0:135 'a2' (int)
0:135 Constant:
0:135 3 (const int)
0:136 add second child into first child (int)
0:136 'a2' (int)
0:136 Constant:
0:136 3 (const int)
0:137 Sequence
0:137 move second child to first child (float)
0:137 'b' (const (read only) float)
0:137 component-wise multiply (float)
0:137 Constant:
0:137 2.000000
0:137 'a1' (float)
0:138 move second child to first child (float)
0:138 direct index (float)
0:138 'a' (3-component vector of float)
0:138 Constant:
0:138 0 (const int)
0:138 add (float)
0:138 'gl_MinProgramTexelOffset' (float)
0:138 'gl_MaxProgramTexelOffset' (float)
0:140 Constant:
0:140 0.000000
0:141 Constant:
0:141 0.000000
0:143 Constant:
0:143 1 (const int)
0:? Linker Objects
0:? 'a' (3-component vector of float)
0:? 'b' (float)
@ -684,6 +728,7 @@ ERROR: node is still EOpNull!
0:? 'Isca' (uniform isamplerCubeArray)
0:? 'Usca' (uniform usamplerCubeArray)
0:? 'Scas' (uniform samplerCubeArrayShadow)
0:? 'x' (int)
0:? 'ai' (const 3-element array of int)
0:? 10 (const int)
0:? 23 (const int)

View File

@ -533,7 +533,7 @@ Warning, version 400 is not yet complete; most version-specific features are pre
ERROR: 0:7: 'vertices' : inconsistent output number of vertices for array size of gl_out
ERROR: 0:11: 'vertices' : inconsistent output number of vertices for array size of a
ERROR: 0:12: 'vertices' : inconsistent output number of vertices for array size of outb
ERROR: 0:26: 'gl_PointSize' : no such field in structure
ERROR: 0:26: 'gl_PointSize' : no such field in structure
ERROR: 0:26: 'assign' : cannot convert from 'float' to 'block{out 4-component vector of float gl_Position}'
ERROR: 0:29: 'out' : type must be an array: outf
ERROR: 6 compilation errors. No code generated.

View File

@ -3,7 +3,7 @@ Warning, version 410 is not yet complete; most version-specific features are pre
ERROR: 0:8: 'myIn' : cannot redeclare a built-in block with a user name
ERROR: 0:12: 'gl_myIn' : no declaration found for redeclaration
ERROR: 0:20: 'gl_PerVertex' : can only redeclare a built-in block once, and before any use
ERROR: 0:32: 'gl_Position' : no such field in structure
ERROR: 0:32: 'gl_Position' : no such field in structure
ERROR: 0:32: '=' : cannot convert from 'block{in float gl_PointSize}' to '4-component vector of float'
ERROR: 0:33: 'gl_Position' : member of nameless block was not redeclared
ERROR: 0:33: 'assign' : cannot convert from 'const 4-component vector of float' to 'layout(stream=0 ) gl_Position void'

View File

@ -3,7 +3,7 @@ Warning, version 400 is not yet complete; most version-specific features are pre
ERROR: 0:7: 'vertices' : inconsistent output number of vertices for array size of gl_out
ERROR: 0:11: 'vertices' : inconsistent output number of vertices for array size of a
ERROR: 0:12: 'vertices' : inconsistent output number of vertices for array size of outb
ERROR: 0:26: 'gl_PointSize' : no such field in structure
ERROR: 0:26: 'gl_PointSize' : no such field in structure
ERROR: 0:26: 'assign' : cannot convert from 'float' to 'block{out 4-component vector of float gl_Position}'
ERROR: 0:29: 'out' : type must be an array: outf
ERROR: 6 compilation errors. No code generated.

View File

@ -31,7 +31,10 @@ ERROR: 0:76: 'binding' : sampler binding not less than gl_MaxCombinedTextureImag
ERROR: 0:85: 'patch' : not supported in this stage: vertex
ERROR: 0:85: '' : vertex input cannot be further qualified
ERROR: 0:86: 'patch' : not supported in this stage: vertex
ERROR: 30 compilation errors. No code generated.
ERROR: 0:97: 'gl_MinProgramTexelOffset' : undeclared identifier
ERROR: 0:97: 'gl_MaxProgramTexelOffset' : undeclared identifier
ERROR: 0:97: '=' : cannot convert from 'float' to 'int'
ERROR: 33 compilation errors. No code generated.
Shader version: 420
@ -105,6 +108,39 @@ ERROR: node is still EOpNull!
0:61 'f' (float)
0:62 'f' (float)
0:63 'f' (float)
0:88 Function Definition: bar23444( (void)
0:88 Function Parameters:
0:? Sequence
0:91 Sequence
0:91 move second child to first child (float)
0:91 'a1' (float)
0:91 direct index (float)
0:91 direct index (3-component vector of float)
0:91 'm43' (4X3 matrix of float)
0:91 Constant:
0:91 3 (const int)
0:91 Constant:
0:91 1 (const int)
0:93 Sequence
0:93 move second child to first child (int)
0:93 'a2' (int)
0:93 Constant:
0:93 4 (const int)
0:94 add second child into first child (int)
0:94 'a2' (int)
0:94 Constant:
0:94 3 (const int)
0:95 add second child into first child (int)
0:95 'a2' (int)
0:95 Constant:
0:95 3 (const int)
0:96 Sequence
0:96 move second child to first child (float)
0:96 'b' (const (read only) float)
0:96 component-wise multiply (float)
0:96 Constant:
0:96 2.000000
0:96 'a1' (float)
0:? Linker Objects
0:? 'v2' (smooth out 2-component vector of float)
0:? 'bad' (in 10-element array of 4-component vector of float)
@ -215,6 +251,39 @@ ERROR: node is still EOpNull!
0:61 'f' (float)
0:62 'f' (float)
0:63 'f' (float)
0:88 Function Definition: bar23444( (void)
0:88 Function Parameters:
0:? Sequence
0:91 Sequence
0:91 move second child to first child (float)
0:91 'a1' (float)
0:91 direct index (float)
0:91 direct index (3-component vector of float)
0:91 'm43' (4X3 matrix of float)
0:91 Constant:
0:91 3 (const int)
0:91 Constant:
0:91 1 (const int)
0:93 Sequence
0:93 move second child to first child (int)
0:93 'a2' (int)
0:93 Constant:
0:93 4 (const int)
0:94 add second child into first child (int)
0:94 'a2' (int)
0:94 Constant:
0:94 3 (const int)
0:95 add second child into first child (int)
0:95 'a2' (int)
0:95 Constant:
0:95 3 (const int)
0:96 Sequence
0:96 move second child to first child (float)
0:96 'b' (const (read only) float)
0:96 component-wise multiply (float)
0:96 Constant:
0:96 2.000000
0:96 'a1' (float)
0:? Linker Objects
0:? 'v2' (smooth out 2-component vector of float)
0:? 'bad' (in 10-element array of 4-component vector of float)

View File

@ -3,7 +3,7 @@ ERROR: 0:10: 'constructor' : too many arguments
ERROR: 0:7: 'const' : non-matching or non-convertible constant type for const initializer
ERROR: 0:17: 'assign' : cannot convert from '2-component vector of float' to '3-component vector of float'
ERROR: 0:18: 'assign' : cannot convert from '2-component vector of float' to '3-component vector of float'
ERROR: 0:19: '.' : field selection not allowed on matrix
ERROR: 0:19: 'xy' : does not apply to this type: 2X3 matrix of float
ERROR: 0:21: '[' : matrix index out of range '2'
ERROR: 0:21: '[' : vector index out of range '4'
ERROR: 7 compilation errors. No code generated.

View File

@ -27,21 +27,18 @@ ERROR: 0:150: '=' : cannot convert from 'const float' to '3-element array of 4-
ERROR: 0:152: 'constructor' : cannot convert parameter 1 from 'const 2-element array of 4-component vector of float' to '4-component vector of float'
ERROR: 0:172: 'x' : undeclared identifier
ERROR: 0:172: '[]' : scalar integer expression required
ERROR: 0:172: 'length' : illegal vector field selection
ERROR: 0:172: '' : function call, method, or subroutine call expected
ERROR: 0:172: '' : no matching overloaded function found
ERROR: 0:175: 'x' : undeclared identifier
ERROR: 0:175: '[]' : scalar integer expression required
ERROR: 0:175: 'b' : left of '[' is not of type array, matrix, or vector
ERROR: 0:175: 'a' : vector field selection out of range
ERROR: 0:175: 'length' : illegal vector field selection
ERROR: 0:175: 'length' : does not operate on this type: const float
ERROR: 0:175: '' : function call, method, or subroutine call expected
ERROR: 0:175: '' : no matching overloaded function found
ERROR: 0:178: '[]' : scalar integer expression required
ERROR: 0:178: 's' : undeclared identifier
ERROR: 0:178: 's' : left of '[' is not of type array, matrix, or vector
ERROR: 0:178: 'a' : vector field selection out of range
ERROR: 0:178: 'length' : illegal vector field selection
ERROR: 0:178: 'length' : does not operate on this type: const float
ERROR: 0:178: '' : function call, method, or subroutine call expected
ERROR: 0:178: '' : no matching overloaded function found
ERROR: 0:198: 'e' : redefinition
@ -49,7 +46,7 @@ ERROR: 0:226: 'in' : not allowed in nested scope
ERROR: 0:227: 'in' : not allowed in nested scope
ERROR: 0:228: 'in' : not allowed in nested scope
ERROR: 0:232: 'out' : not allowed in nested scope
ERROR: 49 compilation errors. No code generated.
ERROR: 46 compilation errors. No code generated.
Shader version: 430
@ -196,7 +193,7 @@ ERROR: node is still EOpNull!
0:171 Constant:
0:171 3 (const int)
0:172 Constant:
0:172 0.000000
0:172 4 (const int)
0:175 Constant:
0:175 0.000000
0:178 Constant:
@ -448,7 +445,7 @@ ERROR: node is still EOpNull!
0:171 Constant:
0:171 3 (const int)
0:172 Constant:
0:172 0.000000
0:172 4 (const int)
0:175 Constant:
0:175 0.000000
0:178 Constant:

View File

@ -172,7 +172,7 @@ Shader Functionality to Implement/Finish
- qualifiers can act independently on the opaque shader variable and the backing image, so extra qualifiers can be used to separately qualify these
+ Variables declared in if and else statements are scoped only to the end of those statements, especially for non-compound statements
Note, this is not backward compatible, it may depend on #version.
- Allow implicit conversions of return values to the declared type of the function.
+ Allow implicit conversions of return values to the declared type of the function.
+ The const keyword can be used to declare variables within a function body with initializer expressions that are not constant expressions.
+ Qualifiers on variable declarations no longer have to follow a strict order. The layout qualifier can be used multiple times, and multiple parameter qualifiers can be used.
+ Parameter qualifiers can include precision and memory qualifiers.
@ -184,7 +184,7 @@ Shader Functionality to Implement/Finish
- packSnorm2x16and unpackSnorm2x16
- Add gl_FragDepth layout qualifiers to communicate what kind of changes will be made to gl_FragDepth (GL_AMD_conservative depth).
+ Add C-style curly brace initializer lists syntax for initializers. Full initialization of aggregates is required when these are used.
- Allow .length() to be applied to vectors and matrices, returning the number of components or columns.
+ Allow .length() to be applied to vectors and matrices, returning the number of components or columns.
+ Clarify that .length() returns an int type and can be used as a constant integer expression.
+ Allow swizzle operations on scalars.
+ Positive signed decimal literals, as well as octal and hexadecimal, can set all 32 bits. This includes setting the sign bit to create a negative value.

View File

@ -312,7 +312,7 @@ enum TOperator {
// Array operators
//
EOpArrayLength,
EOpArrayLength, // "Array" distinguishes from length(v) built-in function, but it applies to vectors and matrices as well.
};
class TIntermTraverser;

View File

@ -669,22 +669,32 @@ void TParseContext::checkIoArrayConsistency(TSourceLoc loc, int requiredSize, co
//
TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped* base, TString& field)
{
TIntermTyped* result = base;
variableCheck(base);
if (base->isArray()) {
//
// It can only be a method (e.g., length), which can't be resolved until
// we later see the function calling syntax. Save away the name for now.
//
if (field == "length") {
//
// .length() can't be resolved until we later see the function-calling syntax.
// Save away the name in the AST for now. Processing is compeleted in
// handleLengthMethod().
//
if (field == "length") {
if (base->isArray()) {
profileRequires(loc, ENoProfile, 120, GL_3DL_array_objects, ".length");
profileRequires(loc, EEsProfile, 300, 0, ".length");
result = intermediate.addMethod(base, TType(EbtInt), &field, loc);
} else
error(loc, "only the length method is supported for array", field.c_str(), "");
} else if (base->isVector() || base->isScalar()) {
} else if (base->isVector() || base->isMatrix()) {
const char* feature = ".length() on vectors and matrices";
requireProfile(loc, ~EEsProfile, feature);
profileRequires(loc, ~EEsProfile, 420, GL_ARB_shading_language_420pack, feature);
} else {
error(loc, "does not operate on this type:", field.c_str(), base->getType().getCompleteString().c_str());
return base;
}
return intermediate.addMethod(base, TType(EbtInt), &field, loc);
}
TIntermTyped* result = base;
if (base->isVector() || base->isScalar()) {
if (base->isScalar()) {
const char* dotFeature = "scalar swizzle";
requireProfile(loc, ~EEsProfile, dotFeature);
@ -720,9 +730,7 @@ TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped*
result->setType(TType(base->getBasicType(), EvqTemporary, base->getType().getQualifier().precision, (int) vectorString.size()));
}
}
} else if (base->isMatrix())
error(loc, "field selection not allowed on matrix", ".", "");
else if (base->getBasicType() == EbtStruct || base->getBasicType() == EbtBlock) {
} else if (base->getBasicType() == EbtStruct || base->getBasicType() == EbtBlock) {
const TTypeList* fields = base->getType().getStruct();
bool fieldFound = false;
int member;
@ -741,9 +749,9 @@ TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped*
result->setType(*(*fields)[member].type);
}
} else
error(loc, " no such field in structure", field.c_str(), "");
error(loc, "no such field in structure", field.c_str(), "");
} else
error(loc, " dot operator does not operater on this type:", field.c_str(), base->getType().getCompleteString().c_str());
error(loc, "does not apply to this type:", field.c_str(), base->getType().getCompleteString().c_str());
return result;
}
@ -1013,7 +1021,10 @@ TIntermTyped* TParseContext::handleFunctionCall(TSourceLoc loc, TFunction* funct
return result;
}
// Do all processing handling object.length().
// Finish processing object.length(). This started earlier in handleDotDereference(), where
// the ".length" part was recognized and semantically checked, and finished here where the
// function syntax "()" is recognized.
//
// Return resulting tree node.
TIntermTyped* TParseContext::handleLengthMethod(TSourceLoc loc, TFunction* function, TIntermNode* intermNode)
{
@ -1021,26 +1032,36 @@ TIntermTyped* TParseContext::handleLengthMethod(TSourceLoc loc, TFunction* funct
if (function->getParamCount() > 0)
error(loc, "method does not accept any arguments", function->getName().c_str(), "");
if (intermNode->getAsTyped() == 0 || ! intermNode->getAsTyped()->getType().isArray())
error(loc, "", function->getName().c_str(), "can only be applied to an array");
else if (intermNode->getAsTyped()->getType().isImplicitlySizedArray()) {
if (intermNode->getAsSymbolNode() && isIoResizeArray(intermNode->getAsTyped()->getType())) {
// We could be between a layout declaration that gives a built-in io array implicit size and
// a user redeclaration of that array, meaning we have to substitute its implicit size here
// without actually redeclaring the array. (It is an error to use a member before the
// redeclaration, but not an error to use the array name itself.)
const TString& name = intermNode->getAsSymbolNode()->getName();
if (name == "gl_in" || name == "gl_out")
length = getIoArrayImplicitSize();
else {
const TType& type = intermNode->getAsTyped()->getType();
if (type.isArray()) {
if (type.isImplicitlySizedArray()) {
if (intermNode->getAsSymbolNode() && isIoResizeArray(type)) {
// We could be between a layout declaration that gives a built-in io array implicit size and
// a user redeclaration of that array, meaning we have to substitute its implicit size here
// without actually redeclaring the array. (It is an error to use a member before the
// redeclaration, but not an error to use the array name itself.)
const TString& name = intermNode->getAsSymbolNode()->getName();
if (name == "gl_in" || name == "gl_out")
length = getIoArrayImplicitSize();
}
if (length == 0) {
if (intermNode->getAsSymbolNode() && isIoResizeArray(type))
error(loc, "", function->getName().c_str(), "array must first be sized by a redeclaration or layout qualifier");
else
error(loc, "", function->getName().c_str(), "array must be declared with a size before using this method");
}
} else
length = type.getArraySize();
} else if (type.isMatrix())
length = type.getMatrixCols();
else if (type.isVector())
length = type.getVectorSize();
else {
// we should not get here, because earlier semantic checking should have prevented this path
error(loc, ".length()", "unexpected use of .length()", "");
}
if (length == 0) {
if (intermNode->getAsSymbolNode() && isIoResizeArray(intermNode->getAsTyped()->getType()))
error(loc, "", function->getName().c_str(), "array must first be sized by a redeclaration or layout qualifier");
else
error(loc, "", function->getName().c_str(), "array must be declared with a size before using this method");
}
} else
length = intermNode->getAsTyped()->getType().getArraySize();
}
if (length == 0)
length = 1;
@ -1633,7 +1654,7 @@ bool TParseContext::lineContinuationCheck(TSourceLoc loc, bool endOfComment)
const char* message = "line continuation";
bool lineContinuationAllowed = (profile == EEsProfile && version >= 300) ||
(profile != EEsProfile && version >= 420);
(profile != EEsProfile && (version >= 420 || extensionsTurnedOn(1, &GL_ARB_shading_language_420pack)));
if (endOfComment) {
if (lineContinuationAllowed)
@ -1645,12 +1666,12 @@ bool TParseContext::lineContinuationCheck(TSourceLoc loc, bool endOfComment)
}
if (messages & EShMsgRelaxedErrors) {
if (! lineContinuationAllowed)
warn(loc, "not allowed in this version", message, "");
return true;
} else {
requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, message);
profileRequires(loc, EEsProfile, 300, 0, message);
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 420, 0, message);
profileRequires(loc, ~EEsProfile, 420, GL_ARB_shading_language_420pack, message);
}
return lineContinuationAllowed;

View File

@ -362,11 +362,8 @@ function_identifier
TIntermMethod* method = $1->getAsMethodNode();
if (method) {
if (method->getObject()->isArray()) {
$$.function = new TFunction(&method->getMethodName(), TType(EbtInt), EOpArrayLength);
$$.intermNode = method->getObject();
} else
parseContext.error(method->getLoc(), "only arrays have methods", "", "");
$$.function = new TFunction(&method->getMethodName(), TType(EbtInt), EOpArrayLength);
$$.intermNode = method->getObject();
} else {
TIntermSymbol* symbol = $1->getAsSymbolNode();
if (symbol) {