diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index a35919589cbb960f647c4ad269e02f3b03b816c5..b0cb64c7590cc86a8bab8fca10caeaa9b203aa9b 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -2,5 +2,5 @@ // For the version, it uses the latest git tag followed by the number of commits. // For the date, it uses the current date (when then script is run). -#define GLSLANG_REVISION "SPIRV99.1394" -#define GLSLANG_DATE "08-Aug-2016" +#define GLSLANG_REVISION "SPIRV99.1396" +#define GLSLANG_DATE "09-Aug-2016" diff --git a/glslang/MachineIndependent/ShaderLang.cpp b/glslang/MachineIndependent/ShaderLang.cpp index dccc1f0b786d556b1c745334812b124f30204a9a..c7aa6a2d5c33c007f631fa6f80b98290c40e742d 100644 --- a/glslang/MachineIndependent/ShaderLang.cpp +++ b/glslang/MachineIndependent/ShaderLang.cpp @@ -146,6 +146,23 @@ int MapProfileToIndex(EProfile profile) return index; } +const int SourceCount = 2; + +int MapSourceToIndex(EShSource source) +{ + int index = 0; + + switch (source) { + case EShSourceGlsl: index = 0; break; + case EShSourceHlsl: index = 1; break; + default: break; + } + + assert(index < SourceCount); + + return index; +} + // only one of these needed for non-ES; ES needs 2 for different precision defaults of built-ins enum EPrecisionClass { EPcGeneral, @@ -161,8 +178,8 @@ enum EPrecisionClass { // Each has a different set of built-ins, and we want to preserve that from // compile to compile. // -TSymbolTable* CommonSymbolTable[VersionCount][SpvVersionCount][ProfileCount][EPcCount] = {}; -TSymbolTable* SharedSymbolTables[VersionCount][SpvVersionCount][ProfileCount][EShLangCount] = {}; +TSymbolTable* CommonSymbolTable[VersionCount][SpvVersionCount][ProfileCount][SourceCount][EPcCount] = {}; +TSymbolTable* SharedSymbolTables[VersionCount][SpvVersionCount][ProfileCount][SourceCount][EShLangCount] = {}; TPoolAllocator* PerProcessGPA = 0; @@ -305,7 +322,8 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp int versionIndex = MapVersionToIndex(version); int spvVersionIndex = MapSpvVersionToIndex(spvVersion); int profileIndex = MapProfileToIndex(profile); - if (CommonSymbolTable[versionIndex][spvVersionIndex][profileIndex][EPcGeneral]) { + int sourceIndex = MapSourceToIndex(source); + if (CommonSymbolTable[versionIndex][spvVersionIndex][profileIndex][sourceIndex][EPcGeneral]) { glslang::ReleaseGlobalLock(); return; @@ -333,18 +351,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][spvVersionIndex][profileIndex][precClass] = new TSymbolTable; - CommonSymbolTable[versionIndex][spvVersionIndex][profileIndex][precClass]->copyTable(*commonTable[precClass]); - CommonSymbolTable[versionIndex][spvVersionIndex][profileIndex][precClass]->readOnly(); + CommonSymbolTable[versionIndex][spvVersionIndex][profileIndex][sourceIndex][precClass] = new TSymbolTable; + CommonSymbolTable[versionIndex][spvVersionIndex][profileIndex][sourceIndex][precClass]->copyTable(*commonTable[precClass]); + CommonSymbolTable[versionIndex][spvVersionIndex][profileIndex][sourceIndex][precClass]->readOnly(); } } for (int stage = 0; stage < EShLangCount; ++stage) { if (! stageTables[stage]->isEmpty()) { - 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(); + SharedSymbolTables[versionIndex][spvVersionIndex][profileIndex][sourceIndex][stage] = new TSymbolTable; + SharedSymbolTables[versionIndex][spvVersionIndex][profileIndex][sourceIndex][stage]->adoptLevels(*CommonSymbolTable + [versionIndex][spvVersionIndex][profileIndex][sourceIndex][CommonIndex(profile, (EShLanguage)stage)]); + SharedSymbolTables[versionIndex][spvVersionIndex][profileIndex][sourceIndex][stage]->copyTable(*stageTables[stage]); + SharedSymbolTables[versionIndex][spvVersionIndex][profileIndex][sourceIndex][stage]->readOnly(); } } @@ -656,6 +674,7 @@ bool ProcessDeferred( TSymbolTable* cachedTable = SharedSymbolTables[MapVersionToIndex(version)] [MapSpvVersionToIndex(spvVersion)] [MapProfileToIndex(profile)] + [MapSourceToIndex(source)] [compiler->getLanguage()]; // Dynamically allocate the symbol table so we can control when it is deallocated WRT the pool. @@ -1092,9 +1111,11 @@ 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][spvVersion][p][lang]; - SharedSymbolTables[version][spvVersion][p][lang] = 0; + for (int source = 0; source < SourceCount; ++source) { + for (int stage = 0; stage < EShLangCount; ++stage) { + delete SharedSymbolTables[version][spvVersion][p][source][stage]; + SharedSymbolTables[version][spvVersion][p][source][stage] = 0; + } } } } @@ -1103,9 +1124,11 @@ 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 pc = 0; pc < EPcCount; ++pc) { - delete CommonSymbolTable[version][spvVersion][p][pc]; - CommonSymbolTable[version][spvVersion][p][pc] = 0; + for (int source = 0; source < SourceCount; ++source) { + for (int pc = 0; pc < EPcCount; ++pc) { + delete CommonSymbolTable[version][spvVersion][p][source][pc]; + CommonSymbolTable[version][spvVersion][p][source][pc] = 0; + } } } } diff --git a/gtests/Initializer.h b/gtests/Initializer.h index 34af9ad9a16f7de29cb3f41eeba8e11e9b9ecc14..b46b3f55dc09491cfe4fa4068f16f473f82b5d64 100644 --- a/gtests/Initializer.h +++ b/gtests/Initializer.h @@ -40,46 +40,14 @@ namespace glslangtest { // Initializes glslang on creation, and destroys it on completion. -// And provides .Acquire() as a way to reinitialize glslang if semantics change. // This object is expected to be a singleton, so that internal glslang state // can be correctly handled. // -// TODO(antiagainst): It's a known bug that some of the internal states need to -// be reset if semantics change: -// https://github.com/KhronosGroup/glslang/issues/166 -// Therefore, the following mechanism is needed. Remove this once the above bug -// gets fixed. class GlslangInitializer { public: - GlslangInitializer() : lastMessages(EShMsgCascadingErrors) - { - glslang::InitializeProcess(); - } + GlslangInitializer() { glslang::InitializeProcess(); } ~GlslangInitializer() { glslang::FinalizeProcess(); } - - // A token indicates that the glslang is reinitialized (if necessary) to the - // required semantics. And that won't change until the token is destroyed. - class InitializationToken { - }; - - // Re-initializes glsl state iff the previous messages and the current - // messages are incompatible. We assume external synchronization, i.e. - // there is at most one acquired token at any one time. - InitializationToken acquire(EShMessages new_messages) - { - if ((lastMessages ^ new_messages) & - (EShMsgVulkanRules | EShMsgSpvRules | EShMsgReadHlsl)) { - glslang::FinalizeProcess(); - glslang::InitializeProcess(); - } - lastMessages = new_messages; - return InitializationToken(); - } - -private: - - EShMessages lastMessages; }; } // namespace glslangtest diff --git a/gtests/TestFixture.h b/gtests/TestFixture.h index 8dffb8050f9751c10a3dd9276bc02835c12e76b1..d196babe1564903ee5a4d95c45d84f5166e3f87b 100644 --- a/gtests/TestFixture.h +++ b/gtests/TestFixture.h @@ -179,8 +179,6 @@ public: shader->setStringsWithLengths(&shaderStrings, &shaderLengths, 1); if (!entryPointName.empty()) shader->setEntryPoint(entryPointName.c_str()); - // Reinitialize glslang if the semantics change. - GlobalTestSettings.initializer->acquire(controls); return shader->parse( (resources ? resources : &glslang::DefaultTBuiltInResource), defaultVersion, isForwardCompatible, controls);