moved device_render_pass to RenderFramework from GPUDevice.
This commit is contained in:
parent
911afc06f6
commit
ff8222c256
2
CMCore
2
CMCore
@ -1 +1 @@
|
||||
Subproject commit 5aad7d81419d02141b3b3f53661e2c8e3e763163
|
||||
Subproject commit 1bcd213b63ed080863fd4a51eaec5fe6205e7589
|
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/platform/Window.h>
|
||||
@ -29,11 +29,14 @@ public:
|
||||
Window * GetWindow (){return win;}
|
||||
GPUDevice * GetDevice (){return device;}
|
||||
|
||||
RenderPass * GetRenderPass (){return device_render_pass;}
|
||||
|
||||
public:
|
||||
|
||||
GraphModuleManager *GetModuleManager(){return module_manager;}
|
||||
RenderPassManager * GetRenderPassManager(){return render_pass_manager;}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
RenderFramework(const OSString &);
|
||||
@ -41,6 +44,12 @@ public:
|
||||
|
||||
virtual bool Init(uint w,uint h);
|
||||
|
||||
public: // event
|
||||
|
||||
void OnResize(uint w,uint h);
|
||||
void OnActive(bool);
|
||||
void OnClose();
|
||||
|
||||
};//class RenderFramework
|
||||
|
||||
VK_NAMESPACE_END
|
||||
|
@ -37,15 +37,10 @@ class GPUDevice
|
||||
|
||||
private:
|
||||
|
||||
RenderPass *device_render_pass;
|
||||
|
||||
RTSwapchain *sc_rt;
|
||||
|
||||
RTSwapchain *CreateSwapchainRenderTarget();
|
||||
|
||||
void InitRenderPassManage();
|
||||
void ClearRenderPassManage();
|
||||
|
||||
private:
|
||||
|
||||
VkCommandBuffer CreateCommandBuffer(const AnsiString &);
|
||||
@ -78,8 +73,6 @@ public:
|
||||
const VkColorSpaceKHR GetColorSpace ()const {return attr->surface_format.colorSpace;}
|
||||
VkQueue GetGraphicsQueue () {return attr->graphics_queue;}
|
||||
|
||||
RenderPass * GetRenderPass () {return device_render_pass;}
|
||||
|
||||
RTSwapchain * GetSwapchainRT () {return sc_rt;}
|
||||
|
||||
const VkExtent2D & GetSwapchainSize ()const {return sc_rt->GetExtent();}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/Map.h>
|
||||
@ -28,14 +28,30 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
GraphModule * GetModule(const size_t type_hash) {return GetObjectFromList(module_map,type_hash);} ///<取得指定类型的模块
|
||||
GraphModule * Get(const size_t type_hash) {return GetObjectFromList(module_map,type_hash);} ///<取得指定类型的模块
|
||||
template<typename T>
|
||||
T * GetModule() {return(GetModule(typeid(T).hash_code()));} ///<取得指定类型的模块
|
||||
T * Get() {return((T *)Get(typeid(T).hash_code()));} ///<取得指定类型的模块
|
||||
|
||||
bool ConatainsModule(const size_t &type_hash)const {return module_map.ContainsKey(type_hash);} ///<确认是否包含指定类型的模块
|
||||
bool Contains(const size_t &type_hash)const {return module_map.ContainsKey(type_hash);} ///<确认是否包含指定类型的模块
|
||||
|
||||
template<typename T>
|
||||
bool Contains()const{return Contains(typeid(T).hash_code());} ///<确认是否包含指定类型的模块
|
||||
|
||||
bool Registry(GraphModule *); ///<注册一个模块
|
||||
bool Unregistry(GraphModule *); ///<注销一个模块
|
||||
|
||||
template<typename T>
|
||||
T *GetOrCreate() ///<注册一个模块
|
||||
{
|
||||
if(Contains<T>())
|
||||
return Get<T>();
|
||||
|
||||
T *result=new T(device);
|
||||
|
||||
Registry(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
};//class GraphModuleManager
|
||||
|
||||
VK_NAMESPACE_END
|
||||
|
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/module/GraphModule.h>
|
||||
#include<hgl/type/Map.h>
|
||||
@ -25,6 +25,8 @@ private:
|
||||
RenderPassManager(GPUDevice *);
|
||||
~RenderPassManager();
|
||||
|
||||
friend class GraphModuleManager;
|
||||
|
||||
private:
|
||||
|
||||
RenderPass * CreateRenderPass( const List<VkAttachmentDescription> &desc_list,
|
||||
|
2
res
2
res
@ -1 +1 @@
|
||||
Subproject commit e1a36d78f0eead5f6bb65493432c4690637b991d
|
||||
Subproject commit 475d8ad43ceee084cd24f5d0bed59de9f6aa36fd
|
@ -183,7 +183,6 @@ SET(VK_DEVICE_SOURCE Vulkan/VKDeviceMemory.cpp
|
||||
Vulkan/VKDeviceMaterial.cpp
|
||||
Vulkan/VKDeviceFramebuffer.cpp
|
||||
Vulkan/VKDeviceSwapchain.cpp
|
||||
Vulkan/VKDeviceRenderPass.cpp
|
||||
Vulkan/VKDeviceRenderTarget.cpp)
|
||||
|
||||
SET(VK_PHYSICAL_DEVICE_SOURCE ${SG_INCLUDE_PATH}/VKPhysicalDevice.h
|
||||
|
@ -1,4 +1,8 @@
|
||||
#include<hgl/graph/RenderFramework.h>
|
||||
#include<hgl/graph/RenderFramework.h>
|
||||
#include<hgl/graph/VKInstance.h>
|
||||
#include<hgl/graph/VKDeviceCreater.h>
|
||||
#include<hgl/graph/module/RenderPassManager.h>
|
||||
#include<hgl/log/Logger.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
@ -9,6 +13,19 @@ namespace
|
||||
{
|
||||
static int RENDER_FRAMEWORK_COUNT=0;
|
||||
|
||||
hgl::graph::VulkanInstance *CreateVulkanInstance(const AnsiString &app_name)
|
||||
{
|
||||
CreateInstanceLayerInfo cili;
|
||||
|
||||
hgl_zero(cili);
|
||||
|
||||
cili.lunarg.standard_validation = true;
|
||||
cili.khronos.validation = true;
|
||||
|
||||
InitVulkanInstanceProperties();
|
||||
|
||||
return CreateInstance(app_name,nullptr,&cili);
|
||||
}
|
||||
}//namespace
|
||||
|
||||
RenderFramework::RenderFramework(const OSString &an)
|
||||
@ -20,6 +37,9 @@ RenderFramework::RenderFramework(const OSString &an)
|
||||
|
||||
RenderFramework::~RenderFramework()
|
||||
{
|
||||
SAFE_CLEAR(device_render_pass);
|
||||
SAFE_CLEAR(module_manager)
|
||||
|
||||
--RENDER_FRAMEWORK_COUNT;
|
||||
|
||||
if(RENDER_FRAMEWORK_COUNT==0)
|
||||
@ -36,10 +56,74 @@ bool RenderFramework::Init(uint w,uint h)
|
||||
return(false);
|
||||
|
||||
logger::InitLogger(app_name);
|
||||
|
||||
InitNativeWindowSystem();
|
||||
}
|
||||
|
||||
++RENDER_FRAMEWORK_COUNT;
|
||||
|
||||
win=CreateRenderWindow(app_name);
|
||||
if(!win)
|
||||
return(false);
|
||||
|
||||
if(!win->Create(w,h))
|
||||
{
|
||||
delete win;
|
||||
win=nullptr;
|
||||
return(false);
|
||||
}
|
||||
|
||||
inst=CreateVulkanInstance(ToAnsiString(app_name));
|
||||
if(!inst)
|
||||
return(false);
|
||||
|
||||
VulkanHardwareRequirement vh_req;
|
||||
|
||||
device=CreateRenderDevice(inst,win,&vh_req);
|
||||
|
||||
if(!device)
|
||||
return(false);
|
||||
|
||||
win->Join(this);
|
||||
|
||||
OnResize(w,h);
|
||||
|
||||
module_manager=new GraphModuleManager(device);
|
||||
|
||||
render_pass_manager=module_manager->GetOrCreate<RenderPassManager>();
|
||||
|
||||
if(!render_pass_manager)
|
||||
return(false);
|
||||
|
||||
{
|
||||
auto *attr=GetDevice()->GetDeviceAttribute();
|
||||
|
||||
SwapchainRenderbufferInfo rbi(attr->surface_format.format,attr->physical_device->GetDepthFormat());
|
||||
|
||||
device_render_pass=render_pass_manager->AcquireRenderPass(&rbi);
|
||||
|
||||
if(!device_render_pass)
|
||||
return(false);
|
||||
|
||||
#ifdef _DEBUG
|
||||
if(attr->debug_utils)
|
||||
attr->debug_utils->SetRenderPass(device_render_pass->GetVkRenderPass(),"MainDeviceRenderPass");
|
||||
#endif//_DEBUG
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void RenderFramework::OnResize(uint w,uint h)
|
||||
{
|
||||
io::WindowEvent::OnResize(w,h);
|
||||
}
|
||||
|
||||
void RenderFramework::OnActive(bool)
|
||||
{
|
||||
}
|
||||
|
||||
void RenderFramework::OnClose()
|
||||
{
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include<hgl/graph/VKRenderPass.h>
|
||||
#include<hgl/graph/VKFramebuffer.h>
|
||||
#include<hgl/graph/VKDescriptorSet.h>
|
||||
#include<hgl/graph/VKDeviceRenderPassManage.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
GPUDevice::GPUDevice(GPUDeviceAttribute *da)
|
||||
@ -18,8 +17,6 @@ GPUDevice::GPUDevice(GPUDeviceAttribute *da)
|
||||
texture_queue=nullptr;
|
||||
texture_cmd_buf=nullptr;
|
||||
|
||||
InitRenderPassManage();
|
||||
|
||||
sc_rt=nullptr;
|
||||
Resize(attr->surface_caps.currentExtent);
|
||||
|
||||
@ -29,8 +26,6 @@ GPUDevice::GPUDevice(GPUDeviceAttribute *da)
|
||||
|
||||
GPUDevice::~GPUDevice()
|
||||
{
|
||||
ClearRenderPassManage();
|
||||
|
||||
SAFE_CLEAR(sc_rt);
|
||||
|
||||
SAFE_CLEAR(texture_queue);
|
||||
|
@ -1,25 +0,0 @@
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VKDeviceAttribute.h>
|
||||
#include<hgl/graph/VKPhysicalDevice.h>
|
||||
#include<hgl/graph/manager/RenderPassManage.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
void GPUDevice::InitRenderPassManage()
|
||||
{
|
||||
render_pass_manage=new RenderPassManager(this);
|
||||
|
||||
SwapchainRenderbufferInfo rbi(attr->surface_format.format,attr->physical_device->GetDepthFormat());
|
||||
|
||||
device_render_pass=render_pass_manage->AcquireRenderPass(&rbi);
|
||||
|
||||
#ifdef _DEBUG
|
||||
if(attr->debug_utils)
|
||||
attr->debug_utils->SetRenderPass(device_render_pass->GetVkRenderPass(),"MainDeviceRenderPass");
|
||||
#endif//_DEBUG
|
||||
}
|
||||
|
||||
void GPUDevice::ClearRenderPassManage()
|
||||
{
|
||||
SAFE_CLEAR(render_pass_manage);
|
||||
}
|
||||
VK_NAMESPACE_END
|
Loading…
x
Reference in New Issue
Block a user