I would like to change/add/remove some mesh vertices in existing VBO's (while deforming and remeshing 3D objects) . With OpenGL I would have to reload whole vertex VBO's. I suppose with Vulkan there could be a way to directly access VBO's to only change/add/remove the changed vertex data. Is there some sample code out there demonstrating how this can be achieved? Many thanks for any help.
With OpenGL I would have to reload whole vertex VBO's.
No you wouldn't. You can use
I suppose with Vulkan there could be a way to directly access VBO's to only change/add/remove the changed vertex data
If you know the memory layout of the vertex buffer, you can find the offset of the contents you want to change, populate a transfer buffer with the new data and then uss vkCmdCopyBuffer to copy the data. The
VkBufferCopy parameter lets you specify the size as well as the source and destination offsets. In other words, every call to
vkCmdCopyBuffer is basically the equivalent of N calls to
To clarify, updating a vertex buffer on Vulkan is almost the same as populating it. If you're on a desktop architecture where device local memory is typically not mappable, then you have to create a transfer buffer that is host visible. You can populate that buffer with a memcpy (or whatever), and then use
vkCmdCopyBuffer to transfer it to the device local memory backed buffer. If you're on a mobile architecture with unified memory, then device local memory is typically also host visible and so you can just map it directly and update it with your
memcpy (or whatever)