Add missing matrix constructor test, and add a size() method for downstream consumers of constArrays.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@26937 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich
2014-06-03 00:20:41 +00:00
parent 974258d88f
commit 9dedb13447
4 changed files with 165 additions and 4 deletions

View File

@@ -152,3 +152,22 @@ void foo123()
mat3x2 rfoo1 = matrixCompMult(m23, m32); // ERROR
mat3x4 rfoo2 = matrixCompMult(m34, m44); // ERROR
}
void matConst()
{
vec2 v2;
vec3 v3;
mat4 m4b1 = mat4(v2, v3); // ERROR, not enough
mat4 m4b2 = mat4(v2, v3, v3, v3, v3, v2, v2); // ERROR, too much
mat4 m4g = mat4(v2, v3, v3, v3, v3, v3);
mat4 m4 = mat4(v2, v3, v3, v3, v3, v2);
mat3 m3 = mat3(m4);
mat3 m3b1 = mat3(m4, v2); // ERROR, extra arg
mat3 m3b2 = mat3(m4, m4); // ERROR, extra arg
mat3x2 m32 = mat3x2(m4);
mat4 m4c = mat4(m32);
mat3 m3s = mat3(v2.x);
mat3 m3a1[2] = mat3[2](m3s, m3s);
mat3 m3a2[2] = mat3[2](m3s, m3s, m3s); // ERROR, too many args
}

View File

