preparing newly GraphModule/RenderModule/RenderPassManager/RenderFramework
This commit is contained in:
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
|
40
inc/hgl/graph/module/RenderPassManager.h
Normal file
40
inc/hgl/graph/module/RenderPassManager.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/module/GraphModule.h>
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/util/hash/Hash.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
using RenderPassHASHCode=util::HashCode<128/8>;
|
||||
inline util::Hash *CreateRenderPassHash()
|
||||
{
|
||||
return util::CreateHash(util::HASH::xxH3_128);
|
||||
}
|
||||
|
||||
class RenderPassManager:public GraphModuleInherit<RenderPassManager>
|
||||
{
|
||||
VkPipelineCache pipeline_cache;
|
||||
|
||||
util::Hash *hash;
|
||||
|
||||
Map<RenderPassHASHCode,RenderPass *> RenderPassList;
|
||||
|
||||
private:
|
||||
|
||||
RenderPassManager(GPUDevice *);
|
||||
~RenderPassManager();
|
||||
|
||||
private:
|
||||
|
||||
RenderPass * CreateRenderPass( const List<VkAttachmentDescription> &desc_list,
|
||||
const List<VkSubpassDescription> &subpass,
|
||||
const List<VkSubpassDependency> &dependency,
|
||||
const RenderbufferInfo *);
|
||||
|
||||
public:
|
||||
|
||||
RenderPass * AcquireRenderPass( const RenderbufferInfo *,const uint subpass_count=2);
|
||||
};//class RenderPassManager
|
||||
|
||||
VK_NAMESPACE_END
|
Reference in New Issue
Block a user