Vulkan:在多个命令缓冲区中排序图像内存屏障 [英] Vulkan: ordering image memory barriers in multiple command buffers

查看:899
本文介绍了Vulkan:在多个命令缓冲区中排序图像内存屏障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于资源转换,您需要知道资源的before和after VkImageLayout (例如在 VkImageMemoryBarrier 传递给 vkCmdPipelineBarrier )。 Vulkan不保证执行命令缓冲区的任何顺序,除非API文档中明确说明(从 this 答案)。但是, vkCmdPipelineBarrier 明确地说,它在调用之前和之后在命令缓冲区中的命令之间创建一个依赖关系。因此,当在单个命令缓冲区中转换时,可以在任何时候知道图像的布局。

For resource transitions, you need to know the 'before' and 'after' VkImageLayout of the resource (eg. in the VkImageMemoryBarrier passed to vkCmdPipelineBarrier). Vulkan does not guarantee any ordering of execution of command buffers, unless explicitly stated in the API documentation (from this answer). However, vkCmdPipelineBarrier does explicitly say that it creates a dependency between commands in the command buffer, before and after the call. So it is possible to 'know' the layout of an image at any point when it is transitioned within a single command buffer.

但是, vkQueueSumbit 不强制执行命令缓冲区的执行顺序。如果有两个命令缓冲区,每个都有 vkCmdPipelineBarrier 调用将同一个映像转换到不同的布局,这两个操作之间是否有依赖关系,或者这种情况下是否需要显式同步?

However, vkQueueSumbit does not enforce the execution order of command buffers. If there are two command buffers, each with vkCmdPipelineBarrier calls transitioning the same image to different layouts, is there any dependency between these two operations, or is explicit synchronization required in this situation?

推荐答案

第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节中,它指出同步命令对包括:

In section 6.4, it states that the pairs of commands for synchronizations include:


第一组:在管道屏障之前的命令。

First set: commands before a pipeline barrier.

第二组:

请注意,它说在同一队列中,而不是在同一个队列中命令缓冲区。

Note that it says "in the same queue", not "in the same command buffer".

这两个语句清楚地表明,流水线障碍影响队列执行命令。执行依赖项不限于单个命令缓冲区的命令。

Both of these statements make it clear that pipeline barriers affect the queue's execution of commands. Execution dependencies are not limited to a single command buffer's commands.

这篇关于Vulkan:在多个命令缓冲区中排序图像内存屏障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