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