2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VKRenderTarget.h>
|
|
|
|
|
#include<hgl/graph/VKDevice.h>
|
|
|
|
|
#include<hgl/graph/VKSwapchain.h>
|
|
|
|
|
#include<hgl/graph/VKCommandBuffer.h>
|
|
|
|
|
#include<hgl/graph/VKSemaphore.h>
|
2020-10-27 22:43:24 +08:00
|
|
|
|
#include<hgl/graph/VKFramebuffer.h>
|
2019-06-19 21:12:39 +08:00
|
|
|
|
|
|
|
|
|
VK_NAMESPACE_BEGIN
|
2020-10-27 22:43:24 +08:00
|
|
|
|
RenderTarget::RenderTarget(GPUDevice *dev,Framebuffer *_fb,const uint32_t fence_count):GPUQueue(dev,dev->GetGraphicsQueue(),fence_count)
|
2019-07-16 19:59:53 +08:00
|
|
|
|
{
|
2020-10-26 21:51:30 +08:00
|
|
|
|
render_pass=nullptr;
|
|
|
|
|
fbo=_fb;
|
2019-07-16 19:59:53 +08:00
|
|
|
|
|
2020-10-26 21:51:30 +08:00
|
|
|
|
if(fbo)
|
|
|
|
|
color_count=fbo->GetColorCount();
|
2020-10-18 17:50:54 +08:00
|
|
|
|
else
|
|
|
|
|
color_count=0;
|
|
|
|
|
|
|
|
|
|
color_textures=nullptr;
|
2020-10-17 22:12:16 +08:00
|
|
|
|
depth_texture=nullptr;
|
2021-09-14 20:31:15 +08:00
|
|
|
|
render_complete_semaphore=dev->CreateGPUSemaphore();
|
2019-07-16 19:59:53 +08:00
|
|
|
|
}
|
2019-07-19 18:25:05 +08:00
|
|
|
|
|
2020-10-27 22:43:24 +08:00
|
|
|
|
RenderTarget::RenderTarget(GPUDevice *dev,RenderPass *_rp,Framebuffer *_fb,Texture2D **ctl,const uint32_t cc,Texture2D *dt,const uint32_t fence_count):GPUQueue(dev,dev->GetGraphicsQueue(),fence_count)
|
2019-07-16 19:59:53 +08:00
|
|
|
|
{
|
2020-10-26 21:51:30 +08:00
|
|
|
|
render_pass=_rp;
|
|
|
|
|
fbo=_fb;
|
2020-10-18 18:35:03 +08:00
|
|
|
|
|
|
|
|
|
depth_texture=dt;
|
2020-10-17 14:16:52 +08:00
|
|
|
|
|
2020-10-18 17:50:54 +08:00
|
|
|
|
color_count=cc;
|
|
|
|
|
if(color_count>0)
|
|
|
|
|
{
|
|
|
|
|
color_textures=new Texture2D *[color_count];
|
2020-10-26 22:16:38 +08:00
|
|
|
|
hgl_cpy(color_textures,ctl,color_count);
|
2020-10-18 18:35:03 +08:00
|
|
|
|
|
|
|
|
|
extent.width=color_textures[0]->GetWidth();
|
|
|
|
|
extent.height=color_textures[0]->GetHeight();
|
2020-10-18 17:50:54 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
color_textures=nullptr;
|
2020-10-18 18:35:03 +08:00
|
|
|
|
|
|
|
|
|
if(depth_texture)
|
|
|
|
|
{
|
|
|
|
|
extent.width=depth_texture->GetWidth();
|
|
|
|
|
extent.height=depth_texture->GetHeight();
|
|
|
|
|
}
|
2020-10-18 17:50:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-14 20:31:15 +08:00
|
|
|
|
render_complete_semaphore=dev->CreateGPUSemaphore();
|
2019-07-16 19:59:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-15 22:13:15 +08:00
|
|
|
|
RenderTarget::~RenderTarget()
|
2020-10-27 18:11:39 +08:00
|
|
|
|
{
|
|
|
|
|
pipeline_list.Clear();
|
2020-10-17 14:16:52 +08:00
|
|
|
|
SAFE_CLEAR(depth_texture);
|
2020-10-18 17:50:54 +08:00
|
|
|
|
SAFE_CLEAR_OBJECT_ARRAY(color_textures,color_count);
|
2020-10-17 22:12:16 +08:00
|
|
|
|
|
|
|
|
|
SAFE_CLEAR(render_complete_semaphore);
|
2020-10-26 21:51:30 +08:00
|
|
|
|
SAFE_CLEAR(fbo);
|
|
|
|
|
SAFE_CLEAR(render_pass);
|
2020-10-15 22:13:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-09 15:37:00 +08:00
|
|
|
|
bool RenderTarget::Submit(RenderCmdBuffer *command_buffer,GPUSemaphore *present_complete_semaphore)
|
2020-10-17 22:12:16 +08:00
|
|
|
|
{
|
2020-10-21 12:39:22 +08:00
|
|
|
|
return this->GPUQueue::Submit(*command_buffer,present_complete_semaphore,render_complete_semaphore);
|
2020-10-17 22:12:16 +08:00
|
|
|
|
}
|
2020-10-18 13:55:12 +08:00
|
|
|
|
VK_NAMESPACE_END
|