Use RenderFramework instead of GPUDevice at Init GraphModuleManager

This commit is contained in:
hyzboy 2024-12-16 23:24:08 +08:00
parent 7dd075b495
commit d1c3934beb
3 changed files with 33 additions and 35 deletions

View File

@ -57,7 +57,7 @@ public: //事件
void OnResize(const VkExtent2D &);
};//class GraphModuleManager
GraphModuleManager *GetGraphModuleManager(GPUDevice *);
GraphModuleManager *GetGraphModuleManager(RenderFramework *);
class GraphModule:public Comparator<GraphModule>
{
@ -65,22 +65,19 @@ class GraphModule:public Comparator<GraphModule>
AnsiIDName module_name;
SortedSet<AnsiIDName> dependent_module; ///<依赖的模块
SortedSet<AnsiIDName> dependent_module; ///<依赖的模块
bool module_init;
bool module_enable;
bool module_inited;
bool module_enabled;
bool module_ready;
protected:
virtual void SetModuleEnable(bool e){module_enable=e;}
virtual void SetModuleEnabled(bool e){module_enabled=e;}
virtual void SetModuleReady(bool r){module_ready=r;}
public:
virtual const bool IsPerFrame () {return false;} ///<是否每帧运行
virtual const bool IsRender () {return false;} ///<是否为渲染模块
GraphModuleManager *GetManager () {return module_manager;} ///<取得模块管理器
GPUDevice * GetDevice () {return module_manager->GetDevice();} ///<取得GPU设备
VkDevice GetVkDevice ()const {return module_manager->GetVkDevice();} ///<取得VkDevice
@ -89,14 +86,15 @@ public:
RenderFramework * GetFramework () {return module_manager->GetFramework();} ///<取得渲染框架
static const AnsiIDName * GetModuleName (){return nullptr;} ///<取得模块名称(标准通用的名称比如Upscale供通用模块使用)
virtual const AnsiIDName * GetName ()const{return &module_name;} ///<取得名称(完整的私有名称比如FSR3Upscale,DLSS3Upscale)
static const AnsiIDName * GetModuleName () {return nullptr;} ///<取得模块名称(标准通用的名称比如Upscale供通用模块使用)
virtual const AnsiIDName * GetName ()const {return &module_name;} ///<取得名称(完整的私有名称比如FSR3Upscale,DLSS3Upscale)
virtual const bool IsRender (){return false;} ///<是否为渲染模块
virtual const bool IsPerFrame () {return false;} ///<是否每帧运行
virtual const bool IsRender () {return false;} ///<是否为渲染模块
const bool IsInit ()const{return module_init;} ///<是否已经初始化
const bool IsEnable ()const noexcept{return module_enable;} ///<当前模块是否启用
const bool IsReady ()const noexcept{return module_ready;} ///<当前模块是否准备好
const bool IsInited ()const {return module_inited;} ///<是否已经初始化
const bool IsEnabled ()const noexcept{return module_enabled;} ///<当前模块是否启用
const bool IsReady ()const noexcept{return module_ready;} ///<当前模块是否准备好
public:
@ -105,7 +103,7 @@ public:
GraphModule(GraphModuleManager *gmm,const AnsiIDName &name);
virtual ~GraphModule();
virtual bool Init(){module_init=true;return true;} ///<初始化当前模块
virtual bool Init(){module_inited=true;return true;} ///<初始化当前模块
const int compare(const GraphModule &gm)const override
{

View File

@ -12,8 +12,8 @@ VK_NAMESPACE_BEGIN
bool InitShaderCompiler();
void CloseShaderCompiler();
GraphModuleManager *InitGraphModuleManager(GPUDevice *dev);
bool ClearGraphModuleManager(GPUDevice *dev);
GraphModuleManager *InitGraphModuleManager(RenderFramework *);
bool ClearGraphModuleManager(RenderFramework *);
namespace
{
@ -40,7 +40,7 @@ RenderFramework::~RenderFramework()
{
// if(swapchain_module)graph_module_manager->ReleaseModule(swapchain_module);
ClearGraphModuleManager(device);
ClearGraphModuleManager(this);
CloseShaderCompiler();
}
@ -56,7 +56,7 @@ void RenderFramework::BeginFrame()
for(GraphModule *rm:per_frame_module_list)
{
if(rm->IsEnable())
if(rm->IsEnabled())
rm->OnPreFrame();
}
@ -69,7 +69,7 @@ void RenderFramework::EndFrame()
for(GraphModule *rm:per_frame_module_list)
{
if(rm->IsEnable())
if(rm->IsEnabled())
rm->OnPostFrame();
}
@ -92,7 +92,7 @@ void RenderFramework::MainLoop()
for(RenderModule *rm:render_module_list)
{
if(rm->IsEnable())
if(rm->IsEnabled())
rm->OnFrameRender(delta_time,rcb);
}
@ -148,7 +148,7 @@ bool RenderFramework::Init(uint w,uint h,const OSString &app_name)
if(!device)
return(false);
graph_module_manager=InitGraphModuleManager(device,this);
graph_module_manager=InitGraphModuleManager(this);
render_pass_manager =graph_module_manager->GetModule<RenderPassManager>(true);
texture_manager =graph_module_manager->GetModule<TextureManager>(true);

View File

@ -8,19 +8,19 @@ void ClearGraphModuleFactory();
namespace
{
using GraphModuleManagerMap=Map<GPUDevice *,GraphModuleManager *>;
using GraphModuleManagerMap=Map<RenderFramework *,GraphModuleManager *>;
static GraphModuleManagerMap *graph_module_manager_map=nullptr;
}
GraphModuleManager *InitGraphModuleManager(GPUDevice *dev)
GraphModuleManager *InitGraphModuleManager(RenderFramework *rf)
{
if(!dev)
if(!rf)
return(nullptr);
if(graph_module_manager_map)
{
if(graph_module_manager_map->ContainsKey(dev))
if(graph_module_manager_map->ContainsKey(rf))
return(nullptr);
}
else
@ -31,16 +31,16 @@ GraphModuleManager *InitGraphModuleManager(GPUDevice *dev)
graph_module_manager_map=new GraphModuleManagerMap;
}
GraphModuleManager *gmm=new GraphModuleManager(dev);
GraphModuleManager *gmm=new GraphModuleManager(rf);
graph_module_manager_map->Add(dev,gmm);
graph_module_manager_map->Add(rf,gmm);
return gmm;
}
bool ClearGraphModuleManager(GPUDevice *dev)
bool ClearGraphModuleManager(RenderFramework *rf)
{
if(!dev)
if(!rf)
return(false);
if(!graph_module_manager_map)
@ -48,10 +48,10 @@ bool ClearGraphModuleManager(GPUDevice *dev)
GraphModuleManager *gmm;
if(!graph_module_manager_map->Get(dev,gmm))
if(!graph_module_manager_map->Get(rf,gmm))
return(false);
graph_module_manager_map->DeleteByKey(dev);
graph_module_manager_map->DeleteByKey(rf);
delete gmm;
@ -64,9 +64,9 @@ bool ClearGraphModuleManager(GPUDevice *dev)
return(true);
}
GraphModuleManager *GetGraphModuleManager(GPUDevice *dev)
GraphModuleManager *GetGraphModuleManager(RenderFramework *rf)
{
if(!dev)
if(!rf)
return(nullptr);
if(!graph_module_manager_map)
@ -74,7 +74,7 @@ GraphModuleManager *GetGraphModuleManager(GPUDevice *dev)
GraphModuleManager *gmm;
if(graph_module_manager_map->Get(dev,gmm))
if(graph_module_manager_map->Get(rf,gmm))
return gmm;
return(nullptr);