created RenderTargetManager they are codes from TextureManager

This commit is contained in:
2024-12-24 13:10:01 +08:00
parent 2516e9cfc1
commit c7ae16b2c8
15 changed files with 71 additions and 88 deletions

View File

@@ -26,7 +26,7 @@ private:
GRAPH_MODULE_CONSTRUCT(RenderPassManager)
~RenderPassManager();
bool Init(GraphModulesMap *) override;
bool Init() override;
private:

View File

@@ -0,0 +1,27 @@
#pragma once
#include<hgl/graph/module/GraphModule.h>
VK_NAMESPACE_BEGIN
class RenderTargetManager:public GraphModule
{
public:
GRAPH_MODULE_CONSTRUCT(RenderTargetManager)
virtual ~RenderTargetManager();
public: //FrameBuffer相关
Framebuffer *CreateFBO(RenderPass *rp,ImageView **color_list,const uint image_count,ImageView *depth);
// Framebuffer *CreateFBO(RenderPass *,List<ImageView *> &color,ImageView *depth);
Framebuffer *CreateFBO(RenderPass *,ImageView *color,ImageView *depth);
Framebuffer *CreateFBO(RenderPass *,ImageView *);
public:
RenderTarget *CreateRT( const FramebufferInfo *fbi,RenderPass *,const uint32_t fence_count=1);
RenderTarget *CreateRT( const FramebufferInfo *fbi,const uint32_t fence_count=1);
};//class RenderTargetManager
VK_NAMESPACE_END

View File

@@ -12,8 +12,6 @@ VK_NAMESPACE_BEGIN
class TextureManager:public GraphModule
{
RenderPassManager *rp_manager=nullptr;
DeviceQueue *texture_queue=nullptr;
TextureCmdBuffer *texture_cmd_buf=nullptr;
@@ -126,18 +124,5 @@ public: // Load
Texture2DArray * CreateTexture2DArray(const AnsiString &name,const uint32_t width,const uint32_t height,const uint32_t layer,const VkFormat &fmt,bool auto_mipmaps=false);
bool LoadTexture2DToArray(Texture2DArray *,const uint32_t layer,const OSString &);
public: //FrameBuffer相关
Framebuffer *CreateFBO(RenderPass *rp,ImageView **color_list,const uint image_count,ImageView *depth);
// Framebuffer *CreateFBO(RenderPass *,List<ImageView *> &color,ImageView *depth);
Framebuffer *CreateFBO(RenderPass *,ImageView *color,ImageView *depth);
Framebuffer *CreateFBO(RenderPass *,ImageView *);
public:
RenderTarget *CreateRT( const FramebufferInfo *fbi,RenderPass *,const uint32_t fence_count=1);
RenderTarget *CreateRT( const FramebufferInfo *fbi,const uint32_t fence_count=1);
};//class TextureManager
VK_NAMESPACE_END

View File

@@ -38,9 +38,11 @@ public:
}
template<typename T>
const bool Get(T *&gm)const
T *Get()const
{
return gm_map_by_hash.Get(GetTypeHash<T>(),gm);
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);}
@@ -101,8 +103,6 @@ class GraphModule:public Comparator<GraphModule>
bool module_enabled;
bool module_ready;
GraphModulesMap dependent_modules;
protected:
//GraphModule *GetModule(const AnsiIDName &name){return module_manager->GetModule(name,true);} ///<获取指定名称的模块
@@ -145,7 +145,10 @@ public:
virtual const size_t GetTypeHash()const=0;
virtual bool InitDependentModules(GraphModulesMap *); ///<初始化依赖的模块
/**
* 依赖的模块是在模板new之前就获取的当前函数仅用于传递这些数据
*/
virtual bool InitDependentModules(GraphModulesMap &){module_inited_dependent=true;return true;} ///<初始化依赖的模块
virtual bool Init()=0; ///<初始化当前模块
@@ -163,13 +166,6 @@ public:
return(dependent_modules_name.Contains(gm.module_name)?1:-1); //如果我依赖于他,那么我比他大
}
public:
GraphModule * GetDependentModule(const AnsiIDName &name){return dependent_modules.Get(name);} ///<获取指定名称的模块
template<typename T>
T * GetDependentModule(){return dependent_modules.Get<T>();} ///<获取指定类型的模块
public: //回调事件
virtual void OnRenderTarget(RenderTarget *){} ///<设置渲染目标

View File

@@ -48,9 +48,9 @@ public:
}
}
GraphModule *gm=new T(gmm,dgm_map);
GraphModule *gm=new T(gmm);
if(!gm->InitDependentModules(gmm))
if(!gm->InitDependentModules(dgm))
{
delete gm;
return(nullptr);

View File

@@ -32,7 +32,9 @@ public:
GRAPH_MODULE_CONSTRUCT(SwapchainModule)
virtual ~SwapchainModule();
bool Init(GraphModulesMap *) override;
bool InitDependentModules(GraphModulesMap &) override;
bool Init() override;
bool BeginFrame();
void EndFrame();