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/BuiltIn_autogen.h b/src/compiler/translator/BuiltIn_autogen.h
new file mode 100644
index 0000000..b70ec80
--- /dev/null
+++ b/src/compiler/translator/BuiltIn_autogen.h
@@ -0,0 +1,56 @@
+// GENERATED FILE - DO NOT EDIT.
+// Generated by gen_builtin_symbols.py using data from builtin_variables.json and
+// builtin_function_declarations.txt.
+//
+// Copyright 2018 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// BuiltIn_autogen.h:
+// Compile-time initialized built-ins.
+
+#ifndef COMPILER_TRANSLATOR_BUILTIN_AUTOGEN_H_
+#define COMPILER_TRANSLATOR_BUILTIN_AUTOGEN_H_
+
+namespace sh
+{
+
+class TVariable;
+
+namespace BuiltInVariable
+{
+
+const TVariable *gl_FragColor();
+const TVariable *gl_FragCoord();
+const TVariable *gl_FragDepth();
+const TVariable *gl_FrontFacing();
+const TVariable *gl_GlobalInvocationID();
+const TVariable *gl_InstanceID();
+const TVariable *gl_InvocationID();
+const TVariable *gl_LastFragColor();
+const TVariable *gl_LastFragColorARM();
+const TVariable *gl_Layer();
+const TVariable *gl_LayerGS();
+const TVariable *gl_LayerVS();
+const TVariable *gl_LocalInvocationID();
+const TVariable *gl_LocalInvocationIndex();
+const TVariable *gl_NumWorkGroups();
+const TVariable *gl_PointCoord();
+const TVariable *gl_PointSize();
+const TVariable *gl_Position();
+const TVariable *gl_PrimitiveID();
+const TVariable *gl_PrimitiveIDGS();
+const TVariable *gl_PrimitiveIDIn();
+const TVariable *gl_SecondaryFragColorEXT();
+const TVariable *gl_VertexID();
+const TVariable *gl_ViewID_OVR();
+const TVariable *gl_ViewID_OVRESSL1();
+const TVariable *gl_ViewportIndex();
+const TVariable *gl_WorkGroupID();
+const TVariable *gl_WorkGroupSize();
+
+} // namespace BuiltInVariable
+
+} // namespace sh
+
+#endif // COMPILER_TRANSLATOR_BUILTIN_AUTOGEN_H_
diff --git a/src/compiler/translator/ClampFragDepth.cpp b/src/compiler/translator/ClampFragDepth.cpp
index 448c9c0..34660ad 100644
--- a/src/compiler/translator/ClampFragDepth.cpp
+++ b/src/compiler/translator/ClampFragDepth.cpp
@@ -10,6 +10,7 @@
#include "compiler/translator/ClampFragDepth.h"
+#include "compiler/translator/BuiltIn_autogen.h"
#include "compiler/translator/FindSymbolNode.h"
#include "compiler/translator/ImmutableString.h"
#include "compiler/translator/IntermNode_util.h"
@@ -27,8 +28,7 @@
return;
}
- TIntermSymbol *fragDepthNode =
- ReferenceBuiltInVariable(ImmutableString("gl_FragDepth"), *symbolTable, 300);
+ TIntermSymbol *fragDepthNode = new TIntermSymbol(BuiltInVariable::gl_FragDepth());
TIntermTyped *minFragDepthNode = CreateZeroNode(TType(EbtFloat, EbpHigh, EvqConst));
diff --git a/src/compiler/translator/ClampPointSize.cpp b/src/compiler/translator/ClampPointSize.cpp
index e6e9a0e..a1da108 100644
--- a/src/compiler/translator/ClampPointSize.cpp
+++ b/src/compiler/translator/ClampPointSize.cpp
@@ -8,6 +8,7 @@
#include "compiler/translator/ClampPointSize.h"
+#include "compiler/translator/BuiltIn_autogen.h"
#include "compiler/translator/FindSymbolNode.h"
#include "compiler/translator/IntermNode_util.h"
#include "compiler/translator/RunAtTheEndOfShader.h"
@@ -24,8 +25,7 @@
return;
}
- TIntermSymbol *pointSizeNode =
- ReferenceBuiltInVariable(ImmutableString("gl_PointSize"), *symbolTable, 100);
+ TIntermSymbol *pointSizeNode = new TIntermSymbol(BuiltInVariable::gl_PointSize());
TConstantUnion *maxPointSizeConstant = new TConstantUnion();
maxPointSizeConstant->setFConst(maxPointSize);
diff --git a/src/compiler/translator/DeclareAndInitBuiltinsForInstancedMultiview.cpp b/src/compiler/translator/DeclareAndInitBuiltinsForInstancedMultiview.cpp
index 5929577..30d1380 100644
--- a/src/compiler/translator/DeclareAndInitBuiltinsForInstancedMultiview.cpp
+++ b/src/compiler/translator/DeclareAndInitBuiltinsForInstancedMultiview.cpp
@@ -9,6 +9,7 @@
#include "compiler/translator/DeclareAndInitBuiltinsForInstancedMultiview.h"
+#include "compiler/translator/BuiltIn_autogen.h"
#include "compiler/translator/FindMain.h"
#include "compiler/translator/InitializeVariables.h"
#include "compiler/translator/IntermNode_util.h"
@@ -24,20 +25,11 @@
namespace
{
-constexpr const ImmutableString kGlLayerString("gl_Layer");
-constexpr const ImmutableString kGlViewportIndexString("gl_ViewportIndex");
-constexpr const ImmutableString kGlViewIdOVRString("gl_ViewID_OVR");
-constexpr const ImmutableString kGlInstanceIdString("gl_InstanceID");
constexpr const ImmutableString kViewIDVariableName("ViewID_OVR");
constexpr const ImmutableString kInstanceIDVariableName("InstanceID");
constexpr const ImmutableString kMultiviewBaseViewLayerIndexVariableName(
"multiviewBaseViewLayerIndex");
-TIntermSymbol *CreateGLInstanceIDSymbol(const TSymbolTable &symbolTable)
-{
- return ReferenceBuiltInVariable(kGlInstanceIdString, symbolTable, 300);
-}
-
// Adds the InstanceID and ViewID_OVR initializers to the end of the initializers' sequence.
void InitializeViewIDAndInstanceID(const TVariable *viewID,
const TVariable *instanceID,
@@ -53,7 +45,7 @@
// Create a uint(gl_InstanceID) node.
TIntermSequence *glInstanceIDSymbolCastArguments = new TIntermSequence();
- glInstanceIDSymbolCastArguments->push_back(CreateGLInstanceIDSymbol(symbolTable));
+ glInstanceIDSymbolCastArguments->push_back(new TIntermSymbol(BuiltInVariable::gl_InstanceID()));
TIntermAggregate *glInstanceIDAsUint = TIntermAggregate::CreateConstructor(
TType(EbtUInt, EbpHigh, EvqTemporary), glInstanceIDSymbolCastArguments);
@@ -105,8 +97,7 @@
TType(EbtInt, EbpHigh, EvqTemporary), viewIDSymbolCastArguments);
// Create a gl_ViewportIndex node.
- TIntermSymbol *viewportIndexSymbol =
- ReferenceBuiltInVariable(kGlViewportIndexString, symbolTable, 0);
+ TIntermSymbol *viewportIndexSymbol = new TIntermSymbol(BuiltInVariable::gl_ViewportIndex());
// Create a { gl_ViewportIndex = int(ViewID_OVR) } node.
TIntermBlock *viewportIndexInitializerInBlock = new TIntermBlock();
@@ -114,7 +105,7 @@
new TIntermBinary(EOpAssign, viewportIndexSymbol, viewIDAsInt));
// Create a gl_Layer node.
- TIntermSymbol *layerSymbol = ReferenceBuiltInVariable(kGlLayerString, symbolTable, 0);
+ TIntermSymbol *layerSymbol = new TIntermSymbol(BuiltInVariable::gl_LayerVS());
// Create an int(ViewID_OVR) + multiviewBaseViewLayerIndex node
TIntermBinary *sumOfViewIDAndBaseViewIndex = new TIntermBinary(
@@ -155,10 +146,7 @@
new TType(EbtUInt, EbpHigh, viewIDQualifier), SymbolType::AngleInternal);
DeclareGlobalVariable(root, viewID);
- ReplaceVariable(
- root,
- static_cast<const TVariable *>(symbolTable->findBuiltIn(kGlViewIdOVRString, 300, true)),
- viewID);
+ ReplaceVariable(root, BuiltInVariable::gl_ViewID_OVR(), viewID);
if (shaderType == GL_VERTEX_SHADER)
{
// Replacing gl_InstanceID with InstanceID should happen before adding the initializers of
@@ -168,10 +156,7 @@
new TVariable(symbolTable, kInstanceIDVariableName, instanceIDVariableType,
SymbolType::AngleInternal);
DeclareGlobalVariable(root, instanceID);
- ReplaceVariable(root,
- static_cast<const TVariable *>(
- symbolTable->findBuiltIn(kGlInstanceIdString, 300, true)),
- instanceID);
+ ReplaceVariable(root, BuiltInVariable::gl_InstanceID(), instanceID);
TIntermSequence *initializers = new TIntermSequence();
InitializeViewIDAndInstanceID(viewID, instanceID, numberOfViews, *symbolTable,
@@ -207,4 +192,4 @@
}
}
-} // namespace sh
\ No newline at end of file
+} // namespace sh
diff --git a/src/compiler/translator/Symbol.cpp b/src/compiler/translator/Symbol.cpp
index 786bf46..7f2edc7 100644
--- a/src/compiler/translator/Symbol.cpp
+++ b/src/compiler/translator/Symbol.cpp
@@ -82,6 +82,14 @@
{
}
+TStructure::TStructure(const TSymbolUniqueId &id,
+ const ImmutableString &name,
+ TExtension extension,
+ const TFieldList *fields)
+ : TSymbol(id, name, SymbolType::BuiltIn, extension), TFieldListCollection(fields)
+{
+}
+
void TStructure::createSamplerSymbols(const char *namePrefix,
const TString &apiNamePrefix,
TVector<const TVariable *> *outputSymbols,
@@ -124,6 +132,17 @@
ASSERT(name != nullptr);
}
+TInterfaceBlock::TInterfaceBlock(const TSymbolUniqueId &id,
+ const ImmutableString &name,
+ TExtension extension,
+ const TFieldList *fields)
+ : TSymbol(id, name, SymbolType::BuiltIn, extension),
+ TFieldListCollection(fields),
+ mBlockStorage(EbsUnspecified),
+ mBinding(0)
+{
+}
+
TFunction::TFunction(TSymbolTable *symbolTable,
const ImmutableString &name,
SymbolType symbolType,
diff --git a/src/compiler/translator/Symbol.h b/src/compiler/translator/Symbol.h
index 7516974..92bba85 100644
--- a/src/compiler/translator/Symbol.h
+++ b/src/compiler/translator/Symbol.h
@@ -89,7 +89,7 @@
void shareConstPointer(const TConstantUnion *constArray) { unionArray = constArray; }
- private:
+ // Note: only to be used for built-in variables with autogenerated ids!
constexpr TVariable(const TSymbolUniqueId &id,
const ImmutableString &name,
SymbolType symbolType,
@@ -99,6 +99,7 @@
{
}
+ private:
const TType *mType;
const TConstantUnion *unionArray;
};
@@ -125,6 +126,13 @@
bool atGlobalScope() const { return mAtGlobalScope; }
private:
+ friend class TSymbolTable;
+ // For creating built-in structs.
+ TStructure(const TSymbolUniqueId &id,
+ const ImmutableString &name,
+ TExtension extension,
+ const TFieldList *fields);
+
// TODO(zmo): Find a way to get rid of the const_cast in function
// setName(). At the moment keep this function private so only
// friend class RegenerateStructNames may call it.
@@ -150,6 +158,13 @@
int blockBinding() const { return mBinding; }
private:
+ friend class TSymbolTable;
+ // For creating built-in interface blocks.
+ TInterfaceBlock(const TSymbolUniqueId &id,
+ const ImmutableString &name,
+ TExtension extension,
+ const TFieldList *fields);
+
TLayoutBlockStorage mBlockStorage;
int mBinding;
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
diff --git a/src/compiler/translator/SymbolTable.h b/src/compiler/translator/SymbolTable.h
index 8988fda..91b6a1d 100644
--- a/src/compiler/translator/SymbolTable.h
+++ b/src/compiler/translator/SymbolTable.h
@@ -30,7 +30,6 @@
// are tracked in the intermediate representation, not the symbol table.
//
-#include <array>
#include <memory>
#include "common/angleutils.h"
@@ -140,44 +139,16 @@
void pushBuiltInLevel();
- // The insert* entry points are used when initializing the symbol table with built-ins.
- void insertVariable(ESymbolLevel level, const ImmutableString &name, const TType *type);
- void insertVariableExt(ESymbolLevel level,
- TExtension ext,
- const ImmutableString &name,
- const TType *type);
-
- template <TPrecision precision>
- void insertConstInt(ESymbolLevel level, const ImmutableString &name, int value);
-
- template <TPrecision precision>
- void insertConstIntExt(ESymbolLevel level,
- TExtension ext,
- const ImmutableString &name,
- int value);
-
- template <TPrecision precision>
- void insertConstIvec3(ESymbolLevel level,
- const ImmutableString &name,
- const std::array<int, 3> &values);
-
- TVariable *insertVariable(ESymbolLevel level,
- const ImmutableString &name,
- const TType *type,
- SymbolType symbolType);
-
void insertBuiltIn(ESymbolLevel level, const TSymbol *symbol);
TFunction *findUserDefinedFunction(const ImmutableString &name) const;
void initSamplerDefaultPrecision(TBasicType samplerType);
- void initializeBuiltInVariables(sh::GLenum type,
- ShShaderSpec spec,
- const ShBuiltInResources &resources);
- void markBuiltInInitializationFinished();
-
void insertBuiltInFunctions(sh::GLenum shaderType);
+ void insertBuiltInVariables(sh::GLenum shaderType,
+ ShShaderSpec spec,
+ const ShBuiltInResources &resources);
std::vector<std::unique_ptr<TSymbolTableBuiltInLevel>> mBuiltInTable;
std::vector<std::unique_ptr<TSymbolTableLevel>> mTable;
@@ -189,12 +160,7 @@
int mUniqueIdCounter;
- static const int kLastStaticBuiltInId;
-
- // -1 before built-in init has finished, one past the last built-in id afterwards.
- // TODO(oetuaho): Make this a compile-time constant once the symbol table is initialized at
- // compile time. http://anglebug.com/1432
- int mUserDefinedUniqueIdsStart;
+ static const int kLastBuiltInId;
sh::GLenum mShaderType;
};
diff --git a/src/compiler/translator/SymbolTable_autogen.cpp b/src/compiler/translator/SymbolTable_autogen.cpp
index 4ec1730..77d0961 100644
--- a/src/compiler/translator/SymbolTable_autogen.cpp
+++ b/src/compiler/translator/SymbolTable_autogen.cpp
@@ -1,5 +1,6 @@
// GENERATED FILE - DO NOT EDIT.
-// Generated by gen_builtin_symbols.py using data from builtin_function_declarations.txt.
+// Generated by gen_builtin_symbols.py using data from builtin_variables.json and
+// builtin_function_declarations.txt.
//
// Copyright 2018 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
@@ -20,8 +21,6 @@
namespace sh
{
-// This is a class instead of a namespace so that we can restrict access to TSymbolUniqueId
-// constructor taking an integer to here.
class BuiltInId
{
public:
@@ -897,9 +896,180 @@
static constexpr const TSymbolUniqueId groupMemoryBarrier_ = TSymbolUniqueId(851);
static constexpr const TSymbolUniqueId EmitVertex_ = TSymbolUniqueId(852);
static constexpr const TSymbolUniqueId EndPrimitive_ = TSymbolUniqueId(853);
-};
+ static constexpr const TSymbolUniqueId gl_DepthRangeParameters = TSymbolUniqueId(854);
+ static constexpr const TSymbolUniqueId gl_DepthRange = TSymbolUniqueId(855);
+ static constexpr const TSymbolUniqueId gl_MaxVertexAttribs = TSymbolUniqueId(856);
+ static constexpr const TSymbolUniqueId gl_MaxVertexUniformVectors = TSymbolUniqueId(857);
+ static constexpr const TSymbolUniqueId gl_MaxVertexTextureImageUnits = TSymbolUniqueId(858);
+ static constexpr const TSymbolUniqueId gl_MaxCombinedTextureImageUnits = TSymbolUniqueId(859);
+ static constexpr const TSymbolUniqueId gl_MaxTextureImageUnits = TSymbolUniqueId(860);
+ static constexpr const TSymbolUniqueId gl_MaxFragmentUniformVectors = TSymbolUniqueId(861);
+ static constexpr const TSymbolUniqueId gl_MaxVaryingVectors = TSymbolUniqueId(862);
+ static constexpr const TSymbolUniqueId gl_MaxDrawBuffers = TSymbolUniqueId(863);
+ static constexpr const TSymbolUniqueId gl_MaxDualSourceDrawBuffersEXT = TSymbolUniqueId(864);
+ static constexpr const TSymbolUniqueId gl_MaxVertexOutputVectors = TSymbolUniqueId(865);
+ static constexpr const TSymbolUniqueId gl_MaxFragmentInputVectors = TSymbolUniqueId(866);
+ static constexpr const TSymbolUniqueId gl_MinProgramTexelOffset = TSymbolUniqueId(867);
+ static constexpr const TSymbolUniqueId gl_MaxProgramTexelOffset = TSymbolUniqueId(868);
+ static constexpr const TSymbolUniqueId gl_MaxImageUnits = TSymbolUniqueId(869);
+ static constexpr const TSymbolUniqueId gl_MaxVertexImageUniforms = TSymbolUniqueId(870);
+ static constexpr const TSymbolUniqueId gl_MaxFragmentImageUniforms = TSymbolUniqueId(871);
+ static constexpr const TSymbolUniqueId gl_MaxComputeImageUniforms = TSymbolUniqueId(872);
+ static constexpr const TSymbolUniqueId gl_MaxCombinedImageUniforms = TSymbolUniqueId(873);
+ static constexpr const TSymbolUniqueId gl_MaxCombinedShaderOutputResources =
+ TSymbolUniqueId(874);
+ static constexpr const TSymbolUniqueId gl_MaxComputeWorkGroupCount = TSymbolUniqueId(875);
+ static constexpr const TSymbolUniqueId gl_MaxComputeWorkGroupSize = TSymbolUniqueId(876);
+ static constexpr const TSymbolUniqueId gl_MaxComputeUniformComponents = TSymbolUniqueId(877);
+ static constexpr const TSymbolUniqueId gl_MaxComputeTextureImageUnits = TSymbolUniqueId(878);
+ static constexpr const TSymbolUniqueId gl_MaxComputeAtomicCounters = TSymbolUniqueId(879);
+ static constexpr const TSymbolUniqueId gl_MaxComputeAtomicCounterBuffers = TSymbolUniqueId(880);
+ static constexpr const TSymbolUniqueId gl_MaxVertexAtomicCounters = TSymbolUniqueId(881);
+ static constexpr const TSymbolUniqueId gl_MaxFragmentAtomicCounters = TSymbolUniqueId(882);
+ static constexpr const TSymbolUniqueId gl_MaxCombinedAtomicCounters = TSymbolUniqueId(883);
+ static constexpr const TSymbolUniqueId gl_MaxAtomicCounterBindings = TSymbolUniqueId(884);
+ static constexpr const TSymbolUniqueId gl_MaxVertexAtomicCounterBuffers = TSymbolUniqueId(885);
+ static constexpr const TSymbolUniqueId gl_MaxFragmentAtomicCounterBuffers =
+ TSymbolUniqueId(886);
+ static constexpr const TSymbolUniqueId gl_MaxCombinedAtomicCounterBuffers =
+ TSymbolUniqueId(887);
+ static constexpr const TSymbolUniqueId gl_MaxAtomicCounterBufferSize = TSymbolUniqueId(888);
+ static constexpr const TSymbolUniqueId gl_MaxGeometryInputComponents = TSymbolUniqueId(889);
+ static constexpr const TSymbolUniqueId gl_MaxGeometryOutputComponents = TSymbolUniqueId(890);
+ static constexpr const TSymbolUniqueId gl_MaxGeometryImageUniforms = TSymbolUniqueId(891);
+ static constexpr const TSymbolUniqueId gl_MaxGeometryTextureImageUnits = TSymbolUniqueId(892);
+ static constexpr const TSymbolUniqueId gl_MaxGeometryOutputVertices = TSymbolUniqueId(893);
+ static constexpr const TSymbolUniqueId gl_MaxGeometryTotalOutputComponents =
+ TSymbolUniqueId(894);
+ static constexpr const TSymbolUniqueId gl_MaxGeometryUniformComponents = TSymbolUniqueId(895);
+ static constexpr const TSymbolUniqueId gl_MaxGeometryAtomicCounters = TSymbolUniqueId(896);
+ static constexpr const TSymbolUniqueId gl_MaxGeometryAtomicCounterBuffers =
+ TSymbolUniqueId(897);
+ static constexpr const TSymbolUniqueId gl_FragCoord = TSymbolUniqueId(898);
+ static constexpr const TSymbolUniqueId gl_FrontFacing = TSymbolUniqueId(899);
+ static constexpr const TSymbolUniqueId gl_PointCoord = TSymbolUniqueId(900);
+ static constexpr const TSymbolUniqueId gl_FragColor = TSymbolUniqueId(901);
+ static constexpr const TSymbolUniqueId gl_FragData = TSymbolUniqueId(902);
+ static constexpr const TSymbolUniqueId gl_FragDepth = TSymbolUniqueId(903);
+ static constexpr const TSymbolUniqueId gl_SecondaryFragColorEXT = TSymbolUniqueId(904);
+ static constexpr const TSymbolUniqueId gl_SecondaryFragDataEXT = TSymbolUniqueId(905);
+ static constexpr const TSymbolUniqueId gl_FragDepthEXT = TSymbolUniqueId(906);
+ static constexpr const TSymbolUniqueId gl_LastFragData = TSymbolUniqueId(907);
+ static constexpr const TSymbolUniqueId gl_LastFragColor = TSymbolUniqueId(908);
+ static constexpr const TSymbolUniqueId gl_LastFragDataNV = TSymbolUniqueId(909);
+ static constexpr const TSymbolUniqueId gl_LastFragColorARM = TSymbolUniqueId(910);
+ static constexpr const TSymbolUniqueId gl_PrimitiveID = TSymbolUniqueId(911);
+ static constexpr const TSymbolUniqueId gl_Layer = TSymbolUniqueId(912);
+ static constexpr const TSymbolUniqueId gl_Position = TSymbolUniqueId(913);
+ static constexpr const TSymbolUniqueId gl_PointSize = TSymbolUniqueId(914);
+ static constexpr const TSymbolUniqueId gl_InstanceID = TSymbolUniqueId(915);
+ static constexpr const TSymbolUniqueId gl_VertexID = TSymbolUniqueId(916);
+ static constexpr const TSymbolUniqueId gl_ViewportIndex = TSymbolUniqueId(917);
+ static constexpr const TSymbolUniqueId gl_LayerVS = TSymbolUniqueId(918);
+ static constexpr const TSymbolUniqueId gl_NumWorkGroups = TSymbolUniqueId(919);
+ static constexpr const TSymbolUniqueId gl_WorkGroupSize = TSymbolUniqueId(920);
+ static constexpr const TSymbolUniqueId gl_WorkGroupID = TSymbolUniqueId(921);
+ static constexpr const TSymbolUniqueId gl_LocalInvocationID = TSymbolUniqueId(922);
+ static constexpr const TSymbolUniqueId gl_GlobalInvocationID = TSymbolUniqueId(923);
+ static constexpr const TSymbolUniqueId gl_LocalInvocationIndex = TSymbolUniqueId(924);
+ static constexpr const TSymbolUniqueId gl_PrimitiveIDIn = TSymbolUniqueId(925);
+ static constexpr const TSymbolUniqueId gl_InvocationID = TSymbolUniqueId(926);
+ static constexpr const TSymbolUniqueId gl_PrimitiveIDGS = TSymbolUniqueId(927);
+ static constexpr const TSymbolUniqueId gl_LayerGS = TSymbolUniqueId(928);
+ static constexpr const TSymbolUniqueId gl_PerVertex = TSymbolUniqueId(929);
+ static constexpr const TSymbolUniqueId gl_in = TSymbolUniqueId(930);
+ static constexpr const TSymbolUniqueId gl_PerVertexOutBlock = TSymbolUniqueId(931);
+ static constexpr const TSymbolUniqueId gl_PositionGS = TSymbolUniqueId(932);
+ static constexpr const TSymbolUniqueId gl_ViewID_OVR = TSymbolUniqueId(933);
+ static constexpr const TSymbolUniqueId gl_ViewID_OVRESSL1 = TSymbolUniqueId(934);
-const int TSymbolTable::kLastStaticBuiltInId = 853;
+}; // namespace BuiltInId
+
+// Since some of the BuiltInId declarations are used outside of constexpr expressions, we need to
+// have these definitions without an initializer. C++17 should eventually remove the need for this.
+constexpr const TSymbolUniqueId BuiltInId::gl_DepthRangeParameters;
+constexpr const TSymbolUniqueId BuiltInId::gl_DepthRange;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxVertexAttribs;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxVertexUniformVectors;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxVertexTextureImageUnits;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxCombinedTextureImageUnits;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxTextureImageUnits;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxFragmentUniformVectors;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxVaryingVectors;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxDrawBuffers;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxDualSourceDrawBuffersEXT;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxVertexOutputVectors;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxFragmentInputVectors;
+constexpr const TSymbolUniqueId BuiltInId::gl_MinProgramTexelOffset;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxProgramTexelOffset;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxImageUnits;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxVertexImageUniforms;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxFragmentImageUniforms;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxComputeImageUniforms;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxCombinedImageUniforms;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxCombinedShaderOutputResources;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxComputeWorkGroupCount;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxComputeWorkGroupSize;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxComputeUniformComponents;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxComputeTextureImageUnits;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxComputeAtomicCounters;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxComputeAtomicCounterBuffers;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxVertexAtomicCounters;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxFragmentAtomicCounters;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxCombinedAtomicCounters;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxAtomicCounterBindings;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxVertexAtomicCounterBuffers;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxFragmentAtomicCounterBuffers;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxCombinedAtomicCounterBuffers;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxAtomicCounterBufferSize;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxGeometryInputComponents;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxGeometryOutputComponents;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxGeometryImageUniforms;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxGeometryTextureImageUnits;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxGeometryOutputVertices;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxGeometryTotalOutputComponents;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxGeometryUniformComponents;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxGeometryAtomicCounters;
+constexpr const TSymbolUniqueId BuiltInId::gl_MaxGeometryAtomicCounterBuffers;
+constexpr const TSymbolUniqueId BuiltInId::gl_FragCoord;
+constexpr const TSymbolUniqueId BuiltInId::gl_FrontFacing;
+constexpr const TSymbolUniqueId BuiltInId::gl_PointCoord;
+constexpr const TSymbolUniqueId BuiltInId::gl_FragColor;
+constexpr const TSymbolUniqueId BuiltInId::gl_FragData;
+constexpr const TSymbolUniqueId BuiltInId::gl_FragDepth;
+constexpr const TSymbolUniqueId BuiltInId::gl_SecondaryFragColorEXT;
+constexpr const TSymbolUniqueId BuiltInId::gl_SecondaryFragDataEXT;
+constexpr const TSymbolUniqueId BuiltInId::gl_FragDepthEXT;
+constexpr const TSymbolUniqueId BuiltInId::gl_LastFragData;
+constexpr const TSymbolUniqueId BuiltInId::gl_LastFragColor;
+constexpr const TSymbolUniqueId BuiltInId::gl_LastFragDataNV;
+constexpr const TSymbolUniqueId BuiltInId::gl_LastFragColorARM;
+constexpr const TSymbolUniqueId BuiltInId::gl_PrimitiveID;
+constexpr const TSymbolUniqueId BuiltInId::gl_Layer;
+constexpr const TSymbolUniqueId BuiltInId::gl_Position;
+constexpr const TSymbolUniqueId BuiltInId::gl_PointSize;
+constexpr const TSymbolUniqueId BuiltInId::gl_InstanceID;
+constexpr const TSymbolUniqueId BuiltInId::gl_VertexID;
+constexpr const TSymbolUniqueId BuiltInId::gl_ViewportIndex;
+constexpr const TSymbolUniqueId BuiltInId::gl_LayerVS;
+constexpr const TSymbolUniqueId BuiltInId::gl_NumWorkGroups;
+constexpr const TSymbolUniqueId BuiltInId::gl_WorkGroupSize;
+constexpr const TSymbolUniqueId BuiltInId::gl_WorkGroupID;
+constexpr const TSymbolUniqueId BuiltInId::gl_LocalInvocationID;
+constexpr const TSymbolUniqueId BuiltInId::gl_GlobalInvocationID;
+constexpr const TSymbolUniqueId BuiltInId::gl_LocalInvocationIndex;
+constexpr const TSymbolUniqueId BuiltInId::gl_PrimitiveIDIn;
+constexpr const TSymbolUniqueId BuiltInId::gl_InvocationID;
+constexpr const TSymbolUniqueId BuiltInId::gl_PrimitiveIDGS;
+constexpr const TSymbolUniqueId BuiltInId::gl_LayerGS;
+constexpr const TSymbolUniqueId BuiltInId::gl_PerVertex;
+constexpr const TSymbolUniqueId BuiltInId::gl_in;
+constexpr const TSymbolUniqueId BuiltInId::gl_PerVertexOutBlock;
+constexpr const TSymbolUniqueId BuiltInId::gl_PositionGS;
+constexpr const TSymbolUniqueId BuiltInId::gl_ViewID_OVR;
+constexpr const TSymbolUniqueId BuiltInId::gl_ViewID_OVRESSL1;
+
+const int TSymbolTable::kLastBuiltInId = 934;
namespace BuiltInName
{
@@ -1095,6 +1265,7 @@
constexpr const ImmutableString determinant_22f_("determinant(22f;");
constexpr const ImmutableString determinant_33f_("determinant(33f;");
constexpr const ImmutableString determinant_44f_("determinant(44f;");
+constexpr const ImmutableString diff("diff");
constexpr const ImmutableString distance("distance");
constexpr const ImmutableString distance_2f_2f_("distance(2f;2f;");
constexpr const ImmutableString distance_3f_3f_("distance(3f;3f;");
@@ -1133,6 +1304,7 @@
constexpr const ImmutableString faceforward_3f_3f_3f_("faceforward(3f;3f;3f;");
constexpr const ImmutableString faceforward_4f_4f_4f_("faceforward(4f;4f;4f;");
constexpr const ImmutableString faceforward_f_f_f_("faceforward(f;f;f;");
+constexpr const ImmutableString far("far");
constexpr const ImmutableString findLSB("findLSB");
constexpr const ImmutableString findLSB_2i_("findLSB(2i;");
constexpr const ImmutableString findLSB_2u_("findLSB(2u;");
@@ -1186,6 +1358,87 @@
constexpr const ImmutableString fwidth_3f_("fwidth(3f;");
constexpr const ImmutableString fwidth_4f_("fwidth(4f;");
constexpr const ImmutableString fwidth_f_("fwidth(f;");
+constexpr const ImmutableString gl_DepthRange("gl_DepthRange");
+constexpr const ImmutableString gl_DepthRangeParameters("gl_DepthRangeParameters");
+constexpr const ImmutableString gl_FragColor("gl_FragColor");
+constexpr const ImmutableString gl_FragCoord("gl_FragCoord");
+constexpr const ImmutableString gl_FragData("gl_FragData");
+constexpr const ImmutableString gl_FragDepth("gl_FragDepth");
+constexpr const ImmutableString gl_FragDepthEXT("gl_FragDepthEXT");
+constexpr const ImmutableString gl_FrontFacing("gl_FrontFacing");
+constexpr const ImmutableString gl_GlobalInvocationID("gl_GlobalInvocationID");
+constexpr const ImmutableString gl_InstanceID("gl_InstanceID");
+constexpr const ImmutableString gl_InvocationID("gl_InvocationID");
+constexpr const ImmutableString gl_LastFragColor("gl_LastFragColor");
+constexpr const ImmutableString gl_LastFragColorARM("gl_LastFragColorARM");
+constexpr const ImmutableString gl_LastFragData("gl_LastFragData");
+constexpr const ImmutableString gl_Layer("gl_Layer");
+constexpr const ImmutableString gl_LocalInvocationID("gl_LocalInvocationID");
+constexpr const ImmutableString gl_LocalInvocationIndex("gl_LocalInvocationIndex");
+constexpr const ImmutableString gl_MaxAtomicCounterBindings("gl_MaxAtomicCounterBindings");
+constexpr const ImmutableString gl_MaxAtomicCounterBufferSize("gl_MaxAtomicCounterBufferSize");
+constexpr const ImmutableString gl_MaxCombinedAtomicCounterBuffers(
+ "gl_MaxCombinedAtomicCounterBuffers");
+constexpr const ImmutableString gl_MaxCombinedAtomicCounters("gl_MaxCombinedAtomicCounters");
+constexpr const ImmutableString gl_MaxCombinedImageUniforms("gl_MaxCombinedImageUniforms");
+constexpr const ImmutableString gl_MaxCombinedShaderOutputResources(
+ "gl_MaxCombinedShaderOutputResources");
+constexpr const ImmutableString gl_MaxCombinedTextureImageUnits("gl_MaxCombinedTextureImageUnits");
+constexpr const ImmutableString gl_MaxComputeAtomicCounterBuffers(
+ "gl_MaxComputeAtomicCounterBuffers");
+constexpr const ImmutableString gl_MaxComputeAtomicCounters("gl_MaxComputeAtomicCounters");
+constexpr const ImmutableString gl_MaxComputeImageUniforms("gl_MaxComputeImageUniforms");
+constexpr const ImmutableString gl_MaxComputeTextureImageUnits("gl_MaxComputeTextureImageUnits");
+constexpr const ImmutableString gl_MaxComputeUniformComponents("gl_MaxComputeUniformComponents");
+constexpr const ImmutableString gl_MaxComputeWorkGroupCount("gl_MaxComputeWorkGroupCount");
+constexpr const ImmutableString gl_MaxComputeWorkGroupSize("gl_MaxComputeWorkGroupSize");
+constexpr const ImmutableString gl_MaxDrawBuffers("gl_MaxDrawBuffers");
+constexpr const ImmutableString gl_MaxDualSourceDrawBuffersEXT("gl_MaxDualSourceDrawBuffersEXT");
+constexpr const ImmutableString gl_MaxFragmentAtomicCounterBuffers(
+ "gl_MaxFragmentAtomicCounterBuffers");
+constexpr const ImmutableString gl_MaxFragmentAtomicCounters("gl_MaxFragmentAtomicCounters");
+constexpr const ImmutableString gl_MaxFragmentImageUniforms("gl_MaxFragmentImageUniforms");
+constexpr const ImmutableString gl_MaxFragmentInputVectors("gl_MaxFragmentInputVectors");
+constexpr const ImmutableString gl_MaxFragmentUniformVectors("gl_MaxFragmentUniformVectors");
+constexpr const ImmutableString gl_MaxGeometryAtomicCounterBuffers(
+ "gl_MaxGeometryAtomicCounterBuffers");
+constexpr const ImmutableString gl_MaxGeometryAtomicCounters("gl_MaxGeometryAtomicCounters");
+constexpr const ImmutableString gl_MaxGeometryImageUniforms("gl_MaxGeometryImageUniforms");
+constexpr const ImmutableString gl_MaxGeometryInputComponents("gl_MaxGeometryInputComponents");
+constexpr const ImmutableString gl_MaxGeometryOutputComponents("gl_MaxGeometryOutputComponents");
+constexpr const ImmutableString gl_MaxGeometryOutputVertices("gl_MaxGeometryOutputVertices");
+constexpr const ImmutableString gl_MaxGeometryTextureImageUnits("gl_MaxGeometryTextureImageUnits");
+constexpr const ImmutableString gl_MaxGeometryTotalOutputComponents(
+ "gl_MaxGeometryTotalOutputComponents");
+constexpr const ImmutableString gl_MaxGeometryUniformComponents("gl_MaxGeometryUniformComponents");
+constexpr const ImmutableString gl_MaxImageUnits("gl_MaxImageUnits");
+constexpr const ImmutableString gl_MaxProgramTexelOffset("gl_MaxProgramTexelOffset");
+constexpr const ImmutableString gl_MaxTextureImageUnits("gl_MaxTextureImageUnits");
+constexpr const ImmutableString gl_MaxVaryingVectors("gl_MaxVaryingVectors");
+constexpr const ImmutableString gl_MaxVertexAtomicCounterBuffers(
+ "gl_MaxVertexAtomicCounterBuffers");
+constexpr const ImmutableString gl_MaxVertexAtomicCounters("gl_MaxVertexAtomicCounters");
+constexpr const ImmutableString gl_MaxVertexAttribs("gl_MaxVertexAttribs");
+constexpr const ImmutableString gl_MaxVertexImageUniforms("gl_MaxVertexImageUniforms");
+constexpr const ImmutableString gl_MaxVertexOutputVectors("gl_MaxVertexOutputVectors");
+constexpr const ImmutableString gl_MaxVertexTextureImageUnits("gl_MaxVertexTextureImageUnits");
+constexpr const ImmutableString gl_MaxVertexUniformVectors("gl_MaxVertexUniformVectors");
+constexpr const ImmutableString gl_MinProgramTexelOffset("gl_MinProgramTexelOffset");
+constexpr const ImmutableString gl_NumWorkGroups("gl_NumWorkGroups");
+constexpr const ImmutableString gl_PerVertex("gl_PerVertex");
+constexpr const ImmutableString gl_PointCoord("gl_PointCoord");
+constexpr const ImmutableString gl_PointSize("gl_PointSize");
+constexpr const ImmutableString gl_Position("gl_Position");
+constexpr const ImmutableString gl_PrimitiveID("gl_PrimitiveID");
+constexpr const ImmutableString gl_PrimitiveIDIn("gl_PrimitiveIDIn");
+constexpr const ImmutableString gl_SecondaryFragColorEXT("gl_SecondaryFragColorEXT");
+constexpr const ImmutableString gl_SecondaryFragDataEXT("gl_SecondaryFragDataEXT");
+constexpr const ImmutableString gl_VertexID("gl_VertexID");
+constexpr const ImmutableString gl_ViewID_OVR("gl_ViewID_OVR");
+constexpr const ImmutableString gl_ViewportIndex("gl_ViewportIndex");
+constexpr const ImmutableString gl_WorkGroupID("gl_WorkGroupID");
+constexpr const ImmutableString gl_WorkGroupSize("gl_WorkGroupSize");
+constexpr const ImmutableString gl_in("gl_in");
constexpr const ImmutableString greaterThan("greaterThan");
constexpr const ImmutableString greaterThanEqual("greaterThanEqual");
constexpr const ImmutableString greaterThanEqual_2f_2f_("greaterThanEqual(2f;2f;");
@@ -1405,6 +1658,7 @@
constexpr const ImmutableString modf_3f_3f_("modf(3f;3f;");
constexpr const ImmutableString modf_4f_4f_("modf(4f;4f;");
constexpr const ImmutableString modf_f_f_("modf(f;f;");
+constexpr const ImmutableString near("near");
constexpr const ImmutableString normalize("normalize");
constexpr const ImmutableString normalize_2f_("normalize(2f;");
constexpr const ImmutableString normalize_3f_("normalize(3f;");
@@ -3550,6 +3804,318 @@
} // namespace UnmangledBuiltIns
// TODO(oetuaho): Would be nice to make this a class instead of a namespace so that we could friend
+// this from TVariable. Now symbol constructors taking an id have to be public even though they're
+// not supposed to be accessible from outside of here. http://anglebug.com/2390
+namespace BuiltInVariable
+{
+
+constexpr const TVariable kVar_gl_FragColor(
+ BuiltInId::gl_FragColor,
+ BuiltInName::gl_FragColor,
+ SymbolType::BuiltIn,
+ TExtension::UNDEFINED,
+ StaticType::Get<EbtFloat, EbpMedium, EvqFragColor, 4, 1>());
+constexpr const TVariable kVar_gl_FragCoord(
+ BuiltInId::gl_FragCoord,
+ BuiltInName::gl_FragCoord,
+ SymbolType::BuiltIn,
+ TExtension::UNDEFINED,
+ StaticType::Get<EbtFloat, EbpMedium, EvqFragCoord, 4, 1>());
+constexpr const TVariable kVar_gl_FragDepth(
+ BuiltInId::gl_FragDepth,
+ BuiltInName::gl_FragDepth,
+ SymbolType::BuiltIn,
+ TExtension::UNDEFINED,
+ StaticType::Get<EbtFloat, EbpHigh, EvqFragDepth, 1, 1>());
+constexpr const TVariable kVar_gl_FrontFacing(
+ BuiltInId::gl_FrontFacing,
+ BuiltInName::gl_FrontFacing,
+ SymbolType::BuiltIn,
+ TExtension::UNDEFINED,
+ StaticType::Get<EbtBool, EbpUndefined, EvqFrontFacing, 1, 1>());
+constexpr const TVariable kVar_gl_GlobalInvocationID(
+ BuiltInId::gl_GlobalInvocationID,
+ BuiltInName::gl_GlobalInvocationID,
+ SymbolType::BuiltIn,
+ TExtension::UNDEFINED,
+ StaticType::Get<EbtUInt, EbpUndefined, EvqGlobalInvocationID, 3, 1>());
+constexpr const TVariable kVar_gl_InstanceID(
+ BuiltInId::gl_InstanceID,
+ BuiltInName::gl_InstanceID,
+ SymbolType::BuiltIn,
+ TExtension::UNDEFINED,
+ StaticType::Get<EbtInt, EbpHigh, EvqInstanceID, 1, 1>());
+constexpr const TVariable kVar_gl_InvocationID(
+ BuiltInId::gl_InvocationID,
+ BuiltInName::gl_InvocationID,
+ SymbolType::BuiltIn,
+ TExtension::EXT_geometry_shader,
+ StaticType::Get<EbtInt, EbpHigh, EvqInvocationID, 1, 1>());
+constexpr const TVariable kVar_gl_LastFragColor(
+ BuiltInId::gl_LastFragColor,
+ BuiltInName::gl_LastFragColor,
+ SymbolType::BuiltIn,
+ TExtension::NV_shader_framebuffer_fetch,
+ StaticType::Get<EbtFloat, EbpMedium, EvqLastFragColor, 4, 1>());
+constexpr const TVariable kVar_gl_LastFragColorARM(
+ BuiltInId::gl_LastFragColorARM,
+ BuiltInName::gl_LastFragColorARM,
+ SymbolType::BuiltIn,
+ TExtension::ARM_shader_framebuffer_fetch,
+ StaticType::Get<EbtFloat, EbpMedium, EvqLastFragColor, 4, 1>());
+constexpr const TVariable kVar_gl_Layer(BuiltInId::gl_Layer,
+ BuiltInName::gl_Layer,
+ SymbolType::BuiltIn,
+ TExtension::EXT_geometry_shader,
+ StaticType::Get<EbtInt, EbpHigh, EvqLayer, 1, 1>());
+constexpr const TVariable kVar_gl_LayerGS(BuiltInId::gl_LayerGS,
+ BuiltInName::gl_Layer,
+ SymbolType::BuiltIn,
+ TExtension::EXT_geometry_shader,
+ StaticType::Get<EbtInt, EbpHigh, EvqLayer, 1, 1>());
+constexpr const TVariable kVar_gl_LayerVS(BuiltInId::gl_LayerVS,
+ BuiltInName::gl_Layer,
+ SymbolType::BuiltIn,
+ TExtension::UNDEFINED,
+ StaticType::Get<EbtInt, EbpHigh, EvqLayer, 1, 1>());
+constexpr const TVariable kVar_gl_LocalInvocationID(
+ BuiltInId::gl_LocalInvocationID,
+ BuiltInName::gl_LocalInvocationID,
+ SymbolType::BuiltIn,
+ TExtension::UNDEFINED,
+ StaticType::Get<EbtUInt, EbpUndefined, EvqLocalInvocationID, 3, 1>());
+constexpr const TVariable kVar_gl_LocalInvocationIndex(
+ BuiltInId::gl_LocalInvocationIndex,
+ BuiltInName::gl_LocalInvocationIndex,
+ SymbolType::BuiltIn,
+ TExtension::UNDEFINED,
+ StaticType::Get<EbtUInt, EbpUndefined, EvqLocalInvocationIndex, 1, 1>());
+constexpr const TVariable kVar_gl_NumWorkGroups(
+ BuiltInId::gl_NumWorkGroups,
+ BuiltInName::gl_NumWorkGroups,
+ SymbolType::BuiltIn,
+ TExtension::UNDEFINED,
+ StaticType::Get<EbtUInt, EbpUndefined, EvqNumWorkGroups, 3, 1>());
+constexpr const TVariable kVar_gl_PointCoord(
+ BuiltInId::gl_PointCoord,
+ BuiltInName::gl_PointCoord,
+ SymbolType::BuiltIn,
+ TExtension::UNDEFINED,
+ StaticType::Get<EbtFloat, EbpMedium, EvqPointCoord, 2, 1>());
+constexpr const TVariable kVar_gl_PointSize(
+ BuiltInId::gl_PointSize,
+ BuiltInName::gl_PointSize,
+ SymbolType::BuiltIn,
+ TExtension::UNDEFINED,
+ StaticType::Get<EbtFloat, EbpMedium, EvqPointSize, 1, 1>());
+constexpr const TVariable kVar_gl_Position(BuiltInId::gl_Position,
+ BuiltInName::gl_Position,
+ SymbolType::BuiltIn,
+ TExtension::UNDEFINED,
+ StaticType::Get<EbtFloat, EbpHigh, EvqPosition, 4, 1>());
+constexpr const TVariable kVar_gl_PrimitiveID(
+ BuiltInId::gl_PrimitiveID,
+ BuiltInName::gl_PrimitiveID,
+ SymbolType::BuiltIn,
+ TExtension::EXT_geometry_shader,
+ StaticType::Get<EbtInt, EbpHigh, EvqPrimitiveID, 1, 1>());
+constexpr const TVariable kVar_gl_PrimitiveIDGS(
+ BuiltInId::gl_PrimitiveIDGS,
+ BuiltInName::gl_PrimitiveID,
+ SymbolType::BuiltIn,
+ TExtension::EXT_geometry_shader,
+ StaticType::Get<EbtInt, EbpHigh, EvqPrimitiveID, 1, 1>());
+constexpr const TVariable kVar_gl_PrimitiveIDIn(
+ BuiltInId::gl_PrimitiveIDIn,
+ BuiltInName::gl_PrimitiveIDIn,
+ SymbolType::BuiltIn,
+ TExtension::EXT_geometry_shader,
+ StaticType::Get<EbtInt, EbpHigh, EvqPrimitiveIDIn, 1, 1>());
+constexpr const TVariable kVar_gl_SecondaryFragColorEXT(
+ BuiltInId::gl_SecondaryFragColorEXT,
+ BuiltInName::gl_SecondaryFragColorEXT,
+ SymbolType::BuiltIn,
+ TExtension::EXT_blend_func_extended,
+ StaticType::Get<EbtFloat, EbpMedium, EvqSecondaryFragColorEXT, 4, 1>());
+constexpr const TVariable kVar_gl_VertexID(BuiltInId::gl_VertexID,
+ BuiltInName::gl_VertexID,
+ SymbolType::BuiltIn,
+ TExtension::UNDEFINED,
+ StaticType::Get<EbtInt, EbpHigh, EvqVertexID, 1, 1>());
+constexpr const TVariable kVar_gl_ViewID_OVR(
+ BuiltInId::gl_ViewID_OVR,
+ BuiltInName::gl_ViewID_OVR,
+ SymbolType::BuiltIn,
+ TExtension::OVR_multiview,
+ StaticType::Get<EbtUInt, EbpHigh, EvqViewIDOVR, 1, 1>());
+constexpr const TVariable kVar_gl_ViewID_OVRESSL1(
+ BuiltInId::gl_ViewID_OVRESSL1,
+ BuiltInName::gl_ViewID_OVR,
+ SymbolType::BuiltIn,
+ TExtension::OVR_multiview,
+ StaticType::Get<EbtInt, EbpHigh, EvqViewIDOVR, 1, 1>());
+constexpr const TVariable kVar_gl_ViewportIndex(
+ BuiltInId::gl_ViewportIndex,
+ BuiltInName::gl_ViewportIndex,
+ SymbolType::BuiltIn,
+ TExtension::UNDEFINED,
+ StaticType::Get<EbtInt, EbpHigh, EvqViewportIndex, 1, 1>());
+constexpr const TVariable kVar_gl_WorkGroupID(
+ BuiltInId::gl_WorkGroupID,
+ BuiltInName::gl_WorkGroupID,
+ SymbolType::BuiltIn,
+ TExtension::UNDEFINED,
+ StaticType::Get<EbtUInt, EbpUndefined, EvqWorkGroupID, 3, 1>());
+constexpr const TVariable kVar_gl_WorkGroupSize(
+ BuiltInId::gl_WorkGroupSize,
+ BuiltInName::gl_WorkGroupSize,
+ SymbolType::BuiltIn,
+ TExtension::UNDEFINED,
+ StaticType::Get<EbtUInt, EbpUndefined, EvqWorkGroupSize, 3, 1>());
+
+const TVariable *gl_FragColor()
+{
+ return &kVar_gl_FragColor;
+}
+
+const TVariable *gl_FragCoord()
+{
+ return &kVar_gl_FragCoord;
+}
+
+const TVariable *gl_FragDepth()
+{
+ return &kVar_gl_FragDepth;
+}
+
+const TVariable *gl_FrontFacing()
+{
+ return &kVar_gl_FrontFacing;
+}
+
+const TVariable *gl_GlobalInvocationID()
+{
+ return &kVar_gl_GlobalInvocationID;
+}
+
+const TVariable *gl_InstanceID()
+{
+ return &kVar_gl_InstanceID;
+}
+
+const TVariable *gl_InvocationID()
+{
+ return &kVar_gl_InvocationID;
+}
+
+const TVariable *gl_LastFragColor()
+{
+ return &kVar_gl_LastFragColor;
+}
+
+const TVariable *gl_LastFragColorARM()
+{
+ return &kVar_gl_LastFragColorARM;
+}
+
+const TVariable *gl_Layer()
+{
+ return &kVar_gl_Layer;
+}
+
+const TVariable *gl_LayerGS()
+{
+ return &kVar_gl_LayerGS;
+}
+
+const TVariable *gl_LayerVS()
+{
+ return &kVar_gl_LayerVS;
+}
+
+const TVariable *gl_LocalInvocationID()
+{
+ return &kVar_gl_LocalInvocationID;
+}
+
+const TVariable *gl_LocalInvocationIndex()
+{
+ return &kVar_gl_LocalInvocationIndex;
+}
+
+const TVariable *gl_NumWorkGroups()
+{
+ return &kVar_gl_NumWorkGroups;
+}
+
+const TVariable *gl_PointCoord()
+{
+ return &kVar_gl_PointCoord;
+}
+
+const TVariable *gl_PointSize()
+{
+ return &kVar_gl_PointSize;
+}
+
+const TVariable *gl_Position()
+{
+ return &kVar_gl_Position;
+}
+
+const TVariable *gl_PrimitiveID()
+{
+ return &kVar_gl_PrimitiveID;
+}
+
+const TVariable *gl_PrimitiveIDGS()
+{
+ return &kVar_gl_PrimitiveIDGS;
+}
+
+const TVariable *gl_PrimitiveIDIn()
+{
+ return &kVar_gl_PrimitiveIDIn;
+}
+
+const TVariable *gl_SecondaryFragColorEXT()
+{
+ return &kVar_gl_SecondaryFragColorEXT;
+}
+
+const TVariable *gl_VertexID()
+{
+ return &kVar_gl_VertexID;
+}
+
+const TVariable *gl_ViewID_OVR()
+{
+ return &kVar_gl_ViewID_OVR;
+}
+
+const TVariable *gl_ViewID_OVRESSL1()
+{
+ return &kVar_gl_ViewID_OVRESSL1;
+}
+
+const TVariable *gl_ViewportIndex()
+{
+ return &kVar_gl_ViewportIndex;
+}
+
+const TVariable *gl_WorkGroupID()
+{
+ return &kVar_gl_WorkGroupID;
+}
+
+const TVariable *gl_WorkGroupSize()
+{
+ return &kVar_gl_WorkGroupSize;
+}
+
+}; // namespace BuiltInVariable
+
+// TODO(oetuaho): Would be nice to make this a class instead of a namespace so that we could friend
// this from TFunction. Now symbol constructors taking an id have to be public even though they're
// not supposed to be accessible from outside of here. http://anglebug.com/2390
namespace BuiltInFunction
@@ -12097,6 +12663,587 @@
} // namespace BuiltInFunction
+void TSymbolTable::insertBuiltInVariables(sh::GLenum shaderType,
+ ShShaderSpec spec,
+ const ShBuiltInResources &resources)
+{
+ const TSourceLoc zeroSourceLoc = {0, 0, 0, 0};
+ TFieldList *fields_gl_DepthRangeParameters = new TFieldList();
+ fields_gl_DepthRangeParameters->push_back(new TField(
+ new TType(EbtFloat, EbpHigh, EvqGlobal, 1, 1), BuiltInName::near, zeroSourceLoc));
+ fields_gl_DepthRangeParameters->push_back(
+ new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1, 1), BuiltInName::far, zeroSourceLoc));
+ fields_gl_DepthRangeParameters->push_back(new TField(
+ new TType(EbtFloat, EbpHigh, EvqGlobal, 1, 1), BuiltInName::diff, zeroSourceLoc));
+ TStructure *gl_DepthRangeParameters =
+ new TStructure(BuiltInId::gl_DepthRangeParameters, BuiltInName::gl_DepthRangeParameters,
+ TExtension::UNDEFINED, fields_gl_DepthRangeParameters);
+ insertBuiltIn(COMMON_BUILTINS, gl_DepthRangeParameters);
+ TType *type_gl_DepthRange = new TType(gl_DepthRangeParameters);
+ type_gl_DepthRange->setQualifier(EvqUniform);
+ type_gl_DepthRange->realize();
+ TVariable *gl_DepthRange =
+ new TVariable(BuiltInId::gl_DepthRange, BuiltInName::gl_DepthRange, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, type_gl_DepthRange);
+ insertBuiltIn(COMMON_BUILTINS, gl_DepthRange);
+ TVariable *gl_MaxVertexAttribs = new TVariable(
+ BuiltInId::gl_MaxVertexAttribs, BuiltInName::gl_MaxVertexAttribs, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxVertexAttribs);
+ gl_MaxVertexAttribs->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(COMMON_BUILTINS, gl_MaxVertexAttribs);
+ TVariable *gl_MaxVertexUniformVectors =
+ new TVariable(BuiltInId::gl_MaxVertexUniformVectors,
+ BuiltInName::gl_MaxVertexUniformVectors, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxVertexUniformVectors);
+ gl_MaxVertexUniformVectors->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(COMMON_BUILTINS, gl_MaxVertexUniformVectors);
+ TVariable *gl_MaxVertexTextureImageUnits =
+ new TVariable(BuiltInId::gl_MaxVertexTextureImageUnits,
+ BuiltInName::gl_MaxVertexTextureImageUnits, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxVertexTextureImageUnits);
+ gl_MaxVertexTextureImageUnits->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(COMMON_BUILTINS, gl_MaxVertexTextureImageUnits);
+ TVariable *gl_MaxCombinedTextureImageUnits =
+ new TVariable(BuiltInId::gl_MaxCombinedTextureImageUnits,
+ BuiltInName::gl_MaxCombinedTextureImageUnits, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxCombinedTextureImageUnits);
+ gl_MaxCombinedTextureImageUnits->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(COMMON_BUILTINS, gl_MaxCombinedTextureImageUnits);
+ TVariable *gl_MaxTextureImageUnits =
+ new TVariable(BuiltInId::gl_MaxTextureImageUnits, BuiltInName::gl_MaxTextureImageUnits,
+ SymbolType::BuiltIn, TExtension::UNDEFINED,
+ StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxTextureImageUnits);
+ gl_MaxTextureImageUnits->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(COMMON_BUILTINS, gl_MaxTextureImageUnits);
+ TVariable *gl_MaxFragmentUniformVectors =
+ new TVariable(BuiltInId::gl_MaxFragmentUniformVectors,
+ BuiltInName::gl_MaxFragmentUniformVectors, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxFragmentUniformVectors);
+ gl_MaxFragmentUniformVectors->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(COMMON_BUILTINS, gl_MaxFragmentUniformVectors);
+ TVariable *gl_MaxVaryingVectors = new TVariable(
+ BuiltInId::gl_MaxVaryingVectors, BuiltInName::gl_MaxVaryingVectors, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxVaryingVectors);
+ gl_MaxVaryingVectors->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL1_BUILTINS, gl_MaxVaryingVectors);
+ TVariable *gl_MaxDrawBuffers = new TVariable(
+ BuiltInId::gl_MaxDrawBuffers, BuiltInName::gl_MaxDrawBuffers, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxDrawBuffers);
+ gl_MaxDrawBuffers->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(COMMON_BUILTINS, gl_MaxDrawBuffers);
+ TVariable *gl_MaxDualSourceDrawBuffersEXT = new TVariable(
+ BuiltInId::gl_MaxDualSourceDrawBuffersEXT, BuiltInName::gl_MaxDualSourceDrawBuffersEXT,
+ SymbolType::BuiltIn, TExtension::EXT_blend_func_extended,
+ StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxDualSourceDrawBuffers);
+ gl_MaxDualSourceDrawBuffersEXT->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(COMMON_BUILTINS, gl_MaxDualSourceDrawBuffersEXT);
+ TVariable *gl_MaxVertexOutputVectors =
+ new TVariable(BuiltInId::gl_MaxVertexOutputVectors, BuiltInName::gl_MaxVertexOutputVectors,
+ SymbolType::BuiltIn, TExtension::UNDEFINED,
+ StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxVertexOutputVectors);
+ gl_MaxVertexOutputVectors->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_BUILTINS, gl_MaxVertexOutputVectors);
+ TVariable *gl_MaxFragmentInputVectors =
+ new TVariable(BuiltInId::gl_MaxFragmentInputVectors,
+ BuiltInName::gl_MaxFragmentInputVectors, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxFragmentInputVectors);
+ gl_MaxFragmentInputVectors->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_BUILTINS, gl_MaxFragmentInputVectors);
+ TVariable *gl_MinProgramTexelOffset =
+ new TVariable(BuiltInId::gl_MinProgramTexelOffset, BuiltInName::gl_MinProgramTexelOffset,
+ SymbolType::BuiltIn, TExtension::UNDEFINED,
+ StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MinProgramTexelOffset);
+ gl_MinProgramTexelOffset->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_BUILTINS, gl_MinProgramTexelOffset);
+ TVariable *gl_MaxProgramTexelOffset =
+ new TVariable(BuiltInId::gl_MaxProgramTexelOffset, BuiltInName::gl_MaxProgramTexelOffset,
+ SymbolType::BuiltIn, TExtension::UNDEFINED,
+ StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxProgramTexelOffset);
+ gl_MaxProgramTexelOffset->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_BUILTINS, gl_MaxProgramTexelOffset);
+ TVariable *gl_MaxImageUnits = new TVariable(
+ BuiltInId::gl_MaxImageUnits, BuiltInName::gl_MaxImageUnits, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxImageUnits);
+ gl_MaxImageUnits->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxImageUnits);
+ TVariable *gl_MaxVertexImageUniforms =
+ new TVariable(BuiltInId::gl_MaxVertexImageUniforms, BuiltInName::gl_MaxVertexImageUniforms,
+ SymbolType::BuiltIn, TExtension::UNDEFINED,
+ StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxVertexImageUniforms);
+ gl_MaxVertexImageUniforms->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxVertexImageUniforms);
+ TVariable *gl_MaxFragmentImageUniforms =
+ new TVariable(BuiltInId::gl_MaxFragmentImageUniforms,
+ BuiltInName::gl_MaxFragmentImageUniforms, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxFragmentImageUniforms);
+ gl_MaxFragmentImageUniforms->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxFragmentImageUniforms);
+ TVariable *gl_MaxComputeImageUniforms =
+ new TVariable(BuiltInId::gl_MaxComputeImageUniforms,
+ BuiltInName::gl_MaxComputeImageUniforms, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxComputeImageUniforms);
+ gl_MaxComputeImageUniforms->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxComputeImageUniforms);
+ TVariable *gl_MaxCombinedImageUniforms =
+ new TVariable(BuiltInId::gl_MaxCombinedImageUniforms,
+ BuiltInName::gl_MaxCombinedImageUniforms, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxCombinedImageUniforms);
+ gl_MaxCombinedImageUniforms->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxCombinedImageUniforms);
+ TVariable *gl_MaxCombinedShaderOutputResources =
+ new TVariable(BuiltInId::gl_MaxCombinedShaderOutputResources,
+ BuiltInName::gl_MaxCombinedShaderOutputResources, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxCombinedShaderOutputResources);
+ gl_MaxCombinedShaderOutputResources->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxCombinedShaderOutputResources);
+ TVariable *gl_MaxComputeWorkGroupCount =
+ new TVariable(BuiltInId::gl_MaxComputeWorkGroupCount,
+ BuiltInName::gl_MaxComputeWorkGroupCount, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpHigh, EvqConst, 3, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[3];
+ for (size_t index = 0u; index < 3; ++index)
+ {
+ unionArray[index].setIConst(resources.MaxComputeWorkGroupCount[index]);
+ }
+ gl_MaxComputeWorkGroupCount->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxComputeWorkGroupCount);
+ TVariable *gl_MaxComputeWorkGroupSize =
+ new TVariable(BuiltInId::gl_MaxComputeWorkGroupSize,
+ BuiltInName::gl_MaxComputeWorkGroupSize, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpHigh, EvqConst, 3, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[3];
+ for (size_t index = 0u; index < 3; ++index)
+ {
+ unionArray[index].setIConst(resources.MaxComputeWorkGroupSize[index]);
+ }
+ gl_MaxComputeWorkGroupSize->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxComputeWorkGroupSize);
+ TVariable *gl_MaxComputeUniformComponents =
+ new TVariable(BuiltInId::gl_MaxComputeUniformComponents,
+ BuiltInName::gl_MaxComputeUniformComponents, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxComputeUniformComponents);
+ gl_MaxComputeUniformComponents->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxComputeUniformComponents);
+ TVariable *gl_MaxComputeTextureImageUnits =
+ new TVariable(BuiltInId::gl_MaxComputeTextureImageUnits,
+ BuiltInName::gl_MaxComputeTextureImageUnits, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxComputeTextureImageUnits);
+ gl_MaxComputeTextureImageUnits->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxComputeTextureImageUnits);
+ TVariable *gl_MaxComputeAtomicCounters =
+ new TVariable(BuiltInId::gl_MaxComputeAtomicCounters,
+ BuiltInName::gl_MaxComputeAtomicCounters, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxComputeAtomicCounters);
+ gl_MaxComputeAtomicCounters->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxComputeAtomicCounters);
+ TVariable *gl_MaxComputeAtomicCounterBuffers =
+ new TVariable(BuiltInId::gl_MaxComputeAtomicCounterBuffers,
+ BuiltInName::gl_MaxComputeAtomicCounterBuffers, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxComputeAtomicCounterBuffers);
+ gl_MaxComputeAtomicCounterBuffers->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxComputeAtomicCounterBuffers);
+ TVariable *gl_MaxVertexAtomicCounters =
+ new TVariable(BuiltInId::gl_MaxVertexAtomicCounters,
+ BuiltInName::gl_MaxVertexAtomicCounters, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxVertexAtomicCounters);
+ gl_MaxVertexAtomicCounters->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxVertexAtomicCounters);
+ TVariable *gl_MaxFragmentAtomicCounters =
+ new TVariable(BuiltInId::gl_MaxFragmentAtomicCounters,
+ BuiltInName::gl_MaxFragmentAtomicCounters, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxFragmentAtomicCounters);
+ gl_MaxFragmentAtomicCounters->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxFragmentAtomicCounters);
+ TVariable *gl_MaxCombinedAtomicCounters =
+ new TVariable(BuiltInId::gl_MaxCombinedAtomicCounters,
+ BuiltInName::gl_MaxCombinedAtomicCounters, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxCombinedAtomicCounters);
+ gl_MaxCombinedAtomicCounters->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxCombinedAtomicCounters);
+ TVariable *gl_MaxAtomicCounterBindings =
+ new TVariable(BuiltInId::gl_MaxAtomicCounterBindings,
+ BuiltInName::gl_MaxAtomicCounterBindings, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxAtomicCounterBindings);
+ gl_MaxAtomicCounterBindings->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxAtomicCounterBindings);
+ TVariable *gl_MaxVertexAtomicCounterBuffers =
+ new TVariable(BuiltInId::gl_MaxVertexAtomicCounterBuffers,
+ BuiltInName::gl_MaxVertexAtomicCounterBuffers, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxVertexAtomicCounterBuffers);
+ gl_MaxVertexAtomicCounterBuffers->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxVertexAtomicCounterBuffers);
+ TVariable *gl_MaxFragmentAtomicCounterBuffers =
+ new TVariable(BuiltInId::gl_MaxFragmentAtomicCounterBuffers,
+ BuiltInName::gl_MaxFragmentAtomicCounterBuffers, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxFragmentAtomicCounterBuffers);
+ gl_MaxFragmentAtomicCounterBuffers->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxFragmentAtomicCounterBuffers);
+ TVariable *gl_MaxCombinedAtomicCounterBuffers =
+ new TVariable(BuiltInId::gl_MaxCombinedAtomicCounterBuffers,
+ BuiltInName::gl_MaxCombinedAtomicCounterBuffers, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxCombinedAtomicCounterBuffers);
+ gl_MaxCombinedAtomicCounterBuffers->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxCombinedAtomicCounterBuffers);
+ TVariable *gl_MaxAtomicCounterBufferSize =
+ new TVariable(BuiltInId::gl_MaxAtomicCounterBufferSize,
+ BuiltInName::gl_MaxAtomicCounterBufferSize, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxAtomicCounterBufferSize);
+ gl_MaxAtomicCounterBufferSize->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxAtomicCounterBufferSize);
+ TVariable *gl_MaxGeometryInputComponents = new TVariable(
+ BuiltInId::gl_MaxGeometryInputComponents, BuiltInName::gl_MaxGeometryInputComponents,
+ SymbolType::BuiltIn, TExtension::EXT_geometry_shader,
+ StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxGeometryInputComponents);
+ gl_MaxGeometryInputComponents->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxGeometryInputComponents);
+ TVariable *gl_MaxGeometryOutputComponents = new TVariable(
+ BuiltInId::gl_MaxGeometryOutputComponents, BuiltInName::gl_MaxGeometryOutputComponents,
+ SymbolType::BuiltIn, TExtension::EXT_geometry_shader,
+ StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxGeometryOutputComponents);
+ gl_MaxGeometryOutputComponents->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxGeometryOutputComponents);
+ TVariable *gl_MaxGeometryImageUniforms = new TVariable(
+ BuiltInId::gl_MaxGeometryImageUniforms, BuiltInName::gl_MaxGeometryImageUniforms,
+ SymbolType::BuiltIn, TExtension::EXT_geometry_shader,
+ StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxGeometryImageUniforms);
+ gl_MaxGeometryImageUniforms->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxGeometryImageUniforms);
+ TVariable *gl_MaxGeometryTextureImageUnits = new TVariable(
+ BuiltInId::gl_MaxGeometryTextureImageUnits, BuiltInName::gl_MaxGeometryTextureImageUnits,
+ SymbolType::BuiltIn, TExtension::EXT_geometry_shader,
+ StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxGeometryTextureImageUnits);
+ gl_MaxGeometryTextureImageUnits->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxGeometryTextureImageUnits);
+ TVariable *gl_MaxGeometryOutputVertices = new TVariable(
+ BuiltInId::gl_MaxGeometryOutputVertices, BuiltInName::gl_MaxGeometryOutputVertices,
+ SymbolType::BuiltIn, TExtension::EXT_geometry_shader,
+ StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxGeometryOutputVertices);
+ gl_MaxGeometryOutputVertices->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxGeometryOutputVertices);
+ TVariable *gl_MaxGeometryTotalOutputComponents = new TVariable(
+ BuiltInId::gl_MaxGeometryTotalOutputComponents,
+ BuiltInName::gl_MaxGeometryTotalOutputComponents, SymbolType::BuiltIn,
+ TExtension::EXT_geometry_shader, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxGeometryTotalOutputComponents);
+ gl_MaxGeometryTotalOutputComponents->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxGeometryTotalOutputComponents);
+ TVariable *gl_MaxGeometryUniformComponents = new TVariable(
+ BuiltInId::gl_MaxGeometryUniformComponents, BuiltInName::gl_MaxGeometryUniformComponents,
+ SymbolType::BuiltIn, TExtension::EXT_geometry_shader,
+ StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxGeometryUniformComponents);
+ gl_MaxGeometryUniformComponents->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxGeometryUniformComponents);
+ TVariable *gl_MaxGeometryAtomicCounters = new TVariable(
+ BuiltInId::gl_MaxGeometryAtomicCounters, BuiltInName::gl_MaxGeometryAtomicCounters,
+ SymbolType::BuiltIn, TExtension::EXT_geometry_shader,
+ StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxGeometryAtomicCounters);
+ gl_MaxGeometryAtomicCounters->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxGeometryAtomicCounters);
+ TVariable *gl_MaxGeometryAtomicCounterBuffers = new TVariable(
+ BuiltInId::gl_MaxGeometryAtomicCounterBuffers,
+ BuiltInName::gl_MaxGeometryAtomicCounterBuffers, SymbolType::BuiltIn,
+ TExtension::EXT_geometry_shader, StaticType::Get<EbtInt, EbpMedium, EvqConst, 1, 1>());
+ {
+ TConstantUnion *unionArray = new TConstantUnion[1];
+ unionArray[0].setIConst(resources.MaxGeometryAtomicCounterBuffers);
+ gl_MaxGeometryAtomicCounterBuffers->shareConstPointer(unionArray);
+ }
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_MaxGeometryAtomicCounterBuffers);
+ if (shaderType == GL_FRAGMENT_SHADER)
+ {
+ insertBuiltIn(COMMON_BUILTINS, &BuiltInVariable::kVar_gl_FragCoord);
+ insertBuiltIn(COMMON_BUILTINS, &BuiltInVariable::kVar_gl_FrontFacing);
+ insertBuiltIn(COMMON_BUILTINS, &BuiltInVariable::kVar_gl_PointCoord);
+ insertBuiltIn(ESSL1_BUILTINS, &BuiltInVariable::kVar_gl_FragColor);
+ TType *type_gl_FragData = new TType(EbtFloat, EbpMedium, EvqFragData, 4);
+ if (spec != SH_WEBGL2_SPEC && spec != SH_WEBGL3_SPEC)
+ {
+ type_gl_FragData->makeArray(resources.MaxDrawBuffers);
+ }
+ else
+ {
+ type_gl_FragData->makeArray(1u);
+ }
+ type_gl_FragData->realize();
+ TVariable *gl_FragData =
+ new TVariable(BuiltInId::gl_FragData, BuiltInName::gl_FragData, SymbolType::BuiltIn,
+ TExtension::UNDEFINED, type_gl_FragData);
+ insertBuiltIn(ESSL1_BUILTINS, gl_FragData);
+ insertBuiltIn(ESSL3_BUILTINS, &BuiltInVariable::kVar_gl_FragDepth);
+ if (resources.EXT_blend_func_extended)
+ {
+ insertBuiltIn(ESSL1_BUILTINS, &BuiltInVariable::kVar_gl_SecondaryFragColorEXT);
+ TType *type_gl_SecondaryFragDataEXT =
+ new TType(EbtFloat, EbpMedium, EvqSecondaryFragDataEXT, 4, 1);
+ type_gl_SecondaryFragDataEXT->makeArray(resources.MaxDualSourceDrawBuffers);
+ type_gl_SecondaryFragDataEXT->realize();
+ TVariable *gl_SecondaryFragDataEXT =
+ new TVariable(BuiltInId::gl_SecondaryFragDataEXT,
+ BuiltInName::gl_SecondaryFragDataEXT, SymbolType::BuiltIn,
+ TExtension::EXT_blend_func_extended, type_gl_SecondaryFragDataEXT);
+ insertBuiltIn(ESSL1_BUILTINS, gl_SecondaryFragDataEXT);
+ }
+ if (resources.EXT_frag_depth)
+ {
+ TType *type_gl_FragDepthEXT =
+ new TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium,
+ EvqFragDepthEXT, 1);
+ type_gl_FragDepthEXT->realize();
+ TVariable *gl_FragDepthEXT = new TVariable(
+ BuiltInId::gl_FragDepthEXT, BuiltInName::gl_FragDepthEXT, SymbolType::BuiltIn,
+ TExtension::EXT_frag_depth, type_gl_FragDepthEXT);
+ insertBuiltIn(ESSL1_BUILTINS, gl_FragDepthEXT);
+ }
+ if (resources.EXT_shader_framebuffer_fetch)
+ {
+ TType *type_gl_LastFragData = new TType(EbtFloat, EbpMedium, EvqLastFragData, 4, 1);
+ type_gl_LastFragData->makeArray(resources.MaxDrawBuffers);
+ type_gl_LastFragData->realize();
+ TVariable *gl_LastFragData = new TVariable(
+ BuiltInId::gl_LastFragData, BuiltInName::gl_LastFragData, SymbolType::BuiltIn,
+ TExtension::EXT_shader_framebuffer_fetch, type_gl_LastFragData);
+ insertBuiltIn(ESSL1_BUILTINS, gl_LastFragData);
+ }
+ if (resources.NV_shader_framebuffer_fetch)
+ {
+ insertBuiltIn(ESSL1_BUILTINS, &BuiltInVariable::kVar_gl_LastFragColor);
+ TType *type_gl_LastFragDataNV = new TType(EbtFloat, EbpMedium, EvqLastFragData, 4, 1);
+ type_gl_LastFragDataNV->makeArray(resources.MaxDrawBuffers);
+ type_gl_LastFragDataNV->realize();
+ TVariable *gl_LastFragDataNV = new TVariable(
+ BuiltInId::gl_LastFragDataNV, BuiltInName::gl_LastFragData, SymbolType::BuiltIn,
+ TExtension::NV_shader_framebuffer_fetch, type_gl_LastFragDataNV);
+ insertBuiltIn(ESSL1_BUILTINS, gl_LastFragDataNV);
+ }
+ if (!resources.EXT_shader_framebuffer_fetch && !resources.NV_shader_framebuffer_fetch &&
+ resources.ARM_shader_framebuffer_fetch)
+ {
+ insertBuiltIn(ESSL1_BUILTINS, &BuiltInVariable::kVar_gl_LastFragColorARM);
+ }
+ if (resources.EXT_geometry_shader)
+ {
+ insertBuiltIn(ESSL3_1_BUILTINS, &BuiltInVariable::kVar_gl_PrimitiveID);
+ insertBuiltIn(ESSL3_1_BUILTINS, &BuiltInVariable::kVar_gl_Layer);
+ }
+ }
+ if (shaderType == GL_VERTEX_SHADER)
+ {
+ insertBuiltIn(COMMON_BUILTINS, &BuiltInVariable::kVar_gl_Position);
+ insertBuiltIn(COMMON_BUILTINS, &BuiltInVariable::kVar_gl_PointSize);
+ insertBuiltIn(ESSL3_BUILTINS, &BuiltInVariable::kVar_gl_InstanceID);
+ insertBuiltIn(ESSL3_BUILTINS, &BuiltInVariable::kVar_gl_VertexID);
+ insertBuiltIn(GLSL_BUILTINS, &BuiltInVariable::kVar_gl_ViewportIndex);
+ insertBuiltIn(GLSL_BUILTINS, &BuiltInVariable::kVar_gl_LayerVS);
+ }
+ if (shaderType == GL_COMPUTE_SHADER)
+ {
+ insertBuiltIn(ESSL3_1_BUILTINS, &BuiltInVariable::kVar_gl_NumWorkGroups);
+ insertBuiltIn(ESSL3_1_BUILTINS, &BuiltInVariable::kVar_gl_WorkGroupSize);
+ insertBuiltIn(ESSL3_1_BUILTINS, &BuiltInVariable::kVar_gl_WorkGroupID);
+ insertBuiltIn(ESSL3_1_BUILTINS, &BuiltInVariable::kVar_gl_LocalInvocationID);
+ insertBuiltIn(ESSL3_1_BUILTINS, &BuiltInVariable::kVar_gl_GlobalInvocationID);
+ insertBuiltIn(ESSL3_1_BUILTINS, &BuiltInVariable::kVar_gl_LocalInvocationIndex);
+ }
+ if (shaderType == GL_GEOMETRY_SHADER_EXT)
+ {
+ insertBuiltIn(ESSL3_1_BUILTINS, &BuiltInVariable::kVar_gl_PrimitiveIDIn);
+ insertBuiltIn(ESSL3_1_BUILTINS, &BuiltInVariable::kVar_gl_InvocationID);
+ insertBuiltIn(ESSL3_1_BUILTINS, &BuiltInVariable::kVar_gl_PrimitiveIDGS);
+ insertBuiltIn(ESSL3_1_BUILTINS, &BuiltInVariable::kVar_gl_LayerGS);
+ TFieldList *fields_gl_PerVertex = new TFieldList();
+ fields_gl_PerVertex->push_back(new TField(new TType(EbtFloat, EbpHigh, EvqPosition, 4, 1),
+ BuiltInName::gl_Position, zeroSourceLoc));
+ TInterfaceBlock *gl_PerVertex =
+ new TInterfaceBlock(BuiltInId::gl_PerVertex, BuiltInName::gl_PerVertex,
+ TExtension::EXT_geometry_shader, fields_gl_PerVertex);
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_PerVertex);
+ TType *type_gl_in = new TType(gl_PerVertex, EvqPerVertexIn, TLayoutQualifier::Create());
+ type_gl_in->makeArray(0u);
+ type_gl_in->realize();
+ TVariable *gl_in = new TVariable(BuiltInId::gl_in, BuiltInName::gl_in, SymbolType::BuiltIn,
+ TExtension::EXT_geometry_shader, type_gl_in);
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_in);
+ TFieldList *fields_gl_PerVertexOutBlock = new TFieldList();
+ fields_gl_PerVertexOutBlock->push_back(
+ new TField(new TType(EbtFloat, EbpHigh, EvqPosition, 4, 1), BuiltInName::gl_Position,
+ zeroSourceLoc));
+ TInterfaceBlock *gl_PerVertexOutBlock =
+ new TInterfaceBlock(BuiltInId::gl_PerVertexOutBlock, BuiltInName::gl_PerVertex,
+ TExtension::EXT_geometry_shader, fields_gl_PerVertexOutBlock);
+ TType *type_gl_PositionGS = new TType(EbtFloat, EbpHigh, EvqPosition, 4);
+ type_gl_PositionGS->setInterfaceBlock(gl_PerVertexOutBlock);
+ type_gl_PositionGS->realize();
+ TVariable *gl_PositionGS =
+ new TVariable(BuiltInId::gl_PositionGS, BuiltInName::gl_Position, SymbolType::BuiltIn,
+ TExtension::EXT_geometry_shader, type_gl_PositionGS);
+ insertBuiltIn(ESSL3_1_BUILTINS, gl_PositionGS);
+ }
+ if (resources.OVR_multiview && shaderType != GL_COMPUTE_SHADER)
+ {
+ insertBuiltIn(ESSL3_BUILTINS, &BuiltInVariable::kVar_gl_ViewID_OVR);
+ insertBuiltIn(ESSL1_BUILTINS, &BuiltInVariable::kVar_gl_ViewID_OVRESSL1);
+ }
+}
+
void TSymbolTable::insertBuiltInFunctions(sh::GLenum shaderType)
{
insertBuiltIn(COMMON_BUILTINS, &BuiltInFunction::kFunction_radians_f_);
diff --git a/src/compiler/translator/Types.cpp b/src/compiler/translator/Types.cpp
index b4bb50d..e6ebc46 100644
--- a/src/compiler/translator/Types.cpp
+++ b/src/compiler/translator/Types.cpp
@@ -774,11 +774,6 @@
getMangledName();
}
-bool TType::isRealized() const
-{
- return mMangledName != nullptr;
-}
-
void TType::invalidateMangledName()
{
mMangledName = nullptr;
diff --git a/src/compiler/translator/Types.h b/src/compiler/translator/Types.h
index 47f96aa..91df74c 100644
--- a/src/compiler/translator/Types.h
+++ b/src/compiler/translator/Types.h
@@ -319,8 +319,6 @@
// Initializes all lazily-initialized members.
void realize();
- bool isRealized() const;
-
private:
void invalidateMangledName();
const char *buildMangledName() const;
diff --git a/src/compiler/translator/builtin_variables.json b/src/compiler/translator/builtin_variables.json
new file mode 100644
index 0000000..23fc381
--- /dev/null
+++ b/src/compiler/translator/builtin_variables.json
@@ -0,0 +1,855 @@
+{
+ "General":{
+ "comment":[
+ " Copyright 2018 The ANGLE Project Authors. All rights reserved.",
+ " Use of this source code is governed by a BSD-style license that can be",
+ " found in the LICENSE file.",
+ "",
+ " The schema of this JSON file is as follows:",
+ "",
+ " The top-level object contains variable groups. Each group can have the following",
+ " properties:",
+ " variables: Object mapping variable names to variable properties.",
+ " subgroups: Object with more groups that fall under the top-level group.",
+ " condition: C++ code determining when these variables should be found from",
+ " the symbol table.",
+ " Each variable can have the following properties:",
+ " level: Symbol table level where the variable is contained.",
+ " type: Object with properties of the type. Can be substituted with initDynamicType.",
+ " initDynamicType: Template string with C++ code for initializing a TType * with the",
+ " name {type_name}. The name will be replaced when generating code.",
+ " May refer to names of previously listed structs or interface",
+ " blocks.",
+ " extension: Optional. Name of the extension where this variable is from.",
+ " value: Optional. String that has one valid value: 'resources'. Denotes that the",
+ " value of the variable should be based on the field of ShBuiltInResources",
+ " with the same name as the variable.",
+ " class: Optional. To be used for interface block or struct definitions. Valid",
+ " values are 'TStructure' or 'TInterfaceBlock'.",
+ " fields: Optional. Object to be used for storing fields of interface block and",
+ " struct definitions. Maps field names to field types.",
+ " suffix: Optional. Suffix to give C++ variables storing the properties of this",
+ " variable a unique name that doesn't conflict with C++ keywords.",
+ " Each type can have the following properties:",
+ " basic: Basic type as in the TBasicType enum without the Ebt prefix.",
+ " precision: Precision as in TPrecision enum without the Ebp prefix.",
+ " qualifier: Optional. Qualifier as in the TQualifier enum without the Evq prefix.",
+ " primarySize: Optional. Vector size or matrix column count.",
+ " secondarySize: Optional. Matrix row count.",
+ " Any group, variable or type can have the property 'comment'."
+ ],
+ "variables":{
+ "gl_DepthRangeParameters":{
+ "class":"TStructure",
+ "level":"COMMON_BUILTINS",
+ "fields":{
+ "near":{
+ "basic":"Float",
+ "precision":"High"
+ },
+ "far":{
+ "basic":"Float",
+ "precision":"High"
+ },
+ "diff":{
+ "basic":"Float",
+ "precision":"High"
+ }
+ }
+ },
+ "gl_DepthRange":{
+ "level":"COMMON_BUILTINS",
+ "initDynamicType":"TType *{type_name} = new TType(gl_DepthRangeParameters); {type_name}->setQualifier(EvqUniform);"
+ }
+ }
+ },
+ "Constants":{
+ "variables":{
+ "gl_MaxVertexAttribs":{
+ "level":"COMMON_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxVertexUniformVectors":{
+ "level":"COMMON_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxVertexTextureImageUnits":{
+ "level":"COMMON_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxCombinedTextureImageUnits":{
+ "level":"COMMON_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxTextureImageUnits":{
+ "level":"COMMON_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxFragmentUniformVectors":{
+ "level":"COMMON_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxVaryingVectors":{
+ "level":"ESSL1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxDrawBuffers":{
+ "level":"COMMON_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxDualSourceDrawBuffersEXT":{
+ "level":"COMMON_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "extension":"EXT_blend_func_extended",
+ "value":"resources",
+ "valueKey":"MaxDualSourceDrawBuffers"
+ },
+ "gl_MaxVertexOutputVectors":{
+ "level":"ESSL3_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxFragmentInputVectors":{
+ "level":"ESSL3_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MinProgramTexelOffset":{
+ "level":"ESSL3_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxProgramTexelOffset":{
+ "level":"ESSL3_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxImageUnits":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxVertexImageUniforms":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxFragmentImageUniforms":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxComputeImageUniforms":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxCombinedImageUniforms":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxCombinedShaderOutputResources":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxComputeWorkGroupCount":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"High",
+ "qualifier":"Const",
+ "primarySize":3
+ },
+ "value":"resources"
+ },
+ "gl_MaxComputeWorkGroupSize":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"High",
+ "qualifier":"Const",
+ "primarySize":3
+ },
+ "value":"resources"
+ },
+ "gl_MaxComputeUniformComponents":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxComputeTextureImageUnits":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxComputeAtomicCounters":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxComputeAtomicCounterBuffers":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxVertexAtomicCounters":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxFragmentAtomicCounters":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxCombinedAtomicCounters":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxAtomicCounterBindings":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxVertexAtomicCounterBuffers":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxFragmentAtomicCounterBuffers":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxCombinedAtomicCounterBuffers":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ },
+ "gl_MaxAtomicCounterBufferSize":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "value":"resources"
+ }
+ },
+ "subgroups":{
+ "EXTGeometryShader":{
+ "variables":{
+ "gl_MaxGeometryInputComponents":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "extension":"EXT_geometry_shader",
+ "value":"resources"
+ },
+ "gl_MaxGeometryOutputComponents":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "extension":"EXT_geometry_shader",
+ "value":"resources"
+ },
+ "gl_MaxGeometryImageUniforms":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "extension":"EXT_geometry_shader",
+ "value":"resources"
+ },
+ "gl_MaxGeometryTextureImageUnits":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "extension":"EXT_geometry_shader",
+ "value":"resources"
+ },
+ "gl_MaxGeometryOutputVertices":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "extension":"EXT_geometry_shader",
+ "value":"resources"
+ },
+ "gl_MaxGeometryTotalOutputComponents":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "extension":"EXT_geometry_shader",
+ "value":"resources"
+ },
+ "gl_MaxGeometryUniformComponents":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "extension":"EXT_geometry_shader",
+ "value":"resources"
+ },
+ "gl_MaxGeometryAtomicCounters":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "extension":"EXT_geometry_shader",
+ "value":"resources"
+ },
+ "gl_MaxGeometryAtomicCounterBuffers":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"Medium",
+ "qualifier":"Const"
+ },
+ "extension":"EXT_geometry_shader",
+ "value":"resources"
+ }
+ }
+ }
+ }
+ },
+ "FragShader":{
+ "condition":"shaderType == GL_FRAGMENT_SHADER",
+ "variables":{
+ "gl_FragCoord":{
+ "level":"COMMON_BUILTINS",
+ "type":{
+ "basic":"Float",
+ "precision":"Medium",
+ "qualifier":"FragCoord",
+ "primarySize":4
+ }
+ },
+ "gl_FrontFacing":{
+ "level":"COMMON_BUILTINS",
+ "type":{
+ "basic":"Bool",
+ "qualifier":"FrontFacing"
+ }
+ },
+ "gl_PointCoord":{
+ "level":"COMMON_BUILTINS",
+ "type":{
+ "basic":"Float",
+ "precision":"Medium",
+ "qualifier":"PointCoord",
+ "primarySize":2
+ }
+ },
+ "gl_FragColor":{
+ "level":"ESSL1_BUILTINS",
+ "type":{
+ "basic":"Float",
+ "precision":"Medium",
+ "qualifier":"FragColor",
+ "primarySize":4
+ }
+ },
+ "gl_FragData":{
+ "level":"ESSL1_BUILTINS",
+ "initDynamicType":"TType *{type_name} = new TType(EbtFloat, EbpMedium, EvqFragData, 4); if (spec != SH_WEBGL2_SPEC && spec != SH_WEBGL3_SPEC) {{ {type_name}->makeArray(resources.MaxDrawBuffers); }} else {{ {type_name}->makeArray(1u); }}"
+ },
+ "gl_FragDepth":{
+ "level":"ESSL3_BUILTINS",
+ "type":{
+ "basic":"Float",
+ "precision":"High",
+ "qualifier":"FragDepth"
+ }
+ }
+ },
+ "subgroups":{
+ "EXTBlendFuncExtended":{
+ "condition":"resources.EXT_blend_func_extended",
+ "variables":{
+ "gl_SecondaryFragColorEXT":{
+ "level":"ESSL1_BUILTINS",
+ "extension":"EXT_blend_func_extended",
+ "type":{
+ "basic":"Float",
+ "precision":"Medium",
+ "qualifier":"SecondaryFragColorEXT",
+ "primarySize":4
+ }
+ },
+ "gl_SecondaryFragDataEXT":{
+ "level":"ESSL1_BUILTINS",
+ "extension":"EXT_blend_func_extended",
+ "initDynamicType":"TType *{type_name} = new TType(EbtFloat, EbpMedium, EvqSecondaryFragDataEXT, 4, 1); {type_name}->makeArray(resources.MaxDualSourceDrawBuffers);"
+ }
+ }
+ },
+ "EXTFragDepth":{
+ "condition":"resources.EXT_frag_depth",
+ "variables":{
+ "gl_FragDepthEXT":{
+ "level":"ESSL1_BUILTINS",
+ "extension":"EXT_frag_depth",
+ "initDynamicType":"TType *{type_name} = new TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepthEXT, 1);"
+ }
+ }
+ },
+ "EXTShaderFramebufferFetch":{
+ "condition":"resources.EXT_shader_framebuffer_fetch",
+ "variables":{
+ "gl_LastFragData":{
+ "level":"ESSL1_BUILTINS",
+ "extension":"EXT_shader_framebuffer_fetch",
+ "initDynamicType":"TType *{type_name} = new TType(EbtFloat, EbpMedium, EvqLastFragData, 4, 1); {type_name}->makeArray(resources.MaxDrawBuffers);"
+ }
+ }
+ },
+ "NVShaderFramebufferFetch":{
+ "condition":"resources.NV_shader_framebuffer_fetch",
+ "variables":{
+ "gl_LastFragColor":{
+ "level":"ESSL1_BUILTINS",
+ "extension":"NV_shader_framebuffer_fetch",
+ "type":{
+ "basic":"Float",
+ "precision":"Medium",
+ "qualifier":"LastFragColor",
+ "primarySize":4
+ }
+ },
+ "gl_LastFragData":{
+ "level":"ESSL1_BUILTINS",
+ "suffix":"NV",
+ "extension":"NV_shader_framebuffer_fetch",
+ "initDynamicType":"TType *{type_name} = new TType(EbtFloat, EbpMedium, EvqLastFragData, 4, 1); {type_name}->makeArray(resources.MaxDrawBuffers);"
+ }
+ }
+ },
+ "ARMShaderFramebufferFetch":{
+ "condition":"!resources.EXT_shader_framebuffer_fetch && !resources.NV_shader_framebuffer_fetch && resources.ARM_shader_framebuffer_fetch",
+ "variables":{
+ "gl_LastFragColorARM":{
+ "level":"ESSL1_BUILTINS",
+ "extension":"ARM_shader_framebuffer_fetch",
+ "type":{
+ "basic":"Float",
+ "precision":"Medium",
+ "qualifier":"LastFragColor",
+ "primarySize":4
+ }
+ }
+ }
+ },
+ "GeometryShaderSupported":{
+ "condition":"resources.EXT_geometry_shader",
+ "variables":{
+ "gl_PrimitiveID":{
+ "level":"ESSL3_1_BUILTINS",
+ "extension":"EXT_geometry_shader",
+ "type":{
+ "basic":"Int",
+ "precision":"High",
+ "qualifier":"PrimitiveID"
+ }
+ },
+ "gl_Layer":{
+ "level":"ESSL3_1_BUILTINS",
+ "extension":"EXT_geometry_shader",
+ "type":{
+ "basic":"Int",
+ "precision":"High",
+ "qualifier":"Layer"
+ }
+ }
+ }
+ }
+ }
+ },
+ "VertexShader":{
+ "condition":"shaderType == GL_VERTEX_SHADER",
+ "variables":{
+ "gl_Position":{
+ "level":"COMMON_BUILTINS",
+ "type":{
+ "basic":"Float",
+ "precision":"High",
+ "qualifier":"Position",
+ "primarySize":4
+ }
+ },
+ "gl_PointSize":{
+ "level":"COMMON_BUILTINS",
+ "type":{
+ "basic":"Float",
+ "precision":"Medium",
+ "qualifier":"PointSize"
+ }
+ },
+ "gl_InstanceID":{
+ "level":"ESSL3_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"High",
+ "qualifier":"InstanceID"
+ }
+ },
+ "gl_VertexID":{
+ "level":"ESSL3_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"High",
+ "qualifier":"VertexID"
+ }
+ },
+ "gl_ViewportIndex":{
+ "comment":"For internal use by ANGLE - not exposed to the parser.",
+ "level":"GLSL_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"High",
+ "qualifier":"ViewportIndex"
+ }
+ },
+ "gl_Layer":{
+ "suffix":"VS",
+ "comment":"gl_Layer exists in other shader stages in ESSL, but not in vertex shader so far.",
+ "level":"GLSL_BUILTINS",
+ "type":{
+ "basic":"Int",
+ "precision":"High",
+ "qualifier":"Layer"
+ }
+ }
+ }
+ },
+ "ComputeShader":{
+ "condition":"shaderType == GL_COMPUTE_SHADER",
+ "variables":{
+ "gl_NumWorkGroups":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"UInt",
+ "precision":"Undefined",
+ "qualifier":"NumWorkGroups",
+ "primarySize":3
+ }
+ },
+ "gl_WorkGroupSize":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"UInt",
+ "precision":"Undefined",
+ "qualifier":"WorkGroupSize",
+ "primarySize":3
+ }
+ },
+ "gl_WorkGroupID":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"UInt",
+ "precision":"Undefined",
+ "qualifier":"WorkGroupID",
+ "primarySize":3
+ }
+ },
+ "gl_LocalInvocationID":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"UInt",
+ "precision":"Undefined",
+ "qualifier":"LocalInvocationID",
+ "primarySize":3
+ }
+ },
+ "gl_GlobalInvocationID":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"UInt",
+ "precision":"Undefined",
+ "qualifier":"GlobalInvocationID",
+ "primarySize":3
+ }
+ },
+ "gl_LocalInvocationIndex":{
+ "level":"ESSL3_1_BUILTINS",
+ "type":{
+ "basic":"UInt",
+ "precision":"Undefined",
+ "qualifier":"LocalInvocationIndex"
+ }
+ }
+ }
+ },
+ "GeometryShader":{
+ "condition":"shaderType == GL_GEOMETRY_SHADER_EXT",
+ "variables":{
+ "gl_PrimitiveIDIn":{
+ "level":"ESSL3_1_BUILTINS",
+ "extension":"EXT_geometry_shader",
+ "type":{
+ "basic":"Int",
+ "precision":"High",
+ "qualifier":"PrimitiveIDIn"
+ }
+ },
+ "gl_InvocationID":{
+ "level":"ESSL3_1_BUILTINS",
+ "extension":"EXT_geometry_shader",
+ "type":{
+ "basic":"Int",
+ "precision":"High",
+ "qualifier":"InvocationID"
+ }
+ },
+ "gl_PrimitiveID":{
+ "suffix":"GS",
+ "level":"ESSL3_1_BUILTINS",
+ "extension":"EXT_geometry_shader",
+ "type":{
+ "basic":"Int",
+ "precision":"High",
+ "qualifier":"PrimitiveID"
+ }
+ },
+ "gl_Layer":{
+ "suffix":"GS",
+ "level":"ESSL3_1_BUILTINS",
+ "extension":"EXT_geometry_shader",
+ "type":{
+ "basic":"Int",
+ "precision":"High",
+ "qualifier":"Layer"
+ }
+ },
+ "gl_PerVertex":{
+ "level":"ESSL3_1_BUILTINS",
+ "extension":"EXT_geometry_shader",
+ "class":"TInterfaceBlock",
+ "fields":{
+ "gl_Position":{
+ "basic":"Float",
+ "precision":"High",
+ "qualifier":"Position",
+ "primarySize":4
+ }
+ }
+ },
+ "gl_in":{
+ "level":"ESSL3_1_BUILTINS",
+ "extension":"EXT_geometry_shader",
+ "initDynamicType":"TType *{type_name} = new TType(gl_PerVertex, EvqPerVertexIn, TLayoutQualifier::Create()); {type_name}->makeArray(0u);",
+ "comment":"The array size of gl_in is undefined until we get a valid input primitive declaration."
+ }
+ },
+ "subgroups":{
+ "Out":{
+ "variables":{
+ "gl_PerVertex":{
+ "suffix":"OutBlock",
+ "level":"ESSL3_1_BUILTINS",
+ "extension":"EXT_geometry_shader",
+ "private":true,
+ "class":"TInterfaceBlock",
+ "fields":{
+ "gl_Position":{
+ "basic":"Float",
+ "precision":"High",
+ "qualifier":"Position",
+ "primarySize":4
+ }
+ }
+ },
+ "gl_Position":{
+ "suffix":"GS",
+ "level":"ESSL3_1_BUILTINS",
+ "extension":"EXT_geometry_shader",
+ "initDynamicType":"TType *{type_name} = new TType(EbtFloat, EbpHigh, EvqPosition, 4); {type_name}->setInterfaceBlock(gl_PerVertexOutBlock);"
+ }
+ }
+ }
+ }
+ },
+ "Multiview":{
+ "condition":"resources.OVR_multiview && shaderType != GL_COMPUTE_SHADER",
+ "subgroups":{
+ "ESSL3":{
+ "variables":{
+ "gl_ViewID_OVR":{
+ "level":"ESSL3_BUILTINS",
+ "extension":"OVR_multiview",
+ "type":{
+ "basic":"UInt",
+ "precision":"High",
+ "qualifier":"ViewIDOVR"
+ }
+ }
+ }
+ },
+ "ESSL1":{
+ "variables":{
+ "gl_ViewID_OVR":{
+ "suffix":"ESSL1",
+ "level":"ESSL1_BUILTINS",
+ "extension":"OVR_multiview",
+ "type":{
+ "basic":"Int",
+ "precision":"High",
+ "qualifier":"ViewIDOVR"
+ }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/compiler/translator/gen_builtin_symbols.py b/src/compiler/translator/gen_builtin_symbols.py
index 0ae6e1b..1dc9a10 100644
--- a/src/compiler/translator/gen_builtin_symbols.py
+++ b/src/compiler/translator/gen_builtin_symbols.py
@@ -47,9 +47,43 @@
}} // namespace sh
"""
+# The header file has a "get" function for each variable. They are used in traversers.
+# Note that we don't currently include get_function_declarations, as they are unused.
+template_builtin_header = """// GENERATED FILE - DO NOT EDIT.
+// Generated by {script_name} using data from {variable_data_source_name} and
+// {function_data_source_name}.
+//
+// Copyright {copyright_year} The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// BuiltIn_autogen.h:
+// Compile-time initialized built-ins.
+
+#ifndef COMPILER_TRANSLATOR_BUILTIN_AUTOGEN_H_
+#define COMPILER_TRANSLATOR_BUILTIN_AUTOGEN_H_
+
+namespace sh
+{{
+
+class TVariable;
+
+namespace BuiltInVariable
+{{
+
+{get_variable_declarations}
+
+}} // namespace BuiltInVariable
+
+}} // namespace sh
+
+#endif // COMPILER_TRANSLATOR_BUILTIN_AUTOGEN_H_
+"""
+
# By having the variables defined in a cpp file we ensure that there's just one instance of each of the declared variables.
template_symboltable_cpp = """// GENERATED FILE - DO NOT EDIT.
-// Generated by {script_name} using data from {function_data_source_name}.
+// Generated by {script_name} using data from {variable_data_source_name} and
+// {function_data_source_name}.
//
// Copyright {copyright_year} The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
@@ -70,17 +104,19 @@
namespace sh
{{
-// This is a class instead of a namespace so that we can restrict access to TSymbolUniqueId
-// constructor taking an integer to here.
class BuiltInId
{{
- public:
+public:
{builtin_id_declarations}
-}};
+}}; // namespace BuiltInId
-const int TSymbolTable::kLastStaticBuiltInId = {last_static_builtin_id};
+// Since some of the BuiltInId declarations are used outside of constexpr expressions, we need to
+// have these definitions without an initializer. C++17 should eventually remove the need for this.
+{builtin_id_definitions}
+
+const int TSymbolTable::kLastBuiltInId = {last_builtin_id};
namespace BuiltInName
{{
@@ -104,6 +140,18 @@
}} // namespace UnmangledBuiltIns
// TODO(oetuaho): Would be nice to make this a class instead of a namespace so that we could friend
+// this from TVariable. Now symbol constructors taking an id have to be public even though they're
+// not supposed to be accessible from outside of here. http://anglebug.com/2390
+namespace BuiltInVariable
+{{
+
+{variable_declarations}
+
+{get_variable_definitions}
+
+}}; // namespace BuiltInVariable
+
+// TODO(oetuaho): Would be nice to make this a class instead of a namespace so that we could friend
// this from TFunction. Now symbol constructors taking an id have to be public even though they're
// not supposed to be accessible from outside of here. http://anglebug.com/2390
namespace BuiltInFunction
@@ -113,6 +161,14 @@
}} // namespace BuiltInFunction
+void TSymbolTable::insertBuiltInVariables(sh::GLenum shaderType,
+ ShShaderSpec spec,
+ const ShBuiltInResources &resources)
+{{
+ const TSourceLoc zeroSourceLoc = {{0, 0, 0, 0}};
+{insert_variables}
+}}
+
void TSymbolTable::insertBuiltInFunctions(sh::GLenum shaderType)
{{
{insert_functions}
@@ -127,6 +183,9 @@
}} // namespace sh
"""
+parsed_variables = None
+
+variables_json_filename = 'builtin_variables.json'
functions_txt_filename = 'builtin_function_declarations.txt'
basic_mangled_names = {
@@ -230,6 +289,10 @@
template_type = 'StaticType::Get<Ebt{basic}, Ebp{precision}, Evq{qualifier}, {primarySize}, {secondarySize}>()'
return template_type.format(**self.data)
+ def get_dynamic_type_string(self):
+ template_type = 'new TType(Ebt{basic}, Ebp{precision}, Evq{qualifier}, {primarySize}, {secondarySize})'
+ return template_type.format(**self.data)
+
def get_mangled_name(self, separator = ';'):
mangled_name = ''
@@ -250,6 +313,9 @@
def is_matrix(self):
return self.data['secondarySize'] > 1
+ def get_object_size(self):
+ return self.data['primarySize'] * self.data['secondarySize']
+
def specific_sampler_or_image_type(self, basic_type_prefix):
if 'genType' in self.data:
type = {}
@@ -428,18 +494,34 @@
raise "Cannot serialize to JSON: " + str(obj)
json.dump(parsed_functions, outfile, indent=4, separators=(',', ': '), default=serialize_obj)
+with open(variables_json_filename) as f:
+ parsed_variables = json.load(f, object_pairs_hook=OrderedDict)
+
# Declarations of symbol unique ids
builtin_id_declarations = []
+# Definitions of symbol unique ids needed for those ids used outside of constexpr expressions.
+builtin_id_definitions = []
+
# Declarations of name string variables
name_declarations = set()
+# Declarations of builtin TVariables
+variable_declarations = []
+
# Declarations of parameter arrays for builtin TFunctions
parameter_declarations = set()
# Declarations of builtin TFunctions
function_declarations = []
+# Functions for querying the pointer to a specific TVariable.
+get_variable_declarations = []
+get_variable_definitions = []
+
+# Code for inserting builtin TVariables to the symbol table.
+insert_variables = []
+
# Code for inserting builtin TFunctions to the symbol table. Grouped by condition.
insert_functions_by_condition = OrderedDict()
@@ -666,17 +748,149 @@
for group_name, group in parsed_functions.iteritems():
process_function_group(group_name, group)
+def process_single_variable_group(group_name, group):
+ global id_counter
+ if 'variables' not in group:
+ return
+ for variable_name, props in group['variables'].iteritems():
+ template_args = {
+ 'id': id_counter,
+ 'name': variable_name,
+ 'name_with_suffix': variable_name + get_suffix(props),
+ 'level': props['level'],
+ 'extension': get_extension(props)
+ }
+
+ template_builtin_id_declaration = ' static constexpr const TSymbolUniqueId {name_with_suffix} = TSymbolUniqueId({id});'
+ builtin_id_declarations.append(template_builtin_id_declaration.format(**template_args))
+ template_builtin_id_definition = 'constexpr const TSymbolUniqueId BuiltInId::{name_with_suffix};'
+ builtin_id_definitions.append(template_builtin_id_definition.format(**template_args))
+
+ template_name_declaration = 'constexpr const ImmutableString {name}("{name}");'
+ name_declarations.add(template_name_declaration.format(**template_args))
+
+ if 'type' in props:
+ if props['type']['basic'] != 'Bool' and 'precision' not in props['type']:
+ raise Exception('Missing precision for variable ' + variable_name)
+ template_args['type'] = TType(props['type']).get_statictype_string()
+
+ if 'fields' in props:
+ # Handle struct and interface block definitions.
+ template_args['class'] = props['class']
+ template_args['fields'] = 'fields_{name_with_suffix}'.format(**template_args)
+ insert_variables.append('TFieldList *{fields} = new TFieldList();'.format(**template_args))
+ for field_name, field_type in props['fields'].iteritems():
+ template_args['field_name'] = field_name
+ template_args['field_type'] = TType(field_type).get_dynamic_type_string()
+ template_name_declaration = 'constexpr const ImmutableString {field_name}("{field_name}");'
+ name_declarations.add(template_name_declaration.format(**template_args))
+ template_add_field = '{fields}->push_back(new TField({field_type}, BuiltInName::{field_name}, zeroSourceLoc));'
+ insert_variables.append(template_add_field.format(**template_args))
+ template_init_variable = ' {class} *{name_with_suffix} = new {class}(BuiltInId::{name_with_suffix}, BuiltInName::{name}, TExtension::{extension}, {fields});'
+ insert_variables.append(template_init_variable.format(**template_args))
+ template_insert_variable = ' insertBuiltIn({level}, {name_with_suffix});'
+ if 'private' not in props or not props['private']:
+ insert_variables.append(template_insert_variable.format(**template_args))
+
+ elif 'initDynamicType' in props:
+ # Handle variables whose type can't be expressed as TStaticType
+ # (type is a struct or has variable array size for example).
+ template_args['type_name'] = 'type_{name_with_suffix}'.format(**template_args)
+ template_args['type'] = template_args['type_name']
+ template_args['initDynamicType'] = props['initDynamicType'].format(**template_args)
+ template_insert_variable = """ {initDynamicType}
+ {type_name}->realize();
+ TVariable *{name_with_suffix} = new TVariable(BuiltInId::{name_with_suffix}, BuiltInName::{name}, SymbolType::BuiltIn, TExtension::{extension}, {type});
+ insertBuiltIn({level}, {name_with_suffix});"""
+ insert_variables.append(template_insert_variable.format(**template_args))
+
+ elif 'value' in props:
+ # Handle variables with constant value, such as gl_MaxDrawBuffers.
+ if props['value'] != 'resources':
+ raise Exception('Unrecognized value source in variable properties: ' + str(props['value']))
+ resources_key = variable_name[3:]
+ if 'valueKey' in props:
+ resources_key = props['valueKey']
+ template_args['value'] = 'resources.' + resources_key
+ template_args['object_size'] = TType(props['type']).get_object_size()
+ template_insert_variable = """ TVariable *{name_with_suffix} = new TVariable(BuiltInId::{name_with_suffix}, BuiltInName::{name}, SymbolType::BuiltIn, TExtension::{extension}, {type});
+ {{
+ TConstantUnion *unionArray = new TConstantUnion[{object_size}];
+ unionArray[0].setIConst({value});
+ {name_with_suffix}->shareConstPointer(unionArray);
+ }}
+ insertBuiltIn({level}, {name_with_suffix});"""
+ if template_args['object_size'] > 1:
+ template_insert_variable = """ TVariable *{name_with_suffix} = new TVariable(BuiltInId::{name_with_suffix}, BuiltInName::{name}, SymbolType::BuiltIn, TExtension::{extension}, {type});
+ {{
+ TConstantUnion *unionArray = new TConstantUnion[{object_size}];
+ for (size_t index = 0u; index < {object_size}; ++index)
+ {{
+ unionArray[index].setIConst({value}[index]);
+ }}
+ {name_with_suffix}->shareConstPointer(unionArray);
+ }}
+ insertBuiltIn({level}, {name_with_suffix});"""
+
+ insert_variables.append(template_insert_variable.format(**template_args))
+
+ else:
+ # Handle variables that can be stored as constexpr TVariable like
+ # gl_Position, gl_FragColor etc.
+ template_variable_declaration = 'constexpr const TVariable kVar_{name_with_suffix}(BuiltInId::{name_with_suffix}, BuiltInName::{name}, SymbolType::BuiltIn, TExtension::{extension}, {type});'
+ variable_declarations.append(template_variable_declaration.format(**template_args))
+
+ template_get_variable_declaration = 'const TVariable *{name_with_suffix}();'
+ get_variable_declarations.append(template_get_variable_declaration.format(**template_args))
+
+ template_get_variable_definition = """const TVariable *{name_with_suffix}()
+{{
+ return &kVar_{name_with_suffix};
+}}
+"""
+ get_variable_definitions.append(template_get_variable_definition.format(**template_args))
+
+ template_insert_variable = ' insertBuiltIn({level}, &BuiltInVariable::kVar_{name_with_suffix});'
+ insert_variables.append(template_insert_variable.format(**template_args))
+
+ id_counter += 1
+
+def process_variable_group(group_name, group):
+ if 'condition' in group:
+ insert_variables.append(' if ({condition})'.format(condition = group['condition']))
+ insert_variables.append(' {')
+
+ process_single_variable_group(group_name, group)
+
+ if 'subgroups' in group:
+ for subgroup_name, subgroup in group['subgroups'].iteritems():
+ process_variable_group(subgroup_name, subgroup)
+
+ if 'condition' in group:
+ insert_variables.append(' }')
+
+for group_name, group in parsed_variables.iteritems():
+ process_variable_group(group_name, group)
+
+
output_strings = {
'script_name': os.path.basename(__file__),
'copyright_year': date.today().year,
'builtin_id_declarations': '\n'.join(builtin_id_declarations),
- 'last_static_builtin_id': id_counter - 1,
+ 'builtin_id_definitions': '\n'.join(builtin_id_definitions),
+ 'last_builtin_id': id_counter - 1,
'name_declarations': '\n'.join(sorted(list(name_declarations))),
'function_data_source_name': functions_txt_filename,
'function_declarations': '\n'.join(function_declarations),
- 'parameter_declarations': '\n'.join(sorted(parameter_declarations))
+ 'parameter_declarations': '\n'.join(sorted(parameter_declarations)),
+
+ 'variable_data_source_name': variables_json_filename,
+ 'variable_declarations': '\n'.join(sorted(variable_declarations)),
+ 'get_variable_declarations': '\n'.join(sorted(get_variable_declarations)),
+ 'get_variable_definitions': '\n'.join(sorted(get_variable_definitions)),
+ 'insert_variables': '\n'.join(insert_variables)
}
insert_functions = []
@@ -745,6 +959,10 @@
output_cpp = template_immutablestringtest_cpp.format(**output_strings)
outfile_cpp.write(output_cpp)
+with open('BuiltIn_autogen.h', 'wt') as outfile_header:
+ output_header = template_builtin_header.format(**output_strings)
+ outfile_header.write(output_header)
+
with open('SymbolTable_autogen.cpp', 'wt') as outfile_cpp:
output_cpp = template_symboltable_cpp.format(**output_strings)
outfile_cpp.write(output_cpp)