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
130.frag
140.frag
precision.frag
nonSquare.vert
matrixError.vert
......@@ -54,22 +54,12 @@
#pragma warning(disable : 4201) // nameless union
#endif
//
// Doing the push and pop below for warnings does not leave the warning state
// the way it was. This seems like a defect in the compiler. We would like
// to do this, but since it does not work correctly right now, it is turned
// off.
//
//??#pragma warning(push, 3)
#include <set>
#include <vector>
#include <map>
#include <list>
#include <string>
#include <stdio.h>
//??#pragma warning(pop)
#include <set>
#include <vector>
#include <map>
#include <list>
#include <string>
#include <stdio.h>
typedef int TSourceLoc;
......
......@@ -113,7 +113,6 @@ private:
unsigned char* mem; // beginning of our allocation (pts to header)
TAllocation* prevAlloc; // prior allocation in the chain
// Support MSVC++ 6.0
const static unsigned char guardBlockBeginVal;
const static unsigned char guardBlockEndVal;
const static unsigned char userDataFill;
......
......@@ -74,8 +74,9 @@ class TPublicType {
public:
TBasicType type;
TQualifier qualifier;
int size; // size of vector or matrix, not size of array
bool matrix;
int vectorSize : 4;
int matrixCols : 4;
int matrixRows : 4;
bool array;
int arraySize;
TType* userDef;
......@@ -84,8 +85,9 @@ public:
void initType(int ln = 0)
{
type = EbtVoid;
size = 1;
matrix = false;
vectorSize = 1;
matrixRows = 0;
matrixCols = 0;
array = false;
arraySize = 0;
userDef = 0;
......@@ -104,10 +106,16 @@ public:
initQualifiers(global);
}
void setAggregate(int s, bool m = false)
void setVector(int s)
{
size = s;
matrix = m;
vectorSize = s;
}
void setMatrix(int c, int r)
{
matrixRows = r;
matrixCols = c;
vectorSize = 0;
}
void setArray(bool a, int s = 0)
......@@ -125,15 +133,16 @@ typedef std::map<TTypeList*, TTypeList*>::iterator TStructureMapIterator;
class TType {
public:
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
explicit TType(TBasicType t, TStorageQualifier q = EvqTemporary, int s = 1, bool m = false, bool a = false) :
type(t), size(s), matrix(m), array(a), arraySize(0),
explicit TType(TBasicType t, TStorageQualifier q = EvqTemporary, int vs = 1, int mc = 0, int mr = 0) :
type(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), array(false), arraySize(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.precision = EpqNone;
}
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)
{
qualifier = p.qualifier;
......@@ -143,8 +152,9 @@ public:
}
}
explicit TType(TTypeList* userDef, const TString& n) :
type(EbtStruct), size(1), matrix(false), array(false), arraySize(0),
structure(userDef), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0) {
type(EbtStruct), vectorSize(1), matrixCols(0), matrixRows(0), array(false), arraySize(0),
structure(userDef), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0)
{
qualifier.storage = EvqTemporary;
qualifier.precision = EpqNone;
typeName = NewPoolTString(n.c_str());
......@@ -158,8 +168,9 @@ public:
{
type = copyOf.type;
qualifier = copyOf.qualifier;
size = copyOf.size;
matrix = copyOf.matrix;
vectorSize = copyOf.vectorSize;
matrixCols = copyOf.matrixCols;
matrixRows = copyOf.matrixRows;
array = copyOf.array;
arraySize = copyOf.arraySize;
......@@ -205,16 +216,30 @@ public:
return newType;
}
virtual void setType(TBasicType t, int s, bool m, bool a, int aS = 0)
{ type = t; size = s; matrix = m; array = a; arraySize = aS; }
virtual void setType(TBasicType t, int s, bool m, TType* userDef = 0)
{ type = t;
size = s;
matrix = m;
if (userDef)
structure = userDef->getStruct();
// leave array information intact.
}
virtual void dereference()
{
if (array) {
array = false;
arraySize = 0;
maxArraySize = 0;
} else if (matrixCols > 0) {
vectorSize = matrixRows;
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 setFieldName(const TString& n) { fieldName = NewPoolTString(n.c_str()); }
virtual const TString& getTypeName() const
......@@ -232,29 +257,20 @@ public:
virtual TBasicType getBasicType() const { return type; }
virtual TQualifier& getQualifier() { 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 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 isMatrix() const { return matrixCols ? true : false; }
virtual bool isArray() const { return array ? true : false; }
int getArraySize() const { return arraySize; }
void setArraySize(int s) { array = true; arraySize = s; }
void setMaxArraySize (int s) { maxArraySize = s; }
int getMaxArraySize () const { return maxArraySize; }
void clearArrayness() { array = false; arraySize = 0; maxArraySize = 0; }
void setArrayInformationType(TType* t) { arrayInformationType = t; }
TType* getArrayInformationType() { return arrayInformationType; }
virtual bool isVector() const { return size > 1 && !matrix; }
virtual bool isVector() const { return vectorSize > 1; }
static char* getBasicString(TBasicType t) {
switch (t) {
case EbtVoid: return "void"; break;
......@@ -285,10 +301,10 @@ public:
if (getBasicType() == EbtStruct)
totalSize = getStructSize();
else if (matrix)
totalSize = size * size;
else if (matrixCols)
totalSize = matrixCols * matrixRows;
else
totalSize = size;
totalSize = vectorSize;
if (isArray())
totalSize *= Max(getArraySize(), getMaxArraySize());
......@@ -307,17 +323,19 @@ public:
return *mangled;
}
bool sameElementType(const TType& right) const {
return type == right.type &&
size == right.size &&
matrix == right.matrix &&
structure == right.structure;
return type == right.type &&
vectorSize == right.vectorSize &&
matrixCols == right.matrixCols &&
matrixRows == right.matrixRows &&
structure == right.structure;
}
bool operator==(const TType& right) const {
return type == right.type &&
size == right.size &&
matrix == right.matrix &&
array == right.array && (!array || arraySize == right.arraySize) &&
structure == right.structure;
return type == right.type &&
vectorSize == right.vectorSize &&
matrixCols == right.matrixCols &&
matrixRows == right.matrixRows &&
array == right.array && (!array || arraySize == right.arraySize) &&
structure == right.structure;
// don't check the qualifier, it's not ever what's being sought after
}
bool operator!=(const TType& right) const {
......@@ -330,8 +348,9 @@ protected:
int getStructSize() const;
TBasicType type : 8;
int size : 8; // size of vector or matrix, not size of array
unsigned int matrix : 1;
int vectorSize : 4;
int matrixCols : 4;
int matrixRows : 4;
unsigned int array : 1;
TQualifier qualifier;
......
......@@ -184,6 +184,7 @@ enum TOperator {
// Constructors
//
EOpConstructGuardStart,
EOpConstructInt,
EOpConstructBool,
EOpConstructFloat,
......@@ -191,16 +192,35 @@ enum TOperator {
EOpConstructVec2,
EOpConstructVec3,
EOpConstructVec4,
EOpConstructDVec2,
EOpConstructDVec3,
EOpConstructDVec4,
EOpConstructBVec2,
EOpConstructBVec3,
EOpConstructBVec4,
EOpConstructIVec2,
EOpConstructIVec3,
EOpConstructIVec4,
EOpConstructMat2,
EOpConstructMat3,
EOpConstructMat4,
EOpConstructMat2x2,
EOpConstructMat2x3,
EOpConstructMat2x4,
EOpConstructMat3x2,
EOpConstructMat3x3,
EOpConstructMat3x4,
EOpConstructMat4x2,
EOpConstructMat4x3,
EOpConstructMat4x4,
EOpConstructDMat2x2,
EOpConstructDMat2x3,
EOpConstructDMat2x4,
EOpConstructDMat3x2,
EOpConstructDMat3x3,
EOpConstructDMat3x4,
EOpConstructDMat4x2,
EOpConstructDMat4x3,
EOpConstructDMat4x4,
EOpConstructStruct,
EOpConstructGuardEnd,
//
// moves
......@@ -286,8 +306,10 @@ public:
virtual TBasicType getBasicType() const { return type.getBasicType(); }
virtual TQualifier& getQualifier() { return type.getQualifier(); }
virtual void propagatePrecision(TPrecisionQualifier);
virtual int getNominalSize() const { return type.getNominalSize(); }
virtual int getSize() const { return type.getInstanceSize(); }
virtual int getVectorSize() const { return type.getVectorSize(); }
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 isArray() const { return type.isArray(); }
virtual bool isVector() const { return type.isVector(); }
......
......@@ -934,7 +934,7 @@ void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable, const TBu
case EShLangFragment: {
// Set up gl_FragData. The array size.
TType fragData(EbtFloat, EvqFragColor, 4, false, true);
TType fragData(EbtFloat, EvqFragColor, 4);
fragData.setArraySize(resources.maxDrawBuffers);
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));
}
......
......@@ -150,55 +150,6 @@ bool TParseContext::parseVectorFields(const TString& compString, int vecSize, TV
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
......@@ -261,7 +212,7 @@ void TParseContext::unaryOpError(int line, char* op, TString operand)
//
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 "
"a right operand of type '%s' (or there is no acceptable conversion)",
op, left.c_str(), right.c_str());
......@@ -425,7 +376,7 @@ bool TParseContext::constErrorCheck(TIntermTyped* node)
//
bool TParseContext::integerErrorCheck(TIntermTyped* node, char* token)
{
if (node->getBasicType() == EbtInt && node->getNominalSize() == 1)
if (node->getBasicType() == EbtInt && node->getVectorSize() == 1)
return false;
error(node->getLine(), "integer expression required", token, "");
......@@ -487,9 +438,24 @@ bool TParseContext::constructorErrorCheck(int line, TIntermNode* node, TFunction
bool constructingMatrix = false;
switch(op) {
case EOpConstructMat2:
case EOpConstructMat3:
case EOpConstructMat4:
case EOpConstructMat2x2:
case EOpConstructMat2x3:
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;
break;
default:
......@@ -608,7 +574,7 @@ bool TParseContext::boolErrorCheck(int line, const TIntermTyped* type)
//
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", "", "");
return true;
}
......@@ -1138,7 +1104,7 @@ TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType* type
TType elementType = *type;
if (type->isArray())
elementType.clearArrayness();
elementType.dereference();
bool singleArg;
if (aggrNode) {
......@@ -1246,13 +1212,35 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType* type, TOperator op, T
case EOpConstructVec2:
case EOpConstructVec3:
case EOpConstructVec4:
case EOpConstructMat2:
case EOpConstructMat3:
case EOpConstructMat4:
case EOpConstructMat2x2:
case EOpConstructMat2x3:
case EOpConstructMat2x4:
case EOpConstructMat3x2:
case EOpConstructMat3x3:
case EOpConstructMat3x4:
case EOpConstructMat4x2:
case EOpConstructMat4x3:
case EOpConstructMat4x4:
case EOpConstructFloat:
basicOp = EOpConstructFloat;
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 EOpConstructIVec3:
case EOpConstructIVec4:
......@@ -1345,7 +1333,7 @@ TIntermTyped* TParseContext::addConstVectorNode(TVectorFields& fields, TIntermTy
for (int i = 0; i < fields.num; i++) {
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();
fields.offsets[i] = 0;
}
......@@ -1368,7 +1356,7 @@ TIntermTyped* TParseContext::addConstMatrixNode(int index, TIntermTyped* node, T
TIntermTyped* typedNode;
TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
if (index >= node->getType().getNominalSize()) {
if (index >= node->getType().getMatrixCols()) {
error(line, "", "[", "matrix field selection out of range '%d'", index);
recover();
index = 0;
......@@ -1376,7 +1364,8 @@ TIntermTyped* TParseContext::addConstMatrixNode(int index, TIntermTyped* node, T
if (tempConstantNode) {
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);
} else {
error(line, "Cannot offset into the matrix", "Error", "");
......@@ -1401,10 +1390,10 @@ TIntermTyped* TParseContext::addConstArrayNode(int index, TIntermTyped* node, TS
TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
int arraySize = node->getType().getArraySize();
TType arrayElementType = node->getType();
arrayElementType.clearArrayness();
arrayElementType.dereference();
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();
index = 0;
}
......
......@@ -100,7 +100,6 @@ struct TParseContext {
void recover();
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 unaryOpError(int line, char* op, TString operand);
void binaryOpError(int line, char* op, TString left, TString right);
......
......@@ -175,7 +175,6 @@ TPoolAllocator::~TPoolAllocator()
}
}
// Support MSVC++ 6.0
const unsigned char TAllocation::guardBlockBeginVal = 0xfb;
const unsigned char TAllocation::guardBlockEndVal = 0xfe;
const unsigned char TAllocation::userDataFill = 0xcd;
......
......@@ -399,21 +399,19 @@ int ShLinkExt(
THandleList cObjects;
{// support MSVC++6.0
for (int i = 0; i < numHandles; ++i) {
if (compHandles[i] == 0)
return 0;
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(compHandles[i]);
if (base->getAsLinker()) {
cObjects.push_back(base->getAsLinker());
}
if (base->getAsCompiler())
cObjects.push_back(base->getAsCompiler());
for (int i = 0; i < numHandles; ++i) {
if (compHandles[i] == 0)
return 0;
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(compHandles[i]);
if (base->getAsLinker()) {
cObjects.push_back(base->getAsLinker());
}
if (base->getAsCompiler())
cObjects.push_back(base->getAsCompiler());
if (cObjects[i] == 0)
return 0;
}
if (cObjects[i] == 0)
return 0;
}
TShHandleBase* base = reinterpret_cast<TShHandleBase*>(linkHandle);
......@@ -424,13 +422,11 @@ int ShLinkExt(
linker->infoSink.info.erase();
{// support MSVC++6.0
for (int i = 0; i < numHandles; ++i) {
if (cObjects[i]->getAsCompiler()) {
if (! cObjects[i]->getAsCompiler()->linkable()) {
linker->infoSink.info.message(EPrefixError, "Not all shaders have valid object code.");
return 0;
}
for (int i = 0; i < numHandles; ++i) {
if (cObjects[i]->getAsCompiler()) {
if (! cObjects[i]->getAsCompiler()->linkable()) {
linker->infoSink.info.message(EPrefixError, "Not all shaders have valid object code.");
return 0;
}
}
}
......
......@@ -70,17 +70,21 @@ void TType::buildMangledName(TString& mangledName)
mangledName += "struct-";
if (typeName)
mangledName += *typeName;
{// support MSVC++6.0
for (unsigned int i = 0; i < structure->size(); ++i) {
mangledName += '-';
(*structure)[i].type->buildMangledName(mangledName);
}
for (unsigned int i = 0; i < structure->size(); ++i) {
mangledName += '-';
(*structure)[i].type->buildMangledName(mangledName);
}
default:
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()) {
const int maxSize = 10;
char buf[maxSize];
......
......@@ -66,10 +66,10 @@ TString TType::getCompleteString() const
p += sprintf_s(p, end - p, "array of ");
if (qualifier.precision != EpqNone)
p += sprintf_s(p, end - p, "%s ", getPrecisionQualifierString());
if (matrix)
p += sprintf_s(p, end - p, "%dX%d matrix of ", size, size);
else if (size > 1)
p += sprintf_s(p, end - p, "%d-component vector of ", size);
if (matrixCols > 0)
p += sprintf_s(p, end - p, "%dX%d matrix of ", matrixCols, matrixRows);
else if (vectorSize > 1)
p += sprintf_s(p, end - p, "%d-component vector of ", vectorSize);
sprintf_s(p, end - p, "%s", getBasicString());
......@@ -276,9 +276,24 @@ bool OutputAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTravers
case EOpConstructIVec2: out.debug << "Construct ivec2"; break;
case EOpConstructIVec3: out.debug << "Construct ivec3"; break;
case EOpConstructIVec4: out.debug << "Construct ivec4"; break;
case EOpConstructMat2: out.debug << "Construct mat2"; break;
case EOpConstructMat3: out.debug << "Construct mat3"; break;
case EOpConstructMat4: out.debug << "Construct mat4"; break;
case EOpConstructMat2x2: out.debug << "Construct mat2"; break;
case EOpConstructMat2x3: out.debug << "Construct mat2x3"; 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 EOpLessThan: out.debug << "Compare Less Than"; break;
......@@ -398,8 +413,8 @@ void OutputConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
sprintf_s(buf, maxSize, "%d (%s)", node->getUnionArrayPointer()[i].getIConst(), "const int");
out.debug << buf << "\n";
break;
}
break;
default:
out.info.message(EPrefixInternalError, "Unknown constant", node->getLine());
break;
......
......@@ -41,7 +41,8 @@
class TConstTraverser : public TIntermTraverser {
public:
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 ;
constUnion *unionArray;
TOperator tOp;
......@@ -53,7 +54,8 @@ public:
bool error;
int size; // size of the constructor ( 4 for vec4)
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
}
bool flag = node->getSequence().size() == 1 && node->getSequence()[0]->getAsTyped()->getAsConstantUnion();
if (flag)
{
if (flag) {
oit->singleConstantParam = true;
oit->constructorType = node->getOp();
oit->size = node->getType().getObjectSize();
if (node->getType().isMatrix()) {
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
oit->constructorType = EOpNull;
oit->size = 0;
oit->isMatrix = false;
oit->matrixSize = 0;
oit->matrixCols = 0;
oit->matrixRows = 0;
}
return false;
......@@ -189,12 +192,13 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
(oit->index)++;
}
} else {
int size, totalSize, matrixSize;
int size, totalSize, matrixCols, matrixRows;
bool isMatrix = false;
size = oit->size;
matrixSize = oit->matrixSize;
matrixCols = oit->matrixCols;
matrixRows = oit->matrixRows;
isMatrix = oit->isMatrix;
totalSize = oit->index + size ;
totalSize = oit->index + size;
constUnion *rightUnionArray = node->getUnionArrayPointer();
if (!isMatrix) {
int count = 0;
......@@ -215,7 +219,7 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
for (int i = index; i < totalSize; i++) {
if (i >= instanceSize)
return;
if (index - i == 0 || (i - index) % (matrixSize + 1) == 0 )
if (index - i == 0 || (i - index) % (matrixRows + 1) == 0 )
leftUnionArray[i] = rightUnionArray[count];
else
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