Skip to content

Commit

Permalink
Use a static variable for generating symbol IDs
Browse files Browse the repository at this point in the history
This is a hacky fix to work around a problem where glslang reuses
symbol IDs across compilation units.

Fixes: KhronosGroup#1285
  • Loading branch information
bpeel authored and infapi00 committed Sep 18, 2018
1 parent d122a72 commit 0fe10b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion glslang/MachineIndependent/SymbolTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,13 @@ void TSymbolTable::copyTable(const TSymbolTable& copyOf)
{
assert(adoptedLevels == copyOf.adoptedLevels);

uniqueId = copyOf.uniqueId;
//uniqueId = copyOf.uniqueId;
noBuiltInRedeclarations = copyOf.noBuiltInRedeclarations;
separateNameSpaces = copyOf.separateNameSpaces;
for (unsigned int i = copyOf.adoptedLevels; i < copyOf.table.size(); ++i)
table.push_back(copyOf.table[i]->clone());
}

int TSymbolTable::uniqueId = 0;

} // end namespace glslang
6 changes: 3 additions & 3 deletions glslang/MachineIndependent/SymbolTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ class TSymbolTableLevel {

class TSymbolTable {
public:
TSymbolTable() : uniqueId(0), noBuiltInRedeclarations(false), separateNameSpaces(false), adoptedLevels(0)
TSymbolTable() : noBuiltInRedeclarations(false), separateNameSpaces(false), adoptedLevels(0)
{
//
// This symbol table cannot be used until push() is called.
Expand All @@ -559,7 +559,7 @@ class TSymbolTable {
table.push_back(symTable.table[level]);
++adoptedLevels;
}
uniqueId = symTable.uniqueId;
//uniqueId = symTable.uniqueId;
noBuiltInRedeclarations = symTable.noBuiltInRedeclarations;
separateNameSpaces = symTable.separateNameSpaces;
}
Expand Down Expand Up @@ -814,7 +814,7 @@ class TSymbolTable {
int currentLevel() const { return static_cast<int>(table.size()) - 1; }

std::vector<TSymbolTableLevel*> table;
int uniqueId; // for unique identification in code generation
static int uniqueId; // for unique identification in code generation
bool noBuiltInRedeclarations;
bool separateNameSpaces;
unsigned int adoptedLevels;
Expand Down

0 comments on commit 0fe10b1

Please sign in to comment.