Now only initializing glslang when compiling shaders

This commit is contained in:
2020-08-06 19:03:39 -07:00
parent 283c4e152a
commit 95fdd30b02
3 changed files with 9 additions and 2 deletions

View File

@@ -106,7 +106,6 @@ KRContext::KRContext(const KrInitializeInfo* initializeInfo)
#endif
createDeviceContexts();
glslang::InitializeProcess();
}
KRContext::~KRContext() {
@@ -171,7 +170,6 @@ KRContext::~KRContext() {
delete m_resourceMap;
m_resourceMap = NULL;
}
glslang::FinalizeProcess();
}
void KRContext::SetLogCallback(log_callback *log_callback, void *user_data)

View File

@@ -33,6 +33,7 @@
#include "KREngine-common.h"
KRShaderManager::KRShaderManager(KRContext &context) : KRResourceManager(context)
, m_initializedGlslang(false)
{
}
@@ -44,6 +45,9 @@ KRShaderManager::~KRShaderManager()
delete (*name_itr).second;
}
}
if (m_initializedGlslang) {
glslang::FinalizeProcess();
}
}
KRResource* KRShaderManager::loadResource(const std::string& name, const std::string& extension, KRDataBlock* data)
@@ -118,5 +122,9 @@ const unordered_map<std::string, KRShader *> &KRShaderManager::get(const std::st
bool KRShaderManager::compileAll()
{
if (!m_initializedGlslang) {
glslang::InitializeProcess();
m_initializedGlslang = true;
}
return true;
}

View File

@@ -61,6 +61,7 @@ public:
private:
unordered_map<std::string, unordered_map<std::string, KRShader *> > m_shaders;
bool m_initializedGlslang;
};
#endif /* defined(KRUNKNOWN_MANAGER_H) */