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