preparing newly GraphModule/RenderModule/RenderPassManager/RenderFramework
This commit is contained in:
46
inc/hgl/graph/RenderFramework.h
Normal file
46
inc/hgl/graph/RenderFramework.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/platform/Window.h>
|
||||
#include<hgl/graph/module/GraphModuleManager.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class RenderPassManager;
|
||||
|
||||
class RenderFramework:public io::WindowEvent
|
||||
{
|
||||
OSString app_name;
|
||||
|
||||
Window * win =nullptr;
|
||||
VulkanInstance * inst =nullptr;
|
||||
|
||||
GPUDevice * device =nullptr;
|
||||
|
||||
protected:
|
||||
|
||||
GraphModuleManager *module_manager =nullptr;
|
||||
|
||||
RenderPassManager * render_pass_manager =nullptr;
|
||||
RenderPass * device_render_pass =nullptr;
|
||||
|
||||
public:
|
||||
|
||||
Window * GetWindow (){return win;}
|
||||
GPUDevice * GetDevice (){return device;}
|
||||
|
||||
public:
|
||||
|
||||
GraphModuleManager *GetModuleManager(){return module_manager;}
|
||||
RenderPassManager * GetRenderPassManager(){return render_pass_manager;}
|
||||
|
||||
public:
|
||||
|
||||
RenderFramework(const OSString &);
|
||||
virtual ~RenderFramework();
|
||||
|
||||
virtual bool Init(uint w,uint h);
|
||||
|
||||
};//class RenderFramework
|
||||
|
||||
VK_NAMESPACE_END
|
@@ -37,7 +37,6 @@ class GPUDevice
|
||||
|
||||
private:
|
||||
|
||||
DeviceRenderPassManage *render_pass_manage;
|
||||
RenderPass *device_render_pass;
|
||||
|
||||
RTSwapchain *sc_rt;
|
||||
@@ -231,8 +230,6 @@ public: //Command Buffer 相关
|
||||
|
||||
public:
|
||||
|
||||
RenderPass * AcquireRenderPass( const RenderbufferInfo *,const uint subpass_count=2);
|
||||
|
||||
Fence * CreateFence(bool);
|
||||
Semaphore * CreateGPUSemaphore();
|
||||
|
||||
|
@@ -29,7 +29,7 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
friend class DeviceRenderPassManage;
|
||||
friend class RenderPassManager;
|
||||
|
||||
RenderPass(VkDevice d,VkPipelineCache pc,VkRenderPass rp,const List<VkFormat> &cf,VkFormat df);
|
||||
|
||||
|
58
inc/hgl/graph/module/GraphModule.h
Normal file
58
inc/hgl/graph/module/GraphModule.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/type/TypeInfo.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class GraphModule
|
||||
{
|
||||
GPUDevice *device;
|
||||
|
||||
public:
|
||||
|
||||
GPUDevice * GetDevice () {return device;} ///<取得GPU设备
|
||||
VkDevice GetVkDevice ()const {return device->GetDevice();} ///<取得VkDevice
|
||||
const GPUPhysicalDevice * GetPhysicalDevice ()const {return device->GetPhysicalDevice();} ///<取得物理设备
|
||||
GPUDeviceAttribute *GetDeviceAttribute () {return device->GetDeviceAttribute();} ///<取得设备属性
|
||||
|
||||
public:
|
||||
|
||||
GraphModule(GPUDevice *dev){device=dev;}
|
||||
virtual ~GraphModule()=default;
|
||||
|
||||
virtual const size_t GetTypeHash()const noexcept=0;
|
||||
virtual const AnsiString &GetName()const=0;
|
||||
};//class GraphModule
|
||||
|
||||
template<typename T> class GraphModuleInherit:public GraphModule
|
||||
{
|
||||
AnsiString manager_name;
|
||||
|
||||
public:
|
||||
|
||||
const size_t GetTypeHash()const noexcept override
|
||||
{
|
||||
return typeid(T).hash_code();
|
||||
}
|
||||
|
||||
const AnsiString &GetName()const override
|
||||
{
|
||||
return manager_name;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
GraphModuleInherit(GPUDevice *dev,const AnsiString &name):GraphModule(dev)
|
||||
{
|
||||
manager_name=name;
|
||||
}
|
||||
|
||||
virtual ~GraphModuleInherit()=default;
|
||||
};//class GraphModuleInherit
|
||||
|
||||
#define GRAPH_MODULE_CLASS(class_name) class class_name:public GraphModuleInherit<class_name>
|
||||
|
||||
#define GRAPH_MODULE_CONSTRUCT(class_name) class_name::class_name(GPUDevice *dev):GraphModuleInherit<class_name>(dev,#class_name)
|
||||
|
||||
VK_NAMESPACE_END
|
41
inc/hgl/graph/module/GraphModuleManager.h
Normal file
41
inc/hgl/graph/module/GraphModuleManager.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/Map.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class GraphModule;
|
||||
|
||||
class GraphModuleManager
|
||||
{
|
||||
GPUDevice *device;
|
||||
|
||||
protected:
|
||||
|
||||
List<GraphModule *> module_list;
|
||||
Map<size_t,GraphModule *> module_map;
|
||||
|
||||
public:
|
||||
|
||||
GraphModuleManager(GPUDevice *dev){device=dev;}
|
||||
|
||||
virtual ~GraphModuleManager();
|
||||
|
||||
public:
|
||||
|
||||
GPUDevice * GetDevice() {return device;} ///<取得GPU设备
|
||||
|
||||
public:
|
||||
|
||||
GraphModule * GetModule(const size_t type_hash) {return GetObjectFromList(module_map,type_hash);} ///<取得指定类型的模块
|
||||
template<typename T>
|
||||
T * GetModule() {return(GetModule(typeid(T).hash_code()));} ///<取得指定类型的模块
|
||||
|
||||
bool ConatainsModule(const size_t &type_hash)const {return module_map.ContainsKey(type_hash);} ///<确认是否包含指定类型的模块
|
||||
|
||||
bool Registry(GraphModule *); ///<注册一个模块
|
||||
bool Unregistry(GraphModule *); ///<注销一个模块
|
||||
};//class GraphModuleManager
|
||||
|
||||
VK_NAMESPACE_END
|
27
inc/hgl/graph/module/RenderModule.h
Normal file
27
inc/hgl/graph/module/RenderModule.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/module/GraphModule.h>
|
||||
#include<hgl/type/Size2.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* 渲染模块基类
|
||||
*/
|
||||
class RenderModule:public GraphModule
|
||||
{
|
||||
VkExtent2D current_extent;
|
||||
|
||||
public:
|
||||
|
||||
NO_COPY_NO_MOVE(RenderModule)
|
||||
|
||||
using GraphModule::GraphModule;
|
||||
virtual ~RenderModule()=default;
|
||||
|
||||
virtual void OnResize(const VkExtent2D &ext){current_extent=ext;} ///<窗口大小改变
|
||||
|
||||
virtual void OnFrameRender(const double,RenderCmdBuffer *)=0; ///<帧绘制回调
|
||||
};//class RenderModule
|
||||
|
||||
VK_NAMESPACE_END
|
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/module/GraphModule.h>
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/util/hash/Hash.h>
|
||||
|
||||
@@ -12,9 +12,8 @@ inline util::Hash *CreateRenderPassHash()
|
||||
return util::CreateHash(util::HASH::xxH3_128);
|
||||
}
|
||||
|
||||
class DeviceRenderPassManage
|
||||
class RenderPassManager:public GraphModuleInherit<RenderPassManager>
|
||||
{
|
||||
VkDevice device;
|
||||
VkPipelineCache pipeline_cache;
|
||||
|
||||
util::Hash *hash;
|
||||
@@ -23,10 +22,8 @@ class DeviceRenderPassManage
|
||||
|
||||
private:
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
DeviceRenderPassManage(VkDevice,VkPipelineCache);
|
||||
~DeviceRenderPassManage();
|
||||
RenderPassManager(GPUDevice *);
|
||||
~RenderPassManager();
|
||||
|
||||
private:
|
||||
|
||||
@@ -35,6 +32,9 @@ private:
|
||||
const List<VkSubpassDependency> &dependency,
|
||||
const RenderbufferInfo *);
|
||||
|
||||
public:
|
||||
|
||||
RenderPass * AcquireRenderPass( const RenderbufferInfo *,const uint subpass_count=2);
|
||||
};//class DeviceRenderPassManage
|
||||
};//class RenderPassManager
|
||||
|
||||
VK_NAMESPACE_END
|
Reference in New Issue
Block a user