splited InitDependentModules

This commit is contained in:
hyzboy 2024-12-21 17:25:30 +08:00
parent bd9e587691
commit 2516e9cfc1
5 changed files with 45 additions and 21 deletions

View File

@ -42,7 +42,9 @@ public:
GRAPH_MODULE_CONSTRUCT(TextureManager)
virtual ~TextureManager();
bool Init(GraphModulesMap *) override;
static const char **GetDependentModules();
bool Init() override;
const VkFormatProperties GetFormatProperties(const VkFormat)const;

View File

@ -96,6 +96,7 @@ class GraphModule:public Comparator<GraphModule>
AnsiIDName module_name;
bool module_inited_dependent;
bool module_inited;
bool module_enabled;
bool module_ready;
@ -130,6 +131,7 @@ public:
virtual const bool IsPerFrame () {return false;} ///<是否每帧运行
virtual const bool IsRender () {return false;} ///<是否为渲染模块
const bool IsInitedDependent ()const {return module_inited_dependent;} ///<是否已经初始化依赖的模块
const bool IsInited ()const {return module_inited;} ///<是否已经初始化
const bool IsEnabled ()const noexcept{return module_enabled;} ///<当前模块是否启用
const bool IsReady ()const noexcept{return module_ready;} ///<当前模块是否准备好
@ -143,7 +145,9 @@ public:
virtual const size_t GetTypeHash()const=0;
virtual bool Init(GraphModulesMap *); ///<初始化当前模块
virtual bool InitDependentModules(GraphModulesMap *); ///<初始化依赖的模块
virtual bool Init()=0; ///<初始化当前模块
static const AnsiIDNameSet &GetDependentModules() ///<取得依赖的模块列表
{

View File

@ -50,6 +50,12 @@ public:
GraphModule *gm=new T(gmm,dgm_map);
if(!gm->InitDependentModules(gmm))
{
delete gm;
return(nullptr);
}
if(!gm->Init())
{
delete gm;

View File

@ -1,6 +1,7 @@
#include<hgl/graph/manager/TextureManager.h>
#include<hgl/graph/manager/TextureManager.h>
#include<hgl/graph/VKDevice.h>
#include<hgl/graph/VKCommandBuffer.h>
#include<hgl/graph/manager/RenderPassManager.h>
VK_NAMESPACE_BEGIN
const VkFormatProperties TextureManager::GetFormatProperties(const VkFormat format) const
@ -8,8 +9,23 @@ const VkFormatProperties TextureManager::GetFormatProperties(const VkFormat form
return GetPhysicalDevice()->GetFormatProperties(format);
}
bool TextureManager::Init()
namespace
{
const char *tex_manager_dep[]
{
"RenderPassManager"
};
}
const char **TextureManager::GetDependentModules() ///<取得依赖的模块列表
{
return tex_manager_dep;
}
bool TextureManager::Init(GraphModulesMap *gmm)
{
GPUDevice *dev=GetDevice();
if(!dev)

View File

@ -31,7 +31,7 @@ GraphModule::~GraphModule()
LOG_INFO("GraphModule::~GraphModule: "+AnsiString(module_name.GetName()))
}
bool GraphModule::Init(GraphModulesMap *gmm)
bool GraphModule::InitDependentModules(GraphModulesMap *)
{
auto dm_list=GetDependentModules();
@ -40,27 +40,23 @@ bool GraphModule::Init(GraphModulesMap *gmm)
if(!gmm)
return(false);
if(!gmm->IsEmpty())
if(gmm->IsEmpty())
return(false);
for(auto dm_name:dm_list)
{
for(auto dm_name:dm_list)
GraphModule *dm=gmm->Get(dm_name);
if(dm&&dm->IsInited())
{
GraphModule *dm;
if(gmm->Get(dm_name,dm))
{
if(dm->IsInited())
{
dependent_modules.Add(dm);
continue;
}
}
return(false);
dependent_modules.Add(dm);
continue;
}
return(false);
}
}
module_inited=true;
return(true);
}