Jump to content
  • Advertisement
Mercesa

Vulkan Usage of command buffers in Vulkan

This topic is 419 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

It is a bit unclear to me for what kind of tasks you would want to create a new command buffer/how to use them. is it ideal to have a command buffer per draw call? Per material call? Per render-pass? 

I know in Dx12 command lists can have complete rendering pipelines recorded, but I am a bit unsure how to see command buffers in Vulkan.

Edited by Mercesa

Share this post


Link to post
Share on other sites
Advertisement

I have experience mainly with compute and did not much rendering yet, but i assume it's the same for both:

You can record a very complex system to just one command buffer. In my case that means prerecording indirect dispatches that may do zero work most of the time, but that approach is a lot faster than doing such decissions on CPU. Vulkan is almost twice as fast than OpenCL for me because of this, although both use the same shader code. AFAIK, you also can put a whole graphics engine in to one CB if you want.

Using only one command buffer is usually the fastest way. (Enqueueing multiple command buffers has a noticeable cost!). But there are two exceptions:

1. Multithreaded command buffer recording on CPU. Interesting if you do not want to prerecord your whole pipeline and do a lot decissions on CPU every frame. 

2. Async compute. As long as you have no pipeline barriers in your queue AMD does it automatically. But otherwise you can use multiple queues to keep working while e.g. a memory barrier stalls a queue. I made this testcase for AMD: https://github.com/JoeJGit/Vulkan-Async-Compute-Test It shows some interesting behaviours and may help to get a sense of when async compute is worth it or not. You can also see the cost of using multiple queues and CBs as small gaps in profiler output. Those gaps are similar if you use just one queue but enqueue multiple CBs to it.

So in both cases the reason to use multiple command buffers is either CPU or GPU parallelization, simply because there is no other way. But other than that you want to put all your work into one buffer and avoid fragmentation most of the time.

 

Edited by JoeJ

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!