When to update Uniform-Buffers on the GPU

Hello guys, i need your advice for something i want to implement.
My current render-loop looks like this:


update(deltaTime);
draw();

where update(deltaTime) updates all my objects and components on them.
Draw is a bit bigger and looks like this:

        
// Updates all data on the gpu and uniforms in descriptor-sets e.g. view-projection, lighting-params. 
// Does a VkQueueWaitIdle to ensure data wont get updated until gpu has finished work with it.
updateGPUData();

// Record commands into command-buffers
recordCommandBuffers();

// Submit all command-buffers at once and present the swapchain-image finally on screen
submit();

The problem is obvious: The CPU spent a lot of time with VkQueueWaitIdle() at updateGPUData() before it can record command-buffers for the new frame.
My solution to that is to implement a system with doubled descriptor-sets and buffers and just update those who arent in use by the GPU, when the GPU uses the other one (like the backbuffer-principle).
What do you think of it? Or do you have ideas for a better place when to update the data on the gpu?

Thanks in Advance
SH :slight_smile:

To me, you should avoid the maximum to use vkQueueWaitIdle or worst vkDeviceWaitIdle. Instead, please use fencing ;).

The way you want to go with, which named “multiple buffering” is, IMO, a good way. Even, if I’d go for triple buffer instead of double buffer.
The idea is as you said, you write in one buffer, during the two others are used by the GPU.

[QUOTE=qnoper;41345]To me, you should avoid the maximum to use vkQueueWaitIdle or worst vkDeviceWaitIdle. Instead, please use fencing ;).

The way you want to go with, which named “multiple buffering” is, IMO, a good way. Even, if I’d go for triple buffer instead of double buffer.
The idea is as you said, you write in one buffer, during the two others are used by the GPU.[/QUOTE]
Okay i will try this! Thanks!