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