From 758acafe88308ea2b86f4510c4beec9d29c4fa81 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Thu, 12 Dec 2024 13:32:28 +0800 Subject: [PATCH] Added module_init in GraphModule, pareparing to splite "new" and "init" operation, because the dependency is must support. --- inc/hgl/graph/module/GraphModule.h | 34 +++++++++++------------ inc/hgl/graph/module/GraphModuleFactory.h | 4 +-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/inc/hgl/graph/module/GraphModule.h b/inc/hgl/graph/module/GraphModule.h index cd3bf9b1..2bb6fcf8 100644 --- a/inc/hgl/graph/module/GraphModule.h +++ b/inc/hgl/graph/module/GraphModule.h @@ -54,7 +54,7 @@ public: //事件 GraphModuleManager *GetGraphModuleManager(GPUDevice *); -class GraphModule +class GraphModule:public Comparator { GraphModuleManager *module_manager; @@ -62,6 +62,7 @@ class GraphModule SortedSet dependent_module; ///<依赖的模块 + bool module_init; bool module_enable; bool module_ready; @@ -72,19 +73,20 @@ protected: public: - 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 + const GPUPhysicalDevice * GetPhysicalDevice ()const{return module_manager->GetPhysicalDevice();} ///<取得物理设备 + GPUDeviceAttribute *GetDeviceAttribute (){return module_manager->GetDeviceAttribute();} ///<取得设备属性 - GraphModuleManager *GetManager (){return module_manager;} ///<取得模块管理器 - GPUDevice * GetDevice (){return module_manager->GetDevice();} ///<取得GPU设备 - VkDevice GetVkDevice ()const{return module_manager->GetVkDevice();} ///<取得VkDevice - const GPUPhysicalDevice * GetPhysicalDevice ()const{return module_manager->GetPhysicalDevice();} ///<取得物理设备 - GPUDeviceAttribute *GetDeviceAttribute (){return module_manager->GetDeviceAttribute();}///<取得设备属性 + static const AnsiIDName *GetModuleName(){return nullptr;} ///<取得模块名称(标准通用的名称,比如Upscale,供通用模块使用) + virtual const AnsiIDName *GetName()const{return &module_name;} ///<取得名称(完整的私有名称,比如FSR3Upscale,DLSS3Upscale) + + virtual const bool IsRender (){return false;} ///<是否为渲染模块 - static const AnsiIDName *GetModuleName(){return nullptr;} ///<取得模块名称(标准通用的名称,比如Upscale,供通用模块使用) - virtual const AnsiIDName *GetName()const{return &module_name;} ///<取得名称(完整的私有名称,比如FSR3Upscale,DLSS3Upscale) - - const bool IsEnable ()const noexcept{return module_enable;} ///<当前模块是否启用 - const bool IsReady ()const noexcept{return module_ready;} ///<当前模块是否准备好 + const bool IsInit ()const{return module_init;} ///<是否已经初始化 + const bool IsEnable ()const noexcept{return module_enable;} ///<当前模块是否启用 + const bool IsReady ()const noexcept{return module_ready;} ///<当前模块是否准备好 public: @@ -93,15 +95,13 @@ public: GraphModule(GraphModuleManager *gmm,const AnsiIDName &name); virtual ~GraphModule(); - virtual bool Init(){return true;} ///<初始化当前模块 + virtual bool Init(){module_init=true;return true;} ///<初始化当前模块 - int Comp(const GraphModule *gm)const + const int compare(const GraphModule &gm)const override { - return(dependent_module.Contains(gm->module_name)?1:-1); //如果我依赖于他,那么我比他大 + return(dependent_module.Contains(gm.module_name)?1:-1); //如果我依赖于他,那么我比他大 } - CompOperator(const GraphModule *,Comp) - public: GraphModule * GetModule(const AnsiIDName &name,bool create=false){return module_manager->GetModule(name,create);} ///<获取指定名称的模块 diff --git a/inc/hgl/graph/module/GraphModuleFactory.h b/inc/hgl/graph/module/GraphModuleFactory.h index 2a83dfa3..1a70bd7f 100644 --- a/inc/hgl/graph/module/GraphModuleFactory.h +++ b/inc/hgl/graph/module/GraphModuleFactory.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include @@ -42,4 +42,4 @@ public: #define REGISTRY_GRAPH_MODULE(Class) {RegistryGraphModuleFactory(#Class,new RegistryGraphModule);} -VK_NAMESPACE_END \ No newline at end of file +VK_NAMESPACE_END