Clean up storing interface blocks in the symbol table
Merge TInterfaceBlock with TInterfaceBlockName, so that there are no
duplicate data structures for interface blocks. This is similar to the
refactoring that was already done to structs.
BUG=angleproject:2267
TEST=angle_unittests
Change-Id: I67d2af6ccbe5344bddf9c99030d118fe532fbbd8
Reviewed-on: https://chromium-review.googlesource.com/805819
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/Initialize.cpp b/src/compiler/translator/Initialize.cpp
index 8d65a6f..6f6ee43 100644
--- a/src/compiler/translator/Initialize.cpp
+++ b/src/compiler/translator/Initialize.cpp
@@ -1015,29 +1015,31 @@
// Add built-in interface block gl_PerVertex and the built-in array gl_in.
// TODO(jiawei.shao@intel.com): implement GL_OES_geometry_point_size.
- const TString *glPerVertexString = NewPoolTString("gl_PerVertex");
- symbolTable.insertInterfaceBlockNameExt(ESSL3_1_BUILTINS, extension, glPerVertexString);
-
- TFieldList *fieldList = new TFieldList();
+ TFieldList *glPerVertexFieldList = new TFieldList();
TSourceLoc zeroSourceLoc = {0, 0, 0, 0};
TField *glPositionField = new TField(new TType(EbtFloat, EbpHigh, EvqPosition, 4),
NewPoolTString("gl_Position"), zeroSourceLoc);
- fieldList->push_back(glPositionField);
+ glPerVertexFieldList->push_back(glPositionField);
- TInterfaceBlock *glInBlock =
- new TInterfaceBlock(glPerVertexString, fieldList, TLayoutQualifier::Create());
+ const TString *glPerVertexString = NewPoolTString("gl_PerVertex");
+ TInterfaceBlock *glPerVertexInBlock = new TInterfaceBlock(
+ &symbolTable, glPerVertexString, glPerVertexFieldList, TLayoutQualifier::Create());
+ glPerVertexInBlock->relateToExtension(extension);
+ symbolTable.insertInterfaceBlock(ESSL3_1_BUILTINS, glPerVertexInBlock);
// The array size of gl_in is undefined until we get a valid input primitive
// declaration.
- TType glInType(glInBlock, EvqPerVertexIn, TLayoutQualifier::Create());
+ TType glInType(glPerVertexInBlock, EvqPerVertexIn, TLayoutQualifier::Create());
glInType.makeArray(0u);
symbolTable.insertVariableExt(ESSL3_1_BUILTINS, extension, "gl_in", glInType);
+ TInterfaceBlock *glPerVertexOutBlock = new TInterfaceBlock(
+ &symbolTable, glPerVertexString, glPerVertexFieldList, TLayoutQualifier::Create());
TType glPositionType(EbtFloat, EbpHigh, EvqPosition, 4);
- glPositionType.setInterfaceBlock(
- new TInterfaceBlock(glPerVertexString, fieldList, TLayoutQualifier::Create()));
+ glPositionType.setInterfaceBlock(glPerVertexOutBlock);
symbolTable.insertVariableExt(ESSL3_1_BUILTINS, extension, "gl_Position",
glPositionType);
+
symbolTable.insertVariableExt(ESSL3_1_BUILTINS, extension, "gl_PrimitiveIDIn",
TType(EbtInt, EbpHigh, EvqPrimitiveIDIn, 1));
symbolTable.insertVariableExt(ESSL3_1_BUILTINS, extension, "gl_InvocationID",