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/preprocessor/DirectiveHandlerBase.h b/src/compiler/preprocessor/DirectiveHandlerBase.h
index 040b25c..eec0d5e 100644
--- a/src/compiler/preprocessor/DirectiveHandlerBase.h
+++ b/src/compiler/preprocessor/DirectiveHandlerBase.h
@@ -29,7 +29,8 @@
     // Handle pragma of form: #pragma name[(value)]
     virtual void handlePragma(const SourceLocation &loc,
                               const std::string &name,
-                              const std::string &value) = 0;
+                              const std::string &value,
+                              bool stdgl) = 0;
 
     virtual void handleExtension(const SourceLocation &loc,
                                  const std::string &name,
diff --git a/src/compiler/preprocessor/DirectiveParser.cpp b/src/compiler/preprocessor/DirectiveParser.cpp
index 6434d5c..e455c36 100644
--- a/src/compiler/preprocessor/DirectiveParser.cpp
+++ b/src/compiler/preprocessor/DirectiveParser.cpp
@@ -592,6 +592,11 @@
     int state = PRAGMA_NAME;
 
     mTokenizer->lex(token);
+    bool stdgl = token->text == "STDGL";
+    if (stdgl)
+    {
+        mTokenizer->lex(token);
+    }
     while ((token->type != '\n') && (token->type != Token::LAST))
     {
         switch(state++)
@@ -627,7 +632,7 @@
     }
     else if (state > PRAGMA_NAME)  // Do not notify for empty pragma.
     {
-        mDirectiveHandler->handlePragma(token->location, name, value);
+        mDirectiveHandler->handlePragma(token->location, name, value, stdgl);
     }
 }