diff --git a/example/Vulkan/CMakeLists.txt b/example/Vulkan/CMakeLists.txt
index 70e7f243..e9e5851f 100644
--- a/example/Vulkan/CMakeLists.txt
+++ b/example/Vulkan/CMakeLists.txt
@@ -18,11 +18,13 @@ SET(VULKAN_TEST_SOURCE_FILES main.cpp
# VKDescriptorSet.cpp
VKRenderPass.cpp
VKShader.cpp
+ VKVertexInput.cpp
)
SET(VULKAN_TEST_HEADER_FILES VK.h
VKInstance.h
VKPhysicalDevice.h
+ VKCommandBuffer.h
VKSurfaceExtensionName.h
RenderSurfaceAttribute.h
RenderSurface.h
@@ -31,6 +33,7 @@ SET(VULKAN_TEST_HEADER_FILES VK.h
# VKDescriptorSet.h
VKRenderPass.h
VKShader.h
+ VKVertexInput.h
Window.h)
SET(SHADER_FILES shader_compile.bat
diff --git a/example/Vulkan/RenderSurfaceAttribute.h b/example/Vulkan/RenderSurfaceAttribute.h
index 4db0e2a2..3772e77d 100644
--- a/example/Vulkan/RenderSurfaceAttribute.h
+++ b/example/Vulkan/RenderSurfaceAttribute.h
@@ -52,7 +52,7 @@ public:
RenderSurfaceAttribute(VkInstance inst,const PhysicalDevice *pd,VkSurfaceKHR s);
~RenderSurfaceAttribute();
- bool CheckMemoryType(uint32_t typeBits,VkFlags requirements_mask,uint32_t *typeIndex)
+ bool CheckMemoryType(uint32_t typeBits,VkFlags requirements_mask,uint32_t *typeIndex) const
{
return physical_device->CheckMemoryType(typeBits,requirements_mask,typeIndex);
}
diff --git a/example/Vulkan/VKCommandBuffer.h b/example/Vulkan/VKCommandBuffer.h
index 37bba7f6..37c8bff8 100644
--- a/example/Vulkan/VKCommandBuffer.h
+++ b/example/Vulkan/VKCommandBuffer.h
@@ -2,6 +2,7 @@
#define HGL_GRAPH_VULKAN_COMMAND_BUFFER_INCLUDE
#include"VK.h"
+#include"VKVertexInput.h"
VK_NAMESPACE_BEGIN
class CommandBuffer
@@ -14,6 +15,15 @@ VK_NAMESPACE_BEGIN
CommandBuffer(VkDevice dev,VkCommandPool cp,VkCommandBuffer cb){device=dev;pool=cp;buf=cb;}
~CommandBuffer();
+
+ void Bind(VertexInput *vi)
+ {
+ auto &buf_list=vi->GetBufferList();
+
+ constexpr VkDeviceSize offsets[1]={0};
+
+ vkCmdBindVertexBuffers(buf,0,buf_list.GetCount(),buf_list.GetData(),offsets);
+ }
};//class CommandBuffer
VK_NAMESPACE_END
#endif//HGL_GRAPH_VULKAN_COMMAND_BUFFER_INCLUDE
diff --git a/example/Vulkan/VKVertexInput.cpp b/example/Vulkan/VKVertexInput.cpp
new file mode 100644
index 00000000..442b53af
--- /dev/null
+++ b/example/Vulkan/VKVertexInput.cpp
@@ -0,0 +1,38 @@
+#include"VKVertexInput.h"
+
+VK_NAMESPACE_BEGIN
+
+//struct VertexInputBuffer
+//{
+// //按API,可以一个binding绑多个attrib,但我们仅支持1v1
+//
+// VkVertexInputBindingDescription binding;
+// VkVertexInputAttributeDescription attrib;
+// Buffer *buf;
+//};
+
+bool VertexInput::Add(VertexBuffer *buf)
+{
+ if(!buf)
+ return(false);
+
+ const int binding_index=vib_list.GetCount(); //参考opengl vab,binding_index必须从0开始,紧密排列,但是否必须这样,待以后测试
+
+ VkVertexInputBindingDescription binding;
+ VkVertexInputAttributeDescription attrib;
+
+ binding.binding=binding_index;
+ binding.stride=buf->GetStride();
+ binding.inputRate=VK_VERTEX_INPUT_RATE_VERTEX; //还有一种是INSTANCE,暂时未知
+
+ attrib.binding=binding_index;
+ attrib.location=0;
+ attrib.format=buf->GetFormat();
+ attrib.offset=0;
+
+ vib_list.Add(new VertexInputBuffer(binding,attrib,buf));
+ buf_list.Add(buf->GetBuffer());
+
+ return(true);
+}
+VK_NAMESPACE_END
diff --git a/example/Vulkan/VKVertexInput.h b/example/Vulkan/VKVertexInput.h
new file mode 100644
index 00000000..7fb4e9a9
--- /dev/null
+++ b/example/Vulkan/VKVertexInput.h
@@ -0,0 +1,43 @@
+#ifndef HGL_GRAPH_VULKAN_VERTEX_INPUT_INCLUDE
+#define HGL_GRAPH_VULKAN_VERTEX_INPUT_INCLUDE
+
+#include"VK.h"
+#include"VKBuffer.h"
+VK_NAMESPACE_BEGIN
+/**
+ * 顶点输入配置,类似于OpenGL的VAB
+ * 注:本引擎不支持一个BUFFER中包括多种数据
+ */
+class VertexInput
+{
+ struct VertexInputBuffer
+ {
+ //按API,可以一个binding绑多个attrib,但我们仅支持1v1
+
+ VkVertexInputBindingDescription binding;
+ VkVertexInputAttributeDescription attrib;
+ VertexBuffer *buffer;
+
+ public:
+
+ VertexInputBuffer(VkVertexInputBindingDescription bind,VkVertexInputAttributeDescription attr,VertexBuffer *buf)
+ {
+ binding=bind;
+ attrib=attr;
+ buffer=buf;
+ }
+ };
+
+ ObjectList vib_list;
+ List buf_list;
+
+public:
+
+ bool Add(VertexBuffer *);
+
+public:
+
+ List &GetBufferList(){return buf_list;}
+};//class VertexInput
+VK_NAMESPACE_END
+#endif//HGL_GRAPH_VULKAN_VERTEX_INPUT_INCLUDE