moved CreateFBO/CreateRT to TextureManager

This commit is contained in:
2024-11-09 00:11:43 +08:00
parent 336688b4f0
commit 6b466f63cf
9 changed files with 77 additions and 53 deletions

View File

@@ -16,7 +16,7 @@ class Framebuffer
private:
friend class GPUDevice;
friend class TextureManager;
Framebuffer(VkDevice,VkFramebuffer,const VkExtent2D &,VkRenderPass,uint32_t color_count,bool depth);

View File

@@ -1,6 +1,6 @@
#pragma once
#include<hgl/graph/manager/GraphManager.h>
#include<hgl/graph/module/GraphModule.h>
#include<hgl/type/SortedSet.h>
#include<hgl/type/IDName.h>
#include<hgl/type/RectScope.h>
@@ -10,14 +10,14 @@
VK_NAMESPACE_BEGIN
class TextureManager:public GraphManager
class TextureManager:public GraphModule
{
DeviceQueue *texture_queue;
TextureCmdBuffer *texture_cmd_buf;
DeviceQueue *texture_queue=nullptr;
TextureCmdBuffer *texture_cmd_buf=nullptr;
private:
TextureID texture_serial;
TextureID texture_serial=0;
const TextureID AcquireID(){return texture_serial++;} ///<取得一个新的纹理ID
@@ -37,9 +37,11 @@ private:
public:
TextureManager(GPUDevice *);
GRAPH_MODULE_CONSTRUCT(TextureManager)
virtual ~TextureManager();
bool Init() override;
public: //Buffer
DeviceBuffer *CreateTransferSourceBuffer(const VkDeviceSize,const void *data_ptr=nullptr);
@@ -119,6 +121,17 @@ 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 color_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

@@ -68,7 +68,7 @@ protected:
public:
virtual const bool IsRender(){return false;} ///<是否为渲染模块
virtual const bool IsRender(){return false;} ///<是否为渲染模块
GraphModuleManager *GetManager (){return module_manager;} ///<取得模块管理器
GPUDevice * GetDevice (){return module_manager->GetDevice();} ///<取得GPU设备
@@ -76,11 +76,11 @@ public:
const GPUPhysicalDevice * GetPhysicalDevice (){return module_manager->GetPhysicalDevice();} ///<取得物理设备
const GPUDeviceAttribute *GetDeviceAttribute (){return module_manager->GetDeviceAttribute();}///<取得设备属性
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)
const bool IsEnable ()const noexcept{return module_enable;} ///<当前模块是否启用
const bool IsReady ()const noexcept{return module_ready;} ///<当前模块是否准备好
const bool IsEnable ()const noexcept{return module_enable;} ///<当前模块是否启用
const bool IsReady ()const noexcept{return module_ready;} ///<当前模块是否准备好
public:
@@ -93,26 +93,34 @@ public:
}
virtual ~GraphModule()=default;
virtual bool Init(){return true;} ///<初始化当前模块
virtual bool Init(){return true;} ///<初始化当前模块
public:
GraphModule * GetModule(const AnsiIDName &name,bool create=false){return module_manager->GetModule(name,create);} ///<获取指定名称的模块
template<typename T>
T * GetModule(bool create=false){return module_manager->GetModule<T>(create);} ///<获取指定类型的模块
public: //回调事件
virtual void OnRenderTarget(RenderTarget *){} ///<设置渲染目标
virtual void OnResize(const VkExtent2D &){} ///<窗口大小改变
virtual void OnRenderTarget(RenderTarget *){} ///<设置渲染目标
virtual void OnResize(const VkExtent2D &){} ///<窗口大小改变
virtual void OnPreFrame(){} ///<帧绘制前回调
virtual void OnPreFrame(){} ///<帧绘制前回调
virtual void OnExecute(const double,RenderCmdBuffer *){}
virtual void OnPostFrame(){} ///<帧绘制后回调
virtual void OnPostFrame(){} ///<帧绘制后回调
};//class GraphModule
#define GRAPH_MODULE_CONSTRUCT(name) public:\
NO_COPY_NO_MOVE(name##Module) \
NO_COPY_NO_MOVE(name) \
static const AnsiIDName &GetModuleName() \
{ \
static const AnsiIDName id_name(#name); \
return id_name; \
} \
\
name##Module(GraphModuleManager *gmm):GraphModule(gmm,GetModuleName()){}
name(GraphModuleManager *gmm):GraphModule(gmm,GetModuleName()){}
VK_NAMESPACE_END

View File

@@ -28,7 +28,15 @@ public:
if(!gmm)
return(nullptr);
return(new T(gmm));
GraphModule *gm=new T(gmm);
if(!gm->Init())
{
delete gm;
return(nullptr);
}
return(true);
}
};//template<typename T> class RegistryGraphModule:public GraphModuleFactory