newly GPUQueue class and VKDevice::CreateQueue function.
This commit is contained in:
parent
57c10fdcba
commit
96dc95276b
@ -42,6 +42,8 @@ private:
|
|||||||
Swapchain *swapchain;
|
Swapchain *swapchain;
|
||||||
SwapchainRenderTarget *swapchainRT;
|
SwapchainRenderTarget *swapchainRT;
|
||||||
|
|
||||||
|
SwapchainRenderTarget *CreateSwapchainRT();
|
||||||
|
|
||||||
void InitRenderPassManage();
|
void InitRenderPassManage();
|
||||||
void ClearRenderPassManage();
|
void ClearRenderPassManage();
|
||||||
|
|
||||||
@ -221,6 +223,8 @@ public:
|
|||||||
GPUFence * CreateFence(bool);
|
GPUFence * CreateFence(bool);
|
||||||
GPUSemaphore * CreateGPUSemaphore();
|
GPUSemaphore * CreateGPUSemaphore();
|
||||||
|
|
||||||
|
GPUQueue * CreateQueue(const uint32_t fence_count=1,const bool create_signaled=false);
|
||||||
|
|
||||||
public: //FrameBuffer相关
|
public: //FrameBuffer相关
|
||||||
|
|
||||||
Framebuffer *CreateFramebuffer(RenderPass *rp,ImageView **color_list,const uint color_count,ImageView *depth);
|
Framebuffer *CreateFramebuffer(RenderPass *rp,ImageView **color_list,const uint color_count,ImageView *depth);
|
||||||
|
@ -8,19 +8,27 @@ class GPUQueue
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
GPUDevice *device;
|
VkDevice device;
|
||||||
VkQueue queue;
|
VkQueue queue;
|
||||||
|
|
||||||
uint32_t current_fence;
|
uint32_t current_fence;
|
||||||
ObjectList<GPUFence> fence_list;
|
GPUFence **fence_list;
|
||||||
|
uint32_t fence_count;
|
||||||
|
|
||||||
SubmitInfo submit_info;
|
SubmitInfo submit_info;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
friend class GPUDevice;
|
||||||
|
|
||||||
|
GPUQueue(VkDevice dev,VkQueue q,GPUFence **,const uint32_t fc);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GPUQueue(GPUDevice *dev,VkQueue q,const uint32_t fence_count=1);
|
|
||||||
virtual ~GPUQueue();
|
virtual ~GPUQueue();
|
||||||
|
|
||||||
|
VkResult Present(const VkPresentInfoKHR *pi){return vkQueuePresentKHR(queue,pi);}
|
||||||
|
|
||||||
bool WaitQueue();
|
bool WaitQueue();
|
||||||
bool WaitFence(const bool wait_all=true,const uint64_t time_out=HGL_NANO_SEC_PER_SEC);
|
bool WaitFence(const bool wait_all=true,const uint64_t time_out=HGL_NANO_SEC_PER_SEC);
|
||||||
bool Submit(const VkCommandBuffer &cmd_buf,GPUSemaphore *wait_sem,GPUSemaphore *complete_sem);
|
bool Submit(const VkCommandBuffer &cmd_buf,GPUSemaphore *wait_sem,GPUSemaphore *complete_sem);
|
||||||
|
@ -46,6 +46,9 @@ GPUDevice::GPUDevice(GPUDeviceAttribute *da)
|
|||||||
swapchainRT=nullptr;
|
swapchainRT=nullptr;
|
||||||
Resize(attr->surface_caps.currentExtent);
|
Resize(attr->surface_caps.currentExtent);
|
||||||
|
|
||||||
|
texture_cmd_buf=CreateTextureCommandBuffer();
|
||||||
|
texture_queue=CreateQueue();
|
||||||
|
|
||||||
LogSurfaceFormat(attr->surface_formats_list);
|
LogSurfaceFormat(attr->surface_formats_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,18 +70,12 @@ bool GPUDevice::Resize(const VkExtent2D &extent)
|
|||||||
SAFE_CLEAR(swapchainRT);
|
SAFE_CLEAR(swapchainRT);
|
||||||
SAFE_CLEAR(swapchain);
|
SAFE_CLEAR(swapchain);
|
||||||
|
|
||||||
SAFE_CLEAR(texture_queue);
|
attr->RefreshSurfaceCaps();
|
||||||
SAFE_CLEAR(texture_cmd_buf);
|
|
||||||
|
|
||||||
attr->Refresh();
|
if(!CreateSwapchain(attr->surface_caps.currentExtent))
|
||||||
|
|
||||||
if(!CreateSwapchain(extent))
|
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
texture_cmd_buf=CreateTextureCommandBuffer();
|
swapchainRT=CreateSwapchainRT();
|
||||||
texture_queue=new GPUQueue(this,attr->graphics_queue,1);
|
|
||||||
|
|
||||||
swapchainRT=new SwapchainRenderTarget(this,swapchain);
|
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
@ -149,4 +146,16 @@ GPUSemaphore *GPUDevice::CreateGPUSemaphore()
|
|||||||
|
|
||||||
return(new GPUSemaphore(attr->device,sem));
|
return(new GPUSemaphore(attr->device,sem));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GPUQueue *GPUDevice::CreateQueue(const uint32_t fence_count,const bool create_signaled)
|
||||||
|
{
|
||||||
|
if(fence_count<=0)return(nullptr);
|
||||||
|
|
||||||
|
GPUFence **fence_list=new GPUFence *[fence_count];
|
||||||
|
|
||||||
|
for(uint32_t i=0;i<fence_count;i++)
|
||||||
|
fence_list[i]=CreateFence(create_signaled);
|
||||||
|
|
||||||
|
return(new GPUQueue(attr->device,attr->graphics_queue,fence_list,fence_count));
|
||||||
|
}
|
||||||
VK_NAMESPACE_END
|
VK_NAMESPACE_END
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include<hgl/graph/VKQueue.h>
|
#include<hgl/graph/VKQueue.h>
|
||||||
#include<hgl/graph/VKDevice.h>
|
|
||||||
#include<hgl/graph/VKSemaphore.h>
|
#include<hgl/graph/VKSemaphore.h>
|
||||||
|
|
||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
@ -8,22 +7,21 @@ namespace
|
|||||||
const VkPipelineStageFlags pipe_stage_flags=VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
const VkPipelineStageFlags pipe_stage_flags=VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||||
}//namespace
|
}//namespace
|
||||||
|
|
||||||
GPUQueue::GPUQueue(GPUDevice *dev,VkQueue q,const uint32_t fence_count)
|
GPUQueue::GPUQueue(VkDevice dev,VkQueue q,GPUFence **fl,const uint32_t fc)
|
||||||
{
|
{
|
||||||
device=dev;
|
device=dev;
|
||||||
queue=q;
|
queue=q;
|
||||||
|
|
||||||
for(uint32_t i=0;i<fence_count;i++)
|
|
||||||
fence_list.Add(device->CreateFence(false));
|
|
||||||
|
|
||||||
current_fence=0;
|
current_fence=0;
|
||||||
|
fence_list=fl;
|
||||||
|
fence_count=fc;
|
||||||
|
|
||||||
submit_info.pWaitDstStageMask = &pipe_stage_flags;
|
submit_info.pWaitDstStageMask = &pipe_stage_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUQueue::~GPUQueue()
|
GPUQueue::~GPUQueue()
|
||||||
{
|
{
|
||||||
fence_list.Clear();
|
SAFE_CLEAR_OBJECT_ARRAY(fence_list,fence_count)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GPUQueue::WaitQueue()
|
bool GPUQueue::WaitQueue()
|
||||||
@ -41,10 +39,10 @@ bool GPUQueue::WaitFence(const bool wait_all,uint64_t time_out)
|
|||||||
VkResult result;
|
VkResult result;
|
||||||
VkFence fence=*fence_list[current_fence];
|
VkFence fence=*fence_list[current_fence];
|
||||||
|
|
||||||
result=vkWaitForFences(device->GetDevice(),1,&fence,wait_all,time_out);
|
result=vkWaitForFences(device,1,&fence,wait_all,time_out);
|
||||||
result=vkResetFences(device->GetDevice(),1,&fence);
|
result=vkResetFences(device,1,&fence);
|
||||||
|
|
||||||
if(++current_fence==fence_list.GetCount())
|
if(++current_fence==fence_count)
|
||||||
current_fence=0;
|
current_fence=0;
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user