#Index vertex texture coordenates
47 messages · Page 1 of 1 (latest)
There is no "the vertex" in Vulkan. What exactly are you referring too?
You can provide vertex attributes both interleaved (single buffer) or separte (multiple buffers).
what is the difference in how you set it up then, do you create multiple uniforms
vertex data is provided via attributes in the pipeline state, not as uniforms
The difference is simply in how you bind buffers in the vertex input state
Interleaved is one binding
Separate is multiple bindings
I currently have this ```c++
c.vkCmdBindVertexBuffers(buffer, 0, 1, &self.vertex_buffer.buffer.buffer, &offsets);
c.vkCmdBindIndexBuffer(buffer, self.vertex_buffer.indices.buffer, 0, c.VK_INDEX_TYPE_UINT32);
Would it be possible to have a separate index buffer for position and texture
I would probably need to change the way I am drawing too right ?
currently ```cpp
c.vkCmdDrawIndexed(buffer, @intCast(self.vertex_buffer.indices_len), 1, 0, 0, 0);
no, you can only ever bind one index buffer for a draw
but you can bind an arbitrary number of vertex buffers per draw
so I need to store the position and texture position together then ?
Cause my obj loader loads the raw data, and to get the ordered vertices you look at the faces
ideally I can represent faces to vulkan so I dont have to copy after loading to wrap each raw vertex position with its associated texture coord
if that makes sense ?
it doesn't matter for Vulkan. You can do both, interleaved or separate.
but there is a single index buffer, sorry I am not quite sure what you mean
for indexed rendering it doesn't matter if you use interleaved or separate vertex attributes
as long as the indices are the same
if you don't know enough yet about Vulkan to understand that, just go with a single interleaved buffer
So the vertex input state would take attributes that are not packed but which have offsets based on the aggregated vertex buffers ?
and you just have multiple bindings for the different buffers in pVertexBindingDescriptions ?
it would use different buffers
that's why it's called separated
offsets are for interleaved buffers
this explains it great https://gamedev.stackexchange.com/questions/61235/one-index-buffer-with-multiple-vertex-buffers
i will need to copy
to a certain extent
here are my binding and attribute descriptions ```cpp
const binding_descriptions = [_]c.VkVertexInputBindingDescription{ .{
.binding = 0,
.stride = @sizeOf(@Vector(4, f32)),
.inputRate = c.VK_VERTEX_INPUT_RATE_VERTEX,
}, .{
.binding = 1,
.stride = @sizeOf(@Vector(2, f32)),
.inputRate = c.VK_VERTEX_INPUT_RATE_VERTEX,
} };
const attribute_descriptions = [_]c.VkVertexInputAttributeDescription{
.{
.binding = 0,
.location = 0,
.format = c.VK_FORMAT_R32G32B32A32_SFLOAT,
.offset = 0,
},
.{
.binding = 1,
.location = 0,
.format = c.VK_FORMAT_R32G32_SFLOAT,
.offset = 0,
},
};
This raises validation error
VUID-vkCmdDrawIndexed-None-02721(ERROR / SPEC): msgNum: 615493573 - Validation Error: [ VUID-vkCmdDrawIndexed-None-02721 ] Object 0: handle = 0x301e6c0000000022, type = VK_OBJECT_TYPE_BUFFER; Object 1: handle = 0xb12fb2000000002c, type = VK_OBJECT_TYPE_PIPELINE; | MessageID = 0x24afafc5 | vkCmdDrawIndexed(): Format VK_FORMAT_R32G32_SFLOAT has an alignment of 4 but the alignment of attribAddress (9) is not aligned in pVertexAttributeDescriptions[1](binding=1 location=0) where attribAddress = vertex buffer offset (1) + binding stride (8) + attribute offset (0). The Vulkan spec states: For a given vertex buffer binding, any attribute data fetched must be entirely contained within the corresponding vertex buffer binding, as described in Vertex Input Description (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdDrawIndexed-None-02721)```
also ```cpp
const offsets = []c.VkDeviceSize{ 0, 1 };
c.vkCmdBindVertexBuffers(buffer, 0, 2, &[]c.VkBuffer{ self.vertex_buffer.position_buffer.buffer, self.vertex_buffer.texel_buffer.buffer }, &offsets);
c.vkCmdBindIndexBuffer(buffer, self.vertex_buffer.index_buffer.buffer, 0, c.VK_INDEX_TYPE_UINT32);
got it working
I was being a bit dumb you are correct
I ended up just changin the location also
in the input attribute
then I just needed to update the shaders
thanks for all the help
I have been slowly reading what you were saying above and it finally clicked
Much easier to work with the vertex data now thank god