Fix issue for new unique id system. Add level bits to help verifying symbols and split symbol tables.
For intermediates rebuilding, now need manually amending level bits for redeclaring built-ins.
This commit is contained in:
parent
74e8f05b9f
commit
93b400f267
17 changed files with 110 additions and 71 deletions
|
|
@ -104,8 +104,8 @@ public:
|
|||
virtual const TAnonMember* getAsAnonMember() const { return 0; }
|
||||
virtual const TType& getType() const = 0;
|
||||
virtual TType& getWritableType() = 0;
|
||||
virtual void setUniqueId(int id) { uniqueId = id; }
|
||||
virtual int getUniqueId() const { return uniqueId; }
|
||||
virtual void setUniqueId(long long id) { uniqueId = id; }
|
||||
virtual long long getUniqueId() const { return uniqueId; }
|
||||
virtual void setExtensions(int numExts, const char* const exts[])
|
||||
{
|
||||
assert(extensions == 0);
|
||||
|
|
@ -130,7 +130,7 @@ protected:
|
|||
TSymbol& operator=(const TSymbol&);
|
||||
|
||||
const TString *name;
|
||||
unsigned int uniqueId; // For cross-scope comparing during code generation
|
||||
unsigned long long uniqueId; // For cross-scope comparing during code generation
|
||||
|
||||
// For tracking what extensions must be present
|
||||
// (don't use if correct version/profile is present).
|
||||
|
|
@ -612,6 +612,7 @@ public:
|
|||
// 3: user-shader globals
|
||||
//
|
||||
protected:
|
||||
static const uint32_t LevelFlagBitOffset = 56;
|
||||
static const int globalLevel = 3;
|
||||
static bool isSharedLevel(int level) { return level <= 1; } // exclude all per-compile levels
|
||||
static bool isBuiltInLevel(int level) { return level <= 2; } // exclude user globals
|
||||
|
|
@ -620,10 +621,12 @@ public:
|
|||
bool isEmpty() { return table.size() == 0; }
|
||||
bool atBuiltInLevel() { return isBuiltInLevel(currentLevel()); }
|
||||
bool atGlobalLevel() { return isGlobalLevel(currentLevel()); }
|
||||
static bool isBuiltInSymbol(int uniqueId) {
|
||||
int level = uniqueId >> LevelFlagBitOffset;
|
||||
static bool isBuiltInSymbol(long long uniqueId) {
|
||||
int level = static_cast<int>(uniqueId >> LevelFlagBitOffset);
|
||||
return isBuiltInLevel(level);
|
||||
}
|
||||
static constexpr uint64_t uniqueIdMask = (1LL << LevelFlagBitOffset) - 1;
|
||||
static const uint32_t MaxLevelInUniqueID = 127;
|
||||
void setNoBuiltInRedeclarations() { noBuiltInRedeclarations = true; }
|
||||
void setSeparateNameSpaces() { separateNameSpaces = true; }
|
||||
|
||||
|
|
@ -691,6 +694,16 @@ public:
|
|||
return table[currentLevel()]->amend(symbol, firstNewMember);
|
||||
}
|
||||
|
||||
// Update the level info in symbol's unique ID to current level
|
||||
void amendSymbolIdLevel(TSymbol& symbol)
|
||||
{
|
||||
// clamp level to avoid overflow
|
||||
uint64_t level = currentLevel() > MaxLevelInUniqueID ? MaxLevelInUniqueID : currentLevel();
|
||||
uint64_t symbolId = symbol.getUniqueId();
|
||||
symbolId &= uniqueIdMask;
|
||||
symbolId |= (level << LevelFlagBitOffset);
|
||||
symbol.setUniqueId(symbolId);
|
||||
}
|
||||
//
|
||||
// To allocate an internal temporary, which will need to be uniquely
|
||||
// identified by the consumer of the AST, but never need to
|
||||
|
|
@ -859,7 +872,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
int getMaxSymbolId() { return uniqueId; }
|
||||
long long getMaxSymbolId() { return uniqueId; }
|
||||
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
|
||||
void dump(TInfoSink& infoSink, bool complete = false) const;
|
||||
#endif
|
||||
|
|
@ -876,19 +889,24 @@ public:
|
|||
// Add current level in the high-bits of unique id
|
||||
void updateUniqueIdLevelFlag() {
|
||||
// clamp level to avoid overflow
|
||||
uint32_t level = currentLevel() > 7 ? 7 : currentLevel();
|
||||
uniqueId &= ((1 << LevelFlagBitOffset) - 1);
|
||||
uint64_t level = currentLevel() > MaxLevelInUniqueID ? MaxLevelInUniqueID : currentLevel();
|
||||
uniqueId &= uniqueIdMask;
|
||||
uniqueId |= (level << LevelFlagBitOffset);
|
||||
}
|
||||
|
||||
void overwriteUniqueId(long long id)
|
||||
{
|
||||
uniqueId = id;
|
||||
updateUniqueIdLevelFlag();
|
||||
}
|
||||
|
||||
protected:
|
||||
TSymbolTable(TSymbolTable&);
|
||||
TSymbolTable& operator=(TSymbolTableLevel&);
|
||||
|
||||
int currentLevel() const { return static_cast<int>(table.size()) - 1; }
|
||||
static const uint32_t LevelFlagBitOffset = 28;
|
||||
std::vector<TSymbolTableLevel*> table;
|
||||
int uniqueId; // for unique identification in code generation
|
||||
long long uniqueId; // for unique identification in code generation
|
||||
bool noBuiltInRedeclarations;
|
||||
bool separateNameSpaces;
|
||||
unsigned int adoptedLevels;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue