c – Vulkan:在多个命令缓冲区中排序图像内存屏障

前端之家收集整理的这篇文章主要介绍了c – Vulkan:在多个命令缓冲区中排序图像内存屏障前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
对于资源转换,您需要知道资源的“之前”和“之后”Vk ImageLayout(例如,传递给vkCmdPipelineBarrier的VkImageMemoryBarrier). Vulkan不保证任何命令缓冲区的执行顺序,除非在API文档中明确说明(从 this回答).但是,vkCmdPipelineBarrier明确表示它在调用之前和之后在命令缓冲区中创建命令之间的依赖关系.因此,当在单个命令缓冲区中转换图像时,可以在任何时刻“知道”图像的布局.

但是,vkQueueSumbit不会强制执行命令缓冲区的执行顺序.如果有两个命令缓冲区,每个命令缓冲区都有vkCmdPipelineBarrier调用将相同的图像转换为不同的布局,这两个操作之间是否存在依赖关系,还是在这种情况下需要显式同步?

解决方法

第2.2.1节说:

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).

请注意,它表示“在同一队列中”,而不是“在同一个命令缓冲区中”.

这两个语句都清楚地表明管道障碍会影响队列的命令执行.执行依赖性不仅限于单个命令缓冲区的命令.

猜你在找的C&C++相关文章