Subsystem startup shutdown (#11128)

* refactor startup/shutdown process of BuiltinResMgr
* refactor startup/shutdown process of ProgramLib
This commit is contained in:
minggo
2022-05-18 11:09:55 +08:00
committed by GitHub
parent cbc500d020
commit fac5bf833a
6 changed files with 43 additions and 35 deletions
+6 -12
View File
@@ -271,9 +271,13 @@ void IProgramInfo::copyFrom(const IShaderInfo &o) {
subpassInputs = o.subpassInputs;
}
ProgramLib::ProgramLib() = default;
ProgramLib::ProgramLib() {
ProgramLib::instance = this;
}
ProgramLib::~ProgramLib() = default;
ProgramLib::~ProgramLib() {
ProgramLib::instance = nullptr;
}
//
/*static*/
@@ -281,19 +285,9 @@ ProgramLib::~ProgramLib() = default;
ProgramLib *ProgramLib::instance = nullptr;
ProgramLib *ProgramLib::getInstance() {
if (!ProgramLib::instance) {
ProgramLib::instance = ccnew ProgramLib();
}
return ProgramLib::instance;
}
void ProgramLib::destroyInstance() {
if (ProgramLib::instance) {
delete ProgramLib::instance;
ProgramLib::instance = nullptr;
}
}
void ProgramLib::registerEffect(EffectAsset *effect) {
for (auto &shader : effect->_shaders) {
auto *tmpl = define(shader);