diff --git a/example/Vulkan/VulkanAppFramework.h b/example/Vulkan/VulkanAppFramework.h index 9e947603..ada7209d 100644 --- a/example/Vulkan/VulkanAppFramework.h +++ b/example/Vulkan/VulkanAppFramework.h @@ -75,9 +75,9 @@ public: 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->QueuePresent(); } diff --git a/example/Vulkan/main.cpp b/example/Vulkan/main.cpp index 3a69b1c4..b35e4695 100644 --- a/example/Vulkan/main.cpp +++ b/example/Vulkan/main.cpp @@ -95,7 +95,7 @@ private: bool InitPipeline() { vulkan::PipelineCreater * - pipeline_creater=new vulkan::PipelineCreater(device,material); + pipeline_creater=new vulkan::PipelineCreater(device,material,device->GetRenderPass()); pipeline_creater->SetDepthTest(false); pipeline_creater->SetDepthWrite(false); pipeline_creater->CloseCullFace(); @@ -161,7 +161,11 @@ public: 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 diff --git a/inc/hgl/graph/vulkan/VKCommandBuffer.h b/inc/hgl/graph/vulkan/VKCommandBuffer.h index 049cc0f4..7f0b5a50 100644 --- a/inc/hgl/graph/vulkan/VKCommandBuffer.h +++ b/inc/hgl/graph/vulkan/VKCommandBuffer.h @@ -25,6 +25,7 @@ public: ~CommandBuffer(); operator VkCommandBuffer(){return cmd_buf;} + operator const VkCommandBuffer()const{return cmd_buf;} void SetRenderArea(const VkRect2D &ra){render_area=ra;} void SetClearColor(float r,float g,float b,float a=1.0f) diff --git a/inc/hgl/graph/vulkan/VKDevice.h b/inc/hgl/graph/vulkan/VKDevice.h index 0426fea6..be111f80 100644 --- a/inc/hgl/graph/vulkan/VKDevice.h +++ b/inc/hgl/graph/vulkan/VKDevice.h @@ -109,7 +109,7 @@ public: //Command Buffer public: //Ìá½»Ïà¹Ø 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 QueuePresent (); };//class Device diff --git a/src/RenderDevice/Vulkan/VKCommandBuffer.cpp b/src/RenderDevice/Vulkan/VKCommandBuffer.cpp index d8e86d75..569a252a 100644 --- a/src/RenderDevice/Vulkan/VKCommandBuffer.cpp +++ b/src/RenderDevice/Vulkan/VKCommandBuffer.cpp @@ -28,9 +28,9 @@ CommandBuffer::CommandBuffer(VkDevice dev,const VkExtent2D &extent,VkCommandPool CommandBuffer::~CommandBuffer() { - VkCommandBuffer cmd_bufs[1] = {cmd_buf}; - vkFreeCommandBuffers(device, pool, 1, cmd_bufs); + vkFreeCommandBuffers(device,pool,1,&cmd_buf); } + bool CommandBuffer::Begin() { VkCommandBufferBeginInfo cmd_buf_info = {}; diff --git a/src/RenderDevice/Vulkan/VKDescriptorSets.cpp b/src/RenderDevice/Vulkan/VKDescriptorSets.cpp index e32092a7..735acdfe 100644 --- a/src/RenderDevice/Vulkan/VKDescriptorSets.cpp +++ b/src/RenderDevice/Vulkan/VKDescriptorSets.cpp @@ -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) { - const int old_count=layout_binding_list.GetCount(); + const uint old_count=layout_binding_list.GetCount(); layout_binding_list.SetCount(old_count+count); VkDescriptorSetLayoutBinding *p=layout_binding_list.GetData()+old_count; - for(int i=old_count;ibinding = *binding; p->descriptorType = desc_type; diff --git a/src/RenderDevice/Vulkan/VKDevice.cpp b/src/RenderDevice/Vulkan/VKDevice.cpp index 7f1f1a87..781be8e7 100644 --- a/src/RenderDevice/Vulkan/VKDevice.cpp +++ b/src/RenderDevice/Vulkan/VKDevice.cpp @@ -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); } -bool Device::QueueSubmit(CommandBuffer *buf) +bool Device::QueueSubmit(const VkCommandBuffer *cmd_bufs,const uint32_t count) { - if(!buf) + if(!cmd_bufs) return(false); VkPipelineStageFlags pipe_stage_flags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; VkSubmitInfo submit_info = {}; VkSemaphore wait_sem=*image_acquired_semaphore; - VkCommandBuffer cmd_bufs=*buf; submit_info.pNext = nullptr; submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; submit_info.waitSemaphoreCount = 1; submit_info.pWaitSemaphores = &wait_sem; submit_info.pWaitDstStageMask = &pipe_stage_flags; - submit_info.commandBufferCount = 1; - submit_info.pCommandBuffers = &cmd_bufs; + submit_info.commandBufferCount = count; + submit_info.pCommandBuffers = cmd_bufs; submit_info.signalSemaphoreCount = 0; submit_info.pSignalSemaphores = nullptr;