Search code examples
vulkan

Do I need two different queue submissions here?


I have once command buffer 1, and command buffer 2. Both have had their recordings finished, and now I want to submit both of them, preferably in an efficient way (one vkQueueSubmit call.

The second command buffer needs to wait until the first one has completed. I thought that I could do this with one submit:

/* I THINK THE FOLLOWING IS WRONG */
VkSubmitInfo info;
info.pCommandBuffers = /* Pointer to the first command buffer */;
info.commandBufferCount = 2;
info.pSignalSemaphores = /* The first pointer value points to the semaphore 
that the first command buffer will signal when completed */
info.pWaitSemaphores = /* The second pointer value points to the same semaphore as above */

So I'm pretty sure the above is a wrong understanding, does that mean the only way in this case to have a dependency of the second command buffer on the first to have two different queue submissions? I mean two different VkSubmitInfo's?


Solution

  • Binary semaphores are meant for interqueue communication. And while you can use timeline semaphores for intraqueue communications, for something like this, it's best to take a step back and ask yourself what is really going on.

    Because it's not true that CB2 needs to wait for CB1 to complete. What's happening is that the result of some operation within CB1 needs to complete before some operation within CB2 can start. This is best accomplished with a VkEvent. CB1's operation can set an event that CB2 corresponding operation will wait on.

    There's no need to separate these operations into different batches, let alone different queue submissions.