Disallow operations on structs containing samplers
ESSL 1.00 spec section 5.9 says that equality operators don't operate on
structs containing sampler types. Section 5.7 also suggests this. ESSL
3.00 doesn't have a similar restriction.
ESSL 1.00 spec section 4.1.7 says that structs containing samplers can't
be used as l-values. This is interpreted to apply also in the case of
ESSL 3.00, which similarly disallows samplers as l-values, but doesn't
explicitly mention structs.
BUG=angleproject:954
TEST=angle_unittests, WebGL conformance tests
Change-Id: I73f74962a192e8d9449990ffa5f3d8c851491601
Reviewed-on: https://chromium-review.googlesource.com/261822
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/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index 884beeb..0e6ae31 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -2792,7 +2792,7 @@
}
// Check that type sizes match exactly on ops that require that.
- // Also check restrictions for structs that contain arrays.
+ // Also check restrictions for structs that contain arrays or samplers.
switch(op)
{
case EOpAssign:
@@ -2805,6 +2805,15 @@
error(loc, "undefined operation for structs containing arrays", GetOperatorString(op));
return false;
}
+ // Samplers as l-values are disallowed also in ESSL 3.00, see section 4.1.7,
+ // we interpret the spec so that this extends to structs containing samplers,
+ // similarly to ESSL 1.00 spec.
+ if ((shaderVersion < 300 || op == EOpAssign || op == EOpInitialize) &&
+ left->getType().isStructureContainingSamplers())
+ {
+ error(loc, "undefined operation for structs containing samplers", GetOperatorString(op));
+ return false;
+ }
case EOpLessThan:
case EOpGreaterThan:
case EOpLessThanEqual: