move QueueWaitIdle to SubmitQueue class.
This commit is contained in:
parent
c686cf70ec
commit
b833688f2a
@ -17,8 +17,9 @@ protected:
|
||||
Framebuffer *fb;
|
||||
|
||||
VkExtent2D extent;
|
||||
|
||||
CommandBuffer *command_buffer;
|
||||
|
||||
Semaphore * render_complete_semaphore =nullptr;
|
||||
CommandBuffer * command_buffer =nullptr;
|
||||
|
||||
protected:
|
||||
|
||||
@ -36,14 +37,17 @@ public:
|
||||
|
||||
virtual ~RenderTarget();
|
||||
|
||||
const VkExtent2D & GetExtent ()const {return extent;}
|
||||
CommandBuffer * GetCommandBuffer() {return command_buffer;}
|
||||
virtual const VkRenderPass GetRenderPass ()const {return fb->GetRenderPass();}
|
||||
virtual const uint32_t GetColorCount ()const {return fb->GetColorCount();}
|
||||
virtual const VkFramebuffer GetFramebuffer ()const {return fb->GetFramebuffer();}
|
||||
const VkExtent2D & GetExtent ()const {return extent;}
|
||||
Semaphore * GetCompleteSemaphore(){return render_complete_semaphore;}
|
||||
CommandBuffer * GetCommandBuffer () {return command_buffer;}
|
||||
virtual const VkRenderPass GetRenderPass ()const {return fb->GetRenderPass();}
|
||||
virtual const uint32_t GetColorCount ()const {return fb->GetColorCount();}
|
||||
virtual const VkFramebuffer GetFramebuffer ()const {return fb->GetFramebuffer();}
|
||||
|
||||
virtual Texture2D * GetColorTexture (const int index=0){return color_texture[index];}
|
||||
virtual Texture2D * GetDepthTexture (){return depth_texture;}
|
||||
virtual Texture2D * GetColorTexture (const int index=0){return color_texture[index];}
|
||||
virtual Texture2D * GetDepthTexture (){return depth_texture;}
|
||||
|
||||
virtual bool Submit (Semaphore *present_complete_semaphore=nullptr);
|
||||
};//class RenderTarget
|
||||
|
||||
/**
|
||||
|
@ -21,6 +21,7 @@ public:
|
||||
SubmitQueue(Device *dev,VkQueue q,const uint32_t fence_count=1);
|
||||
virtual ~SubmitQueue();
|
||||
|
||||
bool QueueWaitIdle();
|
||||
bool Wait(const bool wait_wall=true,const uint64_t time_out=HGL_NANO_SEC_PER_SEC);
|
||||
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);
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include<hgl/graph/vulkan/VKDevice.h>
|
||||
#include<hgl/graph/vulkan/VKSwapchain.h>
|
||||
#include<hgl/graph/vulkan/VKCommandBuffer.h>
|
||||
#include<hgl/graph/vulkan/VKSemaphore.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
namespace
|
||||
@ -14,7 +15,8 @@ RenderTarget::RenderTarget(Device *dev,Framebuffer *_fb,CommandBuffer *_cb,const
|
||||
fb=_fb;
|
||||
command_buffer=_cb;
|
||||
|
||||
depth_texture=nullptr;
|
||||
depth_texture=nullptr;
|
||||
render_complete_semaphore=dev->CreateSem();
|
||||
}
|
||||
|
||||
RenderTarget::RenderTarget(Device *dev,Framebuffer *_fb,CommandBuffer *_cb,Texture2D **ctl,const uint32_t cc,Texture2D *dt,const uint32_t fence_count):SubmitQueue(dev,dev->GetGraphicsQueue(),fence_count)
|
||||
@ -24,16 +26,23 @@ RenderTarget::RenderTarget(Device *dev,Framebuffer *_fb,CommandBuffer *_cb,Textu
|
||||
|
||||
color_texture.Add(ctl,cc);
|
||||
depth_texture=dt;
|
||||
render_complete_semaphore=dev->CreateSem();
|
||||
}
|
||||
|
||||
RenderTarget::~RenderTarget()
|
||||
{
|
||||
{
|
||||
SAFE_CLEAR(depth_texture);
|
||||
color_texture.Clear();
|
||||
|
||||
|
||||
SAFE_CLEAR(render_complete_semaphore);
|
||||
SAFE_CLEAR(command_buffer);
|
||||
}
|
||||
|
||||
bool RenderTarget::Submit(Semaphore *present_complete_semaphore)
|
||||
{
|
||||
return this->SubmitQueue::Submit(*command_buffer,present_complete_semaphore,render_complete_semaphore);
|
||||
}
|
||||
|
||||
SwapchainRenderTarget::SwapchainRenderTarget(Device *dev,Swapchain *sc):RenderTarget(dev,nullptr,nullptr,sc->GetImageCount())
|
||||
{
|
||||
swapchain=sc;
|
||||
@ -95,11 +104,6 @@ bool SwapchainRenderTarget::PresentBackbuffer(VkSemaphore *render_complete_semap
|
||||
}
|
||||
}
|
||||
|
||||
result=vkQueueWaitIdle(queue);
|
||||
|
||||
if(result!=VK_SUCCESS)
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
@ -26,11 +26,20 @@ SubmitQueue::~SubmitQueue()
|
||||
fence_list.Clear();
|
||||
}
|
||||
|
||||
bool SubmitQueue::QueueWaitIdle()
|
||||
{
|
||||
VkResult result=vkQueueWaitIdle(queue);
|
||||
|
||||
if(result!=VK_SUCCESS)
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool SubmitQueue::Wait(const bool wait_all,uint64_t time_out)
|
||||
{
|
||||
VkFence fence=*fence_list[current_fence];
|
||||
|
||||
VkResult result;
|
||||
VkFence fence=*fence_list[current_fence];
|
||||
|
||||
result=vkWaitForFences(device->GetDevice(),1,&fence,wait_all,time_out);
|
||||
result=vkResetFences(device->GetDevice(),1,&fence);
|
||||
|
Loading…
x
Reference in New Issue
Block a user