From 0fe10b11c82241e66466e66181ce41aec12ec626 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Tue, 13 Mar 2018 00:16:00 +0100 Subject: [PATCH] Use a static variable for generating symbol IDs This is a hacky fix to work around a problem where glslang reuses symbol IDs across compilation units. Fixes: https://github.com/KhronosGroup/glslang/issues/1285 --- glslang/MachineIndependent/SymbolTable.cpp | 4 +++- glslang/MachineIndependent/SymbolTable.h | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/glslang/MachineIndependent/SymbolTable.cpp b/glslang/MachineIndependent/SymbolTable.cpp index db46e1075d..fd65d4a8c4 100644 --- a/glslang/MachineIndependent/SymbolTable.cpp +++ b/glslang/MachineIndependent/SymbolTable.cpp @@ -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 diff --git a/glslang/MachineIndependent/SymbolTable.h b/glslang/MachineIndependent/SymbolTable.h index f928b7aedf..3ed807db2a 100644 --- a/glslang/MachineIndependent/SymbolTable.h +++ b/glslang/MachineIndependent/SymbolTable.h @@ -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. @@ -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; } @@ -814,7 +814,7 @@ class TSymbolTable { int currentLevel() const { return static_cast(table.size()) - 1; } std::vector 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;