Only apply Appendix A limitations to ESSL 1.00 shaders
ESSL 1.00 specifies a set of minimum functionality, and ANGLE
automatically checks that WebGL shaders stay within this minimum
functionality. However, this should only apply to ESSL 1.00. ESSL 3.00
shaders compiled for WebGL 2.0 should not be subject to these
restrictions, since there is no similar spec for minimum functionality
for ESSL 3.00.
In case a non-WebGL based shader spec is used, the restrictions can be
toggled from outside by specifying the SH_VALIDATE_LOOP_INDEXING flag,
same as before this patch.
BUG=angleproject:1116
TEST=WebGL 2 conformance tests
Change-Id: Idaec0fb4c7c85cd72020d0b23112fddb1b020571
Reviewed-on: https://chromium-review.googlesource.com/293933
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp
index 3e9a0b6..555d794 100644
--- a/src/compiler/translator/Compiler.cpp
+++ b/src/compiler/translator/Compiler.cpp
@@ -182,8 +182,9 @@
return compileTreeImpl(shaderStrings, numStrings, compileOptions);
}
-TIntermNode *TCompiler::compileTreeImpl(const char* const shaderStrings[],
- size_t numStrings, int compileOptions)
+TIntermNode *TCompiler::compileTreeImpl(const char *const shaderStrings[],
+ size_t numStrings,
+ const int compileOptions)
{
clearResults();
@@ -193,10 +194,6 @@
// Reset the extension behavior for each compilation unit.
ResetExtensionBehavior(extensionBehavior);
- // If compiling for WebGL, validate loop and indexing as well.
- if (IsWebGLBasedSpec(shaderSpec))
- compileOptions |= SH_VALIDATE_LOOP_INDEXING;
-
// First string is path of source file if flag is set. The actual source follows.
size_t firstSource = 0;
if (compileOptions & SH_SOURCE_PATH)
@@ -231,6 +228,12 @@
success = false;
}
+ // If compiling an ESSL 1.00 shader for WebGL, or if its been requested through the API,
+ // validate loop and indexing as well (to verify that the shader only uses minimal functionality
+ // of ESSL 1.00 as in Appendix A of the spec).
+ bool validateLoopAndIndexing = (IsWebGLBasedSpec(shaderSpec) && shaderVersion == 100) ||
+ (compileOptions & SH_VALIDATE_LOOP_INDEXING);
+
TIntermNode *root = nullptr;
if (success)
@@ -273,7 +276,7 @@
if (success && shaderVersion == 300 && shaderType == GL_FRAGMENT_SHADER)
success = validateOutputs(root);
- if (success && (compileOptions & SH_VALIDATE_LOOP_INDEXING))
+ if (success && validateLoopAndIndexing)
success = validateLimitations(root);
if (success && (compileOptions & SH_TIMING_RESTRICTIONS))