Vulkan VertexInput 相关概念了解

VkVertexInputBindingDescription

一个buffer下面可以有多个binding, 每一个binding里面可以有多个location

struct Vertex {
    glm::vec2 pos;
    glm::vec3 color;
};
VkVertexInputBindingDescription bindingDescription{};
bindingDescription.binding = 0;
bindingDescription.stride = sizeof(Vertex);
bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;

VkVertexInputAttributeDescription

attributeDescriptions[0].binding = 0;
attributeDescriptions[0].location = 0;
attributeDescriptions[0].format = VK_FORMAT_R32G32_SFLOAT;
attributeDescriptions[0].offset = offsetof(Vertex, pos);

attributeDescriptions[1].binding = 0;
attributeDescriptions[1].location = 1;
attributeDescriptions[1].format = VK_FORMAT_R32G32B32_SFLOAT;
attributeDescriptions[1].offset = offsetof(Vertex, color);

关于更加详细的解释可以参见这个链接
https://github.com/KhronosGroup/Vulkan-Guide/blob/main/chapters/vertex_input_data_processing.adoc

posted @ 2025-01-02 20:03  风冷无霜  阅读(35)  评论(0)    收藏  举报