WIP Binding vertex buffers

This commit is contained in:
2022-02-13 22:22:51 -08:00
parent 8414c1c0bb
commit 400a7e0061
4 changed files with 51 additions and 5 deletions

View File

@@ -184,12 +184,32 @@ KRPipeline::KRPipeline(KRContext& context, KrDeviceHandle deviceHandle, VkFormat
// failed! TODO - Error handling
}
// TODO - Make bindings dynamic...
VkVertexInputBindingDescription bindingDescription{};
bindingDescription.binding = 0;
bindingDescription.stride = sizeof(float) * 3 + sizeof(uint16_t) * 2;
bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
const int kMaxVertexDescriptions = 16;
VkVertexInputAttributeDescription vertexAttributeDescriptions[kMaxVertexDescriptions]{};
// position
vertexAttributeDescriptions[0].binding = 0;
vertexAttributeDescriptions[0].location = 0;
vertexAttributeDescriptions[0].format = VK_FORMAT_R32G32B32_SFLOAT;
vertexAttributeDescriptions[0].offset = 0;
// uv
vertexAttributeDescriptions[1].binding = 0;
vertexAttributeDescriptions[1].location = 1;
vertexAttributeDescriptions[1].format = VK_FORMAT_R32G32_SFLOAT;
vertexAttributeDescriptions[1].offset = sizeof(float) * 3;
VkPipelineVertexInputStateCreateInfo vertexInputInfo{};
vertexInputInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
vertexInputInfo.vertexBindingDescriptionCount = 0;
vertexInputInfo.pVertexBindingDescriptions = nullptr; // TODO
vertexInputInfo.vertexAttributeDescriptionCount = 0;
vertexInputInfo.pVertexAttributeDescriptions = nullptr; // TODO
vertexInputInfo.vertexBindingDescriptionCount = 1;
vertexInputInfo.pVertexBindingDescriptions = &bindingDescription;
vertexInputInfo.vertexAttributeDescriptionCount = 2;
vertexInputInfo.pVertexAttributeDescriptions = vertexAttributeDescriptions;
VkPipelineInputAssemblyStateCreateInfo inputAssembly{};
inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;