如何处理可呈现图像的布局? [英] How to deal with the layouts of presentable images?

查看:72
本文介绍了如何处理可呈现图像的布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可展示的图像从VK_IMAGE_LAYOUT_UNDEFINED开始,但是在展示一次后将成为VK_IMAGE_LAYOUT_PRESENT_SRC_KHR.

A presentable image starts out in VK_IMAGE_LAYOUT_UNDEFINED but will be VK_IMAGE_LAYOUT_PRESENT_SRC_KHR after they have been presented once.

许多示例在创建vkSwapchain之后立即将所有vkImages转换为VK_IMAGE_LAYOUT_PRESENT_SRC_KHR.这使他们可以将VK_IMAGE_LAYOUT_PRESENT_SRC_KHR用于oldLayout. 但是在创建交换链后立即进行过渡是不允许.

A lot of examples do a transition of all vkImages to VK_IMAGE_LAYOUT_PRESENT_SRC_KHR immediately after creating the vkSwapchain. Which allows them to use an VK_IMAGE_LAYOUT_PRESENT_SRC_KHR for oldLayout. But doing the transition right after creation of the swapchain is not allowed.

仅在vkAcquireNextImageKHR返回图像之后,并且在vkQueuePresentKHR呈现图像之前,才可以使用可呈现的图像. 这包括转换图像布局和渲染命令.

Use of a presentable image must occur only after the image is returned by vkAcquireNextImageKHR, and before it is presented by vkQueuePresentKHR. This includes transitioning the image layout and rendering commands.

我有哪些正确处理交换链图像布局的选项?

What are my options to deal with the swapchain image layouts correctly?

推荐答案

有3个选项.从最佳到最差(IMO)排序:

There are 3 options. Ordered from best to worst (IMO):

  1. 只需将renderPass中附件的initialLayout每次设置为VK_IMAGE_LAYOUT_UNDEFINED或从VK_IMAGE_LAYOUT_UNDEFINED过渡. 这是允许的,这意味着您无需担心图像中仍然存在的数据.多数情况下,无论如何,您都会清除或完全覆盖图像.

  1. Simply set the initialLayout of the attachment in the renderPass to VK_IMAGE_LAYOUT_UNDEFINED or transition from VK_IMAGE_LAYOUT_UNDEFINED every time. This is allowed and will imply that you don't care about the data still in the image. Most often you will be clearing or fully overwriting the image anyway.

有效用法 [属于VkImageMemoryBarrier]
[...]

valid Usage [of VkImageMemoryBarrier]
[...]

  • oldLayout必须为VK_IMAGE_LAYOUT_UNDEFINEDVK_IMAGE_LAYOUT_PREINITIALIZED或受栅​​栏影响的图像区域的当前布局
  • oldLayout must be VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_PREINITIALIZED or the current layout of the image region affected by the barrier

  • 跟踪已通过管道的图像,并在记录commandBuffer时相应地选择oldLayout.

    在创建交换链之后执行转换,但是使用vkAcquireNextImageKHRvkQueuePresentKHR来确保应用程序在转换时拥有映像.无法保证您以什么顺序获得图像,因此有可能一幅图像从不退回.

    Do the transitions after creating the swapchain but using vkAcquireNextImageKHR and vkQueuePresentKHR to ensure the application owns the image while transitioning. There is no guarantee in which order you get the images So it may be possible one image never gets returned.

    这篇关于如何处理可呈现图像的布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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