Vulkan Image Layouts(图像布局)

29 篇文章 2 订阅
10 篇文章 3 订阅

ulkan官方英文原文:请见 Vulkan® 1.3.236 - A Specification 12.4 章节。

对应的Vulkan技术规格说明书版本: Vulkan 1.3.2

Images are stored in implementation-dependent opaque layouts in memory. Each layout has limitations on what kinds of operations are supported for image subresources using the layout. At any given time, the data representing an image subresource in memory exists in a particular layout which is determined by the most recent layout transition that was performed on that image subresource. Applications have control over which layout each image subresource uses, and can transition an image subresource from one layout to another. Transitions can happen with an image memory barrier, included as part of a vkCmdPipelineBarrier or a vkCmdWaitEvents command buffer command (see Image Memory Barriers), or as part of a subpass dependency within a render pass (see VkSubpassDependency).

图像被存储在实现依赖不透明的内存中。每种布局对应各种使用这种布局的图像子资源所支持的操作都有限制。在任何给定的时间,内存中表示图像子资源的数据存在于特定布局中,此布局机制由由最近的布局转换决定,这个转换是在图像子资源上执行的。应用程序可以控制每个图像子资源使用的布局,并且可以将图像子资源从一种布局转换为另一种布局。图像内存屏障可以发生转换,作为vkCmdPipelineBarrier或vkCmdWaitEvents 命令缓冲区命令的一部分包括进来,或者作为一个渲染通道内的部分子通道依赖(请见 VkSubpassDependency)。

Image layout is per-image subresource. Separate image subresources of the same image can be in

different layouts at the same time, with the exception that depth and stencil aspects of a given image subresource can only be in different layouts if the separateDepthStencilLayouts feature is enabled.

图像布局是每个图像子资源。如果separateDepthStencilLayouts 特性启用的话,除了给定图像子资源的深度和模板这两方面只能用不同的布局之外,同一个图像的独立图像子资源同时可以用不同的布局。

Note:

Each layout may offer optimal performance for a specific usage of image memory.

For example, an image with a layout of VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL may provide optimal performance for use as a color attachment, but be unsupported for use in transfer commands. Applications can transition an image subresource from one layout to another in order to achieve optimal performance when the image subresource is used for multiple kinds of operations. After initialization, applications need not use any layout other than the general layout, though this may produce suboptimal performance on some implementations.

注意:

每种布局都能为图像内存特定的使用情况提供最优性能。

例如,一个用了VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL布局的图像,作为颜色附件使用的时候,性能最佳,但是它不支持应用于传输命令。当图像子资源被用于多种操作的时候,为了实现最优性能, 应用程序能将图像子资源的布局从一种转换为另一种。初始化之后,应用程序不需要使用除通用布局之外的任何布局,尽管在一些具体实现中这可能导致性能略差。

Upon creation, all image subresources of an image are initially in the same layout, where that layout is selected by the VkImageCreateInfo::initialLayout member. The initialLayout must be either VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED. If it is VK_IMAGE_LAYOUT_PREINITIALIZED, then the image data can be preinitialized by the host while using

this layout, and the transition away from this layout will preserve that data. If it is VK_IMAGE_LAYOUT_UNDEFINED, then the contents of the data are considered to be undefined, and the transition away from this layout is not guaranteed to preserve that data. For either of these initial layouts, any image subresources must be transitioned to another layout before they are accessed by the device.

图像对象一经创建,同一个图像上的所有图像子资源都用同样的布局初始化,这里的布局是由VkImageCreateInfo::initialLayout 成员变量的值指定的。初始化 initialLayout 必须是VK_IMAGE_LAYOUT_UNDEFINED 或 VK_IMAGE_LAYOUT_PREINITIALIZED二选一。如果此值是VK_IMAGE_LAYOUT_PREINITIALIZED,那么此图像数据可以被主机使用这个布局预初始化,并且从此布局转换到别的布局将保留相关数据。如果 initialLayout 的值是 VK_IMAGE_LAYOUT_UNDEFINED,那么数据的内容被认为是未定义的,并且从此布局转换到别的布局将不能保证保留相关数据。对于这些初始布局中的任何一个,任何图像子资源被设备实际访问之前,必须被转换到其他布局。

Host access to image memory is only well-defined for linear images and for image subresources of those images which are currently in either the VK_IMAGE_LAYOUT_PREINITIALIZED or VK_IMAGE_LAYOUT_GENERAL layout. Calling vkGetImageSubresourceLayout for a linear image returns a subresource layout mapping that is valid for either of those image layouts.

主机访问图像内存是定义明确的线性图像,以及那些当前使用VK_IMAGE_LAYOUT_PREINITIALIZED 或 VK_IMAGE_LAYOUT_GENERAL 这两者之一的图像的图像子资源。在线性图像上调用 vkGetImageSubresourceLayout 会返回一个对这些图像布局都有效的子资源布局映射。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值