Invariant related processing.
* Fix a bug in PreProcessor for STDGL pragma.
* Record all invariant settings and set them in ShaderVariable.
* Write #pragma STDGL invariant(all) in GL
BUG=angle:776
TEST=https://www.khronos.org/registry/webgl/sdk/tests/conformance/glsl/misc/shaders-with-invariance.html
Change-Id: Ie28b75480deed79f0c9f26e3b98f1778d1290182
Reviewed-on: https://chromium-review.googlesource.com/223610
Tested-by: Zhenyao Mo <zmo@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp
index 8e1743d..2824064 100644
--- a/src/compiler/translator/Compiler.cpp
+++ b/src/compiler/translator/Compiler.cpp
@@ -181,6 +181,12 @@
if (success)
{
+ mPragma = parseContext.pragma();
+ if (mPragma.stdgl.invariantAll)
+ {
+ symbolTable.setGlobalInvariant();
+ }
+
TIntermNode* root = parseContext.treeRoot;
success = intermediate.postProcess(root);
@@ -508,7 +514,8 @@
&uniforms,
&varyings,
&interfaceBlocks,
- hashFunction);
+ hashFunction,
+ symbolTable);
root->traverse(&collect);
// For backwards compatiblity with ShGetVariableInfo, expand struct
@@ -582,3 +589,10 @@
{
return builtInFunctionEmulator;
}
+
+void TCompiler::writePragma()
+{
+ TInfoSinkBase &sink = infoSink.obj;
+ if (mPragma.stdgl.invariantAll)
+ sink << "#pragma STDGL invariant(all)\n";
+}