2019-06-19 21:12:39 +08:00
|
|
|
|
#ifndef HGL_GRAPH_VULKAN_RENDER_TARGET_INCLUDE
|
|
|
|
|
#define HGL_GRAPH_VULKAN_RENDER_TARGET_INCLUDE
|
|
|
|
|
|
|
|
|
|
#include<hgl/graph/vulkan/VK.h>
|
2019-07-16 20:57:17 +08:00
|
|
|
|
#include<hgl/graph/vulkan/VKFence.h>
|
2019-06-19 21:12:39 +08:00
|
|
|
|
#include<hgl/graph/vulkan/VKRenderPass.h>
|
|
|
|
|
#include<hgl/graph/vulkan/VKFramebuffer.h>
|
2019-07-16 19:59:53 +08:00
|
|
|
|
#include<hgl/graph/vulkan/VKSwapchain.h>
|
2019-06-19 21:12:39 +08:00
|
|
|
|
VK_NAMESPACE_BEGIN
|
2019-07-16 19:59:53 +08:00
|
|
|
|
class SubmitQueue
|
2019-06-19 21:12:39 +08:00
|
|
|
|
{
|
2019-07-16 19:59:53 +08:00
|
|
|
|
protected:
|
|
|
|
|
|
2019-06-19 21:12:39 +08:00
|
|
|
|
Device *device;
|
2019-07-16 19:59:53 +08:00
|
|
|
|
VkQueue queue;
|
|
|
|
|
|
|
|
|
|
uint32_t current_fence;
|
|
|
|
|
ObjectList<Fence> fence_list;
|
2019-06-19 21:12:39 +08:00
|
|
|
|
|
2019-07-16 19:59:53 +08:00
|
|
|
|
VkSubmitInfo submit_info;
|
2019-06-19 21:12:39 +08:00
|
|
|
|
|
2019-07-16 19:59:53 +08:00
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
SubmitQueue(Device *dev,VkQueue q,const uint32_t fence_count=1);
|
|
|
|
|
virtual ~SubmitQueue();
|
|
|
|
|
|
2020-01-23 21:00:35 +08:00
|
|
|
|
bool Wait(const bool wait_wall=true,const uint64_t time_out=HGL_NANO_SEC_PER_SEC);
|
2019-07-16 21:21:20 +08:00
|
|
|
|
bool Submit(const VkCommandBuffer &cmd_buf,vulkan::Semaphore *wait_sem,vulkan::Semaphore *complete_sem);
|
|
|
|
|
bool Submit(const VkCommandBuffer *cmd_buf,const uint32_t count,vulkan::Semaphore *wait_sem,vulkan::Semaphore *complete_sem);
|
2019-07-16 19:59:53 +08:00
|
|
|
|
};//class SumbitQueue
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 渲染目标
|
|
|
|
|
*/
|
|
|
|
|
class RenderTarget:public SubmitQueue
|
|
|
|
|
{
|
|
|
|
|
protected:
|
2019-06-19 21:12:39 +08:00
|
|
|
|
|
2019-07-16 19:59:53 +08:00
|
|
|
|
Framebuffer *fb;
|
2019-07-16 20:22:29 +08:00
|
|
|
|
|
|
|
|
|
VkExtent2D extent;
|
2019-06-19 21:12:39 +08:00
|
|
|
|
|
2019-07-16 19:59:53 +08:00
|
|
|
|
protected:
|
2019-06-19 21:12:39 +08:00
|
|
|
|
|
|
|
|
|
friend class Device;
|
|
|
|
|
|
2019-07-16 19:59:53 +08:00
|
|
|
|
RenderTarget(Device *dev,Framebuffer *_fb,const uint32_t fence_count=1);
|
2019-06-19 21:12:39 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2019-07-16 19:59:53 +08:00
|
|
|
|
virtual ~RenderTarget()=default;
|
|
|
|
|
|
2019-07-16 20:22:29 +08:00
|
|
|
|
const VkExtent2D & GetExtent()const{return extent;}
|
|
|
|
|
virtual const VkRenderPass GetRenderPass()const{return fb->GetRenderPass();}
|
|
|
|
|
virtual const uint32_t GetColorCount()const{return fb->GetColorCount();}
|
2019-07-16 21:32:29 +08:00
|
|
|
|
virtual const VkFramebuffer GetFramebuffer()const{return fb->GetFramebuffer();}
|
2019-07-16 19:59:53 +08:00
|
|
|
|
};//class RenderTarget
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 交换链专用渲染目标
|
|
|
|
|
*/
|
|
|
|
|
class SwapchainRenderTarget:public RenderTarget
|
|
|
|
|
{
|
|
|
|
|
Swapchain *swapchain;
|
|
|
|
|
VkSwapchainKHR vk_swapchain;
|
|
|
|
|
VkPresentInfoKHR present_info;
|
2019-06-19 21:12:39 +08:00
|
|
|
|
|
2019-07-16 19:59:53 +08:00
|
|
|
|
RenderPass *main_rp=nullptr;
|
2019-06-19 21:12:39 +08:00
|
|
|
|
|
2019-07-16 19:59:53 +08:00
|
|
|
|
uint32_t swap_chain_count;
|
|
|
|
|
|
|
|
|
|
uint32_t current_frame;
|
|
|
|
|
ObjectList<Framebuffer> render_frame;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
SwapchainRenderTarget(Device *dev,Swapchain *sc);
|
|
|
|
|
~SwapchainRenderTarget();
|
|
|
|
|
|
2019-07-16 20:22:29 +08:00
|
|
|
|
const VkRenderPass GetRenderPass()const override{return *main_rp;}
|
2019-07-16 21:32:29 +08:00
|
|
|
|
const VkFramebuffer GetFramebuffer()const override{return render_frame[current_frame]->GetFramebuffer();}
|
2019-07-16 20:22:29 +08:00
|
|
|
|
VkFramebuffer GetFramebuffer(const uint32_t index){return render_frame[index]->GetFramebuffer();}
|
2019-07-16 19:59:53 +08:00
|
|
|
|
|
2019-07-16 20:22:29 +08:00
|
|
|
|
const uint32_t GetColorCount()const override{return 1;}
|
|
|
|
|
const uint32_t GetImageCount()const{return swap_chain_count;}
|
2019-07-16 19:59:53 +08:00
|
|
|
|
|
2019-07-16 20:22:29 +08:00
|
|
|
|
const uint32_t GetCurrentFrameIndices()const{return current_frame;}
|
2019-07-16 19:59:53 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 请求下一帧画面的索引
|
|
|
|
|
* @param present_complete_semaphore 推送完成信号
|
|
|
|
|
*/
|
|
|
|
|
int AcquireNextImage(vulkan::Semaphore *present_complete_semaphore);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 推送后台画面到前台
|
|
|
|
|
* @param render_complete_semaphore 渲染完成信号
|
|
|
|
|
*/
|
|
|
|
|
bool PresentBackbuffer(vulkan::Semaphore *render_complete_semaphore);
|
|
|
|
|
};//class SwapchainRenderTarget:public RenderTarget
|
2019-06-19 21:12:39 +08:00
|
|
|
|
VK_NAMESPACE_END
|
|
|
|
|
#endif//HGL_GRAPH_VULKAN_RENDER_TARGET_INCLUDE
|