Commit 6c85047a by Olli Etuaho Committed by Jamie Madill

Reject compound assignments of the type scalar op= vector/matrix

scalar op vector/matrix produces a vector/matrix, which can't be assigned to a scalar. Handle this correctly for addition, subtraction and division. Multiplication was already handled correctly as a special case. BUG=angle:832 TEST=WebGL conformance tests Change-Id: I318cae8bf353a5c58c588876ce3f29d18389263c Reviewed-on: https://chromium-review.googlesource.com/232601Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent 2c43325d
...@@ -569,11 +569,19 @@ bool TIntermBinary::promote(TInfoSink &infoSink) ...@@ -569,11 +569,19 @@ bool TIntermBinary::promote(TInfoSink &infoSink)
if (mLeft->getNominalSize() != mRight->getNominalSize() || if (mLeft->getNominalSize() != mRight->getNominalSize() ||
mLeft->getSecondarySize() != mRight->getSecondarySize()) mLeft->getSecondarySize() != mRight->getSecondarySize())
{ {
// If the nominal size of operands do not match: // If the nominal sizes of operands do not match:
// One of them must be scalar. // One of them must be a scalar.
if (!mLeft->isScalar() && !mRight->isScalar()) if (!mLeft->isScalar() && !mRight->isScalar())
return false; return false;
// In the case of compound assignment, the right side needs to be a
// scalar. Otherwise a vector/matrix would be assigned to a scalar.
if (!mRight->isScalar() &&
(mOp == EOpAddAssign ||
mOp == EOpSubAssign ||
mOp == EOpDivAssign))
return false;
// Operator cannot be of type pure assignment. // Operator cannot be of type pure assignment.
if (mOp == EOpAssign || mOp == EOpInitialize) if (mOp == EOpAssign || mOp == EOpInitialize)
return false; return false;
......
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