From fc28d2d4fe920990301fa3c79b5744f16104d3d5 Mon Sep 17 00:00:00 2001 From: HuYingzhuo Date: Tue, 16 Apr 2019 13:21:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BCommandBuffer::Bind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/Vulkan/VKCommandBuffer.h | 17 +++++++++++++---- example/Vulkan/VKVertexInput.h | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/example/Vulkan/VKCommandBuffer.h b/example/Vulkan/VKCommandBuffer.h index 37c8bff8..ff8eb05b 100644 --- a/example/Vulkan/VKCommandBuffer.h +++ b/example/Vulkan/VKCommandBuffer.h @@ -5,6 +5,7 @@ #include"VKVertexInput.h" VK_NAMESPACE_BEGIN + class CommandBuffer { VkDevice device; @@ -16,13 +17,21 @@ VK_NAMESPACE_BEGIN CommandBuffer(VkDevice dev,VkCommandPool cp,VkCommandBuffer cb){device=dev;pool=cp;buf=cb;} ~CommandBuffer(); - void Bind(VertexInput *vi) + bool Bind(VertexInput *vi) { - auto &buf_list=vi->GetBufferList(); + if(!vi) + return(false); - constexpr VkDeviceSize offsets[1]={0}; + const List &buf_list=vi->GetBufferList(); - vkCmdBindVertexBuffers(buf,0,buf_list.GetCount(),buf_list.GetData(),offsets); + if(buf_list.GetCount()<=0) + return(false); + + constexpr VkDeviceSize zero_offsets[1]={0}; + + vkCmdBindVertexBuffers(buf,0,buf_list.GetCount(),buf_list.GetData(),zero_offsets); + + return(true); } };//class CommandBuffer VK_NAMESPACE_END diff --git a/example/Vulkan/VKVertexInput.h b/example/Vulkan/VKVertexInput.h index 7fb4e9a9..b1471195 100644 --- a/example/Vulkan/VKVertexInput.h +++ b/example/Vulkan/VKVertexInput.h @@ -37,7 +37,7 @@ public: public: - List &GetBufferList(){return buf_list;} + const List &GetBufferList()const{return buf_list;} };//class VertexInput VK_NAMESPACE_END #endif//HGL_GRAPH_VULKAN_VERTEX_INPUT_INCLUDE