vulkan: terminate shader compiler only once if inited
fixes assert/crash when switching rendering api
This commit is contained in:
parent
72c2ee1008
commit
9928af2506
|
@ -128,13 +128,18 @@ static const TBuiltInResource DefaultTBuiltInResource = {
|
|||
/* .generalConstantMatrixVectorIndexing = */ true,
|
||||
}};
|
||||
|
||||
int ShaderCompiler::initCount;
|
||||
|
||||
void ShaderCompiler::Init()
|
||||
{
|
||||
verify(glslang::InitializeProcess());
|
||||
if (initCount++ == 0)
|
||||
verify(glslang::InitializeProcess());
|
||||
}
|
||||
void ShaderCompiler::Term()
|
||||
{
|
||||
glslang::FinalizeProcess();
|
||||
if (--initCount == 0)
|
||||
glslang::FinalizeProcess();
|
||||
initCount = std::max(initCount, 0);
|
||||
}
|
||||
|
||||
static EShLanguage translateShaderStage(vk::ShaderStageFlagBits stage)
|
||||
|
|
|
@ -26,4 +26,6 @@ public:
|
|||
static void Init();
|
||||
static void Term();
|
||||
static vk::UniqueShaderModule Compile(vk::ShaderStageFlagBits shaderStage, std::string const& shaderText);
|
||||
private:
|
||||
static int initCount;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue