moved CreateFBO/CreateRT to TextureManager
This commit is contained in:
parent
336688b4f0
commit
6b466f63cf
@ -16,7 +16,7 @@ class Framebuffer
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class GPUDevice;
|
friend class TextureManager;
|
||||||
|
|
||||||
Framebuffer(VkDevice,VkFramebuffer,const VkExtent2D &,VkRenderPass,uint32_t color_count,bool depth);
|
Framebuffer(VkDevice,VkFramebuffer,const VkExtent2D &,VkRenderPass,uint32_t color_count,bool depth);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include<hgl/graph/manager/GraphManager.h>
|
#include<hgl/graph/module/GraphModule.h>
|
||||||
#include<hgl/type/SortedSet.h>
|
#include<hgl/type/SortedSet.h>
|
||||||
#include<hgl/type/IDName.h>
|
#include<hgl/type/IDName.h>
|
||||||
#include<hgl/type/RectScope.h>
|
#include<hgl/type/RectScope.h>
|
||||||
@ -10,14 +10,14 @@
|
|||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
|
|
||||||
class TextureManager:public GraphManager
|
class TextureManager:public GraphModule
|
||||||
{
|
{
|
||||||
DeviceQueue *texture_queue;
|
DeviceQueue *texture_queue=nullptr;
|
||||||
TextureCmdBuffer *texture_cmd_buf;
|
TextureCmdBuffer *texture_cmd_buf=nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
TextureID texture_serial;
|
TextureID texture_serial=0;
|
||||||
|
|
||||||
const TextureID AcquireID(){return texture_serial++;} ///<取得一个新的纹理ID
|
const TextureID AcquireID(){return texture_serial++;} ///<取得一个新的纹理ID
|
||||||
|
|
||||||
@ -37,9 +37,11 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TextureManager(GPUDevice *);
|
GRAPH_MODULE_CONSTRUCT(TextureManager)
|
||||||
virtual ~TextureManager();
|
virtual ~TextureManager();
|
||||||
|
|
||||||
|
bool Init() override;
|
||||||
|
|
||||||
public: //Buffer
|
public: //Buffer
|
||||||
|
|
||||||
DeviceBuffer *CreateTransferSourceBuffer(const VkDeviceSize,const void *data_ptr=nullptr);
|
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);
|
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 &);
|
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
|
};//class TextureManager
|
||||||
|
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -68,7 +68,7 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual const bool IsRender(){return false;} ///<是否为渲染模块
|
virtual const bool IsRender(){return false;} ///<是否为渲染模块
|
||||||
|
|
||||||
GraphModuleManager *GetManager (){return module_manager;} ///<取得模块管理器
|
GraphModuleManager *GetManager (){return module_manager;} ///<取得模块管理器
|
||||||
GPUDevice * GetDevice (){return module_manager->GetDevice();} ///<取得GPU设备
|
GPUDevice * GetDevice (){return module_manager->GetDevice();} ///<取得GPU设备
|
||||||
@ -76,11 +76,11 @@ public:
|
|||||||
const GPUPhysicalDevice * GetPhysicalDevice (){return module_manager->GetPhysicalDevice();} ///<取得物理设备
|
const GPUPhysicalDevice * GetPhysicalDevice (){return module_manager->GetPhysicalDevice();} ///<取得物理设备
|
||||||
const GPUDeviceAttribute *GetDeviceAttribute (){return module_manager->GetDeviceAttribute();}///<取得设备属性
|
const GPUDeviceAttribute *GetDeviceAttribute (){return module_manager->GetDeviceAttribute();}///<取得设备属性
|
||||||
|
|
||||||
static const AnsiIDName *GetModuleName(){return nullptr;} ///<取得模块名称(标准通用的名称,比如Upscale,供通用模块使用)
|
static const AnsiIDName *GetModuleName(){return nullptr;} ///<取得模块名称(标准通用的名称,比如Upscale,供通用模块使用)
|
||||||
virtual const AnsiIDName *GetName()const{return &module_name;} ///<取得名称(完整的私有名称,比如FSR3Upscale,DLSS3Upscale)
|
virtual const AnsiIDName *GetName()const{return &module_name;} ///<取得名称(完整的私有名称,比如FSR3Upscale,DLSS3Upscale)
|
||||||
|
|
||||||
const bool IsEnable ()const noexcept{return module_enable;} ///<当前模块是否启用
|
const bool IsEnable ()const noexcept{return module_enable;} ///<当前模块是否启用
|
||||||
const bool IsReady ()const noexcept{return module_ready;} ///<当前模块是否准备好
|
const bool IsReady ()const noexcept{return module_ready;} ///<当前模块是否准备好
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -93,26 +93,34 @@ public:
|
|||||||
}
|
}
|
||||||
virtual ~GraphModule()=default;
|
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: //回调事件
|
public: //回调事件
|
||||||
|
|
||||||
virtual void OnRenderTarget(RenderTarget *){} ///<设置渲染目标
|
virtual void OnRenderTarget(RenderTarget *){} ///<设置渲染目标
|
||||||
virtual void OnResize(const VkExtent2D &){} ///<窗口大小改变
|
virtual void OnResize(const VkExtent2D &){} ///<窗口大小改变
|
||||||
|
|
||||||
virtual void OnPreFrame(){} ///<帧绘制前回调
|
virtual void OnPreFrame(){} ///<帧绘制前回调
|
||||||
virtual void OnExecute(const double,RenderCmdBuffer *){}
|
virtual void OnExecute(const double,RenderCmdBuffer *){}
|
||||||
virtual void OnPostFrame(){} ///<帧绘制后回调
|
virtual void OnPostFrame(){} ///<帧绘制后回调
|
||||||
};//class GraphModule
|
};//class GraphModule
|
||||||
|
|
||||||
#define GRAPH_MODULE_CONSTRUCT(name) public:\
|
#define GRAPH_MODULE_CONSTRUCT(name) public:\
|
||||||
NO_COPY_NO_MOVE(name##Module) \
|
NO_COPY_NO_MOVE(name) \
|
||||||
static const AnsiIDName &GetModuleName() \
|
static const AnsiIDName &GetModuleName() \
|
||||||
{ \
|
{ \
|
||||||
static const AnsiIDName id_name(#name); \
|
static const AnsiIDName id_name(#name); \
|
||||||
return id_name; \
|
return id_name; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
name##Module(GraphModuleManager *gmm):GraphModule(gmm,GetModuleName()){}
|
name(GraphModuleManager *gmm):GraphModule(gmm,GetModuleName()){}
|
||||||
|
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -28,7 +28,15 @@ public:
|
|||||||
if(!gmm)
|
if(!gmm)
|
||||||
return(nullptr);
|
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
|
};//template<typename T> class RegistryGraphModule:public GraphModuleFactory
|
||||||
|
|
||||||
|
@ -298,10 +298,8 @@ SOURCE_GROUP("Render Framework\\Module" FILES ${GRAPH_MODULE_HEADER}
|
|||||||
|
|
||||||
SET(SG_MANAGER_HEADER_PATH ${SG_INCLUDE_PATH}/manager)
|
SET(SG_MANAGER_HEADER_PATH ${SG_INCLUDE_PATH}/manager)
|
||||||
|
|
||||||
SET(GRAPH_MANAGER_HEADER ${SG_MANAGER_HEADER_PATH}/GraphManager.h
|
SET(GRAPH_MANAGER_HEADER ${SG_MANAGER_HEADER_PATH}/TextureManager.h)
|
||||||
${SG_MANAGER_HEADER_PATH}/TextureManager.h)
|
SET(GRAPH_MANAGER_SOURCE manager/TextureManager.cpp)
|
||||||
SET(GRAPH_MANAGER_SOURCE manager/GraphManager.cpp
|
|
||||||
manager/TextureManager.cpp)
|
|
||||||
|
|
||||||
SOURCE_GROUP("Render Framework\\Manager" FILES ${GRAPH_MANAGER_HEADER} ${GRAPH_MANAGER_SOURCE})
|
SOURCE_GROUP("Render Framework\\Manager" FILES ${GRAPH_MANAGER_HEADER} ${GRAPH_MANAGER_SOURCE})
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include<hgl/graph/VKDevice.h>
|
#include<hgl/graph/VKDevice.h>
|
||||||
|
#include<hgl/graph/manager/TextureManager.h>
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
VkFramebuffer CreateVulkanFramebuffer(VkDevice device,RenderPass *rp,const VkExtent2D &extent,VkImageView *attachments,const uint attachmentCount)
|
VkFramebuffer CreateVulkanFramebuffer(VkDevice device,RenderPass *rp,const VkExtent2D &extent,VkImageView *attachments,const uint attachmentCount)
|
||||||
@ -20,7 +21,7 @@ VkFramebuffer CreateVulkanFramebuffer(VkDevice device,RenderPass *rp,const VkExt
|
|||||||
return fb;
|
return fb;
|
||||||
}
|
}
|
||||||
|
|
||||||
Framebuffer *GPUDevice::CreateFBO(RenderPass *rp,ImageView **color_list,const uint color_count,ImageView *depth)
|
Framebuffer *TextureManager::CreateFBO(RenderPass *rp,ImageView **color_list,const uint color_count,ImageView *depth)
|
||||||
{
|
{
|
||||||
uint att_count=color_count;
|
uint att_count=color_count;
|
||||||
|
|
||||||
@ -70,12 +71,12 @@ Framebuffer *GPUDevice::CreateFBO(RenderPass *rp,ImageView **color_list,const ui
|
|||||||
extent.height=color_list[0]->GetExtent().height;
|
extent.height=color_list[0]->GetExtent().height;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkFramebuffer fbo=CreateVulkanFramebuffer(GetDevice(),rp,extent,attachments,att_count);
|
VkFramebuffer fbo=CreateVulkanFramebuffer(GetVkDevice(),rp,extent,attachments,att_count);
|
||||||
|
|
||||||
if(!fbo)
|
if(!fbo)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
return(new Framebuffer(GetDevice(),fbo,extent,rp->GetVkRenderPass(),color_count,depth));
|
return(new Framebuffer(GetVkDevice(),fbo,extent,rp->GetVkRenderPass(),color_count,depth));
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
//Framebuffer *GPUDevice::CreateFBO(RenderPass *rp,List<ImageView *> &color,ImageView *depth)
|
//Framebuffer *GPUDevice::CreateFBO(RenderPass *rp,List<ImageView *> &color,ImageView *depth)
|
||||||
@ -89,7 +90,7 @@ Framebuffer *GPUDevice::CreateFBO(RenderPass *rp,ImageView **color_list,const ui
|
|||||||
// return CreateFBO(rp,color.GetData(),color.GetCount(),depth);
|
// return CreateFBO(rp,color.GetData(),color.GetCount(),depth);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
Framebuffer *GPUDevice::CreateFBO(RenderPass *rp,ImageView *color,ImageView *depth)
|
Framebuffer *TextureManager::CreateFBO(RenderPass *rp,ImageView *color,ImageView *depth)
|
||||||
{
|
{
|
||||||
if(!rp)return(nullptr);
|
if(!rp)return(nullptr);
|
||||||
if(!color&&!depth)return(nullptr);
|
if(!color&&!depth)return(nullptr);
|
||||||
@ -97,7 +98,7 @@ Framebuffer *GPUDevice::CreateFBO(RenderPass *rp,ImageView *color,ImageView *dep
|
|||||||
return CreateFBO(rp,&color,1,depth);
|
return CreateFBO(rp,&color,1,depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
Framebuffer *GPUDevice::CreateFBO(RenderPass *rp,ImageView *iv)
|
Framebuffer *TextureManager::CreateFBO(RenderPass *rp,ImageView *iv)
|
||||||
{
|
{
|
||||||
if(!rp)return(nullptr);
|
if(!rp)return(nullptr);
|
||||||
if(!iv)return(nullptr);
|
if(!iv)return(nullptr);
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#include<hgl/graph/VKDevice.h>
|
#include<hgl/graph/VKDevice.h>
|
||||||
|
#include<hgl/graph/manager/TextureManager.h>
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
RenderTarget *GPUDevice::CreateRT(const FramebufferInfo *fbi,RenderPass *rp,const uint32_t fence_count)
|
RenderTarget *TextureManager::CreateRT(const FramebufferInfo *fbi,RenderPass *rp,const uint32_t fence_count)
|
||||||
{
|
{
|
||||||
if(!fbi)return(nullptr);
|
if(!fbi)return(nullptr);
|
||||||
if(!rp)return(nullptr);
|
if(!rp)return(nullptr);
|
||||||
@ -46,7 +47,7 @@ RenderTarget *GPUDevice::CreateRT(const FramebufferInfo *fbi,RenderPass *rp,cons
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderTarget *GPUDevice::CreateRT(const FramebufferInfo *fbi,const uint32_t fence_count)
|
RenderTarget *TextureManager::CreateRT(const FramebufferInfo *fbi,const uint32_t fence_count)
|
||||||
{
|
{
|
||||||
if(!fbi)return(nullptr);
|
if(!fbi)return(nullptr);
|
||||||
|
|
||||||
@ -57,25 +58,4 @@ RenderTarget *GPUDevice::CreateRT(const FramebufferInfo *fbi,const uint32_t fenc
|
|||||||
return CreateRT(fbi,rp,fence_count);
|
return CreateRT(fbi,rp,fence_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
RTSwapchain *GPUDevice::CreateSwapchainRenderTarget()
|
|
||||||
{
|
|
||||||
Swapchain *sc=CreateSwapchain(attr->surface_caps.currentExtent);
|
|
||||||
|
|
||||||
if(!sc)
|
|
||||||
return(nullptr);
|
|
||||||
|
|
||||||
DeviceQueue *q=CreateQueue(sc->color_count,false);
|
|
||||||
Semaphore *render_complete_semaphore=CreateGPUSemaphore();
|
|
||||||
Semaphore *present_complete_semaphore=CreateGPUSemaphore();
|
|
||||||
|
|
||||||
RTSwapchain *srt=new RTSwapchain( attr->device,
|
|
||||||
sc,
|
|
||||||
q,
|
|
||||||
render_complete_semaphore,
|
|
||||||
present_complete_semaphore,
|
|
||||||
device_render_pass
|
|
||||||
);
|
|
||||||
|
|
||||||
return srt;
|
|
||||||
}
|
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -4,12 +4,26 @@
|
|||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
|
|
||||||
TextureManager::TextureManager(GPUDevice *dev):GraphManager(dev)
|
bool TextureManager::Init()
|
||||||
{
|
{
|
||||||
|
GPUDevice *dev=GetDevice();
|
||||||
|
|
||||||
|
if(!dev)
|
||||||
|
return(false);
|
||||||
|
|
||||||
texture_cmd_buf=dev->CreateTextureCommandBuffer(GetPhysicalDevice()->GetDeviceName()+AnsiString(":TexCmdBuffer"));
|
texture_cmd_buf=dev->CreateTextureCommandBuffer(GetPhysicalDevice()->GetDeviceName()+AnsiString(":TexCmdBuffer"));
|
||||||
|
|
||||||
|
if(!texture_cmd_buf)
|
||||||
|
return(false);
|
||||||
|
|
||||||
texture_queue=dev->CreateQueue();
|
texture_queue=dev->CreateQueue();
|
||||||
|
|
||||||
|
if(!texture_queue)
|
||||||
|
return(false);
|
||||||
|
|
||||||
texture_serial=0;
|
texture_serial=0;
|
||||||
|
|
||||||
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureManager::~TextureManager()
|
TextureManager::~TextureManager()
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
#include<hgl/graph/module/GraphModuleFactory.h>
|
#include<hgl/graph/module/GraphModuleFactory.h>
|
||||||
|
#include<hgl/graph/manager/TextureManager.h>
|
||||||
#include<hgl/graph/module/SwapchainModule.h>
|
#include<hgl/graph/module/SwapchainModule.h>
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
|
|
||||||
void RegistryCommonGraphModule()
|
void RegistryCommonGraphModule()
|
||||||
{
|
{
|
||||||
|
REGISTRY_GRAPH_MODULE(TextureManager)
|
||||||
REGISTRY_GRAPH_MODULE(Swapchain)
|
REGISTRY_GRAPH_MODULE(Swapchain)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user