vkCmdPipelineBarrier
明确表示它在调用之前和之后在命令缓冲区中创建命令之间的依赖关系.因此,当在单个命令缓冲区中转换图像时,可以在任何时刻“知道”图像的布局.
但是,vkQueueSumbit不会强制执行命令缓冲区的执行顺序.如果有两个命令缓冲区,每个命令缓冲区都有vkCmdPipelineBarrier调用将相同的图像转换为不同的布局,这两个操作之间是否存在依赖关系,还是在这种情况下需要显式同步?
解决方法
Command buffer boundaries,both between primary command buffers of the same or different batches or submissions as well as between primary and secondary command buffers,do not introduce any implicit ordering constraints. In other words,submitting the set of command buffers (which can include executing secondary command buffers) between any semaphore or fence operations plays back the recorded commands as if they had all been recorded into a single primary command buffer,except that the current state is reset on each boundary.
在6.4节中,它指出用于同步的命令对包括:
First set: commands before a pipeline barrier.
Second set: commands after that pipeline barrier in the same queue (possibly limited to within the same subpass).
请注意,它表示“在同一队列中”,而不是“在同一个命令缓冲区中”.
这两个语句都清楚地表明管道障碍会影响队列的命令执行.执行依赖性不仅限于单个命令缓冲区的命令.