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/Initialize.cpp b/src/compiler/translator/Initialize.cpp
index 45c3dcf..c362ae2 100644
--- a/src/compiler/translator/Initialize.cpp
+++ b/src/compiler/translator/Initialize.cpp
@@ -871,11 +871,11 @@
                                               "gl_LastFragColorARM",
                                               TType(EbtFloat, EbpMedium, EvqLastFragColor, 4));
             }
+
+            break;
         }
-
-        break;
-
         case GL_VERTEX_SHADER:
+        {
             symbolTable.insertVariable(COMMON_BUILTINS, "gl_Position",
                                        TType(EbtFloat, EbpHigh, EvqPosition, 4));
             symbolTable.insertVariable(COMMON_BUILTINS, "gl_PointSize",
@@ -884,7 +884,12 @@
                                        TType(EbtInt, EbpHigh, EvqInstanceID, 1));
             symbolTable.insertVariable(ESSL3_BUILTINS, "gl_VertexID",
                                        TType(EbtInt, EbpHigh, EvqVertexID, 1));
+
+            // For internal use by ANGLE - not exposed to the parser.
+            symbolTable.insertVariable(GLSL_BUILTINS, "gl_ViewportIndex",
+                                       TType(EbtInt, EbpHigh, EvqViewportIndex));
             break;
+        }
         case GL_COMPUTE_SHADER:
         {
             symbolTable.insertVariable(ESSL3_1_BUILTINS, "gl_NumWorkGroups",
@@ -899,15 +904,15 @@
                                        TType(EbtUInt, EbpUndefined, EvqGlobalInvocationID, 3));
             symbolTable.insertVariable(ESSL3_1_BUILTINS, "gl_LocalInvocationIndex",
                                        TType(EbtUInt, EbpUndefined, EvqLocalInvocationIndex, 1));
+            break;
         }
-        break;
 
         case GL_GEOMETRY_SHADER_OES:
             // TODO(jiawei.shao@intel.com): add Geometry Shader built-in variables.
             break;
 
         default:
-            assert(false && "Language not supported");
+            UNREACHABLE();
     }
 }