Add support for bitwise operations in ESSL3
Add support for <<, >>, &, |, ^, and their compound assignment variants
<<=, >>=, &=, |=, ^=. Also add support for bitwise not (~).
BUG=angle:870
Change-Id: I5e6a835409589556d5d58d58078fdf505cfd8da5
Reviewed-on: https://chromium-review.googlesource.com/241850
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/compiler/translator/Intermediate.cpp b/src/compiler/translator/Intermediate.cpp
index de72cfe..d33ef34 100644
--- a/src/compiler/translator/Intermediate.cpp
+++ b/src/compiler/translator/Intermediate.cpp
@@ -87,11 +87,14 @@
return NULL;
}
break;
+ // Note that for bitwise ops, type checking is done in promote() to
+ // share code between ops and compound assignment
default:
break;
}
- if (left->getBasicType() != right->getBasicType())
+ // This check is duplicated between here and node->promote() as an optimization.
+ if (left->getBasicType() != right->getBasicType() && op != EOpBitShiftLeft && op != EOpBitShiftRight)
{
return NULL;
}
@@ -193,23 +196,30 @@
switch (op)
{
case EOpLogicalNot:
- if (child->getType().getBasicType() != EbtBool ||
- child->getType().isMatrix() ||
- child->getType().isArray() ||
- child->getType().isVector())
+ if (child->getBasicType() != EbtBool ||
+ child->isMatrix() ||
+ child->isArray() ||
+ child->isVector())
{
return NULL;
}
break;
-
+ case EOpBitwiseNot:
+ if ((child->getBasicType() != EbtInt && child->getBasicType() != EbtUInt) ||
+ child->isMatrix() ||
+ child->isArray())
+ {
+ return NULL;
+ }
+ break;
case EOpPostIncrement:
case EOpPreIncrement:
case EOpPostDecrement:
case EOpPreDecrement:
case EOpNegative:
case EOpPositive:
- if (child->getType().getBasicType() == EbtStruct ||
- child->getType().isArray())
+ if (child->getBasicType() == EbtStruct ||
+ child->isArray())
{
return NULL;
}