@@ -34,7 +34,15 @@ ERROR: 0:152: 'matrixCompMult' : no matching overloaded function found
ERROR: 0:152: '=' : cannot convert from 'const float' to '3X2 matrix of float'
ERROR: 0:153: 'matrixCompMult' : no matching overloaded function found
ERROR: 0:153: '=' : cannot convert from 'const float' to '3X4 matrix of float'
ERROR: 35 compilation errors. No code generated.
ERROR: 0:160: 'constructor' : not enough data provided for construction
ERROR: 0:160: '=' : cannot convert from 'const float' to '4X4 matrix of float'
ERROR: 0:161: 'constructor' : too many arguments
ERROR: 0:161: '=' : cannot convert from 'const float' to '4X4 matrix of float'
ERROR: 0:165: 'constructor' : matrix constructed from matrix can only have one argument
ERROR: 0:166: 'constructor' : matrix constructed from matrix can only have one argument
ERROR: 0:172: 'constructor' : array constructor needs one argument per array element
ERROR: 0:172: '=' : cannot convert from 'const float' to '2-element array of 3X3 matrix of float'
ERROR: 43 compilation errors. No code generated.
Shader version: 120
@@ -365,6 +373,70 @@ ERROR: node is still EOpNull!
0:150 component-wise multiply (4X3 matrix of float)
0:150 'm43' (4X3 matrix of float)
0:150 'm43' (4X3 matrix of float)
0:156 Function Definition: matConst( (void)
0:156 Function Parameters:
0:? Sequence
0:162 Sequence
0:162 move second child to first child (4X4 matrix of float)
0:162 'm4g' (4X4 matrix of float)
0:162 Construct mat4 (4X4 matrix of float)
0:162 'v2' (2-component vector of float)
0:162 'v3' (3-component vector of float)
0:162 'v3' (3-component vector of float)
0:162 'v3' (3-component vector of float)
0:162 'v3' (3-component vector of float)
0:162 'v3' (3-component vector of float)
0:163 Sequence
0:163 move second child to first child (4X4 matrix of float)
0:163 'm4' (4X4 matrix of float)
0:163 Construct mat4 (4X4 matrix of float)
0:163 'v2' (2-component vector of float)
0:163 'v3' (3-component vector of float)
0:163 'v3' (3-component vector of float)
0:163 'v3' (3-component vector of float)
0:163 'v3' (3-component vector of float)
0:163 'v2' (2-component vector of float)
0:164 Sequence
0:164 move second child to first child (3X3 matrix of float)
0:164 'm3' (3X3 matrix of float)
0:164 Construct mat3 (3X3 matrix of float)
0:164 'm4' (4X4 matrix of float)
0:165 Sequence
0:165 move second child to first child (3X3 matrix of float)
0:165 'm3b1' (3X3 matrix of float)
0:165 Construct mat3 (3X3 matrix of float)
0:165 'm4' (4X4 matrix of float)
0:165 'v2' (2-component vector of float)
0:166 Sequence
0:166 move second child to first child (3X3 matrix of float)
0:166 'm3b2' (3X3 matrix of float)
0:166 Construct mat3 (3X3 matrix of float)
0:166 'm4' (4X4 matrix of float)
0:166 'm4' (4X4 matrix of float)
0:167 Sequence
0:167 move second child to first child (3X2 matrix of float)
0:167 'm32' (3X2 matrix of float)
0:167 Construct mat3x2 (3X2 matrix of float)
0:167 'm4' (4X4 matrix of float)
0:168 Sequence
0:168 move second child to first child (4X4 matrix of float)
0:168 'm4c' (4X4 matrix of float)
0:168 Construct mat4 (4X4 matrix of float)
0:168 'm32' (3X2 matrix of float)
0:169 Sequence
0:169 move second child to first child (3X3 matrix of float)
0:169 'm3s' (3X3 matrix of float)
0:169 Construct mat3 (3X3 matrix of float)
0:169 direct index (float)
0:169 'v2' (2-component vector of float)
0:169 Constant:
0:169 0 (const int)
0:171 Sequence
0:171 move second child to first child (2-element array of 3X3 matrix of float)
0:171 'm3a1' (2-element array of 3X3 matrix of float)
0:171 Construct mat3 (2-element array of 3X3 matrix of float)
0:171 'm3s' (3X3 matrix of float)
0:171 'm3s' (3X3 matrix of float)
0:? Linker Objects
0:? 'lowp' (float)
0:? 'mediump' (float)
@@ -723,6 +795,70 @@ ERROR: node is still EOpNull!
0:150 component-wise multiply (4X3 matrix of float)
0:150 'm43' (4X3 matrix of float)
0:150 'm43' (4X3 matrix of float)
0:156 Function Definition: matConst( (void)
0:156 Function Parameters:
0:? Sequence
0:162 Sequence
0:162 move second child to first child (4X4 matrix of float)
0:162 'm4g' (4X4 matrix of float)
0:162 Construct mat4 (4X4 matrix of float)
0:162 'v2' (2-component vector of float)
0:162 'v3' (3-component vector of float)
0:162 'v3' (3-component vector of float)
0:162 'v3' (3-component vector of float)
0:162 'v3' (3-component vector of float)
0:162 'v3' (3-component vector of float)
0:163 Sequence
0:163 move second child to first child (4X4 matrix of float)
0:163 'm4' (4X4 matrix of float)
0:163 Construct mat4 (4X4 matrix of float)
0:163 'v2' (2-component vector of float)
0:163 'v3' (3-component vector of float)
0:163 'v3' (3-component vector of float)
0:163 'v3' (3-component vector of float)
0:163 'v3' (3-component vector of float)
0:163 'v2' (2-component vector of float)
0:164 Sequence
0:164 move second child to first child (3X3 matrix of float)
0:164 'm3' (3X3 matrix of float)
0:164 Construct mat3 (3X3 matrix of float)
0:164 'm4' (4X4 matrix of float)
0:165 Sequence
0:165 move second child to first child (3X3 matrix of float)
0:165 'm3b1' (3X3 matrix of float)
0:165 Construct mat3 (3X3 matrix of float)
0:165 'm4' (4X4 matrix of float)
0:165 'v2' (2-component vector of float)
0:166 Sequence
0:166 move second child to first child (3X3 matrix of float)
0:166 'm3b2' (3X3 matrix of float)
0:166 Construct mat3 (3X3 matrix of float)
0:166 'm4' (4X4 matrix of float)
0:166 'm4' (4X4 matrix of float)
0:167 Sequence
0:167 move second child to first child (3X2 matrix of float)
0:167 'm32' (3X2 matrix of float)
0:167 Construct mat3x2 (3X2 matrix of float)
0:167 'm4' (4X4 matrix of float)
0:168 Sequence
0:168 move second child to first child (4X4 matrix of float)
0:168 'm4c' (4X4 matrix of float)
0:168 Construct mat4 (4X4 matrix of float)
0:168 'm32' (3X2 matrix of float)
0:169 Sequence
0:169 move second child to first child (3X3 matrix of float)
0:169 'm3s' (3X3 matrix of float)
0:169 Construct mat3 (3X3 matrix of float)
0:169 direct index (float)
0:169 'v2' (2-component vector of float)
0:169 Constant:
0:169 0 (const int)
0:171 Sequence
0:171 move second child to first child (2-element array of 3X3 matrix of float)
0:171 'm3a1' (2-element array of 3X3 matrix of float)
0:171 Construct mat3 (2-element array of 3X3 matrix of float)
0:171 'm3s' (3X3 matrix of float)
0:171 'm3s' (3X3 matrix of float)
0:? Linker Objects
0:? 'lowp' (float)
0:? 'mediump' (float)

View File

@@ -445,6 +445,7 @@ public:
unionArray = new TConstUnionVector(size, val);
}
int size() const { return unionArray ? (int)unionArray->size() : 0; }
TConstUnion& operator[](size_t index) { return (*unionArray)[index]; }
const TConstUnion& operator[](size_t index) const { return (*unionArray)[index]; }
bool operator==(const TConstUnionArray& rhs) const

View File

@@ -1698,9 +1698,9 @@ bool TParseContext::builtInName(const TString& identifier)
}
//
// Make sure there is enough data provided to the constructor to build
// something of the type of the constructor. Also returns the type of
// the constructor.
// Make sure there is enough data and not too many arguments provided to the
// constructor to build something of the type of the constructor. Also returns
// the type of the constructor.
//
// Returns true if there was an error in construction.
//
@@ -1781,6 +1781,11 @@ bool TParseContext::constructorError(TSourceLoc loc, TIntermNode* node, TFunctio
if (matrixInMatrix && ! type.isArray()) {
profileRequires(loc, ENoProfile, 120, 0, "constructing matrix from matrix");
// "If a matrix argument is given to a matrix constructor,
// it is a compile-time error to have any other arguments."
if (function.getParamCount() > 1)
error(loc, "matrix constructed from matrix can only have one argument", "constructor", "");
return false;
}