Generate code for initializing built-in variables

gen_builtin_symbols.py now generates code for initializing built-in
variable symbols as well. Some of the variable symbols are static, but
some of them also get initialized dynamically based on values in
ShBuiltInResources.

The static symbols have get functions in a header file so they can be
referenced from AST traversers as well without doing a lookup.

BUG=angleproject:2267
TEST=angle_unittests, angle_end2end_tests

Change-Id: Ida7f3aeb06d2bce0f737f1483b1bd5833aeddd2e
Reviewed-on: https://chromium-review.googlesource.com/911768
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/SymbolTable.cpp b/src/compiler/translator/SymbolTable.cpp
index e8d0a8f..3d15c8e 100644
--- a/src/compiler/translator/SymbolTable.cpp
+++ b/src/compiler/translator/SymbolTable.cpp
@@ -17,6 +17,7 @@
 #include <set>
 
 #include "angle_gl.h"
+#include "compiler/translator/BuiltIn_autogen.h"
 #include "compiler/translator/ImmutableString.h"
 #include "compiler/translator/IntermNode.h"
 #include "compiler/translator/StaticType.h"
@@ -109,8 +110,7 @@
         return (*it).second;
 }
 
-TSymbolTable::TSymbolTable()
-    : mUniqueIdCounter(0), mUserDefinedUniqueIdsStart(-1), mShaderType(GL_FRAGMENT_SHADER)
+TSymbolTable::TSymbolTable() : mUniqueIdCounter(0), mShaderType(GL_FRAGMENT_SHADER)
 {
 }
 
@@ -252,25 +252,6 @@
     mTable[0]->insert(function);
 }
 
-void TSymbolTable::insertVariable(ESymbolLevel level,
-                                  const ImmutableString &name,
-                                  const TType *type)
-{
-    ASSERT(type->isRealized());
-    TVariable *var = new TVariable(this, name, type, SymbolType::BuiltIn);
-    insertBuiltIn(level, var);
-}
-
-void TSymbolTable::insertVariableExt(ESymbolLevel level,
-                                     TExtension ext,
-                                     const ImmutableString &name,
-                                     const TType *type)
-{
-    ASSERT(type->isRealized());
-    TVariable *var = new TVariable(this, name, type, SymbolType::BuiltIn, ext);
-    insertBuiltIn(level, var);
-}
-
 void TSymbolTable::insertBuiltIn(ESymbolLevel level, const TSymbol *symbol)
 {
     ASSERT(symbol);
@@ -279,49 +260,6 @@
     mBuiltInTable[level]->insert(symbol);
 }
 
-template <TPrecision precision>
-void TSymbolTable::insertConstInt(ESymbolLevel level, const ImmutableString &name, int value)
-{
-    TVariable *constant = new TVariable(
-        this, name, StaticType::Get<EbtInt, precision, EvqConst, 1, 1>(), SymbolType::BuiltIn);
-    TConstantUnion *unionArray = new TConstantUnion[1];
-    unionArray[0].setIConst(value);
-    constant->shareConstPointer(unionArray);
-    insertBuiltIn(level, constant);
-}
-
-template <TPrecision precision>
-void TSymbolTable::insertConstIntExt(ESymbolLevel level,
-                                     TExtension ext,
-                                     const ImmutableString &name,
-                                     int value)
-{
-    TVariable *constant = new TVariable(
-        this, name, StaticType::Get<EbtInt, precision, EvqConst, 1, 1>(), SymbolType::BuiltIn, ext);
-    TConstantUnion *unionArray = new TConstantUnion[1];
-    unionArray[0].setIConst(value);
-    constant->shareConstPointer(unionArray);
-    insertBuiltIn(level, constant);
-}
-
-template <TPrecision precision>
-void TSymbolTable::insertConstIvec3(ESymbolLevel level,
-                                    const ImmutableString &name,
-                                    const std::array<int, 3> &values)
-{
-    TVariable *constantIvec3 = new TVariable(
-        this, name, StaticType::Get<EbtInt, precision, EvqConst, 3, 1>(), SymbolType::BuiltIn);
-
-    TConstantUnion *unionArray = new TConstantUnion[3];
-    for (size_t index = 0u; index < 3u; ++index)
-    {
-        unionArray[index].setIConst(values[index]);
-    }
-    constantIvec3->shareConstPointer(unionArray);
-
-    insertBuiltIn(level, constantIvec3);
-}
-
 void TSymbolTable::setDefaultPrecision(TBasicType type, TPrecision prec)
 {
     int indexOfLastElement = static_cast<int>(mPrecisionStack.size()) - 1;
@@ -372,14 +310,9 @@
     mTable.back()->setGlobalInvariant(invariant);
 }
 
