1
$\begingroup$

I have been learning computer graphics and for some time and can't seem to wrap my head around one concept. How to handle vertex data changes?

Ex. 1. I have a text rendering on a screen. And up on hitting a character corresponding glyph should be rendered. I have managed to achieve this using Open GL with dynamic draw where during each frame I would submit subbuffer data of the whole vertex and index set plus new verices for the new glyph at a 0 offset in memory. I would think this is not the optimal way to change what is shown on screen between frames, but it is good enough for learning. This aproach introduces a bug though. Or at least I have a bug. Where upon deleting a glyph and resubmiting vertex and index data the glyth would still be renderd during next frame. I guess it is because allocated buffer points to a contiguous block of memory and text rendering is just bunch of rectangles where the count of indices per glyph remains constant and until I do not clear or overwrite the subitted data at the address it will continue rendering.

Ex. 2. I have an entity loaded from .obj file the vertex and index data is converted tiny_obj_loader library. I would like for the entity to move in a scene. And not by moving or changing UBO. So I have tried this using Open GL and have achieved this using similar method to my previous example, using dynamic draw. And it worked. But once I have tried this in vulkan I have almost hit a brick wall. I can not change vertex data each frame since VkBufferMemory for vertices and indices is allocated before even commad buffers are created.

So my question is how do I manage vertex/index data changes in vulkan or more in general? Should I write some alogorithms that would determine the place in memory should be cleared or is there a better way than dynamic draw? How does it look like using vulkan? Is there some way to rebind new data and send it to gpu on every render pass?

$\endgroup$
1
  • 1
    $\begingroup$ In Vulkan "everything" is a buffer. Because of this there is a rich environment for working with those buffers, as well as, a wide range of buffers. The code could overwrite the data every frame with appropriate barriers to synchronize the data. It could use a single buffer that is 2x the max data size and then set the buffer starting point using dynamic descriptors. It could use multiple separate buffers and bind the relevant buffer at draw time. The list goes on and on. I suggest narrowing in on a particular method that sounds appealing to make it easier to answer the question. $\endgroup$
    – pmw1234
    Mar 16, 2023 at 13:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.