[WIP]
This commit is contained in:
parent
76103a869b
commit
baa2e758f2
@ -1,10 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/BlendMode.h>
|
||||
#include<hgl/type/List.h>
|
||||
#include<hgl/platform/Window.h>
|
||||
#include<hgl/graph/BlendMode.h>
|
||||
#include<hgl/graph/ViewportInfo.h>
|
||||
#include<hgl/graph/module/GraphModule.h>
|
||||
#include<hgl/io/event/WindowEvent.h>
|
||||
#include<hgl/graph/module/GraphModuleMap.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
@ -34,9 +35,7 @@ protected:
|
||||
|
||||
protected:
|
||||
|
||||
GraphModuleManager *graph_module_manager=nullptr;
|
||||
|
||||
ObjectList<GraphModule> module_list;
|
||||
GraphModulesMap graph_module_map;
|
||||
|
||||
List<GraphModule *> per_frame_module_list;
|
||||
List<RenderModule *> render_module_list;
|
||||
@ -59,35 +58,39 @@ private:
|
||||
double last_time =0;
|
||||
double cur_time =0;
|
||||
|
||||
uint64 frame_count =0;
|
||||
int64 frame_count =0;
|
||||
|
||||
public:
|
||||
|
||||
const uint64 GetFrameCount ()const noexcept{return frame_count;} ///<取得当前帧数
|
||||
const int64 GetFrameCount ()const noexcept{return frame_count;} ///<取得当前帧数
|
||||
void RestartFrameCount ()noexcept{frame_count=0;} ///<重新开始统计帧数
|
||||
|
||||
public: //module
|
||||
|
||||
template<typename T> T *GetModule(){return graph_module_manager->GetModule<T>(false);} ///<获取指定类型的模块
|
||||
template<typename T>
|
||||
T * GetModule(){return graph_module_map.Get<T>();} ///<获取指定类型的模块
|
||||
GraphModule * GetModule(const AnsiIDName &name,bool create=false); ///<获取指定名称的模块
|
||||
|
||||
template<typename T> T *AddModule()
|
||||
{
|
||||
T *tm=new T(graph_module_manager);
|
||||
//template<typename T> T *AddModule()
|
||||
//{
|
||||
// T *tm=new T(graph_module_manager);
|
||||
|
||||
module_list.Add(tm);
|
||||
// module_list.Add(tm);
|
||||
|
||||
if(tm->IsPerFrame())
|
||||
per_frame_module_list.Add(tm);
|
||||
// if(tm->IsPerFrame())
|
||||
// per_frame_module_list.Add(tm);
|
||||
|
||||
if(tm->IsRender())
|
||||
render_module_list.Add(tm);
|
||||
// if(tm->IsRender())
|
||||
// render_module_list.Add(tm);
|
||||
|
||||
return tm;
|
||||
}
|
||||
// return tm;
|
||||
//}
|
||||
|
||||
GPUDevice * GetDevice (){return device;}
|
||||
VkDevice GetVkDevice (){return device->GetDevice();}
|
||||
SwapchainModule * GetSwapchain(){return swapchain_module;} ///<取得Swapchain模块
|
||||
GPUDevice * GetDevice () {return device;}
|
||||
VkDevice GetVkDevice ()const {return device->GetDevice();}
|
||||
const GPUPhysicalDevice * GetPhysicalDevice ()const {return device->GetPhysicalDevice();} ///<取得物理设备
|
||||
GPUDeviceAttribute *GetDeviceAttribute () {return device->GetDeviceAttribute();} ///<取得设备属性
|
||||
SwapchainModule * GetSwapchain () {return swapchain_module;} ///<取得Swapchain模块
|
||||
|
||||
public: //manager
|
||||
|
||||
@ -104,7 +107,14 @@ public:
|
||||
|
||||
NO_COPY_NO_MOVE(RenderFramework)
|
||||
|
||||
private:
|
||||
|
||||
RenderFramework();
|
||||
|
||||
friend RenderFramework *CreateRenderFramework();
|
||||
|
||||
public:
|
||||
|
||||
virtual ~RenderFramework();
|
||||
|
||||
virtual bool Init(uint w,uint h,const OSString &app_name); ///<初始化
|
||||
@ -130,4 +140,6 @@ public: //TileData
|
||||
TileFont *CreateTileFont(FontSource *fs,int limit_count=-1); ///<创建一个Tile字体
|
||||
};//class RenderFramework
|
||||
|
||||
RenderFramework *CreateRenderFramework();
|
||||
|
||||
VK_NAMESPACE_END
|
||||
|
@ -26,8 +26,6 @@ private:
|
||||
GRAPH_MODULE_CONSTRUCT(RenderPassManager)
|
||||
~RenderPassManager();
|
||||
|
||||
bool Init() override;
|
||||
|
||||
private:
|
||||
|
||||
RenderPass * CreateRenderPass( const List<VkAttachmentDescription> &desc_list,
|
||||
|
@ -10,6 +10,10 @@
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
struct TextureManagerData
|
||||
{
|
||||
};
|
||||
|
||||
class TextureManager:public GraphModule
|
||||
{
|
||||
DeviceQueue *texture_queue=nullptr;
|
||||
@ -40,10 +44,6 @@ public:
|
||||
GRAPH_MODULE_CONSTRUCT(TextureManager)
|
||||
virtual ~TextureManager();
|
||||
|
||||
static const char **GetDependentModules();
|
||||
|
||||
bool Init() override;
|
||||
|
||||
const VkFormatProperties GetFormatProperties(const VkFormat)const;
|
||||
|
||||
public: //Buffer
|
||||
|
@ -1,107 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/type/IDName.h>
|
||||
#include<hgl/type/StrChar.h>
|
||||
#include<hgl/graph/RenderFramework.h>
|
||||
#include<initializer_list>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class RenderCmdBuffer;
|
||||
class GraphModule;
|
||||
|
||||
class RenderFramework;
|
||||
|
||||
struct GraphModulesMap
|
||||
using GraphModuleHashList=std::initializer_list<size_t>;
|
||||
|
||||
class GraphModule
|
||||
{
|
||||
SortedSet<GraphModule *> gm_set;
|
||||
|
||||
Map<AnsiIDName,GraphModule *> gm_map_by_name;
|
||||
Map<size_t,GraphModule *> gm_map_by_hash;
|
||||
|
||||
List<GraphModule *> gm_list; //按创建顺序记录,用于倒序释放
|
||||
|
||||
public:
|
||||
|
||||
bool Add(GraphModule *gm);
|
||||
|
||||
const bool IsEmpty()const
|
||||
{
|
||||
return gm_set.IsEmpty();
|
||||
}
|
||||
|
||||
GraphModule *Get(const AnsiIDName &name)const
|
||||
{
|
||||
GraphModule *gm;
|
||||
|
||||
if(gm_map_by_name.Get(name,gm))
|
||||
return gm;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T *Get()const
|
||||
{
|
||||
GraphModule *gm;
|
||||
|
||||
return gm_map_by_hash.Get(GetTypeHash<T>(),gm)?(T *)gm:nullptr;
|
||||
}
|
||||
|
||||
const bool IsLoaded(const AnsiIDName &name)const{return gm_map_by_name.ContainsKey(name);}
|
||||
|
||||
template<typename T>
|
||||
const bool IsLoaded()const{return gm_map_by_hash.ContainsKey(T::GetTypeHash());}
|
||||
|
||||
bool Release(GraphModule *gm);
|
||||
|
||||
void Destory();
|
||||
};
|
||||
|
||||
class GraphModuleManager
|
||||
{
|
||||
GPUDevice *device;
|
||||
RenderFramework *framework;
|
||||
|
||||
GraphModulesMap graph_module_map; ///<模块映射表
|
||||
|
||||
public:
|
||||
|
||||
GraphModuleManager(RenderFramework *);
|
||||
virtual ~GraphModuleManager();
|
||||
|
||||
GPUDevice * GetDevice ()noexcept {return device;} ///<取得GPU设备
|
||||
VkDevice GetVkDevice ()const {return device->GetDevice();}
|
||||
const GPUPhysicalDevice * GetPhysicalDevice ()const {return device->GetPhysicalDevice();} ///<取得物理设备
|
||||
GPUDeviceAttribute *GetDeviceAttribute () {return device->GetDeviceAttribute();} ///<取得设备属性
|
||||
|
||||
RenderFramework * GetFramework () {return framework;} ///<取得渲染框架
|
||||
|
||||
/**
|
||||
* 获取指定名称的模块
|
||||
* @param create 如果不存在,是否创建新的
|
||||
*/
|
||||
GraphModule *GetModule(const AnsiIDName &name,bool create); ///<获取指定名称的模块
|
||||
|
||||
/**
|
||||
* 获取指定类型的模块
|
||||
* @param create 如果不存在,是否创建新的
|
||||
*/
|
||||
template<typename T>
|
||||
T *GetModule(bool create=false){return (T *)GetModule(T::GetModuleName(),create);} ///<获取指定类型的模块
|
||||
|
||||
void ReleaseModule(GraphModule *); ///<释放指定模块
|
||||
|
||||
public: //事件
|
||||
|
||||
void OnResize(const VkExtent2D &);
|
||||
};//class GraphModuleManager
|
||||
|
||||
GraphModuleManager *GetGraphModuleManager(RenderFramework *);
|
||||
|
||||
class GraphModule:public Comparator<GraphModule>
|
||||
{
|
||||
GraphModuleManager *module_manager;
|
||||
RenderFramework *render_framework;
|
||||
|
||||
AnsiIDName module_name;
|
||||
|
||||
@ -111,10 +23,9 @@ class GraphModule:public Comparator<GraphModule>
|
||||
|
||||
protected:
|
||||
|
||||
GraphModule *GetModule(const AnsiIDName &name){return module_manager->GetModule(name,false);} ///<获取指定名称的模块
|
||||
|
||||
template<typename T>
|
||||
T *GetModule(){return module_manager->GetModule<T>();} ///<获取指定类型的模块
|
||||
T * GetModule(bool create=false){return render_framework->GetModule<T>(create);} ///<获取指定类型的模块
|
||||
GraphModule * GetModule(const AnsiIDName &name,bool create=false); ///<获取指定名称的模块
|
||||
|
||||
protected:
|
||||
|
||||
@ -123,13 +34,12 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
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();} ///<取得设备属性
|
||||
GPUDevice * GetDevice () {return render_framework->GetDevice();} ///<取得GPU设备
|
||||
VkDevice GetVkDevice ()const {return render_framework->GetVkDevice();} ///<取得VkDevice
|
||||
const GPUPhysicalDevice * GetPhysicalDevice ()const {return render_framework->GetPhysicalDevice();} ///<取得物理设备
|
||||
GPUDeviceAttribute *GetDeviceAttribute () {return render_framework->GetDeviceAttribute();} ///<取得设备属性
|
||||
|
||||
RenderFramework * GetFramework () {return module_manager->GetFramework();} ///<取得渲染框架
|
||||
RenderFramework * GetFramework () {return render_framework;} ///<取得渲染框架
|
||||
|
||||
const AnsiIDName & GetName ()const {return module_name;} ///<取得模块名称(标准通用的名称,比如Upscale,供通用模块使用)
|
||||
virtual const AnsiIDName & GetFullName ()const {return module_name;} ///<取得名称(完整的私有名称,比如FSR3Upscale,DLSS3Upscale)
|
||||
@ -145,29 +55,17 @@ public:
|
||||
|
||||
NO_COPY_NO_MOVE(GraphModule)
|
||||
|
||||
GraphModule(GraphModuleManager *gmm,const AnsiIDName &name);
|
||||
protected:
|
||||
|
||||
GraphModule(RenderFramework *rf,const AnsiIDName &name);
|
||||
|
||||
public:
|
||||
|
||||
virtual ~GraphModule();
|
||||
|
||||
virtual const size_t GetTypeHash()const=0;
|
||||
|
||||
virtual bool Init()=0; ///<初始化当前模块
|
||||
|
||||
static const char **GetDependentModules(){return nullptr;} ///<取得依赖的模块列表
|
||||
|
||||
const int compare(const GraphModule &gm)const override
|
||||
{
|
||||
const char **dependent_modules_list=GetDependentModules();
|
||||
|
||||
if(!dependent_modules_list)
|
||||
return -1;
|
||||
|
||||
const char *self_module_name=gm.GetName().ToString();
|
||||
|
||||
if(string_in_list(dependent_modules_list,self_module_name))
|
||||
return 1;//如果我依赖于他,那么我比他大
|
||||
|
||||
return 0;
|
||||
}
|
||||
static const GraphModuleHashList GetDependentModules(){return {};} ///<取得依赖的模块列表
|
||||
|
||||
public: //回调事件
|
||||
|
||||
@ -178,28 +76,43 @@ public: //回调事件
|
||||
virtual void OnPostFrame(){} ///<帧绘制后回调
|
||||
};//class GraphModule
|
||||
|
||||
#define GRAPH_MODULE_CONSTRUCT(name) public:\
|
||||
NO_COPY_NO_MOVE(name) \
|
||||
static const size_t StaticHash(){return typeid(name).hash_code();} \
|
||||
const size_t GetTypeHash()const override{return name::StaticHash();} \
|
||||
static const AnsiIDName &GetModuleName() \
|
||||
{ \
|
||||
static const AnsiIDName id_name(#name); \
|
||||
return id_name; \
|
||||
} \
|
||||
\
|
||||
name(GraphModuleManager *gmm):GraphModule(gmm,GetModuleName()){}
|
||||
using GraphModuleMapByIDName=Map<AnsiIDName,GraphModule *>;
|
||||
|
||||
#define RENDER_MODULE_CONSTRUCT(name) public:\
|
||||
//template<typename T,typename BASE> class GraphModuleInherit:public BASE
|
||||
//{
|
||||
//public:
|
||||
//
|
||||
// GraphModuleInherit(RenderFramework *rf):BASE(rf,typeid(T))
|
||||
// {}
|
||||
//
|
||||
// static const size_t StaticHash()
|
||||
// {
|
||||
// return typeid(T).hash_code();
|
||||
// }
|
||||
//
|
||||
//};//class GraphModuleInherit
|
||||
|
||||
#define GRAPH_MODULE_CREATE_FUNC(name) name *name::CreateModule(RenderFramework *rf,GraphModuleMapByIDName &dep_modules)
|
||||
|
||||
#define GRAPH_BASE_MODULE_CONSTRUCT(name,base_class) public:\
|
||||
NO_COPY_NO_MOVE(name) \
|
||||
static const size_t StaticHash(){return typeid(name).hash_code();} \
|
||||
const size_t GetTypeHash()const override{return name::StaticHash();} \
|
||||
NO_COPY_NO_MOVE(name) \
|
||||
static const AnsiIDName &GetModuleName() \
|
||||
{ \
|
||||
static const AnsiIDName id_name(#name); \
|
||||
return id_name; \
|
||||
} \
|
||||
\
|
||||
name(GraphModuleManager *gmm):RenderModule(gmm,GetModuleName()){}
|
||||
private: \
|
||||
name(RenderFramework *rf):base_class(rf,GetModuleName()){} \
|
||||
\
|
||||
public: \
|
||||
static name *CreateModule(RenderFramework *rf,GraphModuleMapByIDName &); \
|
||||
static const GraphModuleHashList GetDependentModules();
|
||||
|
||||
|
||||
#define GRAPH_MODULE_CONSTRUCT(name) GRAPH_BASE_MODULE_CONSTRUCT(name,GraphModule)
|
||||
#define RENDER_MODULE_CONSTRUCT(name) GRAPH_BASE_MODULE_CONSTRUCT(name,RenderModule)
|
||||
|
||||
VK_NAMESPACE_END
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include<hgl/graph/VKNamespace.h>
|
||||
#include<hgl/type/IDName.h>
|
||||
#include<hgl/graph/module/GraphModule.h>
|
||||
#include<hgl/graph/RenderFramework.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
@ -13,7 +14,7 @@ public:
|
||||
GraphModuleFactory()=default;
|
||||
virtual ~GraphModuleFactory()=default;
|
||||
|
||||
virtual GraphModule *Create(GraphModuleManager *)=0;
|
||||
virtual GraphModule *Create(RenderFramework *)=0;
|
||||
};//class GraphModuleFactory
|
||||
|
||||
bool RegistryGraphModuleFactory(const char *module_name,GraphModuleFactory *);
|
||||
@ -22,9 +23,9 @@ template<typename T> class RegistryGraphModule:public GraphModuleFactory
|
||||
{
|
||||
public:
|
||||
|
||||
GraphModule *Create(GraphModuleManager *gmm) override
|
||||
GraphModule *Create(RenderFramework *rf) override
|
||||
{
|
||||
if(!gmm)
|
||||
if(!rf)
|
||||
return(nullptr);
|
||||
|
||||
Map<AnsiIDName,GraphModule *> dgm_map;
|
||||
@ -37,7 +38,7 @@ public:
|
||||
{
|
||||
for(const AnsiIDName &name:dependent_modules)
|
||||
{
|
||||
GraphModule *dgm=gmm->GetModule(name,true);
|
||||
GraphModule *dgm=rf->GetModule(name,true);
|
||||
|
||||
if(!dgm)
|
||||
return(nullptr);
|
||||
@ -47,13 +48,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
GraphModule *gm=new T(gmm);
|
||||
|
||||
if(!gm->Init())
|
||||
{
|
||||
delete gm;
|
||||
return(nullptr);
|
||||
}
|
||||
T *gm=T::CreateModule(rf,dgm_map);
|
||||
|
||||
return(gm);
|
||||
}
|
||||
|
56
inc/hgl/graph/module/GraphModuleMap.h
Normal file
56
inc/hgl/graph/module/GraphModuleMap.h
Normal file
@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/IDName.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class GraphModule;
|
||||
|
||||
class GraphModulesMap
|
||||
{
|
||||
SortedSet<GraphModule *> gm_set;
|
||||
|
||||
Map<AnsiIDName,GraphModule *> gm_map_by_name;
|
||||
Map<size_t,GraphModule *> gm_map_by_hash;
|
||||
|
||||
List<GraphModule *> gm_list; //按创建顺序记录,用于倒序释放
|
||||
|
||||
public:
|
||||
|
||||
bool Add(GraphModule *gm);
|
||||
|
||||
const bool IsEmpty()const
|
||||
{
|
||||
return gm_set.IsEmpty();
|
||||
}
|
||||
|
||||
GraphModule *Get(const AnsiIDName &name)
|
||||
{
|
||||
GraphModule *gm;
|
||||
|
||||
if(gm_map_by_name.Get(name,gm))
|
||||
return gm;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T *Get()
|
||||
{
|
||||
GraphModule *gm;
|
||||
|
||||
return gm_map_by_hash.Get(GetTypeHash<T>(),gm)?(T *)gm:nullptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const bool IsLoaded()const{return gm_map_by_hash.ContainsKey(T::GetTypeHash());}
|
||||
|
||||
const bool IsLoaded(const AnsiIDName &name)const{return gm_map_by_name.ContainsKey(name);}
|
||||
|
||||
bool Release(GraphModule *gm); ///<释放一个模块
|
||||
|
||||
void Destory(); ///<销毁所有模块
|
||||
};//class GraphModulesMap
|
||||
|
||||
VK_NAMESPACE_END
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/module/RenderModule.h>
|
||||
#include<hgl/graph/VKRenderTarget.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
@ -32,8 +33,6 @@ public:
|
||||
GRAPH_MODULE_CONSTRUCT(SwapchainModule)
|
||||
virtual ~SwapchainModule();
|
||||
|
||||
bool Init() override;
|
||||
|
||||
bool BeginFrame();
|
||||
void EndFrame();
|
||||
|
||||
|
2
res
2
res
@ -1 +1 @@
|
||||
Subproject commit 475d8ad43ceee084cd24f5d0bed59de9f6aa36fd
|
||||
Subproject commit e1a36d78f0eead5f6bb65493432c4690637b991d
|
@ -277,12 +277,12 @@ SOURCE_GROUP("Scene Graph\\Component" FILES ${SG_COMPONENT_HEADER} ${SG_COMPONEN
|
||||
SET(SG_MODULE_HEADER_PATH ${SG_INCLUDE_PATH}/module)
|
||||
|
||||
SET(GRAPH_MODULE_HEADER ${SG_MODULE_HEADER_PATH}/GraphModule.h
|
||||
${SG_MODULE_HEADER_PATH}/GraphModuleMap.h
|
||||
${SG_MODULE_HEADER_PATH}/GraphModuleFactory.h
|
||||
${SG_MODULE_HEADER_PATH}/RenderModule.h
|
||||
${SG_MODULE_HEADER_PATH}/SwapchainModule.h)
|
||||
|
||||
SET(GRAPH_MODULE_SOURCE module/GraphModule.cpp
|
||||
module/GraphModuleManager.cpp
|
||||
module/GraphModuleFactory.cpp
|
||||
module/RenderModule.cpp
|
||||
module/RegistryCommonModule.cpp
|
||||
|
@ -12,8 +12,16 @@ VK_NAMESPACE_BEGIN
|
||||
bool InitShaderCompiler();
|
||||
void CloseShaderCompiler();
|
||||
|
||||
GraphModuleManager *InitGraphModuleManager(RenderFramework *);
|
||||
bool ClearGraphModuleManager(RenderFramework *);
|
||||
void InitGraphModuleFactory();
|
||||
void ClearGraphModuleFactory();
|
||||
|
||||
namespace
|
||||
{
|
||||
static int RENDER_FRAMEWORK_COUNT=0;
|
||||
|
||||
}//namespace
|
||||
|
||||
GraphModule *CreateGraphModule(const AnsiIDName &name,RenderFramework *rf);
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -32,17 +40,43 @@ namespace
|
||||
}
|
||||
}//namespace
|
||||
|
||||
RenderFramework::RenderFramework()
|
||||
GraphModule *RenderFramework::GetModule(const AnsiIDName &name,bool create)
|
||||
{
|
||||
GraphModule *gm=graph_module_map.Get(name);
|
||||
|
||||
if(!gm)
|
||||
{
|
||||
gm=CreateGraphModule(name,this);
|
||||
}
|
||||
}
|
||||
|
||||
RenderFramework *CreateRenderFramework()
|
||||
{
|
||||
if(RENDER_FRAMEWORK_COUNT==0)
|
||||
{
|
||||
if(!InitShaderCompiler())
|
||||
return(nullptr);
|
||||
|
||||
InitGraphModuleFactory();
|
||||
RegistryCommonGraphModule();
|
||||
}
|
||||
|
||||
++RENDER_FRAMEWORK_COUNT;
|
||||
}
|
||||
|
||||
RenderFramework::RenderFramework(){}
|
||||
|
||||
RenderFramework::~RenderFramework()
|
||||
{
|
||||
// if(swapchain_module)graph_module_manager->ReleaseModule(swapchain_module);
|
||||
graph_module_map.Destory();
|
||||
|
||||
ClearGraphModuleManager(this);
|
||||
--RENDER_FRAMEWORK_COUNT;
|
||||
|
||||
if(RENDER_FRAMEWORK_COUNT==0)
|
||||
{
|
||||
ClearGraphModuleFactory();
|
||||
CloseShaderCompiler();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderFramework::StartTime()
|
||||
|
@ -9,28 +9,21 @@ const VkFormatProperties TextureManager::GetFormatProperties(const VkFormat form
|
||||
return GetPhysicalDevice()->GetFormatProperties(format);
|
||||
}
|
||||
|
||||
namespace
|
||||
const GraphModuleHashList TextureManager::GetDependentModules() ///<取得依赖的模块列表
|
||||
{
|
||||
const char *tex_manager_dep[]
|
||||
{
|
||||
"RenderPassManager",
|
||||
nullptr //一定要0结尾
|
||||
};
|
||||
return {RenderPassManager::StaticHash()};
|
||||
}
|
||||
|
||||
const char **TextureManager::GetDependentModules() ///<取得依赖的模块列表
|
||||
GRAPH_MODULE_CREATE_FUNC(TextureManager)
|
||||
{
|
||||
return tex_manager_dep;
|
||||
}
|
||||
|
||||
bool TextureManager::Init()
|
||||
{
|
||||
GPUDevice *dev=GetDevice();
|
||||
GPUDevice *dev=rf->GetDevice();
|
||||
|
||||
if(!dev)
|
||||
return(false);
|
||||
|
||||
texture_cmd_buf=dev->CreateTextureCommandBuffer(GetPhysicalDevice()->GetDeviceName()+AnsiString(":TexCmdBuffer"));
|
||||
auto phy_device=rf->GetPhysicalDevice();
|
||||
|
||||
texture_cmd_buf=dev->CreateTextureCommandBuffer(phy_device->GetDeviceName()+AnsiString(":TexCmdBuffer"));
|
||||
|
||||
if(!texture_cmd_buf)
|
||||
return(false);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include<hgl/graph/module/GraphModule.h>
|
||||
#include<hgl/graph/RenderFramework.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/log/LogInfo.h>
|
||||
|
||||
@ -54,9 +55,9 @@ bool GraphModulesMap::Release(GraphModule *gm)
|
||||
return(true);
|
||||
}
|
||||
|
||||
GraphModule::GraphModule(GraphModuleManager *gmm,const AnsiIDName &name)
|
||||
GraphModule::GraphModule(RenderFramework *rf,const AnsiIDName &name)
|
||||
{
|
||||
module_manager=gmm;
|
||||
render_framework=rf;
|
||||
module_name=name;
|
||||
|
||||
LOG_INFO("GraphModule::GraphModule: "+AnsiString(module_name.GetName()))
|
||||
@ -67,4 +68,9 @@ GraphModule::~GraphModule()
|
||||
LOG_INFO("GraphModule::~GraphModule: "+AnsiString(module_name.GetName()))
|
||||
}
|
||||
|
||||
GraphModule *GraphModule::GetModule(const AnsiIDName &name,bool create)
|
||||
{
|
||||
render_framework->GetModule(name,create);
|
||||
}
|
||||
|
||||
VK_NAMESPACE_END
|
||||
|
@ -43,9 +43,9 @@ bool RegistryGraphModuleFactory(const char *module_name,GraphModuleFactory *gmf)
|
||||
return(true);
|
||||
}
|
||||
|
||||
GraphModule *CreateGraphModule(const AnsiIDName &name,GraphModuleManager *gmm)
|
||||
GraphModule *CreateGraphModule(const AnsiIDName &name,RenderFramework *rf)
|
||||
{
|
||||
if(!gmm)
|
||||
if(!rf)
|
||||
return(nullptr);
|
||||
|
||||
if(!gmf_map)
|
||||
@ -56,7 +56,7 @@ GraphModule *CreateGraphModule(const AnsiIDName &name,GraphModuleManager *gmm)
|
||||
if(!gmf_map->Get(name,gmf))
|
||||
return(nullptr);
|
||||
|
||||
return gmf->Create(gmm);
|
||||
return gmf->Create(rf);
|
||||
}
|
||||
|
||||
VK_NAMESPACE_END
|
||||
|
@ -1,134 +0,0 @@
|
||||
#include<hgl/graph/module/GraphModule.h>
|
||||
#include<hgl/graph/RenderFramework.h>
|
||||
#include<hgl/type/Map.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
void InitGraphModuleFactory();
|
||||
void ClearGraphModuleFactory();
|
||||
|
||||
namespace
|
||||
{
|
||||
using GraphModuleManagerMap=Map<RenderFramework *,GraphModuleManager *>;
|
||||
|
||||
static GraphModuleManagerMap *graph_module_manager_map=nullptr;
|
||||
}
|
||||
|
||||
GraphModuleManager *InitGraphModuleManager(RenderFramework *rf)
|
||||
{
|
||||
if(!rf)
|
||||
return(nullptr);
|
||||
|
||||
if(graph_module_manager_map)
|
||||
{
|
||||
if(graph_module_manager_map->ContainsKey(rf))
|
||||
return(nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
InitGraphModuleFactory();
|
||||
RegistryCommonGraphModule();
|
||||
|
||||
graph_module_manager_map=new GraphModuleManagerMap;
|
||||
}
|
||||
|
||||
GraphModuleManager *gmm=new GraphModuleManager(rf);
|
||||
|
||||
graph_module_manager_map->Add(rf,gmm);
|
||||
|
||||
return gmm;
|
||||
}
|
||||
|
||||
bool ClearGraphModuleManager(RenderFramework *rf)
|
||||
{
|
||||
if(!rf)
|
||||
return(false);
|
||||
|
||||
if(!graph_module_manager_map)
|
||||
return(false);
|
||||
|
||||
GraphModuleManager *gmm;
|
||||
|
||||
if(!graph_module_manager_map->Get(rf,gmm))
|
||||
return(false);
|
||||
|
||||
graph_module_manager_map->DeleteByKey(rf);
|
||||
|
||||
delete gmm;
|
||||
|
||||
if(graph_module_manager_map->IsEmpty())
|
||||
{
|
||||
ClearGraphModuleFactory();
|
||||
SAFE_CLEAR(graph_module_manager_map);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
GraphModuleManager *GetGraphModuleManager(RenderFramework *rf)
|
||||
{
|
||||
if(!rf)
|
||||
return(nullptr);
|
||||
|
||||
if(!graph_module_manager_map)
|
||||
return(nullptr);
|
||||
|
||||
GraphModuleManager *gmm;
|
||||
|
||||
if(graph_module_manager_map->Get(rf,gmm))
|
||||
return gmm;
|
||||
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
GraphModule *CreateGraphModule(const AnsiIDName &name,GraphModuleManager *gmm);
|
||||
|
||||
GraphModule *GraphModuleManager::GetModule(const AnsiIDName &name,bool create)
|
||||
{
|
||||
GraphModule *gm=graph_module_map.Get(name);
|
||||
|
||||
if(gm)
|
||||
return gm;
|
||||
|
||||
if(create)
|
||||
{
|
||||
gm=CreateGraphModule(name,this);
|
||||
|
||||
if(gm)
|
||||
graph_module_map.Add(gm);
|
||||
}
|
||||
|
||||
return gm;
|
||||
}
|
||||
|
||||
GraphModuleManager::GraphModuleManager(RenderFramework *rf)
|
||||
{
|
||||
framework=rf;
|
||||
device=rf->GetDevice();
|
||||
}
|
||||
|
||||
GraphModuleManager::~GraphModuleManager()
|
||||
{
|
||||
graph_module_map.Destory();
|
||||
}
|
||||
|
||||
void GraphModuleManager::ReleaseModule(GraphModule *gm)
|
||||
{
|
||||
if(!gm)
|
||||
return;
|
||||
|
||||
graph_module_map.Release(gm);
|
||||
}
|
||||
|
||||
void GraphModuleManager::OnResize(const VkExtent2D &extent)
|
||||
{
|
||||
if(graph_module_map.IsEmpty())
|
||||
return;
|
||||
|
||||
for(auto *gm:graph_module_map.gm_list)
|
||||
{
|
||||
gm->OnResize(extent);
|
||||
}
|
||||
}
|
||||
|
||||
VK_NAMESPACE_END
|
Loading…
x
Reference in New Issue
Block a user