Vulkan:难以理解帧缓冲区的循环 [英] Vulkan: trouble understanding cycling of framebuffers

查看:79
本文介绍了Vulkan:难以理解帧缓冲区的循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Vulkan中,

信号量( A )和围栏( X )可以传递给 vkAcquireNextImageKHR.该信号量( A )随后传递到 vkQueueSubmit ,以等待图像由 Presentation Engine 释放.(PE).篱笆( Y )也可以传递给 vkQueueSubmit .客户端代码可以通过检查围栅( Y )来检查提交的完成时间.

A semaphore(A) and a fence(X) can be passed to vkAcquireNextImageKHR. That semaphore(A) is subsequently passed to vkQueueSubmit, to wait until the image is released by the Presentation Engine (PE). A fence(Y) can also be passed to vkQueueSubmit. Client code can check when the submission has completed by checking fence(Y).

当击出栅栏( Y )时,这意味着PE可以显示图像.

When fence(Y) signals, this means the PE can display the image.

我的问题:

如何知道在调用 vkQueuePresentKHR 后PE何时完成使用图像?在我看来,这似乎不是通过检查fence( X )来完成的,因为这是为了让客户端代码知道何时可以通过<写入图像.code> vkQueueSubmit ,不是吗?将图像发送到 vkQueueSubmit 后,似乎击穿了围栅( X )的用处.或者,可以在调用 vkQueuePresentKHR 后使用相同的围栅( X )查询图像的可用性吗?

How do I know when the PE has finished using the image after a call to vkQueuePresentKHR? To me, it doesn't seem that it would be by checking fence(X), because that is for client code to know when the image can be written to by vkQueueSubmit, isn't it? After the image is sent to vkQueueSubmit, it seems the usefulness of fence(X) is done. Or, can the same fence(X) be used to query the image availability after the call to vkQueuePresentKHR?

我不知道在调用 vkQueuePresentKHR 之后是否又可以再次使用该图像,而不必调用 vkAcquireNextImageKHR .

I don't know when the image is available again after a call to vkQueuePresentKHR, without having to call vkAcquireNextImageKHR.

这给我造成麻烦的原因是,在异步的60fps,三重缓冲的应用程序(可丢弃的学习代码)中,事情像这样破烂了:

The reason this is causing trouble for me is that in an asynchronous, 60fps, triple buffered app (throwaway learning code), things get out of wack like this:

  1. 将初始帧缓冲区发送到PE.现在,该帧缓冲区在16毫秒内不可用.
  2. 在16毫秒内,获取第二个图像/帧缓冲区,提交命令,但不显示.
  3. 与#2相同,以获得第三张图像.我们在16毫秒之前提交.
  4. 16ms已经过去了,所以我们 vkQueuePresentKHR 第二张图片.
  5. 现在,如果我调用 vkAcquireNextImageKHR ,那么如果尚未使用#1图像,整个事情就会失败,因为此时我已经获取了三张图像.
  6. 如何不调用 vkAcquireNextImageKHR 而知道图像#1是否再次可用?
  1. Send an initial framebuffer to the PE. This framebuffer is now unavailable for 16 milliseconds.
  2. Within the 16ms, acquire a second image/framebuffer, submit commands, but don't present.
  3. Do the same as #2, for a third image. We submit it before 16ms.
  4. 16ms have gone by, so we vkQueuePresentKHR the second image.
  5. Now, if I call vkAcquireNextImageKHR, the whole thing can fail if image #1 is not yet done being used, because I have acquired three images at this point.
  6. How to know if image #1 is available again without calling vkAcquireNextImageKHR?

推荐答案

在调用 vkQueuePresentKHR 后,如何知道PE何时完成使用图像?

How do I know when the PE has finished using the image after a call to vkQueuePresentKHR?

您通常不需要知道.

您要么需要获取一个新的 VkImage ,要么您不需要.PE是否完成甚至都不输入该决定.

Either you need to acquire a new VkImage, or you don't. Whether PE has finished or not does not even enter that decision.

仅想知道的原因是您是否要测量演示时间.有一个特殊的扩展名: VK_GOOGLE_display_timing .

Only reason wanting to know is if you want to measure presentation times. There's a special extension for that: VK_GOOGLE_display_timing.

将图像发送到 vkQueueSubmit 后,似乎击穿了( X )的功能.

After the image is sent to vkQueueSubmit, it seems the usefulness of fence(X) is done.

好吧,您可以重新使用围栏.但是,一旦收到信号,该实现便停止使用它,并且不再将其状态更改为任何状态(如果您要这样做的话(因此您可以自由地 vkDestroy 它或执行其他操作)的东西.)

Well, you can reuse the fence. But the Implementation has stopped using it as soon as it was signaled and won't be changing its state anymore to anything, if that's what you are asking (and so you are free to vkDestroy it or do other things with it).

我不知道在调用 vkQueuePresentKHR 之后是否又可以再次使用该图像,而不必调用 vkAcquireNextImageKHR .

I don't know when the image is available again after a call to vkQueuePresentKHR, without having to call vkAcquireNextImageKHR.

希望我在下面介绍了它,但我不确定这是什么问题.我也不知道怎么也没有汤匙吃汤.只需使用汤匙-我的意思是 vkAcquireNextImageKHR .

Hopefully I cover it below, but I am not precisely sure what the problem here is. I don't know how to eat a soup without a spoon neither. Simply use a spoon— I mean vkAcquireNextImageKHR.

  1. 现在,如果我调用 vkAcquireNextImageKHR ,如果尚未使用图像#1>,整个事情可能会失败,因为此时我已经获得了3张图像.
  2. 如何不调用> vkAcquireNextImageKHR 而知道图像#1是否再次可用?
  1. Now, if I call vkAcquireNextImageKHR, the whole thing can fail if image #1 >is not yet done being used, because I have acquired 3 images at this point.
  2. How to know if image #1 is available again without calling >vkAcquireNextImageKHR?

与图片#1和#2有什么不同?

How is it any different than image #1 and #2?

是的,您可能已经获取了交换链必须提供的所有图像,或者PE还没有准备好"提供图像,即使它有两个.

Yes, you may have already acquired all the images the swapchain has to offer, or the PE is "not ready" to give away an image even if it has two.

在第一种情况下,规范建议不要使用 UINT64_MAX timeout 调用 vkAcquireNextImageKHR .与 vkQueuePresentKHR 相比,计算成功的 vkAcquireNextImageKHR 调用很简单.一种方法可能是简单地执行一个 vkAcquireNextImageKHR 然后执行一个 vkQueuePresentKHR .

In the first case the spec advises against calling vkAcquireNextImageKHR with timeout of UINT64_MAX. It is a simple matter of counting the successful vkAcquireNextImageKHR calls vs the vkQueuePresentKHRs. One way may be to simply do one vkAcquireNextImageKHR and then do one vkQueuePresentKHR.

在第二种情况下,您只需调用 vkAcquireNextImageKHR ,您最终将获得图像.

In the second case you can simply call vkAcquireNextImageKHR and you will eventually get the image.

这篇关于Vulkan:难以理解帧缓冲区的循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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