Populate gl_InstanceID attribute information explicitly

While compiling ESSL1 shaders, with the compiler having both
SH_INITIALIZE_BUILTINS_FOR_INSTANCED_MULTIVIEW and SH_VARIABLES
set, variable collection terminates with an assertion failure. The reason
behind this is that SH_INITIALIZE_BUILTINS_FOR_INSTANCED_MULTIVIEW
adds gl_InstanceID to the AST to initialize the multiview builtins, but
the variable collection pass cannot find gl_InstanceID information in
the symbol table because the builtin is only available in ESSL 3.00 and
greater.

To address this the patch populates the gl_InstanceID attribute
information explicitly in the variable collection pass instead of
retrieving it from the symbol table.

BUG=angleproject:2062
TEST=angle_unittests

Change-Id: I5ecb9967ebe6658e956d17a2637090f9b685ef33
Reviewed-on: https://chromium-review.googlesource.com/559669
Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/VariableInfo.cpp b/src/compiler/translator/VariableInfo.cpp
index cb22d40..2af0bc1 100644
--- a/src/compiler/translator/VariableInfo.cpp
+++ b/src/compiler/translator/VariableInfo.cpp
@@ -336,7 +336,25 @@
                 recordBuiltInVaryingUsed("gl_PointCoord", &mPointCoordAdded);
                 return;
             case EvqInstanceID:
-                recordBuiltInAttributeUsed("gl_InstanceID", &mInstanceIDAdded);
+                // Whenever the SH_INITIALIZE_BUILTINS_FOR_INSTANCED_MULTIVIEW option is set,
+                // gl_InstanceID is added inside expressions to initialize ViewID_OVR and
+                // InstanceID. gl_InstanceID is not added to the symbol table for ESSL1 shaders
+                // which makes it necessary to populate the type information explicitly instead of
+                // extracting it from the symbol table.
+                if (!mInstanceIDAdded)
+                {
+                    Attribute info;
+                    const char kName[] = "gl_InstanceID";
+                    info.name          = kName;
+                    info.mappedName    = kName;
+                    info.type          = GL_INT;
+                    info.arraySize     = 0;
+                    info.precision     = GL_HIGH_INT;  // Defined by spec.
+                    info.staticUse     = true;
+                    info.location      = -1;
+                    mAttribs->push_back(info);
+                    mInstanceIDAdded = true;
+                }
                 return;
             case EvqVertexID:
                 recordBuiltInAttributeUsed("gl_VertexID", &mVertexIDAdded);