Commit f0fdc53e by John Kessenich

Implement non-square matrices, and make a few type improvements. Cleaned up a…

Implement non-square matrices, and make a few type improvements. Cleaned up a few old issues. Added two tests. Details - added all the new non-square types - separated concepts of matrix size and vector size - removed VS 6.0 comments/workarounds - removed obsolete concept of matrix fields git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@20436 e7fa87d3-cd2b-0410-9028-fcbf551c1848
parent 1c809955
#version 120
attribute vec3 v3;
uniform mat3x2 m32;
const mat2x4 m24 = mat2x4(1.0, 2.0,
3.0, 4.0,
3.0, 4.0,
3.0, 4.0, 5.0);
void main()
{
mat2x3 m23;
vec3 a, b;
a = v3 * m23;
b = m32 * v3;
m23.xy;
gl_Position = vec4(m23 * m32 * v3, m24[2][4]);
}
#version 120
attribute vec3 v3;
attribute vec4 v4;
uniform mat3x2 m32;
const vec2 cv2 = vec2(10.0, 20.0);
const mat2x4 m24 = mat2x4(3.0);
const mat4x2 m42 = mat4x2(1.0, 2.0,
3.0, 4.0,
5.0, 6.0,
7.0, 8.0);
void main()
{
mat2x3 m23;
vec2 a, b;
a = v3 * m23;
b = m32 * v3;
gl_Position = vec4(m23 * m32 * v3, m24[1][3]) +
(m24 * m42) * v4 + cv2 * m42 + m24 * cv2 + vec4(cv2[1], cv2.x, m42[2][1], m42[2][0]);
}
...@@ -10,3 +10,6 @@ versionsErrors.vert ...@@ -10,3 +10,6 @@ versionsErrors.vert
130.frag 130.frag
140.frag 140.frag
precision.frag precision.frag
nonSquare.vert
matrixError.vert
...@@ -54,22 +54,12 @@ ...@@ -54,22 +54,12 @@
#pragma warning(disable : 4201) // nameless union #pragma warning(disable : 4201) // nameless union
#endif #endif
// #include <set>
// Doing the push and pop below for warnings does not leave the warning state #include <vector>
// the way it was. This seems like a defect in the compiler. We would like #include <map>
// to do this, but since it does not work correctly right now, it is turned #include <list>
// off. #include <string>
// #include <stdio.h>
//??#pragma warning(push, 3)
#include <set>
#include <vector>
#include <map>
#include <list>
#include <string>
#include <stdio.h>
//??#pragma warning(pop)
typedef int TSourceLoc; typedef int TSourceLoc;
......
...@@ -113,7 +113,6 @@ private: ...@@ -113,7 +113,6 @@ private:
unsigned char* mem; // beginning of our allocation (pts to header) unsigned char* mem; // beginning of our allocation (pts to header)
TAllocation* prevAlloc; // prior allocation in the chain TAllocation* prevAlloc; // prior allocation in the chain
// Support MSVC++ 6.0
const static unsigned char guardBlockBeginVal; const static unsigned char guardBlockBeginVal;
const static unsigned char guardBlockEndVal; const static unsigned char guardBlockEndVal;
const static unsigned char userDataFill; const static unsigned char userDataFill;
......
...@@ -74,8 +74,9 @@ class TPublicType { ...@@ -74,8 +74,9 @@ class TPublicType {
public: public:
TBasicType type; TBasicType type;
TQualifier qualifier; TQualifier qualifier;
int size; // size of vector or matrix, not size of array int vectorSize : 4;
bool matrix; int matrixCols : 4;
int matrixRows : 4;
bool array; bool array;
int arraySize; int arraySize;
TType* userDef; TType* userDef;
...@@ -84,8 +85,9 @@ public: ...@@ -84,8 +85,9 @@ public:
void initType(int ln = 0) void initType(int ln = 0)
{ {
type = EbtVoid; type = EbtVoid;
size = 1; vectorSize = 1;
matrix = false; matrixRows = 0;
matrixCols = 0;
array = false; array = false;
arraySize = 0; arraySize = 0;
userDef = 0; userDef = 0;
...@@ -104,10 +106,16 @@ public: ...@@ -104,10 +106,16 @@ public:
initQualifiers(global); initQualifiers(global);
} }
void setAggregate(int s, bool m = false) void setVector(int s)
{ {
size = s; vectorSize = s;
matrix = m; }
void setMatrix(int c, int r)
{
matrixRows = r;
matrixCols = c;
vectorSize = 0;
} }
void setArray(bool a, int s = 0) void setArray(bool a, int s = 0)
...@@ -125,15 +133,16 @@ typedef std::map<TTypeList*, TTypeList*>::iterator TStructureMapIterator; ...@@ -125,15 +133,16 @@ typedef std::map<TTypeList*, TTypeList*>::iterator TStructureMapIterator;
class TType { class TType {
public: public:
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator) POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
explicit TType(TBasicType t, TStorageQualifier q = EvqTemporary, int s = 1, bool m = false, bool a = false) : explicit TType(TBasicType t, TStorageQualifier q = EvqTemporary, int vs = 1, int mc = 0, int mr = 0) :
type(t), size(s), matrix(m), array(a), arraySize(0), type(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), array(false), arraySize(0),
structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0),
fieldName(0), mangled(0), typeName(0) { fieldName(0), mangled(0), typeName(0)
{
qualifier.storage = q; qualifier.storage = q;
qualifier.precision = EpqNone; qualifier.precision = EpqNone;
} }
explicit TType(const TPublicType &p) : explicit TType(const TPublicType &p) :
type(p.type), size(p.size), matrix(p.matrix), array(p.array), arraySize(p.arraySize), type(p.type), vectorSize(p.vectorSize), matrixCols(p.matrixCols), matrixRows(p.matrixRows), array(p.array), arraySize(p.arraySize),
structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0), typeName(0) structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0), typeName(0)
{ {
qualifier = p.qualifier; qualifier = p.qualifier;
...@@ -143,8 +152,9 @@ public: ...@@ -143,8 +152,9 @@ public:
} }
} }
explicit TType(TTypeList* userDef, const TString& n) : explicit TType(TTypeList* userDef, const TString& n) :
type(EbtStruct), size(1), matrix(false), array(false), arraySize(0), type(EbtStruct), vectorSize(1), matrixCols(0), matrixRows(0), array(false), arraySize(0),
structure(userDef), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0) { structure(userDef), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0)
{
qualifier.storage = EvqTemporary; qualifier.storage = EvqTemporary;
qualifier.precision = EpqNone; qualifier.precision = EpqNone;
typeName = NewPoolTString(n.c_str()); typeName = NewPoolTString(n.c_str());
...@@ -158,8 +168,9 @@ public: ...@@ -158,8 +168,9 @@ public:
{ {
type = copyOf.type; type = copyOf.type;
qualifier = copyOf.qualifier; qualifier = copyOf.qualifier;
size = copyOf.size; vectorSize = copyOf.vectorSize;
matrix = copyOf.matrix; matrixCols = copyOf.matrixCols;
matrixRows = copyOf.matrixRows;
array = copyOf.array; array = copyOf.array;
arraySize = copyOf.arraySize; arraySize = copyOf.arraySize;
...@@ -205,16 +216,30 @@ public: ...@@ -205,16 +216,30 @@ public:
return newType; return newType;
} }
virtual void setType(TBasicType t, int s, bool m, bool a, int aS = 0) virtual void dereference()
{ type = t; size = s; matrix = m; array = a; arraySize = aS; } {
virtual void setType(TBasicType t, int s, bool m, TType* userDef = 0) if (array) {
{ type = t; array = false;
size = s; arraySize = 0;
matrix = m; maxArraySize = 0;
if (userDef) } else if (matrixCols > 0) {
structure = userDef->getStruct(); vectorSize = matrixRows;
// leave array information intact. matrixCols = 0;
} matrixRows = 0;
} else if (vectorSize > 1)
vectorSize = 1;
}
virtual void setElementType(TBasicType t, int s, int mc, int mr, TType* userDef)
{
type = t;
vectorSize = s;
matrixCols = mc;
matrixRows = mr;
if (userDef)
structure = userDef->getStruct();
// leave array information intact.
}
virtual void setTypeName(const TString& n) { typeName = NewPoolTString(n.c_str()); } 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
...@@ -232,29 +257,20 @@ public: ...@@ -232,29 +257,20 @@ public:
virtual TBasicType getBasicType() const { return type; } virtual TBasicType getBasicType() const { return type; }
virtual TQualifier& getQualifier() { return qualifier; } virtual TQualifier& getQualifier() { return qualifier; }
virtual const TQualifier& getQualifier() const { return qualifier; } virtual const TQualifier& getQualifier() const { return qualifier; }
virtual int getVectorSize() const { return vectorSize; }
virtual int getMatrixCols() const { return matrixCols; }
virtual int getMatrixRows() const { return matrixRows; }
// One-dimensional size of single instance type virtual bool isMatrix() const { return matrixCols ? true : false; }
virtual int getNominalSize() const { return size; }
// Full-dimensional size of single instance of type
virtual int getInstanceSize() const
{
if (matrix)
return size * size;
else
return size;
}
virtual bool isMatrix() const { return matrix ? true : false; }
virtual bool isArray() const { return array ? true : false; } virtual bool isArray() const { return array ? true : false; }
int getArraySize() const { return arraySize; } int getArraySize() const { return arraySize; }
void setArraySize(int s) { array = true; arraySize = s; } void setArraySize(int s) { array = true; arraySize = s; }
void setMaxArraySize (int s) { maxArraySize = s; } void setMaxArraySize (int s) { maxArraySize = s; }
int getMaxArraySize () const { return maxArraySize; } int getMaxArraySize () const { return maxArraySize; }
void clearArrayness() { array = false; arraySize = 0; maxArraySize = 0; }
void setArrayInformationType(TType* t) { arrayInformationType = t; } void setArrayInformationType(TType* t) { arrayInformationType = t; }
TType* getArrayInformationType() { return arrayInformationType; } TType* getArrayInformationType() { return arrayInformationType; }
virtual bool isVector() const { return size > 1 && !matrix; } virtual bool isVector() const { return vectorSize > 1; }
static char* getBasicString(TBasicType t) { static char* getBasicString(TBasicType t) {
switch (t) { switch (t) {
case EbtVoid: return "void"; break; case EbtVoid: return "void"; break;
...@@ -285,10 +301,10 @@ public: ...@@ -285,10 +301,10 @@ public:
if (getBasicType() == EbtStruct) if (getBasicType() == EbtStruct)
totalSize = getStructSize(); totalSize = getStructSize();
else if (matrix) else if (matrixCols)
totalSize = size * size; totalSize = matrixCols * matrixRows;
else else
totalSize = size; totalSize = vectorSize;
if (isArray()) if (isArray())
totalSize *= Max(getArraySize(), getMaxArraySize()); totalSize *= Max(getArraySize(), getMaxArraySize());
...@@ -307,17 +323,19 @@ public: ...@@ -307,17 +323,19 @@ public:
return *mangled; return *mangled;
} }
bool sameElementType(const TType& right) const { bool sameElementType(const TType& right) const {
return type == right.type && return type == right.type &&
size == right.size && vectorSize == right.vectorSize &&
matrix == right.matrix && matrixCols == right.matrixCols &&
structure == right.structure; matrixRows == right.matrixRows &&
structure == right.structure;
} }
bool operator==(const TType& right) const { bool operator==(const TType& right) const {
return type == right.type && return type == right.type &&
size == right.size && vectorSize == right.vectorSize &&
matrix == right.matrix && matrixCols == right.matrixCols &&
array == right.array && (!array || arraySize == right.arraySize) && matrixRows == right.matrixRows &&
structure == right.structure; array == right.array && (!array || arraySize == right.arraySize) &&
structure == right.structure;
// don't check the qualifier, it's not ever what's being sought after // don't check the qualifier, it's not ever what's being sought after
} }
bool operator!=(const TType& right) const { bool operator!=(const TType& right) const {
...@@ -330,8 +348,9 @@ protected: ...@@ -330,8 +348,9 @@ protected:
int getStructSize() const; int getStructSize() const;
TBasicType type : 8; TBasicType type : 8;
int size : 8; // size of vector or matrix, not size of array int vectorSize : 4;
unsigned int matrix : 1; int matrixCols : 4;
int matrixRows : 4;
unsigned int array : 1; unsigned int array : 1;
TQualifier qualifier; TQualifier qualifier;
......
...@@ -184,6 +184,7 @@ enum TOperator { ...@@ -184,6 +184,7 @@ enum TOperator {
// Constructors // Constructors
// //
EOpConstructGuardStart,
EOpConstructInt, EOpConstructInt,
EOpConstructBool, EOpConstructBool,
EOpConstructFloat, EOpConstructFloat,
...@@ -191,16 +192,35 @@ enum TOperator { ...@@ -191,16 +192,35 @@ enum TOperator {
EOpConstructVec2, EOpConstructVec2,
EOpConstructVec3, EOpConstructVec3,
EOpConstructVec4, EOpConstructVec4,
EOpConstructDVec2,
EOpConstructDVec3,
EOpConstructDVec4,
EOpConstructBVec2, EOpConstructBVec2,
EOpConstructBVec3, EOpConstructBVec3,
EOpConstructBVec4, EOpConstructBVec4,
EOpConstructIVec2, EOpConstructIVec2,
EOpConstructIVec3, EOpConstructIVec3,
EOpConstructIVec4, EOpConstructIVec4,
EOpConstructMat2, EOpConstructMat2x2,
EOpConstructMat3, EOpConstructMat2x3,
EOpConstructMat4, EOpConstructMat2x4,
EOpConstructMat3x2,
EOpConstructMat3x3,
EOpConstructMat3x4,
EOpConstructMat4x2,
EOpConstructMat4x3,
EOpConstructMat4x4,
EOpConstructDMat2x2,
EOpConstructDMat2x3,
EOpConstructDMat2x4,
EOpConstructDMat3x2,
EOpConstructDMat3x3,
EOpConstructDMat3x4,
EOpConstructDMat4x2,
EOpConstructDMat4x3,
EOpConstructDMat4x4,
EOpConstructStruct, EOpConstructStruct,
EOpConstructGuardEnd,
// //
// moves // moves
...@@ -286,8 +306,10 @@ public: ...@@ -286,8 +306,10 @@ public:
virtual TBasicType getBasicType() const { return type.getBasicType(); } virtual TBasicType getBasicType() const { return type.getBasicType(); }
virtual TQualifier& getQualifier() { return type.getQualifier(); } virtual TQualifier& getQualifier() { return type.getQualifier(); }
virtual void propagatePrecision(TPrecisionQualifier); virtual void propagatePrecision(TPrecisionQualifier);
virtual int getNominalSize() const { return type.getNominalSize(); } virtual int getVectorSize() const { return type.getVectorSize(); }
virtual int getSize() const { return type.getInstanceSize(); } virtual int getMatrixCols() const { return type.getMatrixCols(); }
virtual int getMatrixRows() const { return type.getMatrixRows(); }
//virtual int getSize() const { return type.getInstanceSize(); }
virtual bool isMatrix() const { return type.isMatrix(); } virtual bool isMatrix() const { return type.isMatrix(); }
virtual bool isArray() const { return type.isArray(); } virtual bool isArray() const { return type.isArray(); }
virtual bool isVector() const { return type.isVector(); } virtual bool isVector() const { return type.isVector(); }
......
...@@ -934,7 +934,7 @@ void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable, const TBu ...@@ -934,7 +934,7 @@ void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable, const TBu
case EShLangFragment: { case EShLangFragment: {
// Set up gl_FragData. The array size. // Set up gl_FragData. The array size.
TType fragData(EbtFloat, EvqFragColor, 4, false, true); TType fragData(EbtFloat, EvqFragColor, 4);
fragData.setArraySize(resources.maxDrawBuffers); fragData.setArraySize(resources.maxDrawBuffers);
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData)); symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));
} }
......
...@@ -150,55 +150,6 @@ bool TParseContext::parseVectorFields(const TString& compString, int vecSize, TV ...@@ -150,55 +150,6 @@ bool TParseContext::parseVectorFields(const TString& compString, int vecSize, TV
return true; return true;
} }
//
// Look at a '.' field selector string and change it into offsets
// for a matrix.
//
bool TParseContext::parseMatrixFields(const TString& compString, int matSize, TMatrixFields& fields, int line)
{
fields.wholeRow = false;
fields.wholeCol = false;
fields.row = -1;
fields.col = -1;
if (compString.size() != 2) {
error(line, "illegal length of matrix field selection", compString.c_str(), "");
return false;
}
if (compString[0] == '_') {
if (compString[1] < '0' || compString[1] > '3') {
error(line, "illegal matrix field selection", compString.c_str(), "");
return false;
}
fields.wholeCol = true;
fields.col = compString[1] - '0';
} else if (compString[1] == '_') {
if (compString[0] < '0' || compString[0] > '3') {
error(line, "illegal matrix field selection", compString.c_str(), "");
return false;
}
fields.wholeRow = true;
fields.row = compString[0] - '0';
} else {
if (compString[0] < '0' || compString[0] > '3' ||
compString[1] < '0' || compString[1] > '3') {
error(line, "illegal matrix field selection", compString.c_str(), "");
return false;
}
fields.row = compString[0] - '0';
fields.col = compString[1] - '0';
}
if (fields.row >= matSize || fields.col >= matSize) {
error(line, "matrix field selection out of range", compString.c_str(), "");
return false;
}
return true;
}
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
// //
// Errors // Errors
...@@ -261,7 +212,7 @@ void TParseContext::unaryOpError(int line, char* op, TString operand) ...@@ -261,7 +212,7 @@ void TParseContext::unaryOpError(int line, char* op, TString operand)
// //
void TParseContext::binaryOpError(int line, char* op, TString left, TString right) void TParseContext::binaryOpError(int line, char* op, TString left, TString right)
{ {
error(line, " wrong operand types ", op, error(line, " wrong operand types:", op,
"no operation '%s' exists that takes a left-hand operand of type '%s' and " "no operation '%s' exists that takes a left-hand operand of type '%s' and "
"a right operand of type '%s' (or there is no acceptable conversion)", "a right operand of type '%s' (or there is no acceptable conversion)",
op, left.c_str(), right.c_str()); op, left.c_str(), right.c_str());
...@@ -425,7 +376,7 @@ bool TParseContext::constErrorCheck(TIntermTyped* node) ...@@ -425,7 +376,7 @@ bool TParseContext::constErrorCheck(TIntermTyped* node)
// //
bool TParseContext::integerErrorCheck(TIntermTyped* node, char* token) bool TParseContext::integerErrorCheck(TIntermTyped* node, char* token)
{ {
if (node->getBasicType() == EbtInt && node->getNominalSize() == 1) if (node->getBasicType() == EbtInt && node->getVectorSize() == 1)
return false; return false;
error(node->getLine(), "integer expression required", token, ""); error(node->getLine(), "integer expression required", token, "");
...@@ -487,9 +438,24 @@ bool TParseContext::constructorErrorCheck(int line, TIntermNode* node, TFunction ...@@ -487,9 +438,24 @@ bool TParseContext::constructorErrorCheck(int line, TIntermNode* node, TFunction
bool constructingMatrix = false; bool constructingMatrix = false;
switch(op) { switch(op) {
case EOpConstructMat2: case EOpConstructMat2x2:
case EOpConstructMat3: case EOpConstructMat2x3:
case EOpConstructMat4: case EOpConstructMat2x4:
case EOpConstructMat3x2:
case EOpConstructMat3x3:
case EOpConstructMat3x4:
case EOpConstructMat4x2:
case EOpConstructMat4x3:
case EOpConstructMat4x4:
case EOpConstructDMat2x2:
case EOpConstructDMat2x3:
case EOpConstructDMat2x4:
case EOpConstructDMat3x2:
case EOpConstructDMat3x3:
case EOpConstructDMat3x4:
case EOpConstructDMat4x2:
case EOpConstructDMat4x3:
case EOpConstructDMat4x4:
constructingMatrix = true; constructingMatrix = true;
break; break;
default: default:
...@@ -608,7 +574,7 @@ bool TParseContext::boolErrorCheck(int line, const TIntermTyped* type) ...@@ -608,7 +574,7 @@ bool TParseContext::boolErrorCheck(int line, const TIntermTyped* type)
// //
bool TParseContext::boolErrorCheck(int line, const TPublicType& pType) bool TParseContext::boolErrorCheck(int line, const TPublicType& pType)
{ {
if (pType.type != EbtBool || pType.array || pType.matrix || (pType.size > 1)) { if (pType.type != EbtBool || pType.array || pType.matrixCols > 1 || (pType.vectorSize > 1)) {
error(line, "boolean expression expected", "", ""); error(line, "boolean expression expected", "", "");
return true; return true;
} }
...@@ -1138,7 +1104,7 @@ TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType* type ...@@ -1138,7 +1104,7 @@ TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType* type
TType elementType = *type; TType elementType = *type;
if (type->isArray()) if (type->isArray())
elementType.clearArrayness(); elementType.dereference();
bool singleArg; bool singleArg;
if (aggrNode) { if (aggrNode) {
...@@ -1246,13 +1212,35 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType* type, TOperator op, T ...@@ -1246,13 +1212,35 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType* type, TOperator op, T
case EOpConstructVec2: case EOpConstructVec2:
case EOpConstructVec3: case EOpConstructVec3:
case EOpConstructVec4: case EOpConstructVec4:
case EOpConstructMat2: case EOpConstructMat2x2:
case EOpConstructMat3: case EOpConstructMat2x3:
case EOpConstructMat4: case EOpConstructMat2x4:
case EOpConstructMat3x2:
case EOpConstructMat3x3:
case EOpConstructMat3x4:
case EOpConstructMat4x2:
case EOpConstructMat4x3:
case EOpConstructMat4x4:
case EOpConstructFloat: case EOpConstructFloat:
basicOp = EOpConstructFloat; basicOp = EOpConstructFloat;
break; break;
case EOpConstructDVec2:
case EOpConstructDVec3:
case EOpConstructDVec4:
case EOpConstructDMat2x2:
case EOpConstructDMat2x3:
case EOpConstructDMat2x4:
case EOpConstructDMat3x2:
case EOpConstructDMat3x3:
case EOpConstructDMat3x4:
case EOpConstructDMat4x2:
case EOpConstructDMat4x3:
case EOpConstructDMat4x4:
case EOpConstructDouble:
basicOp = EOpConstructDouble;
break;
case EOpConstructIVec2: case EOpConstructIVec2:
case EOpConstructIVec3: case EOpConstructIVec3:
case EOpConstructIVec4: case EOpConstructIVec4:
...@@ -1345,7 +1333,7 @@ TIntermTyped* TParseContext::addConstVectorNode(TVectorFields& fields, TIntermTy ...@@ -1345,7 +1333,7 @@ TIntermTyped* TParseContext::addConstVectorNode(TVectorFields& fields, TIntermTy
for (int i = 0; i < fields.num; i++) { for (int i = 0; i < fields.num; i++) {
if (fields.offsets[i] >= node->getType().getObjectSize()) { if (fields.offsets[i] >= node->getType().getObjectSize()) {
error(line, "", "[", "vector field selection out of range '%d'", fields.offsets[i]); error(line, "", "[", "vector index out of range '%d'", fields.offsets[i]);
recover(); recover();
fields.offsets[i] = 0; fields.offsets[i] = 0;
} }
...@@ -1368,7 +1356,7 @@ TIntermTyped* TParseContext::addConstMatrixNode(int index, TIntermTyped* node, T ...@@ -1368,7 +1356,7 @@ TIntermTyped* TParseContext::addConstMatrixNode(int index, TIntermTyped* node, T
TIntermTyped* typedNode; TIntermTyped* typedNode;
TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion(); TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
if (index >= node->getType().getNominalSize()) { if (index >= node->getType().getMatrixCols()) {
error(line, "", "[", "matrix field selection out of range '%d'", index); error(line, "", "[", "matrix field selection out of range '%d'", index);
recover(); recover();
index = 0; index = 0;
...@@ -1376,7 +1364,8 @@ TIntermTyped* TParseContext::addConstMatrixNode(int index, TIntermTyped* node, T ...@@ -1376,7 +1364,8 @@ TIntermTyped* TParseContext::addConstMatrixNode(int index, TIntermTyped* node, T
if (tempConstantNode) { if (tempConstantNode) {
constUnion* unionArray = tempConstantNode->getUnionArrayPointer(); constUnion* unionArray = tempConstantNode->getUnionArrayPointer();
int size = tempConstantNode->getType().getNominalSize(); int size = tempConstantNode->getType().getMatrixRows();
// Note: the type is corrected (dereferenced) by the caller
typedNode = intermediate.addConstantUnion(&unionArray[size*index], tempConstantNode->getType(), line); typedNode = intermediate.addConstantUnion(&unionArray[size*index], tempConstantNode->getType(), line);
} else { } else {
error(line, "Cannot offset into the matrix", "Error", ""); error(line, "Cannot offset into the matrix", "Error", "");
...@@ -1401,10 +1390,10 @@ TIntermTyped* TParseContext::addConstArrayNode(int index, TIntermTyped* node, TS ...@@ -1401,10 +1390,10 @@ TIntermTyped* TParseContext::addConstArrayNode(int index, TIntermTyped* node, TS
TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion(); TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
int arraySize = node->getType().getArraySize(); int arraySize = node->getType().getArraySize();
TType arrayElementType = node->getType(); TType arrayElementType = node->getType();
arrayElementType.clearArrayness(); arrayElementType.dereference();
if (index >= node->getType().getArraySize()) { if (index >= node->getType().getArraySize()) {
error(line, "", "[", "array field selection out of range '%d'", index); error(line, "", "[", "array index out of range '%d'", index);
recover(); recover();
index = 0; index = 0;
} }
......
...@@ -100,7 +100,6 @@ struct TParseContext { ...@@ -100,7 +100,6 @@ struct TParseContext {
void recover(); void recover();
bool parseVectorFields(const TString&, int vecSize, TVectorFields&, int line); bool parseVectorFields(const TString&, int vecSize, TVectorFields&, int line);
bool parseMatrixFields(const TString&, int matSize, TMatrixFields&, int line);
void assignError(int line, const char* op, TString left, TString right); void assignError(int line, const char* op, TString left, TString right);
void unaryOpError(int line, char* op, TString operand); void unaryOpError(int line, char* op, TString operand);
void binaryOpError(int line, char* op, TString left, TString right); void binaryOpError(int line, char* op, TString left, TString right);
......
...@@ -175,7 +175,6 @@ TPoolAllocator::~TPoolAllocator() ...@@ -175,7 +175,6 @@ TPoolAllocator::~TPoolAllocator()
} }
} }
// Support MSVC++ 6.0
const unsigned char TAllocation::guardBlockBeginVal = 0xfb; const unsigned char TAllocation::guardBlockBeginVal = 0xfb;
const unsigned char TAllocation::guardBlockEndVal = 0xfe; const unsigned char TAllocation::guardBlockEndVal = 0xfe;
const unsigned char TAllocation::userDataFill = 0xcd; const unsigned char TAllocation::userDataFill = 0xcd;
......
...@@ -399,21 +399,19 @@ int ShLinkExt( ...@@ -399,21 +399,19 @@ int ShLinkExt(
THandleList cObjects; THandleList cObjects;
{// support MSVC++6.0 for (int i = 0; i < numHandles; ++i) {
for (int i = 0; i < numHandles; ++i) { if (compHandles[i] == 0)
if (compHandles[i] == 0) return 0;
return 0; TShHandleBase* base = reinterpret_cast<TShHandleBase*>(compHandles[i]);
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(compHandles[i]); if (base->getAsLinker()) {
if (base->getAsLinker()) { cObjects.push_back(base->getAsLinker());
cObjects.push_back(base->getAsLinker()); }
} if (base->getAsCompiler())
if (base->getAsCompiler()) cObjects.push_back(base->getAsCompiler());
cObjects.push_back(base->getAsCompiler());
if (cObjects[i] == 0) if (cObjects[i] == 0)
return 0; return 0;
}
} }
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(linkHandle); TShHandleBase* base = reinterpret_cast<TShHandleBase*>(linkHandle);
...@@ -424,13 +422,11 @@ int ShLinkExt( ...@@ -424,13 +422,11 @@ int ShLinkExt(
linker->infoSink.info.erase(); linker->infoSink.info.erase();
{// support MSVC++6.0 for (int i = 0; i < numHandles; ++i) {
for (int i = 0; i < numHandles; ++i) { if (cObjects[i]->getAsCompiler()) {
if (cObjects[i]->getAsCompiler()) { if (! cObjects[i]->getAsCompiler()->linkable()) {
if (! cObjects[i]->getAsCompiler()->linkable()) { linker->infoSink.info.message(EPrefixError, "Not all shaders have valid object code.");
linker->infoSink.info.message(EPrefixError, "Not all shaders have valid object code."); return 0;
return 0;
}
} }
} }
} }
......
...@@ -70,17 +70,21 @@ void TType::buildMangledName(TString& mangledName) ...@@ -70,17 +70,21 @@ void TType::buildMangledName(TString& mangledName)
mangledName += "struct-"; mangledName += "struct-";
if (typeName) if (typeName)
mangledName += *typeName; mangledName += *typeName;
{// support MSVC++6.0 for (unsigned int i = 0; i < structure->size(); ++i) {
for (unsigned int i = 0; i < structure->size(); ++i) { mangledName += '-';
mangledName += '-'; (*structure)[i].type->buildMangledName(mangledName);
(*structure)[i].type->buildMangledName(mangledName);
}
} }
default: default:
break; break;
} }
mangledName += static_cast<char>('0' + getNominalSize()); if (getVectorSize() > 0)
mangledName += static_cast<char>('0' + getVectorSize());
else {
mangledName += static_cast<char>('0' + getMatrixCols());
mangledName += static_cast<char>('0' + getMatrixRows());
}
if (isArray()) { if (isArray()) {
const int maxSize = 10; const int maxSize = 10;
char buf[maxSize]; char buf[maxSize];
......
...@@ -66,10 +66,10 @@ TString TType::getCompleteString() const ...@@ -66,10 +66,10 @@ TString TType::getCompleteString() const
p += sprintf_s(p, end - p, "array of "); p += sprintf_s(p, end - p, "array of ");
if (qualifier.precision != EpqNone) if (qualifier.precision != EpqNone)
p += sprintf_s(p, end - p, "%s ", getPrecisionQualifierString()); p += sprintf_s(p, end - p, "%s ", getPrecisionQualifierString());
if (matrix) if (matrixCols > 0)
p += sprintf_s(p, end - p, "%dX%d matrix of ", size, size); p += sprintf_s(p, end - p, "%dX%d matrix of ", matrixCols, matrixRows);
else if (size > 1) else if (vectorSize > 1)
p += sprintf_s(p, end - p, "%d-component vector of ", size); p += sprintf_s(p, end - p, "%d-component vector of ", vectorSize);
sprintf_s(p, end - p, "%s", getBasicString()); sprintf_s(p, end - p, "%s", getBasicString());
...@@ -276,9 +276,24 @@ bool OutputAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTravers ...@@ -276,9 +276,24 @@ bool OutputAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTravers
case EOpConstructIVec2: out.debug << "Construct ivec2"; break; case EOpConstructIVec2: out.debug << "Construct ivec2"; break;
case EOpConstructIVec3: out.debug << "Construct ivec3"; break; case EOpConstructIVec3: out.debug << "Construct ivec3"; break;
case EOpConstructIVec4: out.debug << "Construct ivec4"; break; case EOpConstructIVec4: out.debug << "Construct ivec4"; break;
case EOpConstructMat2: out.debug << "Construct mat2"; break; case EOpConstructMat2x2: out.debug << "Construct mat2"; break;
case EOpConstructMat3: out.debug << "Construct mat3"; break; case EOpConstructMat2x3: out.debug << "Construct mat2x3"; break;
case EOpConstructMat4: out.debug << "Construct mat4"; break; case EOpConstructMat2x4: out.debug << "Construct mat2x4"; break;
case EOpConstructMat3x2: out.debug << "Construct mat3x2"; break;
case EOpConstructMat3x3: out.debug << "Construct mat3"; break;
case EOpConstructMat3x4: out.debug << "Construct mat3x4"; break;
case EOpConstructMat4x2: out.debug << "Construct mat4x2"; break;
case EOpConstructMat4x3: out.debug << "Construct mat4x3"; break;
case EOpConstructMat4x4: out.debug << "Construct mat4"; break;
case EOpConstructDMat2x2: out.debug << "Construct dmat2"; break;
case EOpConstructDMat2x3: out.debug << "Construct dmat2x3"; break;
case EOpConstructDMat2x4: out.debug << "Construct dmat2x4"; break;
case EOpConstructDMat3x2: out.debug << "Construct dmat3x2"; break;
case EOpConstructDMat3x3: out.debug << "Construct dmat3"; break;
case EOpConstructDMat3x4: out.debug << "Construct dmat3x4"; break;
case EOpConstructDMat4x2: out.debug << "Construct dmat4x2"; break;
case EOpConstructDMat4x3: out.debug << "Construct dmat4x3"; break;
case EOpConstructDMat4x4: out.debug << "Construct dmat4"; break;
case EOpConstructStruct: out.debug << "Construct structure"; break; case EOpConstructStruct: out.debug << "Construct structure"; break;
case EOpLessThan: out.debug << "Compare Less Than"; break; case EOpLessThan: out.debug << "Compare Less Than"; break;
...@@ -398,8 +413,8 @@ void OutputConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it) ...@@ -398,8 +413,8 @@ void OutputConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
sprintf_s(buf, maxSize, "%d (%s)", node->getUnionArrayPointer()[i].getIConst(), "const int"); sprintf_s(buf, maxSize, "%d (%s)", node->getUnionArrayPointer()[i].getIConst(), "const int");
out.debug << buf << "\n"; out.debug << buf << "\n";
break;
} }
break;
default: default:
out.info.message(EPrefixInternalError, "Unknown constant", node->getLine()); out.info.message(EPrefixInternalError, "Unknown constant", node->getLine());
break; break;
......
...@@ -41,7 +41,8 @@ ...@@ -41,7 +41,8 @@
class TConstTraverser : public TIntermTraverser { class TConstTraverser : public TIntermTraverser {
public: public:
TConstTraverser(constUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, TSymbolTable& symTable, TType& t) : unionArray(cUnion), type(t), TConstTraverser(constUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, TSymbolTable& symTable, TType& t) : unionArray(cUnion), type(t),
constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), symbolTable(symTable), error(false), isMatrix(false), matrixSize(0) { index = 0; tOp = EOpNull;} constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), symbolTable(symTable), error(false), isMatrix(false),
matrixCols(0), matrixRows(0) { index = 0; tOp = EOpNull;}
int index ; int index ;
constUnion *unionArray; constUnion *unionArray;
TOperator tOp; TOperator tOp;
...@@ -53,7 +54,8 @@ public: ...@@ -53,7 +54,8 @@ public:
bool error; bool error;
int size; // size of the constructor ( 4 for vec4) int size; // size of the constructor ( 4 for vec4)
bool isMatrix; bool isMatrix;
int matrixSize; // dimension of the matrix (nominal size and not the instance size) int matrixCols;
int matrixRows;
}; };
// //
...@@ -128,15 +130,15 @@ bool ParseAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTraverse ...@@ -128,15 +130,15 @@ bool ParseAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTraverse
} }
bool flag = node->getSequence().size() == 1 && node->getSequence()[0]->getAsTyped()->getAsConstantUnion(); bool flag = node->getSequence().size() == 1 && node->getSequence()[0]->getAsTyped()->getAsConstantUnion();
if (flag) if (flag) {
{
oit->singleConstantParam = true; oit->singleConstantParam = true;
oit->constructorType = node->getOp(); oit->constructorType = node->getOp();
oit->size = node->getType().getObjectSize(); oit->size = node->getType().getObjectSize();
if (node->getType().isMatrix()) { if (node->getType().isMatrix()) {
oit->isMatrix = true; oit->isMatrix = true;
oit->matrixSize = node->getType().getNominalSize(); oit->matrixCols = node->getType().getMatrixCols();
oit->matrixRows = node->getType().getMatrixRows();
} }
} }
...@@ -154,7 +156,8 @@ bool ParseAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTraverse ...@@ -154,7 +156,8 @@ bool ParseAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTraverse
oit->constructorType = EOpNull; oit->constructorType = EOpNull;
oit->size = 0; oit->size = 0;
oit->isMatrix = false; oit->isMatrix = false;
oit->matrixSize = 0; oit->matrixCols = 0;
oit->matrixRows = 0;
} }
return false; return false;
...@@ -189,12 +192,13 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it) ...@@ -189,12 +192,13 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
(oit->index)++; (oit->index)++;
} }
} else { } else {
int size, totalSize, matrixSize; int size, totalSize, matrixCols, matrixRows;
bool isMatrix = false; bool isMatrix = false;
size = oit->size; size = oit->size;
matrixSize = oit->matrixSize; matrixCols = oit->matrixCols;
matrixRows = oit->matrixRows;
isMatrix = oit->isMatrix; isMatrix = oit->isMatrix;
totalSize = oit->index + size ; totalSize = oit->index + size;
constUnion *rightUnionArray = node->getUnionArrayPointer(); constUnion *rightUnionArray = node->getUnionArrayPointer();
if (!isMatrix) { if (!isMatrix) {
int count = 0; int count = 0;
...@@ -215,7 +219,7 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it) ...@@ -215,7 +219,7 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
for (int i = index; i < totalSize; i++) { for (int i = index; i < totalSize; i++) {
if (i >= instanceSize) if (i >= instanceSize)
return; return;
if (index - i == 0 || (i - index) % (matrixSize + 1) == 0 ) if (index - i == 0 || (i - index) % (matrixRows + 1) == 0 )
leftUnionArray[i] = rightUnionArray[count]; leftUnionArray[i] = rightUnionArray[count];
else else
leftUnionArray[i].setFConst(0.0f); leftUnionArray[i].setFConst(0.0f);
......
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