ulak blade
ulak blade

Reputation: 2665

Creating multiple command pools per thread in Vulkan

I am trying to set up a multi-threaded renderer with Vulkan and I have a question about command pools.

Here https://on-demand.gputechconf.com/siggraph/2016/video/sig1625-tristan-lorach-vulkan-nvidia-essentials.mp4 at 13 minutes, they talk about how you should make 1 command pool per FRAME and cycle them in a ring buffer. enter image description here

Why allocate 3 command pools per thread(one for each frame in a 3-frame ring buffer) instead of having just one command pool per thread and having 3 command buffers from it?

Upvotes: 10

Views: 3229

Answers (2)

krOoze
krOoze

Reputation: 13306

I think the premise here is that vkResetCommandPool is better than resetting individual command buffers. Which also requires VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT flag, whose existence is a little hint by the Specification itself that the ability to reset individual cmdbuffers may not be for free.

Actually the speaker says so if you do not just read slides but get the full presentation.

Upvotes: 9

solidpixel
solidpixel

Reputation: 12239

It's basically about limiting how much synchronization and state tracking you have to do. If you have one Command pool per frame per thread then you just need to track a single event for completion and then reset the entire Command pool, no matter how many Command buffers you created in it for that frame.

From an engine point of view this can be quite nice for command buffers you don't intend to reuse multiple times - they become stateless fire and forget entities and you just need to persistently track the pool.

Exact trade offs are going to vary here from application to application, and driver to driver, so YMMV in terms of what works best.

Upvotes: 9

Related Questions