Hi everyone,
I’m rendering points, and I have some issues with vertex attribute data being random where it shouldn’t. I’m using a single binding for 2 attributes (vec4), and I don’t want the attributes to be interleaved. That’s why I’m using a single buffer of size 2N split in two, with the data of attribute 0 in [0, N) and the data of attribute 1 in [N,2N). I double checked how I created the buffer and memory, and the data I wrote is correct.
Here is my code :
// Buffer update
vkMapMemory(device, hostMemory, 0, 2*sizeof(glm::vec4)*n, 0, &data);
memcpy(data, ....);
vkUnmapMemory(device, hostMemory);
// Vertex Input State
std::vector<VkVertexInputBindingDescription> bindings = {
{0, sizeof(glm::vec4), VK_VERTEX_INPUT_RATE_VERTEX},
};
std::vector<VkVertexInputAttributeDescription> attributes = {
{0, 0, VK_FORMAT_R32G32B32A32_SFLOAT, 0},
{1, 0, VK_FORMAT_R32G32B32A32_SFLOAT, sizeof(glm::vec4)*n}
};
// Vertex buffer bind
VkDeviceSize offsets[] = {0};
vkCmdBindVertexBuffers(cb, 0, 1, &hostBuffer, offsets);
// Draw
vkCmdDraw(cb, n, 1, 0, 0);
Is my understanding of binding and attributes wrong? Or did I miss something?
Thank you for your time.