-void TSymbolTable::markBuiltInInitializationFinished()
-{
-    mUserDefinedUniqueIdsStart = mUniqueIdCounter;
-}
-
 void TSymbolTable::clearCompilationResults()
 {
-    mUniqueIdCounter = mUserDefinedUniqueIdsStart;
+    mUniqueIdCounter = kLastBuiltInId + 1;
 
     // User-defined scopes should have already been cleared when the compilation finished.
     ASSERT(mTable.size() == 0u);
@@ -436,10 +369,8 @@
     setDefaultPrecision(EbtAtomicCounter, EbpHigh);
 
     insertBuiltInFunctions(type);
-    mUniqueIdCounter = kLastStaticBuiltInId + 1;
-
-    initializeBuiltInVariables(type, spec, resources);
-    markBuiltInInitializationFinished();
+    insertBuiltInVariables(type, spec, resources);
+    mUniqueIdCounter = kLastBuiltInId + 1;
 }
 
 void TSymbolTable::initSamplerDefaultPrecision(TBasicType samplerType)
@@ -448,361 +379,4 @@
     setDefaultPrecision(samplerType, EbpLow);
 }
 
-
-void TSymbolTable::initializeBuiltInVariables(sh::GLenum type,
-                                              ShShaderSpec spec,
-                                              const ShBuiltInResources &resources)
-{
-    const TSourceLoc zeroSourceLoc = {0, 0, 0, 0};
-
-    //
-    // Depth range in window coordinates
-    //
-    TFieldList *fields = new TFieldList();
-    auto highpFloat1   = new TType(EbtFloat, EbpHigh, EvqGlobal, 1);
-    TField *near       = new TField(highpFloat1, ImmutableString("near"), zeroSourceLoc);
-    TField *far        = new TField(highpFloat1, ImmutableString("far"), zeroSourceLoc);
-    TField *diff       = new TField(highpFloat1, ImmutableString("diff"), zeroSourceLoc);
-    fields->push_back(near);
-    fields->push_back(far);
-    fields->push_back(diff);
-    TStructure *depthRangeStruct = new TStructure(this, ImmutableString("gl_DepthRangeParameters"),
-                                                  fields, SymbolType::BuiltIn);
-    insertBuiltIn(COMMON_BUILTINS, depthRangeStruct);
-    TType *depthRangeType = new TType(depthRangeStruct);
-    depthRangeType->setQualifier(EvqUniform);
-    depthRangeType->realize();
-    insertVariable(COMMON_BUILTINS, ImmutableString("gl_DepthRange"), depthRangeType);
-
-    //
-    // Implementation dependent built-in constants.
-    //
-    insertConstInt<EbpMedium>(COMMON_BUILTINS, ImmutableString("gl_MaxVertexAttribs"),
-                              resources.MaxVertexAttribs);
-    insertConstInt<EbpMedium>(COMMON_BUILTINS, ImmutableString("gl_MaxVertexUniformVectors"),
-                              resources.MaxVertexUniformVectors);
-    insertConstInt<EbpMedium>(COMMON_BUILTINS, ImmutableString("gl_MaxVertexTextureImageUnits"),
-                              resources.MaxVertexTextureImageUnits);
-    insertConstInt<EbpMedium>(COMMON_BUILTINS, ImmutableString("gl_MaxCombinedTextureImageUnits"),
-                              resources.MaxCombinedTextureImageUnits);
-    insertConstInt<EbpMedium>(COMMON_BUILTINS, ImmutableString("gl_MaxTextureImageUnits"),
-                              resources.MaxTextureImageUnits);
-    insertConstInt<EbpMedium>(COMMON_BUILTINS, ImmutableString("gl_MaxFragmentUniformVectors"),
-                              resources.MaxFragmentUniformVectors);
-
-    insertConstInt<EbpMedium>(ESSL1_BUILTINS, ImmutableString("gl_MaxVaryingVectors"),
-                              resources.MaxVaryingVectors);
-
-    insertConstInt<EbpMedium>(COMMON_BUILTINS, ImmutableString("gl_MaxDrawBuffers"),
-                              resources.MaxDrawBuffers);
-    insertConstIntExt<EbpMedium>(COMMON_BUILTINS, TExtension::EXT_blend_func_extended,
-                                 ImmutableString("gl_MaxDualSourceDrawBuffersEXT"),
-                                 resources.MaxDualSourceDrawBuffers);
-
-    insertConstInt<EbpMedium>(ESSL3_BUILTINS, ImmutableString("gl_MaxVertexOutputVectors"),
-                              resources.MaxVertexOutputVectors);
-    insertConstInt<EbpMedium>(ESSL3_BUILTINS, ImmutableString("gl_MaxFragmentInputVectors"),
-                              resources.MaxFragmentInputVectors);
-    insertConstInt<EbpMedium>(ESSL3_BUILTINS, ImmutableString("gl_MinProgramTexelOffset"),
-                              resources.MinProgramTexelOffset);
-    insertConstInt<EbpMedium>(ESSL3_BUILTINS, ImmutableString("gl_MaxProgramTexelOffset"),
-                              resources.MaxProgramTexelOffset);
-
-    insertConstInt<EbpMedium>(ESSL3_1_BUILTINS, ImmutableString("gl_MaxImageUnits"),
-                              resources.MaxImageUnits);
-    insertConstInt<EbpMedium>(ESSL3_1_BUILTINS, ImmutableString("gl_MaxVertexImageUniforms"),
-                              resources.MaxVertexImageUniforms);
-    insertConstInt<EbpMedium>(ESSL3_1_BUILTINS, ImmutableString("gl_MaxFragmentImageUniforms"),
-                              resources.MaxFragmentImageUniforms);
-    insertConstInt<EbpMedium>(ESSL3_1_BUILTINS, ImmutableString("gl_MaxComputeImageUniforms"),
-                              resources.MaxComputeImageUniforms);
-    insertConstInt<EbpMedium>(ESSL3_1_BUILTINS, ImmutableString("gl_MaxCombinedImageUniforms"),
-                              resources.MaxCombinedImageUniforms);
-
-    insertConstInt<EbpMedium>(ESSL3_1_BUILTINS,
-                              ImmutableString("gl_MaxCombinedShaderOutputResources"),
-                              resources.MaxCombinedShaderOutputResources);
-
-    insertConstIvec3<EbpHigh>(ESSL3_1_BUILTINS, ImmutableString("gl_MaxComputeWorkGroupCount"),
-                              resources.MaxComputeWorkGroupCount);
-    insertConstIvec3<EbpHigh>(ESSL3_1_BUILTINS, ImmutableString("gl_MaxComputeWorkGroupSize"),
-                              resources.MaxComputeWorkGroupSize);
-    insertConstInt<EbpMedium>(ESSL3_1_BUILTINS, ImmutableString("gl_MaxComputeUniformComponents"),
-                              resources.MaxComputeUniformComponents);
-    insertConstInt<EbpMedium>(ESSL3_1_BUILTINS, ImmutableString("gl_MaxComputeTextureImageUnits"),
-                              resources.MaxComputeTextureImageUnits);
-
-    insertConstInt<EbpMedium>(ESSL3_1_BUILTINS, ImmutableString("gl_MaxComputeAtomicCounters"),
-                              resources.MaxComputeAtomicCounters);
-    insertConstInt<EbpMedium>(ESSL3_1_BUILTINS,
-                              ImmutableString("gl_MaxComputeAtomicCounterBuffers"),
-                              resources.MaxComputeAtomicCounterBuffers);
-
-    insertConstInt<EbpMedium>(ESSL3_1_BUILTINS, ImmutableString("gl_MaxVertexAtomicCounters"),
-                              resources.MaxVertexAtomicCounters);
-    insertConstInt<EbpMedium>(ESSL3_1_BUILTINS, ImmutableString("gl_MaxFragmentAtomicCounters"),
-                              resources.MaxFragmentAtomicCounters);
-    insertConstInt<EbpMedium>(ESSL3_1_BUILTINS, ImmutableString("gl_MaxCombinedAtomicCounters"),
-                              resources.MaxCombinedAtomicCounters);
-    insertConstInt<EbpMedium>(ESSL3_1_BUILTINS, ImmutableString("gl_MaxAtomicCounterBindings"),
-                              resources.MaxAtomicCounterBindings);
-
-    insertConstInt<EbpMedium>(ESSL3_1_BUILTINS, ImmutableString("gl_MaxVertexAtomicCounterBuffers"),
-                              resources.MaxVertexAtomicCounterBuffers);
-    insertConstInt<EbpMedium>(ESSL3_1_BUILTINS,
-                              ImmutableString("gl_MaxFragmentAtomicCounterBuffers"),
-                              resources.MaxFragmentAtomicCounterBuffers);
-    insertConstInt<EbpMedium>(ESSL3_1_BUILTINS,
-                              ImmutableString("gl_MaxCombinedAtomicCounterBuffers"),
-                              resources.MaxCombinedAtomicCounterBuffers);
-    insertConstInt<EbpMedium>(ESSL3_1_BUILTINS, ImmutableString("gl_MaxAtomicCounterBufferSize"),
-                              resources.MaxAtomicCounterBufferSize);
-
-    {
-        TExtension ext = TExtension::EXT_geometry_shader;
-        insertConstIntExt<EbpMedium>(ESSL3_1_BUILTINS, ext,
-                                     ImmutableString("gl_MaxGeometryInputComponents"),
-                                     resources.MaxGeometryInputComponents);
-        insertConstIntExt<EbpMedium>(ESSL3_1_BUILTINS, ext,
-                                     ImmutableString("gl_MaxGeometryOutputComponents"),
-                                     resources.MaxGeometryOutputComponents);
-        insertConstIntExt<EbpMedium>(ESSL3_1_BUILTINS, ext,
-                                     ImmutableString("gl_MaxGeometryImageUniforms"),
-                                     resources.MaxGeometryImageUniforms);
-        insertConstIntExt<EbpMedium>(ESSL3_1_BUILTINS, ext,
-                                     ImmutableString("gl_MaxGeometryTextureImageUnits"),
-                                     resources.MaxGeometryTextureImageUnits);
-        insertConstIntExt<EbpMedium>(ESSL3_1_BUILTINS, ext,
-                                     ImmutableString("gl_MaxGeometryOutputVertices"),
-                                     resources.MaxGeometryOutputVertices);
-        insertConstIntExt<EbpMedium>(ESSL3_1_BUILTINS, ext,
-                                     ImmutableString("gl_MaxGeometryTotalOutputComponents"),
-                                     resources.MaxGeometryTotalOutputComponents);
-        insertConstIntExt<EbpMedium>(ESSL3_1_BUILTINS, ext,
-                                     ImmutableString("gl_MaxGeometryUniformComponents"),
-                                     resources.MaxGeometryUniformComponents);
-        insertConstIntExt<EbpMedium>(ESSL3_1_BUILTINS, ext,
-                                     ImmutableString("gl_MaxGeometryAtomicCounters"),
-                                     resources.MaxGeometryAtomicCounters);
-        insertConstIntExt<EbpMedium>(ESSL3_1_BUILTINS, ext,
-                                     ImmutableString("gl_MaxGeometryAtomicCounterBuffers"),
-                                     resources.MaxGeometryAtomicCounterBuffers);
-    }
-
-    //
-    // Insert some special built-in variables that are not in
-    // the built-in header files.
-    //
-
-    if (resources.OVR_multiview && type != GL_COMPUTE_SHADER)
-    {
-        const TType *viewIDType = StaticType::Get<EbtUInt, EbpHigh, EvqViewIDOVR, 1, 1>();
-        insertVariableExt(ESSL3_BUILTINS, TExtension::OVR_multiview,
-                          ImmutableString("gl_ViewID_OVR"), viewIDType);
-
-        // ESSL 1.00 doesn't have unsigned integers, so gl_ViewID_OVR is a signed integer in ESSL
-        // 1.00. This is specified in the WEBGL_multiview spec.
-        const TType *viewIDIntType = StaticType::Get<EbtInt, EbpHigh, EvqViewIDOVR, 1, 1>();
-        insertVariableExt(ESSL1_BUILTINS, TExtension::OVR_multiview,
-                          ImmutableString("gl_ViewID_OVR"), viewIDIntType);
-    }
-
-    const TType *positionType    = StaticType::Get<EbtFloat, EbpHigh, EvqPosition, 4, 1>();
-    const TType *primitiveIDType = StaticType::Get<EbtInt, EbpHigh, EvqPrimitiveID, 1, 1>();
-    const TType *layerType       = StaticType::Get<EbtInt, EbpHigh, EvqLayer, 1, 1>();
-
-    switch (type)
-    {
-        case GL_FRAGMENT_SHADER:
-        {
-            const TType *fragCoordType = StaticType::Get<EbtFloat, EbpMedium, EvqFragCoord, 4, 1>();
-            insertVariable(COMMON_BUILTINS, ImmutableString("gl_FragCoord"), fragCoordType);
-            const TType *frontFacingType = StaticType::GetQualified<EbtBool, EvqFrontFacing>();
-            insertVariable(COMMON_BUILTINS, ImmutableString("gl_FrontFacing"), frontFacingType);
-            const TType *pointCoordType =
-                StaticType::Get<EbtFloat, EbpMedium, EvqPointCoord, 2, 1>();
-            insertVariable(COMMON_BUILTINS, ImmutableString("gl_PointCoord"), pointCoordType);
-
-            const TType *fragColorType = StaticType::Get<EbtFloat, EbpMedium, EvqFragColor, 4, 1>();
-            insertVariable(ESSL1_BUILTINS, ImmutableString("gl_FragColor"), fragColorType);
-
-            TType *fragDataType = new TType(EbtFloat, EbpMedium, EvqFragData, 4);
-            if (spec != SH_WEBGL2_SPEC && spec != SH_WEBGL3_SPEC)
-            {
-                fragDataType->makeArray(resources.MaxDrawBuffers);
-            }
-            else
-            {
-                fragDataType->makeArray(1u);
-            }
-            fragDataType->realize();
-            insertVariable(ESSL1_BUILTINS, ImmutableString("gl_FragData"), fragDataType);
-
-            if (resources.EXT_blend_func_extended)
-            {
-                const TType *secondaryFragColorType =
-                    StaticType::Get<EbtFloat, EbpMedium, EvqSecondaryFragColorEXT, 4, 1>();
-                insertVariableExt(ESSL1_BUILTINS, TExtension::EXT_blend_func_extended,
-                                  ImmutableString("gl_SecondaryFragColorEXT"),
-                                  secondaryFragColorType);
-                TType *secondaryFragDataType =
-                    new TType(EbtFloat, EbpMedium, EvqSecondaryFragDataEXT, 4, 1);
-                secondaryFragDataType->makeArray(resources.MaxDualSourceDrawBuffers);
-                secondaryFragDataType->realize();
-                insertVariableExt(ESSL1_BUILTINS, TExtension::EXT_blend_func_extended,
-                                  ImmutableString("gl_SecondaryFragDataEXT"),
-                                  secondaryFragDataType);
-            }
-
-            if (resources.EXT_frag_depth)
-            {
-                TType *fragDepthEXTType =
-                    new TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium,
-                              EvqFragDepthEXT, 1);
-                fragDepthEXTType->realize();
-                insertVariableExt(ESSL1_BUILTINS, TExtension::EXT_frag_depth,
-                                  ImmutableString("gl_FragDepthEXT"), fragDepthEXTType);
-            }
-
-            const TType *fragDepthType = StaticType::Get<EbtFloat, EbpHigh, EvqFragDepth, 1, 1>();
-            insertVariable(ESSL3_BUILTINS, ImmutableString("gl_FragDepth"), fragDepthType);
-
-            const TType *lastFragColorType =
-                StaticType::Get<EbtFloat, EbpMedium, EvqLastFragColor, 4, 1>();
-
-            if (resources.EXT_shader_framebuffer_fetch || resources.NV_shader_framebuffer_fetch)
-            {
-                TType *lastFragDataType = new TType(EbtFloat, EbpMedium, EvqLastFragData, 4, 1);
-                lastFragDataType->makeArray(resources.MaxDrawBuffers);
-                lastFragDataType->realize();
-
-                if (resources.EXT_shader_framebuffer_fetch)
-                {
-                    insertVariableExt(ESSL1_BUILTINS, TExtension::EXT_shader_framebuffer_fetch,
-                                      ImmutableString("gl_LastFragData"), lastFragDataType);
-                }
-                else if (resources.NV_shader_framebuffer_fetch)
-                {
-                    insertVariableExt(ESSL1_BUILTINS, TExtension::NV_shader_framebuffer_fetch,
-                                      ImmutableString("gl_LastFragColor"), lastFragColorType);
-                    insertVariableExt(ESSL1_BUILTINS, TExtension::NV_shader_framebuffer_fetch,
-                                      ImmutableString("gl_LastFragData"), lastFragDataType);
-                }
-            }
-            else if (resources.ARM_shader_framebuffer_fetch)
-            {
-                insertVariableExt(ESSL1_BUILTINS, TExtension::ARM_shader_framebuffer_fetch,
-                                  ImmutableString("gl_LastFragColorARM"), lastFragColorType);
-            }
-
-            if (resources.EXT_geometry_shader)
-            {
-                TExtension extension = TExtension::EXT_geometry_shader;
-                insertVariableExt(ESSL3_1_BUILTINS, extension, ImmutableString("gl_PrimitiveID"),
-                                  primitiveIDType);
-                insertVariableExt(ESSL3_1_BUILTINS, extension, ImmutableString("gl_Layer"),
-                                  layerType);
-            }
-
-            break;
-        }
-        case GL_VERTEX_SHADER:
-        {
-            insertVariable(COMMON_BUILTINS, ImmutableString("gl_Position"), positionType);
-            const TType *pointSizeType = StaticType::Get<EbtFloat, EbpMedium, EvqPointSize, 1, 1>();
-            insertVariable(COMMON_BUILTINS, ImmutableString("gl_PointSize"), pointSizeType);
-            const TType *instanceIDType = StaticType::Get<EbtInt, EbpHigh, EvqInstanceID, 1, 1>();
-            insertVariable(ESSL3_BUILTINS, ImmutableString("gl_InstanceID"), instanceIDType);
-            const TType *vertexIDType = StaticType::Get<EbtInt, EbpHigh, EvqVertexID, 1, 1>();
-            insertVariable(ESSL3_BUILTINS, ImmutableString("gl_VertexID"), vertexIDType);
-
-            // For internal use by ANGLE - not exposed to the parser.
-            const TType *viewportIndexType =
-                StaticType::Get<EbtInt, EbpHigh, EvqViewportIndex, 1, 1>();
-            insertVariable(GLSL_BUILTINS, ImmutableString("gl_ViewportIndex"), viewportIndexType);
-            // gl_Layer exists in other shader stages in ESSL, but not in vertex shader so far.
-            insertVariable(GLSL_BUILTINS, ImmutableString("gl_Layer"), layerType);
-            break;
-        }
-        case GL_COMPUTE_SHADER:
-        {
-            const TType *numWorkGroupsType =
-                StaticType::Get<EbtUInt, EbpUndefined, EvqNumWorkGroups, 3, 1>();
-            insertVariable(ESSL3_1_BUILTINS, ImmutableString("gl_NumWorkGroups"),
-                           numWorkGroupsType);
-            const TType *workGroupSizeType =
-                StaticType::Get<EbtUInt, EbpUndefined, EvqWorkGroupSize, 3, 1>();
-            insertVariable(ESSL3_1_BUILTINS, ImmutableString("gl_WorkGroupSize"),
-                           workGroupSizeType);
-            const TType *workGroupIDType =
-                StaticType::Get<EbtUInt, EbpUndefined, EvqWorkGroupID, 3, 1>();
-            insertVariable(ESSL3_1_BUILTINS, ImmutableString("gl_WorkGroupID"), workGroupIDType);
-            const TType *localInvocationIDType =
-                StaticType::Get<EbtUInt, EbpUndefined, EvqLocalInvocationID, 3, 1>();
-            insertVariable(ESSL3_1_BUILTINS, ImmutableString("gl_LocalInvocationID"),
-                           localInvocationIDType);
-            const TType *globalInvocationIDType =
-                StaticType::Get<EbtUInt, EbpUndefined, EvqGlobalInvocationID, 3, 1>();
-            insertVariable(ESSL3_1_BUILTINS, ImmutableString("gl_GlobalInvocationID"),
-                           globalInvocationIDType);
-            const TType *localInvocationIndexType =
-                StaticType::Get<EbtUInt, EbpUndefined, EvqLocalInvocationIndex, 1, 1>();
-            insertVariable(ESSL3_1_BUILTINS, ImmutableString("gl_LocalInvocationIndex"),
-                           localInvocationIndexType);
-            break;
-        }
-
-        case GL_GEOMETRY_SHADER_EXT:
-        {
-            TExtension extension = TExtension::EXT_geometry_shader;
-
-            // Add built-in interface block gl_PerVertex and the built-in array gl_in.
-            // TODO(jiawei.shao@intel.com): implement GL_EXT_geometry_point_size.
-            TFieldList *glPerVertexFieldList = new TFieldList();
-            TField *glPositionField =
-                new TField(new TType(*positionType), ImmutableString("gl_Position"), zeroSourceLoc);
-            glPerVertexFieldList->push_back(glPositionField);
-
-            const ImmutableString glPerVertexString("gl_PerVertex");
-            TInterfaceBlock *glPerVertexInBlock =
-                new TInterfaceBlock(this, glPerVertexString, glPerVertexFieldList,
-                                    TLayoutQualifier::Create(), SymbolType::BuiltIn, extension);
-            insertBuiltIn(ESSL3_1_BUILTINS, glPerVertexInBlock);
-
-            // The array size of gl_in is undefined until we get a valid input primitive
-            // declaration.
-            TType *glInType =
-                new TType(glPerVertexInBlock, EvqPerVertexIn, TLayoutQualifier::Create());
-            glInType->makeArray(0u);
-            glInType->realize();
-            insertVariableExt(ESSL3_1_BUILTINS, extension, ImmutableString("gl_in"), glInType);
-
-            TInterfaceBlock *glPerVertexOutBlock =
-                new TInterfaceBlock(this, glPerVertexString, glPerVertexFieldList,
-                                    TLayoutQualifier::Create(), SymbolType::BuiltIn);
-            TType *glPositionInBlockType = new TType(EbtFloat, EbpHigh, EvqPosition, 4);
-            glPositionInBlockType->setInterfaceBlock(glPerVertexOutBlock);
-            glPositionInBlockType->realize();
-            insertVariableExt(ESSL3_1_BUILTINS, extension, ImmutableString("gl_Position"),
-                              glPositionInBlockType);
-
-            const TType *primitiveIDInType =
-                StaticType::Get<EbtInt, EbpHigh, EvqPrimitiveIDIn, 1, 1>();
-            insertVariableExt(ESSL3_1_BUILTINS, extension, ImmutableString("gl_PrimitiveIDIn"),
-                              primitiveIDInType);
-            const TType *invocationIDType =
-                StaticType::Get<EbtInt, EbpHigh, EvqInvocationID, 1, 1>();
-            insertVariableExt(ESSL3_1_BUILTINS, extension, ImmutableString("gl_InvocationID"),
-                              invocationIDType);
-            insertVariableExt(ESSL3_1_BUILTINS, extension, ImmutableString("gl_PrimitiveID"),
-                              primitiveIDType);
-            insertVariableExt(ESSL3_1_BUILTINS, extension, ImmutableString("gl_Layer"), layerType);
-
-            break;
-        }
-        default:
-            UNREACHABLE();
-    }
-}
-
 }  // namespace sh