2019-04-16 02:23:03 +08:00
|
|
|
|
#include"VKVertexInput.h"
|
|
|
|
|
|
|
|
|
|
VK_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
|
|
//struct VertexInputBuffer
|
|
|
|
|
//{
|
|
|
|
|
// //按API,可以一个binding绑多个attrib,但我们仅支持1v1
|
|
|
|
|
//
|
|
|
|
|
// VkVertexInputBindingDescription binding;
|
|
|
|
|
// VkVertexInputAttributeDescription attrib;
|
|
|
|
|
// Buffer *buf;
|
|
|
|
|
//};
|
|
|
|
|
|
2019-04-16 14:17:39 +08:00
|
|
|
|
bool VertexInput::Add(VertexBuffer *buf,bool instance)
|
2019-04-16 02:23:03 +08:00
|
|
|
|
{
|
|
|
|
|
if(!buf)
|
|
|
|
|
return(false);
|
|
|
|
|
|
2019-04-16 14:17:39 +08:00
|
|
|
|
const int binding_index=vib_list.GetCount(); //参考opengl vab,binding_index必须从0开始,紧密排列。对应在vkCmdBindVertexBuffer中的缓冲区索引
|
2019-04-16 02:23:03 +08:00
|
|
|
|
|
|
|
|
|
VkVertexInputBindingDescription binding;
|
|
|
|
|
VkVertexInputAttributeDescription attrib;
|
|
|
|
|
|
|
|
|
|
binding.binding=binding_index;
|
|
|
|
|
binding.stride=buf->GetStride();
|
2019-04-16 14:17:39 +08:00
|
|
|
|
binding.inputRate=instance?VK_VERTEX_INPUT_RATE_INSTANCE:VK_VERTEX_INPUT_RATE_VERTEX;
|
2019-04-16 02:23:03 +08:00
|
|
|
|
|
|
|
|
|
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
|