Add a secondary size field to the shader language types, to account for matrix…

Add a secondary size field to the shader language types, to account for matrix rows. Also add some extra logic to the promote method to check that the sizes of the arguments to multiplications are properly formed. We require this extra information for non-square matrix support. TRAC #23081 Signed-off-by: Geoff Lang Signed-off-by: Nicolas Capens Author: Jamie Madill git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2392 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent b7dc4038
#define MAJOR_VERSION 1
#define MINOR_VERSION 1
#define BUILD_VERSION 0
#define BUILD_REVISION 1991
#define BUILD_REVISION 1992
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -327,7 +327,7 @@ BuiltInFunctionEmulator::TBuiltInFunction
BuiltInFunctionEmulator::IdentifyFunction(
TOperator op, const TType& param)
{
if (param.getNominalSize() > 4)
if (param.getNominalSize() > 4 || param.getSecondarySize() > 4)
return TFunctionUnknown;
unsigned int function = TFunctionUnknown;
switch (op) {
......@@ -356,9 +356,9 @@ BuiltInFunctionEmulator::IdentifyFunction(
{
// Right now for all the emulated functions with two parameters, the two
// parameters have the same type.
if (param1.isVector() != param2.isVector() ||
param1.getNominalSize() != param2.getNominalSize() ||
param1.getNominalSize() > 4)
if (param1.getNominalSize() != param2.getNominalSize() ||
param1.getSecondarySize() != param2.getSecondarySize() ||
param1.getNominalSize() > 4 || param1.getSecondarySize() > 4)
return TFunctionUnknown;
unsigned int function = TFunctionUnknown;
......
......@@ -619,7 +619,7 @@ void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec,
symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqFragData, 4)));
} else {
symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("css_MixColor"), TType(EbtFloat, EbpMedium, EvqGlobal, 4)));
symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("css_ColorMatrix"), TType(EbtFloat, EbpMedium, EvqGlobal, 4, true)));
symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("css_ColorMatrix"), TType(EbtFloat, EbpMedium, EvqGlobal, 4, 4)));
}
break;
......@@ -717,7 +717,7 @@ void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec,
case SH_FRAGMENT_SHADER:
if (spec != SH_CSS_SHADERS_SPEC) {
// Set up gl_FragData. The array size.
TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, false, true);
TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true);
fragData.setArraySize(resources.MaxDrawBuffers);
symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragData"), fragData));
}
......
......@@ -150,7 +150,7 @@ const ActiveInterfaceBlocks &OutputHLSL::getInterfaceBlocks() const
int OutputHLSL::vectorSize(const TType &type) const
{
int elementSize = type.isMatrix() ? type.getNominalSize() : 1;
int elementSize = type.isMatrix() ? type.getRows() : 1;
int arraySize = type.isArray() ? type.getArraySize() : 1;
return elementSize * arraySize;
......@@ -1573,7 +1573,7 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node)
{
if (node->getLeft()->isMatrix())
{
switch (node->getLeft()->getNominalSize())
switch (node->getLeft()->getRows())
{
case 2: mUsesEqualMat2 = true; break;
case 3: mUsesEqualMat3 = true; break;
......@@ -2210,8 +2210,9 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
case EOpMod:
{
// We need to look at the number of components in both arguments
switch (node->getSequence()[0]->getAsTyped()->getNominalSize() * 10
+ node->getSequence()[1]->getAsTyped()->getNominalSize())
const int modValue = node->getSequence()[0]->getAsTyped()->getNominalSize() * 10
+ node->getSequence()[1]->getAsTyped()->getNominalSize();
switch (modValue)
{
case 11: mUsesMod1 = true; break;
case 22: mUsesMod2v = true; break;
......@@ -2525,7 +2526,7 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node)
if (symbol && constant)
{
if (constant->getBasicType() == EbtInt && constant->getNominalSize() == 1)
if (constant->getBasicType() == EbtInt && constant->isScalar())
{
index = symbol;
initial = constant->getIConst(0);
......@@ -2547,7 +2548,7 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node)
if (constant)
{
if (constant->getBasicType() == EbtInt && constant->getNominalSize() == 1)
if (constant->getBasicType() == EbtInt && constant->isScalar())
{
comparator = test->getOp();
limit = constant->getIConst(0);
......@@ -2569,7 +2570,7 @@ bool OutputHLSL::handleExcessiveLoop(TIntermLoop *node)
if (constant)
{
if (constant->getBasicType() == EbtInt && constant->getNominalSize() == 1)
if (constant->getBasicType() == EbtInt && constant->isScalar())
{
int value = constant->getIConst(0);
......@@ -2815,7 +2816,7 @@ TString OutputHLSL::typeString(const TType &type)
}
else if (type.isMatrix())
{
switch (type.getNominalSize())
switch (type.getRows())
{
case 2: return "float2x2";
case 3: return "float3x3";
......@@ -3015,18 +3016,19 @@ void OutputHLSL::addConstructor(const TType &type, const TString &name, const TI
if (ctorType.isMatrix() && ctorParameters.size() == 1)
{
int dim = ctorType.getNominalSize();
int rows = ctorType.getRows();
int cols = ctorType.getCols();
const TType &parameter = ctorParameters[0];
if (parameter.isScalar())
{
for (int row = 0; row < dim; row++)
for (int row = 0; row < rows; row++)
{
for (int col = 0; col < dim; col++)
for (int col = 0; col < cols; col++)
{
constructor += TString((row == col) ? "x0" : "0.0");
if (row < dim - 1 || col < dim - 1)
if (row < rows - 1 || col < cols - 1)
{
constructor += ", ";
}
......@@ -3035,11 +3037,11 @@ void OutputHLSL::addConstructor(const TType &type, const TString &name, const TI
}
else if (parameter.isMatrix())
{
for (int row = 0; row < dim; row++)
for (int row = 0; row < rows; row++)
{
for (int col = 0; col < dim; col++)
for (int col = 0; col < cols; col++)
{
if (row < parameter.getNominalSize() && col < parameter.getNominalSize())
if (row < parameter.getRows() && col < parameter.getCols())
{
constructor += TString("x0") + "[" + str(row) + "]" + "[" + str(col) + "]";
}
......@@ -3048,7 +3050,7 @@ void OutputHLSL::addConstructor(const TType &type, const TString &name, const TI
constructor += TString((row == col) ? "1.0" : "0.0");
}
if (row < dim - 1 || col < dim - 1)
if (row < rows - 1 || col < cols - 1)
{
constructor += ", ";
}
......@@ -3079,7 +3081,7 @@ void OutputHLSL::addConstructor(const TType &type, const TString &name, const TI
{
remainingComponents -= parameter.getObjectSize();
}
else if (remainingComponents < parameter.getNominalSize())
else if (remainingComponents < parameter.getCols())
{
switch (remainingComponents)
{
......@@ -3350,7 +3352,7 @@ GLenum OutputHLSL::glVariableType(const TType &type)
}
else if (type.isMatrix())
{
switch(type.getNominalSize())
switch(type.getRows())
{
case 2: return GL_FLOAT_MAT2;
case 3: return GL_FLOAT_MAT3;
......
......@@ -115,7 +115,7 @@ bool TParseContext::parseVectorFields(const TString& compString, int vecSize, TV
// 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)
bool TParseContext::parseMatrixFields(const TString& compString, int matCols, int matRows, TMatrixFields& fields, int line)
{
fields.wholeRow = false;
fields.wholeCol = false;
......@@ -151,7 +151,7 @@ bool TParseContext::parseMatrixFields(const TString& compString, int matSize, TM
fields.col = compString[1] - '0';
}
if (fields.row >= matSize || fields.col >= matSize) {
if (fields.row >= matRows || fields.col >= matCols) {
error(line, "matrix field selection out of range", compString.c_str());
return false;
}
......@@ -396,7 +396,7 @@ bool TParseContext::constErrorCheck(TIntermTyped* node)
//
bool TParseContext::integerErrorCheck(TIntermTyped* node, const char* token)
{
if (node->getBasicType() == EbtInt && node->getNominalSize() == 1)
if (node->getBasicType() == EbtInt && node->isScalar())
return false;
error(node->getLine(), "integer expression required", token);
......@@ -599,7 +599,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.isAggregate()) {
error(line, "boolean expression expected", "");
return true;
}
......@@ -1355,7 +1355,7 @@ TIntermTyped* TParseContext::addConstMatrixNode(int index, TIntermTyped* node, T
TIntermTyped* typedNode;
TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
if (index >= node->getType().getNominalSize()) {
if (index >= node->getType().getRows()) {
std::stringstream extraInfoStream;
extraInfoStream << "matrix field selection out of range '" << index << "'";
std::string extraInfo = extraInfoStream.str();
......@@ -1366,7 +1366,7 @@ TIntermTyped* TParseContext::addConstMatrixNode(int index, TIntermTyped* node, T
if (tempConstantNode) {
ConstantUnion* unionArray = tempConstantNode->getUnionArrayPointer();
int size = tempConstantNode->getType().getNominalSize();
int size = tempConstantNode->getType().getCols();
typedNode = intermediate.addConstantUnion(&unionArray[size*index], tempConstantNode->getType(), line);
} else {
error(line, "Cannot offset into the matrix", "Error");
......@@ -1642,7 +1642,11 @@ TIntermTyped* TParseContext::addIndexExpression(TIntermTyped *baseExpression, TS
{
if (indexExpression->getQualifier() == EvqConst)
{
if ((baseExpression->isVector() || baseExpression->isMatrix()) && baseExpression->getType().getNominalSize() <= indexExpression->getAsConstantUnion()->getIConst(0) && !baseExpression->isArray() )
const bool isMatrixOrVector = (baseExpression->isVector() || baseExpression->isMatrix());
const bool indexOOR = (isMatrixOrVector && baseExpression->getType().getNominalSize() <= indexExpression->getAsConstantUnion()->getIConst(0));
// check for index out-of-range
if (indexOOR && !baseExpression->isArray())
{
std::stringstream extraInfoStream;
extraInfoStream << "field selection out of range '" << indexExpression->getAsConstantUnion()->getIConst(0) << "'";
......@@ -1711,7 +1715,7 @@ TIntermTyped* TParseContext::addIndexExpression(TIntermTyped *baseExpression, TS
}
else
{
indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision(), EvqTemporary, baseExpression->getNominalSize(), baseExpression->isMatrix()));
indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision(), EvqTemporary, baseExpression->getNominalSize(), baseExpression->getSecondarySize()));
}
if (baseExpression->getType().getQualifier() == EvqConst)
......@@ -1721,11 +1725,11 @@ TIntermTyped* TParseContext::addIndexExpression(TIntermTyped *baseExpression, TS
}
else if (baseExpression->isMatrix() && baseExpression->getType().getQualifier() == EvqConst)
{
indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision(), EvqConst, baseExpression->getNominalSize()));
indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision(), EvqConst, baseExpression->getRows()));
}
else if (baseExpression->isMatrix())
{
indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision(), EvqTemporary, baseExpression->getNominalSize()));
indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision(), EvqTemporary, baseExpression->getRows()));
}
else if (baseExpression->isVector() && baseExpression->getType().getQualifier() == EvqConst)
{
......@@ -1788,7 +1792,7 @@ TIntermTyped* TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpre
else if (baseExpression->isMatrix())
{
TMatrixFields fields;
if (!parseMatrixFields(fieldString, baseExpression->getNominalSize(), fields, fieldLocation))
if (!parseMatrixFields(fieldString, baseExpression->getCols(), baseExpression->getRows(), fields, fieldLocation))
{
fields.wholeRow = false;
fields.wholeCol = false;
......@@ -1805,12 +1809,12 @@ TIntermTyped* TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpre
unionArray->setIConst(0);
TIntermTyped* index = intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), fieldLocation);
indexedExpression = intermediate.addIndex(EOpIndexDirect, baseExpression, index, dotLocation);
indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision(),EvqTemporary, baseExpression->getNominalSize()));
indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision(),EvqTemporary, baseExpression->getCols(), baseExpression->getRows()));
}
else
{
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setIConst(fields.col * baseExpression->getNominalSize() + fields.row);
unionArray->setIConst(fields.col * baseExpression->getRows() + fields.row);
TIntermTyped* index = intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), fieldLocation);
indexedExpression = intermediate.addIndex(EOpIndexDirect, baseExpression, index, dotLocation);
indexedExpression->setType(TType(baseExpression->getBasicType(), baseExpression->getPrecision()));
......@@ -1938,8 +1942,8 @@ TTypeList *TParseContext::addStructDeclaratorList(const TPublicType& typeSpecifi
//
TType* type = (*typeList)[i].type;
type->setBasicType(typeSpecifier.type);
type->setNominalSize(typeSpecifier.size);
type->setMatrix(typeSpecifier.matrix);
type->setPrimarySize(typeSpecifier.primarySize);
type->setSecondarySize(typeSpecifier.secondarySize);
type->setPrecision(typeSpecifier.precision);
type->setQualifier(typeSpecifier.qualifier);
......
......@@ -79,7 +79,7 @@ struct TParseContext {
void recover();
bool parseVectorFields(const TString&, int vecSize, TVectorFields&, int line);
bool parseMatrixFields(const TString&, int matSize, TMatrixFields&, int line);
bool parseMatrixFields(const TString&, int matCols, int matRows, TMatrixFields&, int line);
bool reservedErrorCheck(int line, const TString& identifier);
void assignError(int line, const char* op, TString left, TString right);
......
......@@ -21,7 +21,7 @@
#include "common/angleutils.h"
TType::TType(const TPublicType &p) :
type(p.type), precision(p.precision), qualifier(p.qualifier), size(p.size), matrix(p.matrix), array(p.array), arraySize(p.arraySize),
type(p.type), precision(p.precision), qualifier(p.qualifier), primarySize(p.primarySize), secondarySize(p.secondarySize), array(p.array), arraySize(p.arraySize),
maxArraySize(0), arrayInformationType(0), interfaceBlockType(0), structure(0), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0), typeName(0)
{
if (p.userDef) {
......@@ -76,7 +76,16 @@ void TType::buildMangledName(TString& mangledName)
break;
}
mangledName += static_cast<char>('0' + getNominalSize());
if (isMatrix())
{
mangledName += static_cast<char>('0' + getCols());
mangledName += static_cast<char>('x');
mangledName += static_cast<char>('0' + getRows());
}
else
{
mangledName += static_cast<char>('0' + getNominalSize());
}
if (isArray()) {
char buf[20];
snprintf(buf, sizeof(buf), "%d", arraySize);
......
......@@ -333,7 +333,7 @@ public:
return true; // Skip sampler types for the time being
if (type.type != EbtFloat && type.type != EbtInt)
return false; // Only set default precision for int/float
if (type.size != 1 || type.matrix || type.array)
if (type.isAggregate())
return false; // Not allowed to set for aggregate types
int indexOfLastElement = static_cast<int>(precisionStack.size()) - 1;
precisionStack[indexOfLastElement][type.type] = prec; // Uses map operator [], overwrites the current value
......
......@@ -40,14 +40,14 @@ class TType
public:
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
TType() {}
TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, int s = 1, bool m = false, bool a = false) :
type(t), precision(p), qualifier(q), size(s), matrix(m), array(a), arraySize(0),
TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, int ps = 1, int ss = 1, bool a = false) :
type(t), precision(p), qualifier(q), primarySize(ps), secondarySize(ss), array(a), arraySize(0),
maxArraySize(0), arrayInformationType(0), interfaceBlockType(0), structure(0), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0), typeName(0), instanceName(0)
{
}
explicit TType(const TPublicType &p);
TType(TTypeList* userDef, const TString& n, TPrecision p = EbpUndefined) :
type(EbtStruct), precision(p), qualifier(EvqTemporary), size(1), matrix(false), array(false), arraySize(0),
type(EbtStruct), precision(p), qualifier(EvqTemporary), primarySize(1), secondarySize(1), array(false), arraySize(0),
maxArraySize(0), arrayInformationType(0), interfaceBlockType(0), structure(userDef), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0), instanceName(0)
{
typeName = NewPoolTString(n.c_str());
......@@ -58,8 +58,8 @@ public:
type = copyOf.type;
precision = copyOf.precision;
qualifier = copyOf.qualifier;
size = copyOf.size;
matrix = copyOf.matrix;
primarySize = copyOf.primarySize;
secondarySize = copyOf.secondarySize;
array = copyOf.array;
arraySize = copyOf.arraySize;
......@@ -120,9 +120,13 @@ public:
TQualifier getQualifier() const { return qualifier; }
void setQualifier(TQualifier q) { qualifier = q; }
// One-dimensional size of single instance type
int getNominalSize() const { return size; }
void setNominalSize(int s) { size = s; }
int getNominalSize() const { return primarySize; }
int getSecondarySize() const { return secondarySize; }
int getCols() const { ASSERT(isMatrix()); return primarySize; }
int getRows() const { ASSERT(isMatrix()); return secondarySize; }
void setPrimarySize(int ps) { primarySize = ps; }
void setSecondarySize(int ss) { secondarySize = ss; }
// Full size of single instance of type
int getObjectSize() const
{
......@@ -130,10 +134,8 @@ public:
if (getBasicType() == EbtStruct)
totalSize = getStructSize();
else if (matrix)
totalSize = size * size;
else
totalSize = size;
totalSize = primarySize * secondarySize;
if (isArray())
totalSize *= std::max(getArraySize(), getMaxArraySize());
......@@ -158,7 +160,7 @@ public:
}
else if (isMatrix())
{
return getNominalSize();
return getRows();
}
else
{
......@@ -178,9 +180,7 @@ public:
}
}
bool isMatrix() const { return matrix ? true : false; }
void setMatrix(bool m) { matrix = m; }
bool isMatrix() const { return primarySize > 1 && secondarySize > 1; }
bool isArray() const { return array ? true : false; }
int getArraySize() const { return arraySize; }
void setArraySize(int s) { array = true; arraySize = s; }
......@@ -193,8 +193,8 @@ public:
TType* getInterfaceBlockType() const { return interfaceBlockType; }
bool isInterfaceBlockMember() const { return interfaceBlockType != NULL; }
bool isVector() const { return size > 1 && !matrix; }
bool isScalar() const { return size == 1 && !matrix && !structure; }
bool isVector() const { return primarySize > 1 && secondarySize == 1; }
bool isScalar() const { return primarySize == 1 && secondarySize == 1 && !structure; }
TTypeList* getStruct() const { return structure; }
void setStruct(TTypeList* s) { structure = s; computeDeepestStructNesting(); }
......@@ -250,16 +250,16 @@ public:
}
bool sameElementType(const TType& right) const {
return type == right.type &&
size == right.size &&
matrix == right.matrix &&
return type == right.type &&
primarySize == right.primarySize &&
secondarySize == right.secondarySize &&
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) &&
return type == right.type &&
primarySize == right.primarySize &&
secondarySize == right.secondarySize &&
array == right.array && (!array || arraySize == right.arraySize) &&
structure == right.structure;
// don't check the qualifier, it's not ever what's being sought after
}
......@@ -268,8 +268,8 @@ public:
}
bool operator<(const TType& right) const {
if (type != right.type) return type < right.type;
if (size != right.size) return size < right.size;
if (matrix != right.matrix) return matrix < right.matrix;
if (primarySize != right.primarySize) return primarySize < right.primarySize;
if (secondarySize != right.secondarySize) return secondarySize < right.secondarySize;
if (array != right.array) return array < right.array;
if (arraySize != right.arraySize) return arraySize < right.arraySize;
if (structure != right.structure) return structure < right.structure;
......@@ -306,9 +306,9 @@ protected:
TBasicType type : 6;
TPrecision precision : 4;
TQualifier qualifier : 7;
int size : 8; // size of vector or matrix, not size of array
unsigned int matrix : 1;
unsigned int array : 1;
int primarySize; // size of vector or cols matrix
int secondarySize; // rows of a matrix
int arraySize;
int maxArraySize;
TType* arrayInformationType;
......@@ -338,8 +338,8 @@ struct TPublicType
TBasicType type;
TQualifier qualifier;
TPrecision precision;
int size; // size of vector or matrix, not size of array
bool matrix;
int primarySize; // size of vector or cols of matrix
int secondarySize; // rows of matrix
bool array;
int arraySize;
TType* userDef;
......@@ -350,18 +350,24 @@ struct TPublicType
type = bt;
qualifier = q;
precision = EbpUndefined;
size = 1;
matrix = false;
primarySize = 1;
secondarySize = 1;
array = false;
arraySize = 0;
userDef = 0;
line = ln;
}
void setAggregate(int s, bool m = false)
void setAggregate(int size)
{
primarySize = size;
}
void setMatrix(int c, int r)
{
size = s;
matrix = m;
ASSERT(c > 1 && r > 1 && c <= 4 && r <= 4);
primarySize = c;
secondarySize = r;
}
void setArray(bool a, int s = 0)
......@@ -379,6 +385,38 @@ struct TPublicType
return userDef->isStructureContainingArrays();
}
bool isMatrix() const
{
return primarySize > 1 && secondarySize > 1;
}
bool isVector() const
{
return primarySize > 1 && secondarySize == 1;
}
int getCols() const
{
ASSERT(isMatrix());
return primarySize;
}
int getRows() const
{
ASSERT(isMatrix());
return secondarySize;
}
int getNominalSize() const
{
return primarySize;
}
bool isAggregate() const
{
return array || isMatrix() || isVector();
}
};
#endif // _TYPES_INCLUDED_
......@@ -19,7 +19,7 @@ static ShDataType getVariableDataType(const TType& type)
switch (type.getBasicType()) {
case EbtFloat:
if (type.isMatrix()) {
switch (type.getNominalSize()) {
switch (type.getRows()) {
case 2: return SH_FLOAT_MAT2;
case 3: return SH_FLOAT_MAT3;
case 4: return SH_FLOAT_MAT4;
......
......@@ -459,14 +459,14 @@ function_identifier
} else {
switch ($1.type) {
case EbtFloat:
if ($1.matrix) {
switch($1.size) {
if ($1.isMatrix()) {
switch($1.getCols()) {
case 2: op = EOpConstructMat2; break;
case 3: op = EOpConstructMat3; break;
case 4: op = EOpConstructMat4; break;
}
} else {
switch($1.size) {
switch($1.getNominalSize()) {
case 1: op = EOpConstructFloat; break;
case 2: op = EOpConstructVec2; break;
case 3: op = EOpConstructVec3; break;
......@@ -475,7 +475,7 @@ function_identifier
}
break;
case EbtInt:
switch($1.size) {
switch($1.getNominalSize()) {
case 1: op = EOpConstructInt; break;
case 2: FRAG_VERT_ONLY("ivec2", $1.line); op = EOpConstructIVec2; break;
case 3: FRAG_VERT_ONLY("ivec3", $1.line); op = EOpConstructIVec3; break;
......@@ -483,7 +483,7 @@ function_identifier
}
break;
case EbtBool:
switch($1.size) {
switch($1.getNominalSize()) {
case 1: op = EOpConstructBool; break;
case 2: FRAG_VERT_ONLY("bvec2", $1.line); op = EOpConstructBVec2; break;
case 3: FRAG_VERT_ONLY("bvec3", $1.line); op = EOpConstructBVec3; break;
......@@ -1592,19 +1592,19 @@ type_specifier_nonarray
FRAG_VERT_ONLY("mat2", $1.line);
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtFloat, qual, $1.line);
$$.setAggregate(2, true);
$$.setMatrix(2, 2);
}
| MATRIX3 {
FRAG_VERT_ONLY("mat3", $1.line);
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtFloat, qual, $1.line);
$$.setAggregate(3, true);
$$.setMatrix(3, 3);
}
| MATRIX4 {
FRAG_VERT_ONLY("mat4", $1.line);
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtFloat, qual, $1.line);
$$.setAggregate(4, true);
$$.setMatrix(4, 4);
}
| SAMPLER2D {
FRAG_VERT_ONLY("sampler2D", $1.line);
......
......@@ -2540,14 +2540,14 @@ yyreduce:
} else {
switch ((yyvsp[(1) - (1)].interm.type).type) {
case EbtFloat:
if ((yyvsp[(1) - (1)].interm.type).matrix) {
switch((yyvsp[(1) - (1)].interm.type).size) {
if ((yyvsp[(1) - (1)].interm.type).isMatrix()) {
switch((yyvsp[(1) - (1)].interm.type).getCols()) {
case 2: op = EOpConstructMat2; break;
case 3: op = EOpConstructMat3; break;
case 4: op = EOpConstructMat4; break;
}
} else {
switch((yyvsp[(1) - (1)].interm.type).size) {
switch((yyvsp[(1) - (1)].interm.type).getNominalSize()) {
case 1: op = EOpConstructFloat; break;
case 2: op = EOpConstructVec2; break;
case 3: op = EOpConstructVec3; break;
......@@ -2556,7 +2556,7 @@ yyreduce:
}
break;
case EbtInt:
switch((yyvsp[(1) - (1)].interm.type).size) {
switch((yyvsp[(1) - (1)].interm.type).getNominalSize()) {
case 1: op = EOpConstructInt; break;
case 2: FRAG_VERT_ONLY("ivec2", (yyvsp[(1) - (1)].interm.type).line); op = EOpConstructIVec2; break;
case 3: FRAG_VERT_ONLY("ivec3", (yyvsp[(1) - (1)].interm.type).line); op = EOpConstructIVec3; break;
......@@ -2564,7 +2564,7 @@ yyreduce:
}
break;
case EbtBool:
switch((yyvsp[(1) - (1)].interm.type).size) {
switch((yyvsp[(1) - (1)].interm.type).getNominalSize()) {
case 1: op = EOpConstructBool; break;
case 2: FRAG_VERT_ONLY("bvec2", (yyvsp[(1) - (1)].interm.type).line); op = EOpConstructBVec2; break;
case 3: FRAG_VERT_ONLY("bvec3", (yyvsp[(1) - (1)].interm.type).line); op = EOpConstructBVec3; break;
......@@ -3940,7 +3940,7 @@ yyreduce:
FRAG_VERT_ONLY("mat2", (yyvsp[(1) - (1)].lex).line);
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
(yyval.interm.type).setBasic(EbtFloat, qual, (yyvsp[(1) - (1)].lex).line);
(yyval.interm.type).setAggregate(2, true);
(yyval.interm.type).setMatrix(2, 2);
}
break;
......@@ -3950,7 +3950,7 @@ yyreduce:
FRAG_VERT_ONLY("mat3", (yyvsp[(1) - (1)].lex).line);
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
(yyval.interm.type).setBasic(EbtFloat, qual, (yyvsp[(1) - (1)].lex).line);
(yyval.interm.type).setAggregate(3, true);
(yyval.interm.type).setMatrix(3, 3);
}
break;
......@@ -3960,7 +3960,7 @@ yyreduce:
FRAG_VERT_ONLY("mat4", (yyvsp[(1) - (1)].lex).line);
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
(yyval.interm.type).setBasic(EbtFloat, qual, (yyvsp[(1) - (1)].lex).line);
(yyval.interm.type).setAggregate(4, true);
(yyval.interm.type).setMatrix(4, 4);
}
break;
......
......@@ -43,10 +43,10 @@ TString TType::getCompleteString() const
stream << getQualifierString() << " " << getPrecisionString() << " ";
if (array)
stream << "array[" << getArraySize() << "] of ";
if (matrix)
stream << size << "X" << size << " matrix of ";
else if (size > 1)
stream << size << "-component vector of ";
if (isMatrix())
stream << getCols() << "X" << getRows() << " matrix of ";
else if (isVector())
stream << getNominalSize() << "-component vector of ";
stream << getBasicString();
return stream.str();
......
......@@ -250,7 +250,10 @@ public:
TBasicType getBasicType() const { return type.getBasicType(); }
TQualifier getQualifier() const { return type.getQualifier(); }
TPrecision getPrecision() const { return type.getPrecision(); }
int getCols() const { return type.getCols(); }
int getRows() const { return type.getRows(); }
int getNominalSize() const { return type.getNominalSize(); }
int getSecondarySize() const { return type.getSecondarySize(); }
bool isMatrix() const { return type.isMatrix(); }
bool isArray() const { return type.isArray(); }
......
......@@ -119,7 +119,7 @@ bool TConstTraverser::visitAggregate(Visit visit, TIntermAggregate* node)
if (node->getType().isMatrix()) {
isMatrix = true;
matrixSize = node->getType().getNominalSize();
matrixSize = node->getType().getRows();
}
}
......@@ -165,10 +165,10 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
return;
if (!singleConstantParam) {
int size = node->getType().getObjectSize();
int objectSize = node->getType().getObjectSize();
ConstantUnion *rightUnionArray = node->getUnionArrayPointer();
for (int i=0; i < size; i++) {
for (int i=0; i < objectSize; i++) {
if (index >= instanceSize)
return;
leftUnionArray[index] = rightUnionArray[i];
......
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