我对 的语义感到困惑vkAcquireNextImageKHR
。具体来说,函数在什么情况下可以返回VK_TIMEOUT
?即什么可以阻止它无法立即获取图像?它可能会等待发生什么?
似乎即使呈现引擎尚未完成从图像的读取,也可以获取图像,并且无论如何都需要使用信号量或栅栏来同步所获取图像的使用。我缺少什么?
Nicol Bolas's answer is correct, but since the responses to it asked for details about where this is used in real implementations I'll add another answer here.
On Android, vkQueuePresentKHR
sends the image to the compositor (SurfaceFlinger), which displays it. The compositor re-displays this image on every display refresh until it gets a new image to display for that window. Until it gets that next image, it doesn't know whether or how many times it will need to read the buffer again in the future, and can't create a semaphore that will signal when the last read completes. (Hypothetically, you could build a system that could do that, but that's not how the Linux kernel sync mechanisms Android uses for this work.) So until you present image N+1, the compositor can't release image N back to your app for it to acquire, since it can't give you a semaphore to go along with it.
It's a little more complicated than that, since even if you present frame N+1, the compositor doesn't know how long it will take until the rendering semaphore signals, so it still doesn't know immediately how much longer it will need to be able to read the image for frame N.
This extends to swapchains with more than two buffers.
我对其他系统不太熟悉,但我相信其他系统也有类似的限制,导致它们无法让您在呈现图像之前任意获取图像。构建一个允许这样做的演示引擎绝对是可能的,但 Vulkan 需要在现有系统和现有演示引擎上工作,因此必须忍受现有系统施加的限制。Khronos 成员无法更改 Windows 合成器,而 X11、Wayland 和 Android 等其他合成器很难/缓慢地更改,因为这样做可能会影响所有现有的应用程序、框架等。
归档时间: |
|
查看次数: |
2140 次 |
最近记录: |