In the 7.4.2. Semaphore Waiting of specification:
A common scenario for using
pWaitDstStageMaskwith values other than
VK_PIPELINE_STAGE_ALL_COMMANDS_BITis when synchronizing a window system presentation operation against subsequent command buffers which render the next frame. In this case, a presentation image must not be overwritten until the presentation operation completes, but other pipeline stages can execute without waiting. A mask of
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BITprevents subsequent color attachment writes from executing until the semaphore signals. Some implementations may be able to execute transfer operations and/or vertex processing work before the semaphore is signaled.
If an image layout transition needs to be performed on a presentable image before it is used in a framebuffer, that can be performed as the first operation submitted to the queue after acquiring the image, and should not prevent other work from overlapping with the presentation operation. For example, a
VK_IMAGE_LAYOUT_UNDEFINED, if the image’s contents need not be preserved.
This barrier accomplishes a dependency chain between previous presentation operations and subsequent color attachment output operations, with the layout transition performed in between, and does not introduce a dependency between previous work and any vertex processing stages. More precisely, the semaphore signals after the presentation operation completes, the semaphore wait stalls the
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BITstage, and there is a dependency from that same stage to itself with the layout transition performed in between.