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