Note. I am self-educating in Vulcan, not knowing modern OpenGL.
While reading the Vulkan specs, I see very beautiful semaphores that allow the command buffer and swapchain to sync. Here, I understand that this is a simple (but I consider inefficient) way of doing things:
- Get image using
vkAcquireNextImageKHR, alarmsem_post_acq - Create a command buffer (or use a prebuilt) with:
- Image obstruction for image transition from
VK_IMAGE_LAYOUT_UNDEFINED - render
- Image of a barrier to transition to
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
- Send to the queue, waiting
sem_post_acqat the stage of the fragment and signaling sem_pre_present. vkQueuePresentKHRexpectations sem_pre_present.
The problem is that the image barriers in the command buffer need to know which image they are passing, which means that they vkAcquireNextImageKHRmust return before anyone knows how to build the command buffer (or which pre-configured command buffer to send). But it vkAcquireNextImageKHRcan sleep a lot (because the presentation engine is busy and there are no free images). On the other hand, presenting a command buffer is expensive and, more importantly, all the steps before a fragment can work without any knowledge of which image will be displayed in the final result.
Theoretically, it seems to me that a scheme like the following will allow a higher degree of parallelism:- Create a command buffer (or use a prebuilt) with:
VK_IMAGE_LAYOUT_UNDEFINEDVK_IMAGE_LAYOUT_PRESENT_SRC_KHR
- ,
sem_post_acq sem_pre_present. vkAcquireNextImageKHR, sem_post_acqvkQueuePresentKHR sem_pre_present.
, vkAcquireNextImageKHR. , , , , ( ), .
: ? , ?
: , vkAcquireNextImageKHR, , ? , , , .