slit RenderTarget, created VKRenderTargetData.h/.cpp, VKRenderTargetSingle.h/.cpp, VKRenderTargetMultiFrame.h, VKRenderTargetSwapchain.h
This commit is contained in:
parent
62e9d2f904
commit
0706f27354
@ -1,5 +1,4 @@
|
|||||||
#ifndef HGL_GRAPH_VULKAN_INCLUDE
|
#pragma once
|
||||||
#define HGL_GRAPH_VULKAN_INCLUDE
|
|
||||||
|
|
||||||
#include<hgl/type/List.h>
|
#include<hgl/type/List.h>
|
||||||
#include<hgl/math/Math.h>
|
#include<hgl/math/Math.h>
|
||||||
@ -49,7 +48,7 @@ class Framebuffer;
|
|||||||
struct Swapchain;
|
struct Swapchain;
|
||||||
class IRenderTarget;
|
class IRenderTarget;
|
||||||
class RenderTarget;
|
class RenderTarget;
|
||||||
class MFRenderTarget;
|
class MultiFrameRenderTarget;
|
||||||
class SwapchainRenderTarget;
|
class SwapchainRenderTarget;
|
||||||
|
|
||||||
struct CopyBufferToImageInfo;
|
struct CopyBufferToImageInfo;
|
||||||
@ -192,5 +191,5 @@ inline void copy(VkExtent3D &e3d,const VkExtent2D &e2d,const uint32 depth=1)
|
|||||||
e3d.height =e2d.height;
|
e3d.height =e2d.height;
|
||||||
e3d.depth =depth;
|
e3d.depth =depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
#endif//HGL_GRAPH_VULKAN_INCLUDE
|
|
||||||
|
@ -36,8 +36,6 @@ using RenderableID =int;
|
|||||||
using SamplerID =int;
|
using SamplerID =int;
|
||||||
using StaticMeshID =int;
|
using StaticMeshID =int;
|
||||||
|
|
||||||
class VertexAttribData;
|
|
||||||
|
|
||||||
using ShaderModuleMapByName=ObjectMap<AnsiString,ShaderModule>;
|
using ShaderModuleMapByName=ObjectMap<AnsiString,ShaderModule>;
|
||||||
constexpr const size_t VK_SHADER_STAGE_TYPE_COUNT=20;//GetBitOffset((uint32_t)VK_SHADER_STAGE_CLUSTER_CULLING_BIT_HUAWEI)+1;
|
constexpr const size_t VK_SHADER_STAGE_TYPE_COUNT=20;//GetBitOffset((uint32_t)VK_SHADER_STAGE_CLUSTER_CULLING_BIT_HUAWEI)+1;
|
||||||
|
|
||||||
|
@ -16,16 +16,6 @@ class RenderFramework;
|
|||||||
|
|
||||||
using UBOViewportInfo=DeviceBufferMap<graph::ViewportInfo>;
|
using UBOViewportInfo=DeviceBufferMap<graph::ViewportInfo>;
|
||||||
|
|
||||||
/**
|
|
||||||
* RenderTarget 存在几种情况:
|
|
||||||
*
|
|
||||||
* 1.正常单帧渲染目标,即只有一帧的数据,每次渲染都是当前帧
|
|
||||||
*
|
|
||||||
* 2.多帧渲染目标,即有多帧数据,每次渲染都是指定帧,典型的是Swapchain
|
|
||||||
*
|
|
||||||
* 所以RenderTarget的其实是一个多态类,根据不同的情况,有不同的实现
|
|
||||||
*/
|
|
||||||
|
|
||||||
class IRenderTarget
|
class IRenderTarget
|
||||||
{
|
{
|
||||||
RenderFramework *render_framework;
|
RenderFramework *render_framework;
|
||||||
@ -89,226 +79,4 @@ public:
|
|||||||
}
|
}
|
||||||
};//class IRenderTarget
|
};//class IRenderTarget
|
||||||
|
|
||||||
struct RenderTargetData
|
|
||||||
{
|
|
||||||
Framebuffer * fbo;
|
|
||||||
DeviceQueue * queue;
|
|
||||||
Semaphore * render_complete_semaphore;
|
|
||||||
|
|
||||||
RenderCmdBuffer * cmd_buf;
|
|
||||||
|
|
||||||
uint32_t color_count; ///<颜色成分数量
|
|
||||||
Texture2D ** color_textures; ///<颜色成分纹理列表
|
|
||||||
Texture2D * depth_texture; ///<深度成分纹理
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Texture2D *GetColorTexture(const uint32_t index)
|
|
||||||
{
|
|
||||||
if(index>=color_count)
|
|
||||||
return(nullptr);
|
|
||||||
|
|
||||||
return color_textures[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void Clear();
|
|
||||||
};//struct RenderTargetData
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单帧渲染目标
|
|
||||||
*/
|
|
||||||
class RenderTarget:public IRenderTarget
|
|
||||||
{
|
|
||||||
RenderTargetData *data;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
friend class SwapchainModule;
|
|
||||||
friend class RenderTargetManager;
|
|
||||||
|
|
||||||
RenderTarget(RenderFramework *rf,RenderTargetData *rtd):IRenderTarget(rf,rtd->fbo->GetExtent())
|
|
||||||
{
|
|
||||||
data=rtd;
|
|
||||||
|
|
||||||
data->cmd_buf->SetDescriptorBinding(GetDescriptorBinding());
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual ~RenderTarget() override
|
|
||||||
{
|
|
||||||
if(data)
|
|
||||||
{
|
|
||||||
data->Clear();
|
|
||||||
delete data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Framebuffer * GetFramebuffer ()override{return data->fbo;}
|
|
||||||
RenderPass * GetRenderPass ()override{return data->fbo->GetRenderPass();}
|
|
||||||
|
|
||||||
uint32_t GetColorCount ()override{return data->color_count;}
|
|
||||||
|
|
||||||
bool hasDepth ()override{return data->depth_texture;}
|
|
||||||
|
|
||||||
Texture2D * GetColorTexture (const int index=0) override{return data->GetColorTexture(index);}
|
|
||||||
Texture2D * GetDepthTexture () override{return data->depth_texture;}
|
|
||||||
|
|
||||||
public: // Command Buffer
|
|
||||||
|
|
||||||
DeviceQueue * GetQueue ()override{return data->queue;}
|
|
||||||
Semaphore * GetRenderCompleteSemaphore()override{return data->render_complete_semaphore;}
|
|
||||||
|
|
||||||
RenderCmdBuffer * GetRenderCmdBuffer ()override{return data->cmd_buf;}
|
|
||||||
|
|
||||||
virtual bool Submit (Semaphore *wait_sem)override
|
|
||||||
{
|
|
||||||
if(!data)
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
return data->queue->Submit(data->cmd_buf,wait_sem,data->render_complete_semaphore);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WaitQueue ()override{return data->queue->WaitQueue();}
|
|
||||||
bool WaitFence ()override{return data->queue->WaitFence();}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual RenderCmdBuffer *BeginRender()override
|
|
||||||
{
|
|
||||||
if(!data->cmd_buf)
|
|
||||||
return(nullptr);
|
|
||||||
|
|
||||||
data->cmd_buf->Begin();
|
|
||||||
data->cmd_buf->SetDescriptorBinding(GetDescriptorBinding());
|
|
||||||
data->cmd_buf->BindFramebuffer(data->fbo);
|
|
||||||
return data->cmd_buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void EndRender() override
|
|
||||||
{
|
|
||||||
if(!data->cmd_buf)
|
|
||||||
return;
|
|
||||||
|
|
||||||
data->cmd_buf->End();
|
|
||||||
}
|
|
||||||
};//class RenderTarget
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 多帧渲染目标
|
|
||||||
*/
|
|
||||||
class MFRenderTarget:public IRenderTarget
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
|
|
||||||
uint32_t frame_number;
|
|
||||||
uint32_t current_frame;
|
|
||||||
|
|
||||||
RenderTarget **rt_list;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
friend class RenderTargetManager;
|
|
||||||
|
|
||||||
MFRenderTarget(RenderFramework *rf,const uint32_t fn,RenderTarget **rtl):IRenderTarget(rf,rtl[0]->GetFramebuffer()->GetExtent())
|
|
||||||
{
|
|
||||||
frame_number=fn;
|
|
||||||
current_frame=0;
|
|
||||||
|
|
||||||
rt_list=rtl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual ~MFRenderTarget() override
|
|
||||||
{
|
|
||||||
SAFE_CLEAR_OBJECT_ARRAY_OBJECT(rt_list,frame_number);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void NextFrame()
|
|
||||||
{
|
|
||||||
++current_frame;
|
|
||||||
|
|
||||||
if(current_frame>=frame_number)
|
|
||||||
current_frame=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t GetCurrentFrameIndices ()const{return current_frame;}
|
|
||||||
uint32_t GetFrameCount ()const{return frame_number;}
|
|
||||||
RenderTarget * GetCurrentFrameRenderTarget (){return rt_list[current_frame];}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Framebuffer * GetFramebuffer ()override{return rt_list[current_frame]->GetFramebuffer();}
|
|
||||||
RenderPass * GetRenderPass ()override{return rt_list[current_frame]->GetRenderPass();}
|
|
||||||
|
|
||||||
uint32_t GetColorCount ()override{return rt_list[current_frame]->GetColorCount();}
|
|
||||||
|
|
||||||
Texture2D * GetColorTexture (const int index=0) override{return rt_list[current_frame]->GetColorTexture(index);}
|
|
||||||
Texture2D * GetDepthTexture () override{return rt_list[current_frame]->GetDepthTexture();}
|
|
||||||
|
|
||||||
|
|
||||||
bool hasDepth ()override{return rt_list[current_frame]->hasDepth();}
|
|
||||||
|
|
||||||
public: // Command Buffer
|
|
||||||
|
|
||||||
DeviceQueue * GetQueue ()override{return rt_list[current_frame]->GetQueue();}
|
|
||||||
Semaphore * GetRenderCompleteSemaphore()override{return rt_list[current_frame]->GetRenderCompleteSemaphore();}
|
|
||||||
RenderCmdBuffer * GetRenderCmdBuffer ()override{return rt_list[current_frame]->GetRenderCmdBuffer();}
|
|
||||||
|
|
||||||
Framebuffer * GetFramebuffer (const uint32_t index){return rt_list[index]->GetFramebuffer();}
|
|
||||||
RenderCmdBuffer * GetRenderCmdBuffer (const uint32_t index){return rt_list[index]->GetRenderCmdBuffer();}
|
|
||||||
|
|
||||||
virtual bool Submit ()override{return rt_list[current_frame]->Submit(nullptr);}
|
|
||||||
|
|
||||||
virtual bool Submit (Semaphore *wait_sem) override
|
|
||||||
{
|
|
||||||
return rt_list[current_frame]->Submit(wait_sem);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WaitQueue ()override{return rt_list[current_frame]->WaitQueue();}
|
|
||||||
bool WaitFence ()override{return rt_list[current_frame]->WaitFence();}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual RenderCmdBuffer *BeginRender()override
|
|
||||||
{
|
|
||||||
//std::cout<<"Begin Render frame="<<current_frame<<std::endl;
|
|
||||||
return rt_list[current_frame]->BeginRender();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void EndRender() override
|
|
||||||
{
|
|
||||||
//std::cout<<"End Render frame="<<current_frame<<std::endl;
|
|
||||||
rt_list[current_frame]->EndRender();
|
|
||||||
}
|
|
||||||
};//class MFRenderTarget
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 交换链专用渲染目标
|
|
||||||
*/
|
|
||||||
class SwapchainRenderTarget:public MFRenderTarget
|
|
||||||
{
|
|
||||||
Swapchain *swapchain;
|
|
||||||
PresentInfo present_info;
|
|
||||||
|
|
||||||
Semaphore *present_complete_semaphore=nullptr;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
SwapchainRenderTarget(RenderFramework *rf,Swapchain *sc,Semaphore *pcs,RenderTarget **rtl);
|
|
||||||
|
|
||||||
friend class SwapchainModule;
|
|
||||||
friend class RenderTargetManager;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
~SwapchainRenderTarget() override;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
IRenderTarget *AcquireNextImage(); ///<获取下一帧的索引
|
|
||||||
|
|
||||||
bool Submit()override; ///<提交当前帧的渲染,交推送到前台
|
|
||||||
};//class SwapchainRenderTarget:public RenderTarget
|
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
32
inc/hgl/graph/VKRenderTargetData.h
Normal file
32
inc/hgl/graph/VKRenderTargetData.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include<hgl/graph/VKFramebuffer.h>
|
||||||
|
|
||||||
|
VK_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
struct RenderTargetData
|
||||||
|
{
|
||||||
|
Framebuffer * fbo;
|
||||||
|
DeviceQueue * queue;
|
||||||
|
Semaphore * render_complete_semaphore;
|
||||||
|
|
||||||
|
RenderCmdBuffer * cmd_buf;
|
||||||
|
|
||||||
|
uint32_t color_count; ///<颜色成分数量
|
||||||
|
Texture2D ** color_textures; ///<颜色成分纹理列表
|
||||||
|
Texture2D * depth_texture; ///<深度成分纹理
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Texture2D *GetColorTexture(const uint32_t index)
|
||||||
|
{
|
||||||
|
if(index>=color_count)
|
||||||
|
return(nullptr);
|
||||||
|
|
||||||
|
return color_textures[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Clear();
|
||||||
|
};//struct RenderTargetData
|
||||||
|
|
||||||
|
VK_NAMESPACE_END
|
95
inc/hgl/graph/VKRenderTargetMultiFrame.h
Normal file
95
inc/hgl/graph/VKRenderTargetMultiFrame.h
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include<hgl/graph/VKRenderTarget.h>
|
||||||
|
#include<hgl/graph/VKRenderTargetData.h>
|
||||||
|
|
||||||
|
VK_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多帧渲染目标
|
||||||
|
*/
|
||||||
|
class MultiFrameRenderTarget:public IRenderTarget
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
uint32_t frame_number;
|
||||||
|
uint32_t current_frame;
|
||||||
|
|
||||||
|
RenderTargetData *rtd_list;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
friend class RenderTargetManager;
|
||||||
|
|
||||||
|
MultiFrameRenderTarget(RenderFramework *rf,const uint32_t fn,RenderTargetData *rtl):IRenderTarget(rf,rtl[0].fbo->GetExtent())
|
||||||
|
{
|
||||||
|
frame_number=fn;
|
||||||
|
current_frame=0;
|
||||||
|
|
||||||
|
rtd_list=rtl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual ~MultiFrameRenderTarget() override;
|
||||||
|
|
||||||
|
virtual void NextFrame()
|
||||||
|
{
|
||||||
|
++current_frame;
|
||||||
|
|
||||||
|
if(current_frame>=frame_number)
|
||||||
|
current_frame=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t GetCurrentFrameIndices ()const{return current_frame;}
|
||||||
|
uint32_t GetFrameCount ()const{return frame_number;}
|
||||||
|
RenderTarget * GetCurrentFrameRenderTarget (){return rt_list[current_frame];}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Framebuffer * GetFramebuffer ()override{return rt_list[current_frame]->GetFramebuffer();}
|
||||||
|
RenderPass * GetRenderPass ()override{return rt_list[current_frame]->GetRenderPass();}
|
||||||
|
|
||||||
|
uint32_t GetColorCount ()override{return rt_list[current_frame]->GetColorCount();}
|
||||||
|
|
||||||
|
Texture2D * GetColorTexture (const int index=0) override{return rt_list[current_frame]->GetColorTexture(index);}
|
||||||
|
Texture2D * GetDepthTexture () override{return rt_list[current_frame]->GetDepthTexture();}
|
||||||
|
|
||||||
|
|
||||||
|
bool hasDepth ()override{return rt_list[current_frame]->hasDepth();}
|
||||||
|
|
||||||
|
public: // Command Buffer
|
||||||
|
|
||||||
|
DeviceQueue * GetQueue ()override{return rt_list[current_frame]->GetQueue();}
|
||||||
|
Semaphore * GetRenderCompleteSemaphore()override{return rt_list[current_frame]->GetRenderCompleteSemaphore();}
|
||||||
|
RenderCmdBuffer * GetRenderCmdBuffer ()override{return rt_list[current_frame]->GetRenderCmdBuffer();}
|
||||||
|
|
||||||
|
Framebuffer * GetFramebuffer (const uint32_t index){return rt_list[index]->GetFramebuffer();}
|
||||||
|
RenderCmdBuffer * GetRenderCmdBuffer (const uint32_t index){return rt_list[index]->GetRenderCmdBuffer();}
|
||||||
|
|
||||||
|
virtual bool Submit ()override{return rt_list[current_frame]->Submit(nullptr);}
|
||||||
|
|
||||||
|
virtual bool Submit (Semaphore *wait_sem) override
|
||||||
|
{
|
||||||
|
return rt_list[current_frame]->Submit(wait_sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WaitQueue ()override{return rt_list[current_frame]->WaitQueue();}
|
||||||
|
bool WaitFence ()override{return rt_list[current_frame]->WaitFence();}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual RenderCmdBuffer *BeginRender()override
|
||||||
|
{
|
||||||
|
//std::cout<<"Begin Render frame="<<current_frame<<std::endl;
|
||||||
|
return rt_list[current_frame]->BeginRender();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void EndRender() override
|
||||||
|
{
|
||||||
|
//std::cout<<"End Render frame="<<current_frame<<std::endl;
|
||||||
|
rt_list[current_frame]->EndRender();
|
||||||
|
}
|
||||||
|
};//class MultiFrameRenderTarget
|
||||||
|
|
||||||
|
VK_NAMESPACE_END
|
88
inc/hgl/graph/VKRenderTargetSingle.h
Normal file
88
inc/hgl/graph/VKRenderTargetSingle.h
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include<hgl/graph/VKRenderTarget.h>
|
||||||
|
#include<hgl/graph/VKRenderTargetData.h>
|
||||||
|
|
||||||
|
VK_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单帧渲染目标
|
||||||
|
*/
|
||||||
|
class RenderTarget:public IRenderTarget
|
||||||
|
{
|
||||||
|
RenderTargetData *data;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
friend class SwapchainModule;
|
||||||
|
friend class RenderTargetManager;
|
||||||
|
|
||||||
|
RenderTarget(RenderFramework *rf,RenderTargetData *rtd):IRenderTarget(rf,rtd->fbo->GetExtent())
|
||||||
|
{
|
||||||
|
data=rtd;
|
||||||
|
|
||||||
|
data->cmd_buf->SetDescriptorBinding(GetDescriptorBinding());
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual ~RenderTarget() override
|
||||||
|
{
|
||||||
|
if(data)
|
||||||
|
{
|
||||||
|
data->Clear();
|
||||||
|
delete data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Framebuffer * GetFramebuffer ()override{return data->fbo;}
|
||||||
|
RenderPass * GetRenderPass ()override{return data->fbo->GetRenderPass();}
|
||||||
|
|
||||||
|
uint32_t GetColorCount ()override{return data->color_count;}
|
||||||
|
|
||||||
|
bool hasDepth ()override{return data->depth_texture;}
|
||||||
|
|
||||||
|
Texture2D * GetColorTexture (const int index=0) override{return data->GetColorTexture(index);}
|
||||||
|
Texture2D * GetDepthTexture () override{return data->depth_texture;}
|
||||||
|
|
||||||
|
public: // Command Buffer
|
||||||
|
|
||||||
|
DeviceQueue * GetQueue ()override{return data->queue;}
|
||||||
|
Semaphore * GetRenderCompleteSemaphore()override{return data->render_complete_semaphore;}
|
||||||
|
|
||||||
|
RenderCmdBuffer * GetRenderCmdBuffer ()override{return data->cmd_buf;}
|
||||||
|
|
||||||
|
virtual bool Submit (Semaphore *wait_sem)override
|
||||||
|
{
|
||||||
|
if(!data)
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
return data->queue->Submit(data->cmd_buf,wait_sem,data->render_complete_semaphore);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WaitQueue ()override{return data->queue->WaitQueue();}
|
||||||
|
bool WaitFence ()override{return data->queue->WaitFence();}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual RenderCmdBuffer *BeginRender()override
|
||||||
|
{
|
||||||
|
if(!data->cmd_buf)
|
||||||
|
return(nullptr);
|
||||||
|
|
||||||
|
data->cmd_buf->Begin();
|
||||||
|
data->cmd_buf->SetDescriptorBinding(GetDescriptorBinding());
|
||||||
|
data->cmd_buf->BindFramebuffer(data->fbo);
|
||||||
|
return data->cmd_buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void EndRender() override
|
||||||
|
{
|
||||||
|
if(!data->cmd_buf)
|
||||||
|
return;
|
||||||
|
|
||||||
|
data->cmd_buf->End();
|
||||||
|
}
|
||||||
|
};//class RenderTarget
|
||||||
|
|
||||||
|
VK_NAMESPACE_END
|
35
inc/hgl/graph/VKRenderTargetSwapchain.h
Normal file
35
inc/hgl/graph/VKRenderTargetSwapchain.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include<hgl/graph/VKRenderTargetMultiFrame.h>
|
||||||
|
|
||||||
|
VK_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 交换链专用渲染目标
|
||||||
|
*/
|
||||||
|
class SwapchainRenderTarget:public MultiFrameRenderTarget
|
||||||
|
{
|
||||||
|
Swapchain *swapchain;
|
||||||
|
PresentInfo present_info;
|
||||||
|
|
||||||
|
Semaphore *present_complete_semaphore=nullptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
SwapchainRenderTarget(RenderFramework *rf,Swapchain *sc,Semaphore *pcs,RenderTarget **rtl);
|
||||||
|
|
||||||
|
friend class SwapchainModule;
|
||||||
|
friend class RenderTargetManager;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
~SwapchainRenderTarget() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
IRenderTarget *AcquireNextImage(); ///<获取下一帧的索引
|
||||||
|
|
||||||
|
bool Submit()override; ///<提交当前帧的渲染,交推送到前台
|
||||||
|
};//class SwapchainRenderTarget:public MultiFrameRenderTarget
|
||||||
|
|
||||||
|
VK_NAMESPACE_END
|
@ -4,4 +4,4 @@ add_subdirectory(SceneGraph)
|
|||||||
add_subdirectory(Work)
|
add_subdirectory(Work)
|
||||||
#add_subdirectory(Tools)
|
#add_subdirectory(Tools)
|
||||||
#add_subdirectory(GUI)
|
#add_subdirectory(GUI)
|
||||||
add_subdirectory(JoltPhysics/Build)
|
#add_subdirectory(JoltPhysics/Build)
|
||||||
|
@ -247,7 +247,6 @@ SET(VK_RENDER_CONTEXT_SOURCE ${SG_INCLUDE_PATH}/VKRenderContext.h
|
|||||||
SET(VK_RENDER_PASS_SOURCE ${SG_INCLUDE_PATH}/VKFramebuffer.h
|
SET(VK_RENDER_PASS_SOURCE ${SG_INCLUDE_PATH}/VKFramebuffer.h
|
||||||
${SG_INCLUDE_PATH}/VKPipeline.h
|
${SG_INCLUDE_PATH}/VKPipeline.h
|
||||||
${SG_INCLUDE_PATH}/VKRenderPass.h
|
${SG_INCLUDE_PATH}/VKRenderPass.h
|
||||||
${SG_INCLUDE_PATH}/VKRenderTarget.h
|
|
||||||
${SG_INCLUDE_PATH}/VKSwapchain.h
|
${SG_INCLUDE_PATH}/VKSwapchain.h
|
||||||
${SG_INCLUDE_PATH}/VKSemaphore.h
|
${SG_INCLUDE_PATH}/VKSemaphore.h
|
||||||
${SG_INCLUDE_PATH}/VKFence.h
|
${SG_INCLUDE_PATH}/VKFence.h
|
||||||
@ -259,13 +258,23 @@ SET(VK_RENDER_PASS_SOURCE ${SG_INCLUDE_PATH}/VKFramebuffer.h
|
|||||||
Vulkan/VKPipelineCache.cpp
|
Vulkan/VKPipelineCache.cpp
|
||||||
#Vulkan/VKSubpass.cpp
|
#Vulkan/VKSubpass.cpp
|
||||||
Vulkan/VKRenderPass.cpp
|
Vulkan/VKRenderPass.cpp
|
||||||
Vulkan/VKRenderTarget.cpp
|
|
||||||
Vulkan/VKSwapchainRenderTarget.cpp
|
|
||||||
Vulkan/VKSwapchain.cpp
|
Vulkan/VKSwapchain.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SOURCE_GROUP("Vulkan\\Render Pass" FILES ${VK_RENDER_PASS_SOURCE})
|
SOURCE_GROUP("Vulkan\\Render Pass" FILES ${VK_RENDER_PASS_SOURCE})
|
||||||
|
|
||||||
|
SET(VK_RENDER_TARGET_SOURCE ${SG_INCLUDE_PATH}/VKRenderTarget.h
|
||||||
|
${SG_INCLUDE_PATH}/VKRenderTargetData.h
|
||||||
|
${SG_INCLUDE_PATH}/VKRenderTargetSingle.h
|
||||||
|
${SG_INCLUDE_PATH}/VKRenderTargetMultiFrame.h
|
||||||
|
${SG_INCLUDE_PATH}/VKRenderTargetSwapchain.h
|
||||||
|
Vulkan/VKRenderTarget.cpp
|
||||||
|
Vulkan/VKRenderTargetData.cpp
|
||||||
|
Vulkan/VKSwapchainRenderTarget.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
SOURCE_GROUP("Vulkan\\Render Target" FILES ${VK_RENDER_TARGET_SOURCE})
|
||||||
|
|
||||||
SOURCE_GROUP("Vulkan\\Render Context" FILES ${VK_RENDER_CONTEXT_SOURCE})
|
SOURCE_GROUP("Vulkan\\Render Context" FILES ${VK_RENDER_CONTEXT_SOURCE})
|
||||||
|
|
||||||
SET(VK_CMD_BUFFER_SOURCE ${SG_INCLUDE_PATH}/VKCommandBuffer.h
|
SET(VK_CMD_BUFFER_SOURCE ${SG_INCLUDE_PATH}/VKCommandBuffer.h
|
||||||
@ -296,17 +305,29 @@ ENDIF(WIN32)
|
|||||||
IF(UNIX)
|
IF(UNIX)
|
||||||
|
|
||||||
IF(ANDROID)
|
IF(ANDROID)
|
||||||
SET(VULKAN_SURFACE_SOURCE Vulkan/Platform/AndroidVulkan.cpp)
|
SET(VULKAN_SURFACE_SOURCE Vulkan/platform/AndroidVulkan.cpp)
|
||||||
ELSE()
|
ELSE()
|
||||||
IF(APPLE)
|
IF(APPLE)
|
||||||
|
if(CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_OSX_SYSROOT MATCHES ".*iPhone.*")
|
||||||
|
message(STATUS "Targeting iOS")
|
||||||
|
set(VULKAN_SURFACE_SOURCE Vulkan/platform/iOSVulkan.cpp)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_OSX_SYSROOT MATCHES ".*MacOSX.*")
|
||||||
|
message(STATUS "Targeting macOS")
|
||||||
|
set(VULKAN_SURFACE_SOURCE Vulkan/platform/MacVulkan.cpp)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Unknown Apple platform")
|
||||||
|
endif()
|
||||||
ELSE()
|
ELSE()
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
SET(VULKAN_SURFACE_SOURCE Vulkan/Platform/XCBVulkan.cpp)
|
pkg_check_modules(WAYLAND_CLIENT wayland-client)
|
||||||
|
if(WAYLAND_CLIENT_FOUND)
|
||||||
|
message(STATUS "Targeting Wayland")
|
||||||
|
set(VULKAN_SURFACE_SOURCE Vulkan/platform/WaylandVulkan.cpp)
|
||||||
|
else()
|
||||||
|
message(STATUS "Targeting XCB")
|
||||||
|
set(VULKAN_SURFACE_SOURCE Vulkan/platform/XCBVulkan.cpp)
|
||||||
|
endif()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
ENDIF(UNIX)
|
ENDIF(UNIX)
|
||||||
@ -328,6 +349,7 @@ SET(VULKAN_RENDER_SOURCE ${VK_RR_SOURCE}
|
|||||||
${VK_TEXTURE_SOURCE}
|
${VK_TEXTURE_SOURCE}
|
||||||
${VK_MATERIAL_SOURCE}
|
${VK_MATERIAL_SOURCE}
|
||||||
${VK_RENDER_PASS_SOURCE}
|
${VK_RENDER_PASS_SOURCE}
|
||||||
|
${VK_RENDER_TARGET_SOURCE}
|
||||||
#${VK_RENDER_CONTEXT_SOURCE}
|
#${VK_RENDER_CONTEXT_SOURCE}
|
||||||
${VK_CMD_BUFFER_SOURCE}
|
${VK_CMD_BUFFER_SOURCE}
|
||||||
${VK_RENDERABLE_SOURCE}
|
${VK_RENDERABLE_SOURCE}
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
#include<hgl/graph/VKRenderTarget.h>
|
#include<hgl/graph/VKRenderTarget.h>
|
||||||
#include<hgl/graph/VKDevice.h>
|
|
||||||
#include<hgl/graph/VKSemaphore.h>
|
|
||||||
#include<hgl/graph/VKFramebuffer.h>
|
|
||||||
#include<hgl/graph/RenderFramework.h>
|
#include<hgl/graph/RenderFramework.h>
|
||||||
#include<hgl/graph/VKBuffer.h>
|
#include<hgl/graph/VKBuffer.h>
|
||||||
|
|
||||||
@ -37,13 +34,4 @@ void IRenderTarget::OnResize(const VkExtent2D &ext)
|
|||||||
ubo_vp_info->Update();
|
ubo_vp_info->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTargetData::Clear()
|
|
||||||
{
|
|
||||||
SAFE_CLEAR(queue);
|
|
||||||
SAFE_CLEAR(render_complete_semaphore);
|
|
||||||
SAFE_CLEAR(fbo);
|
|
||||||
SAFE_CLEAR_OBJECT_ARRAY_OBJECT(color_textures,color_count);
|
|
||||||
SAFE_CLEAR(depth_texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
17
src/SceneGraph/Vulkan/VKRenderTargetData.cpp
Normal file
17
src/SceneGraph/Vulkan/VKRenderTargetData.cpp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include<hgl/graph/VKRenderTargetData.h>
|
||||||
|
#include<hgl/graph/VKDevice.h>
|
||||||
|
#include<hgl/graph/VKSemaphore.h>
|
||||||
|
#include<hgl/graph/VKFramebuffer.h>
|
||||||
|
|
||||||
|
VK_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
void RenderTargetData::Clear()
|
||||||
|
{
|
||||||
|
SAFE_CLEAR(queue);
|
||||||
|
SAFE_CLEAR(render_complete_semaphore);
|
||||||
|
SAFE_CLEAR(fbo);
|
||||||
|
SAFE_CLEAR_OBJECT_ARRAY_OBJECT(color_textures,color_count);
|
||||||
|
SAFE_CLEAR(depth_texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
VK_NAMESPACE_END
|
@ -4,7 +4,7 @@
|
|||||||
//#include<iostream>
|
//#include<iostream>
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
SwapchainRenderTarget::SwapchainRenderTarget(RenderFramework *rf,Swapchain *sc,Semaphore *pcs,RenderTarget **rtl):MFRenderTarget(rf,sc->image_count,rtl)
|
SwapchainRenderTarget::SwapchainRenderTarget(RenderFramework *rf,Swapchain *sc,Semaphore *pcs,RenderTarget **rtl):MultiFrameRenderTarget(rf,sc->image_count,rtl)
|
||||||
{
|
{
|
||||||
swapchain=sc;
|
swapchain=sc;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include<hgl/graph/module/RenderTargetManager.h>
|
#include<hgl/graph/module/RenderTargetManager.h>
|
||||||
#include<hgl/graph/VKRenderTarget.h>
|
#include<hgl/graph/VKRenderTargetSingle.h>
|
||||||
#include<hgl/graph/VKDevice.h>
|
#include<hgl/graph/VKDevice.h>
|
||||||
#include<hgl/graph/module/TextureManager.h>
|
#include<hgl/graph/module/TextureManager.h>
|
||||||
#include<hgl/graph/module/RenderPassManager.h>
|
#include<hgl/graph/module/RenderPassManager.h>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include<hgl/graph/VKDevice.h>
|
#include<hgl/graph/VKDevice.h>
|
||||||
#include<hgl/graph/VKSwapchain.h>
|
#include<hgl/graph/VKSwapchain.h>
|
||||||
#include<hgl/graph/VKDeviceAttribute.h>
|
#include<hgl/graph/VKDeviceAttribute.h>
|
||||||
#include<hgl/graph/VKRenderTarget.h>
|
#include<hgl/graph/VKRenderTargetSwapchain.h>
|
||||||
#include<hgl/graph/VKCommandBuffer.h>
|
#include<hgl/graph/VKCommandBuffer.h>
|
||||||
#include<hgl/graph/VKSemaphore.h>
|
#include<hgl/graph/VKSemaphore.h>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user