Commit 56193ce3 by Olli Etuaho

Clean up parseMatrixFields

Applying field selection directly on matrices is not mentioned in ESSL 1.00 or 3.00 specs. Remove erroneous code that generated odd error messages when a shader tried to apply certain kinds of field selection on a matrix. BUG=angleproject:1118 TEST=angle_unittests, dEQP-GLES3.functional.shaders.swizzles.* Change-Id: I7bbf5d0cbaee3f21d20b830d904c0feef445dd78 Reviewed-on: https://chromium-review.googlesource.com/293190Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent 391befef
......@@ -126,68 +126,6 @@ bool TParseContext::parseVectorFields(const TString &compString,
return true;
}
//
// Look at a '.' field selector string and change it into offsets
// for a matrix.
//
bool TParseContext::parseMatrixFields(const TString &compString,
int matCols,
int matRows,
TMatrixFields &fields,
const TSourceLoc &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 >= matRows || fields.col >= matCols)
{
error(line, "matrix field selection out of range", compString.c_str());
return false;
}
return true;
}
///////////////////////////////////////////////////////////////////////
//
// Errors
......@@ -3033,46 +2971,6 @@ TIntermTyped *TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpre
(unsigned char)vectorString.size()));
}
}
else if (baseExpression->isMatrix())
{
TMatrixFields fields;
if (!parseMatrixFields(fieldString, baseExpression->getCols(), baseExpression->getRows(),
fields, fieldLocation))
{
fields.wholeRow = false;
fields.wholeCol = false;
fields.row = 0;
fields.col = 0;
recover();
}
if (fields.wholeRow || fields.wholeCol)
{
error(dotLocation, " non-scalar fields not implemented yet", ".");
recover();
TConstantUnion *unionArray = new TConstantUnion[1];
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,
static_cast<unsigned char>(baseExpression->getCols()),
static_cast<unsigned char>(baseExpression->getRows())));
}
else
{
TConstantUnion *unionArray = new TConstantUnion[1];
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()));
}
}
else if (baseExpression->getBasicType() == EbtStruct)
{
bool fieldFound = false;
......@@ -3174,15 +3072,14 @@ TIntermTyped *TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpre
{
if (mShaderVersion < 300)
{
error(dotLocation,
" field selection requires structure, vector, or matrix on left hand side",
error(dotLocation, " field selection requires structure or vector on left hand side",
fieldString.c_str());
}
else
{
error(dotLocation,
" field selection requires structure, vector, matrix, or interface block on left "
"hand side",
" field selection requires structure, vector, or interface block on left hand "
"side",
fieldString.c_str());
}
recover();
......
......@@ -114,7 +114,6 @@ class TParseContext : angle::NonCopyable
const TVariable *getNamedVariable(const TSourceLoc &location, const TString *name, const TSymbol *symbol);
bool parseVectorFields(const TString&, int vecSize, TVectorFields&, const TSourceLoc &line);
bool parseMatrixFields(const TString&, int matCols, int matRows, TMatrixFields&, const TSourceLoc &line);
bool reservedErrorCheck(const TSourceLoc &line, const TString &identifier);
void assignError(const TSourceLoc &line, const char *op, TString left, TString right);
......
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