Device::QueueSubmit改为一次可提交多个cmd buf
This commit is contained in:
parent
9a3eef5712
commit
d4b9b17362
@ -75,9 +75,9 @@ public:
|
|||||||
device->AcquireNextImage();
|
device->AcquireNextImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Submit(vulkan::CommandBuffer *cmd_buf)
|
void Submit(const VkCommandBuffer cmd_buf)
|
||||||
{
|
{
|
||||||
device->QueueSubmit(cmd_buf);
|
device->QueueSubmit(&cmd_buf);
|
||||||
device->Wait();
|
device->Wait();
|
||||||
device->QueuePresent();
|
device->QueuePresent();
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ private:
|
|||||||
bool InitPipeline()
|
bool InitPipeline()
|
||||||
{
|
{
|
||||||
vulkan::PipelineCreater *
|
vulkan::PipelineCreater *
|
||||||
pipeline_creater=new vulkan::PipelineCreater(device,material);
|
pipeline_creater=new vulkan::PipelineCreater(device,material,device->GetRenderPass());
|
||||||
pipeline_creater->SetDepthTest(false);
|
pipeline_creater->SetDepthTest(false);
|
||||||
pipeline_creater->SetDepthWrite(false);
|
pipeline_creater->SetDepthWrite(false);
|
||||||
pipeline_creater->CloseCullFace();
|
pipeline_creater->CloseCullFace();
|
||||||
@ -161,7 +161,11 @@ public:
|
|||||||
|
|
||||||
void Draw() override
|
void Draw() override
|
||||||
{
|
{
|
||||||
Submit(cmd_buf[device->GetCurrentFrameIndices()]);
|
const uint32_t frame_index=device->GetCurrentFrameIndices();
|
||||||
|
|
||||||
|
const vulkan::CommandBuffer *cb=cmd_buf[frame_index];
|
||||||
|
|
||||||
|
Submit(*cb);
|
||||||
}
|
}
|
||||||
};//class TestApp:public VulkanApplicationFramework
|
};//class TestApp:public VulkanApplicationFramework
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ public:
|
|||||||
~CommandBuffer();
|
~CommandBuffer();
|
||||||
|
|
||||||
operator VkCommandBuffer(){return cmd_buf;}
|
operator VkCommandBuffer(){return cmd_buf;}
|
||||||
|
operator const VkCommandBuffer()const{return cmd_buf;}
|
||||||
|
|
||||||
void SetRenderArea(const VkRect2D &ra){render_area=ra;}
|
void SetRenderArea(const VkRect2D &ra){render_area=ra;}
|
||||||
void SetClearColor(float r,float g,float b,float a=1.0f)
|
void SetClearColor(float r,float g,float b,float a=1.0f)
|
||||||
|
@ -109,7 +109,7 @@ public: //Command Buffer
|
|||||||
public: //提交相关
|
public: //提交相关
|
||||||
|
|
||||||
bool AcquireNextImage ();
|
bool AcquireNextImage ();
|
||||||
bool QueueSubmit (CommandBuffer *);
|
bool QueueSubmit (const VkCommandBuffer *,const uint32_t count=1);
|
||||||
bool Wait (bool wait_all=VK_TRUE,uint64_t time_out=HGL_NANO_SEC_PER_SEC*0.1);
|
bool Wait (bool wait_all=VK_TRUE,uint64_t time_out=HGL_NANO_SEC_PER_SEC*0.1);
|
||||||
bool QueuePresent ();
|
bool QueuePresent ();
|
||||||
};//class Device
|
};//class Device
|
||||||
|
@ -28,9 +28,9 @@ CommandBuffer::CommandBuffer(VkDevice dev,const VkExtent2D &extent,VkCommandPool
|
|||||||
|
|
||||||
CommandBuffer::~CommandBuffer()
|
CommandBuffer::~CommandBuffer()
|
||||||
{
|
{
|
||||||
VkCommandBuffer cmd_bufs[1] = {cmd_buf};
|
vkFreeCommandBuffers(device,pool,1,&cmd_buf);
|
||||||
vkFreeCommandBuffers(device, pool, 1, cmd_bufs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CommandBuffer::Begin()
|
bool CommandBuffer::Begin()
|
||||||
{
|
{
|
||||||
VkCommandBufferBeginInfo cmd_buf_info = {};
|
VkCommandBufferBeginInfo cmd_buf_info = {};
|
||||||
|
@ -53,13 +53,13 @@ void DescriptorSetLayoutCreater::Bind(const uint32_t binding,VkDescriptorType de
|
|||||||
|
|
||||||
void DescriptorSetLayoutCreater::Bind(const uint32_t *binding,const uint32_t count,VkDescriptorType desc_type,VkShaderStageFlagBits stageFlags)
|
void DescriptorSetLayoutCreater::Bind(const uint32_t *binding,const uint32_t count,VkDescriptorType desc_type,VkShaderStageFlagBits stageFlags)
|
||||||
{
|
{
|
||||||
const int old_count=layout_binding_list.GetCount();
|
const uint old_count=layout_binding_list.GetCount();
|
||||||
|
|
||||||
layout_binding_list.SetCount(old_count+count);
|
layout_binding_list.SetCount(old_count+count);
|
||||||
|
|
||||||
VkDescriptorSetLayoutBinding *p=layout_binding_list.GetData()+old_count;
|
VkDescriptorSetLayoutBinding *p=layout_binding_list.GetData()+old_count;
|
||||||
|
|
||||||
for(int i=old_count;i<old_count+count;i++)
|
for(uint i=old_count;i<old_count+count;i++)
|
||||||
{
|
{
|
||||||
p->binding = *binding;
|
p->binding = *binding;
|
||||||
p->descriptorType = desc_type;
|
p->descriptorType = desc_type;
|
||||||
|
@ -201,24 +201,23 @@ bool Device::AcquireNextImage()
|
|||||||
return(vkAcquireNextImageKHR(attr->device,attr->swap_chain,UINT64_MAX,*image_acquired_semaphore,VK_NULL_HANDLE,¤t_frame)==VK_SUCCESS);
|
return(vkAcquireNextImageKHR(attr->device,attr->swap_chain,UINT64_MAX,*image_acquired_semaphore,VK_NULL_HANDLE,¤t_frame)==VK_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Device::QueueSubmit(CommandBuffer *buf)
|
bool Device::QueueSubmit(const VkCommandBuffer *cmd_bufs,const uint32_t count)
|
||||||
{
|
{
|
||||||
if(!buf)
|
if(!cmd_bufs)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
VkPipelineStageFlags pipe_stage_flags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
VkPipelineStageFlags pipe_stage_flags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
||||||
VkSubmitInfo submit_info = {};
|
VkSubmitInfo submit_info = {};
|
||||||
|
|
||||||
VkSemaphore wait_sem=*image_acquired_semaphore;
|
VkSemaphore wait_sem=*image_acquired_semaphore;
|
||||||
VkCommandBuffer cmd_bufs=*buf;
|
|
||||||
|
|
||||||
submit_info.pNext = nullptr;
|
submit_info.pNext = nullptr;
|
||||||
submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
||||||
submit_info.waitSemaphoreCount = 1;
|
submit_info.waitSemaphoreCount = 1;
|
||||||
submit_info.pWaitSemaphores = &wait_sem;
|
submit_info.pWaitSemaphores = &wait_sem;
|
||||||
submit_info.pWaitDstStageMask = &pipe_stage_flags;
|
submit_info.pWaitDstStageMask = &pipe_stage_flags;
|
||||||
submit_info.commandBufferCount = 1;
|
submit_info.commandBufferCount = count;
|
||||||
submit_info.pCommandBuffers = &cmd_bufs;
|
submit_info.pCommandBuffers = cmd_bufs;
|
||||||
submit_info.signalSemaphoreCount = 0;
|
submit_info.signalSemaphoreCount = 0;
|
||||||
submit_info.pSignalSemaphores = nullptr;
|
submit_info.pSignalSemaphores = nullptr;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user