vulkano-rs / vulkano

Safe and rich Rust wrapper around the Vulkan API
Apache License 2.0
4.53k stars 436 forks source link

Question: Idiomatic not to reuse command buffers? #2456

Closed johan-overbye closed 9 months ago

johan-overbye commented 9 months ago

I have a performance question regarding vulkano 34.1.

I'm in the process of porting a game project from ash to vulkano in order to simplify and strengthen the game code. Version 34.1's triangle example doesn't seem to store any persistent command buffers on the app side. But rather it calls AutoCommandBufferBuilder::primary each frame.

Some questions:

Thanks! ❤️

Rua commented 9 months ago

Vulkano's CommandBufferAllocator will store and re-use command buffers after they have been used and dropped. But only the allocation is reused this way; the contents is wiped. To keep the recorded command buffer around and re-use it, is no more performant in Vulkano than it is in Vulkan.

On the other hand, there is not much of a performance bottleneck in recording command buffers every time anyway. They are very much designed to be used this way. You can keep the command buffers around and re-use them for subsequent frames, but whether this is feasible depends very much on what is needed for your program. Vulkano doesn't do anything for you there.

johan-overbye commented 9 months ago

Thanks a lot @Rua!

That's very helpful, thanks. I was recording the commands from scratch each frame anyway, so no change there.

Super excited about vulkano so far. Seems to let me cut out swaths of simultaneously boring and very error-prone code. 😅