Add gl_ViewportIndex to the symbol table

gl_ViewportIndex is a GLSL built-in that's needed to implement
instanced multiview. It is a bit of a special case: it only exists in
desktop GLSL and not ESSL, and it shouldn't be exposed to the parser.
We add a new level to the symbol table that's hidden from the parser
to make adding this kind of builtins in AST transforms consistent with
the way ESSL builtins are supported.

BUG=angleproject:1490
TEST=angle_unittests

Change-Id: I51b2d983950b38c8e85e4b6ed00c6b39f9b3cb03
Reviewed-on: https://chromium-review.googlesource.com/580953
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/SymbolTable.cpp b/src/compiler/translator/SymbolTable.cpp
index c3ca928..38a87ed 100644
--- a/src/compiler/translator/SymbolTable.cpp
+++ b/src/compiler/translator/SymbolTable.cpp
@@ -141,6 +141,8 @@
 
     do
     {
+        if (level == GLSL_BUILTINS)
+            level--;
         if (level == ESSL3_1_BUILTINS && shaderVersion != 310)
             level--;
         if (level == ESSL3_BUILTINS && shaderVersion < 300)
@@ -167,8 +169,17 @@
 
 TSymbol *TSymbolTable::findBuiltIn(const TString &name, int shaderVersion) const
 {
+    return findBuiltIn(name, shaderVersion, false);
+}
+
+TSymbol *TSymbolTable::findBuiltIn(const TString &name,
+                                   int shaderVersion,
+                                   bool includeGLSLBuiltins) const
+{
     for (int level = LAST_BUILTIN_LEVEL; level >= 0; level--)
     {
+        if (level == GLSL_BUILTINS && !includeGLSLBuiltins)
+            level--;
         if (level == ESSL3_1_BUILTINS && shaderVersion != 310)
             level--;
         if (level == ESSL3_BUILTINS && shaderVersion < 300)
@@ -182,7 +193,7 @@
             return symbol;
     }
 
-    return 0;
+    return nullptr;
 }
 
 TSymbolTable::~TSymbolTable()