Commit e79904c3 by Olli Etuaho

Accept equality and assignment for arrays in parsing

This is enough to support the operations in GLSL output. HLSL output will likely require additional work to support this. BUG=angleproject:941 Change-Id: I728d511ab07af94bc3382dc2796c1e9ac79d1442 Reviewed-on: https://chromium-review.googlesource.com/260801Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent 1ade24db
...@@ -387,8 +387,7 @@ bool TIntermUnary::promote(TInfoSink &) ...@@ -387,8 +387,7 @@ bool TIntermUnary::promote(TInfoSink &)
// //
bool TIntermBinary::promote(TInfoSink &infoSink) bool TIntermBinary::promote(TInfoSink &infoSink)
{ {
// This function only handles scalars, vectors, and matrices. ASSERT(mLeft->isArray() == mRight->isArray());
ASSERT(!mLeft->isArray() && !mRight->isArray());
// GLSL ES 2.0 does not support implicit type casting. // GLSL ES 2.0 does not support implicit type casting.
// So the basic type should usually match. // So the basic type should usually match.
...@@ -670,6 +669,11 @@ bool TIntermBinary::promote(TInfoSink &infoSink) ...@@ -670,6 +669,11 @@ bool TIntermBinary::promote(TInfoSink &infoSink)
mLeft->getSecondarySize(), mRight->getSecondarySize()); mLeft->getSecondarySize(), mRight->getSecondarySize());
setType(TType(basicType, higherPrecision, EvqTemporary, setType(TType(basicType, higherPrecision, EvqTemporary,
nominalSize, secondarySize)); nominalSize, secondarySize));
if (mLeft->isArray())
{
ASSERT(mLeft->getArraySize() == mRight->getArraySize());
mType.setArraySize(mLeft->getArraySize());
}
} }
break; break;
......
...@@ -1393,7 +1393,16 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node) ...@@ -1393,7 +1393,16 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node)
switch (node->getOp()) switch (node->getOp())
{ {
case EOpAssign: outputTriplet(visit, "(", " = ", ")"); break; case EOpAssign:
if (node->getLeft()->isArray())
{
UNIMPLEMENTED();
}
else
{
outputTriplet(visit, "(", " = ", ")");
}
break;
case EOpInitialize: case EOpInitialize:
if (visit == PreVisit) if (visit == PreVisit)
{ {
...@@ -1565,7 +1574,11 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node) ...@@ -1565,7 +1574,11 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node)
case EOpBitwiseOr: outputTriplet(visit, "(", " | ", ")"); break; case EOpBitwiseOr: outputTriplet(visit, "(", " | ", ")"); break;
case EOpEqual: case EOpEqual:
case EOpNotEqual: case EOpNotEqual:
if (node->getLeft()->isScalar()) if (node->getLeft()->isArray())
{
UNIMPLEMENTED();
}
else if (node->getLeft()->isScalar())
{ {
if (node->getOp() == EOpEqual) if (node->getOp() == EOpEqual)
{ {
......
...@@ -2721,8 +2721,34 @@ bool TParseContext::binaryOpArrayCheck(TOperator op, TIntermTyped *left, TInterm ...@@ -2721,8 +2721,34 @@ bool TParseContext::binaryOpArrayCheck(TOperator op, TIntermTyped *left, TInterm
{ {
if (left->isArray() || right->isArray()) if (left->isArray() || right->isArray())
{ {
error(loc, "Invalid operation for arrays", GetOperatorString(op)); if (shaderVersion < 300)
return false; {
error(loc, "Invalid operation for arrays", GetOperatorString(op));
return false;
}
if (left->isArray() != right->isArray())
{
error(loc, "array / non-array mismatch", GetOperatorString(op));
return false;
}
switch (op)
{
case EOpEqual:
case EOpNotEqual:
case EOpAssign:
case EOpInitialize:
break;
default:
error(loc, "Invalid operation for arrays", GetOperatorString(op));
return false;
}
if (left->getArraySize() != right->getArraySize())
{
error(loc, "array size mismatch", GetOperatorString(op));
return false;
}
} }
return true; return true;
} }
......
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