Suppose I'm rendering simple cubes at random positions.
Having 3 of them as the starting number of cubes, the application acquires a VkBuffer
handle and binds it to a VkDeviceMemory
in order to store the model matrices of all cubes consecutively in it, and which is later on accessed by the shader via the descriptor set. The VkDeviceMemory
has just enough memory for those 3 cubes.
What I want to do is, every time the user presses a key, a new cube should pop up somewhere. My question is, how should I go about resizing that memory? Could you provide an overview of the steps I should go through?
I realize I could use separate VkBuffer
/VkDeviceMemory
for each cube but I do not want to do that. Everywhere I read it is stated that's sort of an anti-pattern.
Should I just discard the VkDeviceMemory
, allocate a new one with the right size, and call it a day? What about descriptor sets, do they need any special handling?
In some places I have read you could allocate a very big chunk of data, so you are on the safe side while dealing with more and more cubes up to a point in which, I suppose, you would stop permitting more of them to pop up because a limit has been reached. Is there a way around this self-imposed limit?
EDIT: I also realize allocating one small chunk at a time is a bad idea. What I'm interested in is the reallocation itself, and what it entails.