Front-end: Handle simultaneous use of SPIR-V or non-SPIR-V.
Symbol table sharing has different sets of symbols for different versions. This needs to take into account that SPIR-V has different symbols than non-SPIR-V.
This commit is contained in:
parent
e5a807276f
commit
1011971981
@ -81,42 +81,70 @@ TBuiltInParseables* CreateBuiltInParseables(TInfoSink& infoSink, EShSource sourc
|
||||
|
||||
// Local mapping functions for making arrays of symbol tables....
|
||||
|
||||
const int VersionCount = 15; // index range in MapVersionToIndex
|
||||
|
||||
int MapVersionToIndex(int version)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
switch (version) {
|
||||
case 100: return 0;
|
||||
case 110: return 1;
|
||||
case 120: return 2;
|
||||
case 130: return 3;
|
||||
case 140: return 4;
|
||||
case 150: return 5;
|
||||
case 300: return 6;
|
||||
case 330: return 7;
|
||||
case 400: return 8;
|
||||
case 410: return 9;
|
||||
case 420: return 10;
|
||||
case 430: return 11;
|
||||
case 440: return 12;
|
||||
case 310: return 13;
|
||||
case 450: return 14;
|
||||
default: // |
|
||||
return 0; // |
|
||||
} // |
|
||||
} // V
|
||||
const int VersionCount = 15; // number of case statements above
|
||||
case 100: index = 0; break;
|
||||
case 110: index = 1; break;
|
||||
case 120: index = 2; break;
|
||||
case 130: index = 3; break;
|
||||
case 140: index = 4; break;
|
||||
case 150: index = 5; break;
|
||||
case 300: index = 6; break;
|
||||
case 330: index = 7; break;
|
||||
case 400: index = 8; break;
|
||||
case 410: index = 9; break;
|
||||
case 420: index = 10; break;
|
||||
case 430: index = 11; break;
|
||||
case 440: index = 12; break;
|
||||
case 310: index = 13; break;
|
||||
case 450: index = 14; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
assert(index < VersionCount);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
const int SpvVersionCount = 3; // index range in MapSpvVersionToIndex
|
||||
|
||||
int MapSpvVersionToIndex(const SpvVersion& spvVersion)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
if (spvVersion.openGl > 0)
|
||||
index = 1;
|
||||
else if (spvVersion.vulkan > 0)
|
||||
index = 2;
|
||||
|
||||
assert(index < SpvVersionCount);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
const int ProfileCount = 4; // index range in MapProfileToIndex
|
||||
|
||||
int MapProfileToIndex(EProfile profile)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
switch (profile) {
|
||||
case ENoProfile: return 0;
|
||||
case ECoreProfile: return 1;
|
||||
case ECompatibilityProfile: return 2;
|
||||
case EEsProfile: return 3;
|
||||
default: // |
|
||||
return 0; // |
|
||||
} // |
|
||||
} // V
|
||||
const int ProfileCount = 4; // number of case statements above
|
||||
case ENoProfile: index = 0; break;
|
||||
case ECoreProfile: index = 1; break;
|
||||
case ECompatibilityProfile: index = 2; break;
|
||||
case EEsProfile: index = 3; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
assert(index < ProfileCount);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
// only one of these needed for non-ES; ES needs 2 for different precision defaults of built-ins
|
||||
enum EPrecisionClass {
|
||||
@ -133,8 +161,8 @@ enum EPrecisionClass {
|
||||
// Each has a different set of built-ins, and we want to preserve that from
|
||||
// compile to compile.
|
||||
//
|
||||
TSymbolTable* CommonSymbolTable[VersionCount][ProfileCount][EPcCount] = {};
|
||||
TSymbolTable* SharedSymbolTables[VersionCount][ProfileCount][EShLangCount] = {};
|
||||
TSymbolTable* CommonSymbolTable[VersionCount][SpvVersionCount][ProfileCount][EPcCount] = {};
|
||||
TSymbolTable* SharedSymbolTables[VersionCount][SpvVersionCount][ProfileCount][EShLangCount] = {};
|
||||
|
||||
TPoolAllocator* PerProcessGPA = 0;
|
||||
|
||||
@ -275,8 +303,9 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp
|
||||
|
||||
// See if it's already been done for this version/profile combination
|
||||
int versionIndex = MapVersionToIndex(version);
|
||||
int spvVersionIndex = MapSpvVersionToIndex(spvVersion);
|
||||
int profileIndex = MapProfileToIndex(profile);
|
||||
if (CommonSymbolTable[versionIndex][profileIndex][EPcGeneral]) {
|
||||
if (CommonSymbolTable[versionIndex][spvVersionIndex][profileIndex][EPcGeneral]) {
|
||||
glslang::ReleaseGlobalLock();
|
||||
|
||||
return;
|
||||
@ -304,17 +333,18 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp
|
||||
// Copy the local symbol tables from the new pool to the global tables using the process-global pool
|
||||
for (int precClass = 0; precClass < EPcCount; ++precClass) {
|
||||
if (! commonTable[precClass]->isEmpty()) {
|
||||
CommonSymbolTable[versionIndex][profileIndex][precClass] = new TSymbolTable;
|
||||
CommonSymbolTable[versionIndex][profileIndex][precClass]->copyTable(*commonTable[precClass]);
|
||||
CommonSymbolTable[versionIndex][profileIndex][precClass]->readOnly();
|
||||
CommonSymbolTable[versionIndex][spvVersionIndex][profileIndex][precClass] = new TSymbolTable;
|
||||
CommonSymbolTable[versionIndex][spvVersionIndex][profileIndex][precClass]->copyTable(*commonTable[precClass]);
|
||||
CommonSymbolTable[versionIndex][spvVersionIndex][profileIndex][precClass]->readOnly();
|
||||
}
|
||||
}
|
||||
for (int stage = 0; stage < EShLangCount; ++stage) {
|
||||
if (! stageTables[stage]->isEmpty()) {
|
||||
SharedSymbolTables[versionIndex][profileIndex][stage] = new TSymbolTable;
|
||||
SharedSymbolTables[versionIndex][profileIndex][stage]->adoptLevels(*CommonSymbolTable[versionIndex][profileIndex][CommonIndex(profile, (EShLanguage)stage)]);
|
||||
SharedSymbolTables[versionIndex][profileIndex][stage]->copyTable(*stageTables[stage]);
|
||||
SharedSymbolTables[versionIndex][profileIndex][stage]->readOnly();
|
||||
SharedSymbolTables[versionIndex][spvVersionIndex][profileIndex][stage] = new TSymbolTable;
|
||||
SharedSymbolTables[versionIndex][spvVersionIndex][profileIndex][stage]->adoptLevels(*CommonSymbolTable
|
||||
[versionIndex][spvVersionIndex][profileIndex][CommonIndex(profile, (EShLanguage)stage)]);
|
||||
SharedSymbolTables[versionIndex][spvVersionIndex][profileIndex][stage]->copyTable(*stageTables[stage]);
|
||||
SharedSymbolTables[versionIndex][spvVersionIndex][profileIndex][stage]->readOnly();
|
||||
}
|
||||
}
|
||||
|
||||
@ -616,6 +646,7 @@ bool ProcessDeferred(
|
||||
SetupBuiltinSymbolTable(version, profile, spvVersion, source);
|
||||
|
||||
TSymbolTable* cachedTable = SharedSymbolTables[MapVersionToIndex(version)]
|
||||
[MapSpvVersionToIndex(spvVersion)]
|
||||
[MapProfileToIndex(profile)]
|
||||
[compiler->getLanguage()];
|
||||
|
||||
@ -1049,19 +1080,23 @@ void ShDestruct(ShHandle handle)
|
||||
int __fastcall ShFinalize()
|
||||
{
|
||||
for (int version = 0; version < VersionCount; ++version) {
|
||||
for (int spvVersion = 0; spvVersion < SpvVersionCount; ++spvVersion) {
|
||||
for (int p = 0; p < ProfileCount; ++p) {
|
||||
for (int lang = 0; lang < EShLangCount; ++lang) {
|
||||
delete SharedSymbolTables[version][p][lang];
|
||||
SharedSymbolTables[version][p][lang] = 0;
|
||||
delete SharedSymbolTables[version][spvVersion][p][lang];
|
||||
SharedSymbolTables[version][spvVersion][p][lang] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int version = 0; version < VersionCount; ++version) {
|
||||
for (int spvVersion = 0; spvVersion < SpvVersionCount; ++spvVersion) {
|
||||
for (int p = 0; p < ProfileCount; ++p) {
|
||||
for (int pc = 0; pc < EPcCount; ++pc) {
|
||||
delete CommonSymbolTable[version][p][pc];
|
||||
CommonSymbolTable[version][p][pc] = 0;
|
||||
delete CommonSymbolTable[version][spvVersion][p][pc];
|
||||
CommonSymbolTable[version][spvVersion][p][pc] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user