1e5c31af7Sopenharmony_ci// Copyright 2015-2021 The Khronos Group, Inc. 2e5c31af7Sopenharmony_ci// 3e5c31af7Sopenharmony_ci// SPDX-License-Identifier: CC-BY-4.0 4e5c31af7Sopenharmony_ci 5e5c31af7Sopenharmony_ci[[sparsememory]] 6e5c31af7Sopenharmony_ci= Sparse Resources 7e5c31af7Sopenharmony_ci 8e5c31af7Sopenharmony_ciAs documented in <<resources-association,Resource Memory Association>>, 9e5c31af7Sopenharmony_cisname:VkBuffer and sname:VkImage resources in Vulkan must: be bound 10e5c31af7Sopenharmony_cicompletely and contiguously to a single sname:VkDeviceMemory object. 11e5c31af7Sopenharmony_ciThis binding must: be done before the resource is used, and the binding is 12e5c31af7Sopenharmony_ciimmutable for the lifetime of the resource. 13e5c31af7Sopenharmony_ci 14e5c31af7Sopenharmony_ci_Sparse resources_ relax these restrictions and provide these additional 15e5c31af7Sopenharmony_cifeatures: 16e5c31af7Sopenharmony_ci 17e5c31af7Sopenharmony_ci * Sparse resources can: be bound non-contiguously to one or more 18e5c31af7Sopenharmony_ci sname:VkDeviceMemory allocations. 19e5c31af7Sopenharmony_ci * Sparse resources can: be re-bound to different memory allocations over 20e5c31af7Sopenharmony_ci the lifetime of the resource. 21e5c31af7Sopenharmony_ci * Sparse resources can: have descriptors generated and used orthogonally 22e5c31af7Sopenharmony_ci with memory binding commands. 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci 25e5c31af7Sopenharmony_ci[[sparsememory-sparseresourcefeatures]] 26e5c31af7Sopenharmony_ci== Sparse Resource Features 27e5c31af7Sopenharmony_ci 28e5c31af7Sopenharmony_ciSparse resources have several features that must: be enabled explicitly at 29e5c31af7Sopenharmony_ciresource creation time. 30e5c31af7Sopenharmony_ciThe features are enabled by including bits in the pname:flags parameter of 31e5c31af7Sopenharmony_cislink:VkImageCreateInfo or slink:VkBufferCreateInfo. 32e5c31af7Sopenharmony_ciEach feature also has one or more corresponding feature enables specified in 33e5c31af7Sopenharmony_cislink:VkPhysicalDeviceFeatures. 34e5c31af7Sopenharmony_ci 35e5c31af7Sopenharmony_ci * <<features-sparseBinding,Sparse binding>> is the base feature, and 36e5c31af7Sopenharmony_ci provides the following capabilities: 37e5c31af7Sopenharmony_ci 38e5c31af7Sopenharmony_ci ** Resources can: be bound at some defined (sparse block) granularity. 39e5c31af7Sopenharmony_ci ** The entire resource must: be bound to memory before use regardless of 40e5c31af7Sopenharmony_ci regions actually accessed. 41e5c31af7Sopenharmony_ci ** No specific mapping of image region to memory offset is defined, i.e. 42e5c31af7Sopenharmony_ci the location that each texel corresponds to in memory is 43e5c31af7Sopenharmony_ci implementation-dependent. 44e5c31af7Sopenharmony_ci ** Sparse buffers have a well-defined mapping of buffer range to memory 45e5c31af7Sopenharmony_ci range, where an offset into a range of the buffer that is bound to a 46e5c31af7Sopenharmony_ci single contiguous range of memory corresponds to an identical offset 47e5c31af7Sopenharmony_ci within that range of memory. 48e5c31af7Sopenharmony_ci ** Requested via the ename:VK_IMAGE_CREATE_SPARSE_BINDING_BIT and 49e5c31af7Sopenharmony_ci ename:VK_BUFFER_CREATE_SPARSE_BINDING_BIT bits. 50e5c31af7Sopenharmony_ci ** A sparse image created using ename:VK_IMAGE_CREATE_SPARSE_BINDING_BIT 51e5c31af7Sopenharmony_ci (but not ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) supports all 52e5c31af7Sopenharmony_ci formats that non-sparse usage supports, and supports both 53e5c31af7Sopenharmony_ci ename:VK_IMAGE_TILING_OPTIMAL and ename:VK_IMAGE_TILING_LINEAR tiling. 54e5c31af7Sopenharmony_ci 55e5c31af7Sopenharmony_ci * _Sparse Residency_ builds on (and requires) the pname:sparseBinding 56e5c31af7Sopenharmony_ci feature. 57e5c31af7Sopenharmony_ci It includes the following capabilities: 58e5c31af7Sopenharmony_ci 59e5c31af7Sopenharmony_ci ** Resources do not have to be completely bound to memory before use on 60e5c31af7Sopenharmony_ci the device. 61e5c31af7Sopenharmony_ci ** Images have a prescribed sparse image block layout, allowing specific 62e5c31af7Sopenharmony_ci rectangular regions of the image to be bound to specific offsets in 63e5c31af7Sopenharmony_ci memory allocations. 64e5c31af7Sopenharmony_ci ** Consistency of access to unbound regions of the resource is defined by 65e5c31af7Sopenharmony_ci the absence or presence of 66e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceSparseProperties::pname:residencyNonResidentStrict. 67e5c31af7Sopenharmony_ci If this property is present, accesses to unbound regions of the 68e5c31af7Sopenharmony_ci resource are well defined and behave as if the data bound is populated 69e5c31af7Sopenharmony_ci with all zeros; writes are discarded. 70e5c31af7Sopenharmony_ci When this property is absent, accesses are considered safe, but reads 71e5c31af7Sopenharmony_ci will return undefined: values. 72e5c31af7Sopenharmony_ci ** Requested via the ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT and 73e5c31af7Sopenharmony_ci ename:VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT bits. 74e5c31af7Sopenharmony_ci ** [[features-sparseResidency]] Sparse residency support is advertised on 75e5c31af7Sopenharmony_ci a finer grain via the following features: 76e5c31af7Sopenharmony_ci+ 77e5c31af7Sopenharmony_ci *** <<features-sparseResidencyBuffer,pname:sparseResidencyBuffer>>: 78e5c31af7Sopenharmony_ci Support for creating sname:VkBuffer objects with the 79e5c31af7Sopenharmony_ci ename:VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT. 80e5c31af7Sopenharmony_ci *** <<features-sparseResidencyImage2D,pname:sparseResidencyImage2D>>: 81e5c31af7Sopenharmony_ci Support for creating 2D single-sampled sname:VkImage objects with 82e5c31af7Sopenharmony_ci ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT. 83e5c31af7Sopenharmony_ci *** <<features-sparseResidencyImage3D,pname:sparseResidencyImage3D>>: 84e5c31af7Sopenharmony_ci Support for creating 3D sname:VkImage objects with 85e5c31af7Sopenharmony_ci ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT. 86e5c31af7Sopenharmony_ci *** <<features-sparseResidency2Samples,pname:sparseResidency2Samples>>: 87e5c31af7Sopenharmony_ci Support for creating 2D sname:VkImage objects with 2 samples and 88e5c31af7Sopenharmony_ci ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT. 89e5c31af7Sopenharmony_ci *** <<features-sparseResidency4Samples,pname:sparseResidency4Samples>>: 90e5c31af7Sopenharmony_ci Support for creating 2D sname:VkImage objects with 4 samples and 91e5c31af7Sopenharmony_ci ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT. 92e5c31af7Sopenharmony_ci *** <<features-sparseResidency8Samples,pname:sparseResidency8Samples>>: 93e5c31af7Sopenharmony_ci Support for creating 2D sname:VkImage objects with 8 samples and 94e5c31af7Sopenharmony_ci ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT. 95e5c31af7Sopenharmony_ci *** <<features-sparseResidency16Samples,pname:sparseResidency16Samples>>: 96e5c31af7Sopenharmony_ci Support for creating 2D sname:VkImage objects with 16 samples and 97e5c31af7Sopenharmony_ci ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT. 98e5c31af7Sopenharmony_ci+ 99e5c31af7Sopenharmony_ciImplementations supporting pname:sparseResidencyImage2D are only required: 100e5c31af7Sopenharmony_cito support sparse 2D, single-sampled images. 101e5c31af7Sopenharmony_ciSupport for sparse 3D and MSAA images is optional: and can: be enabled via 102e5c31af7Sopenharmony_cipname:sparseResidencyImage3D, pname:sparseResidency2Samples, 103e5c31af7Sopenharmony_cipname:sparseResidency4Samples, pname:sparseResidency8Samples, and 104e5c31af7Sopenharmony_cipname:sparseResidency16Samples. 105e5c31af7Sopenharmony_ci 106e5c31af7Sopenharmony_ci ** A sparse image created using ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT 107e5c31af7Sopenharmony_ci supports all non-compressed color formats with power-of-two element 108e5c31af7Sopenharmony_ci size that non-sparse usage supports. 109e5c31af7Sopenharmony_ci Additional formats may: also be supported and can: be queried via 110e5c31af7Sopenharmony_ci flink:vkGetPhysicalDeviceSparseImageFormatProperties. 111e5c31af7Sopenharmony_ci ename:VK_IMAGE_TILING_LINEAR tiling is not supported. 112e5c31af7Sopenharmony_ci 113e5c31af7Sopenharmony_ci * <<features-sparseResidencyAliased,Sparse aliasing>> provides the 114e5c31af7Sopenharmony_ci following capability that can: be enabled per resource: 115e5c31af7Sopenharmony_ci+ 116e5c31af7Sopenharmony_ciAllows physical memory ranges to be shared between multiple locations in the 117e5c31af7Sopenharmony_cisame sparse resource or between multiple sparse resources, with each binding 118e5c31af7Sopenharmony_ciof a memory location observing a consistent interpretation of the memory 119e5c31af7Sopenharmony_cicontents. 120e5c31af7Sopenharmony_ci+ 121e5c31af7Sopenharmony_ciSee <<sparsememory-sparse-memory-aliasing,Sparse Memory Aliasing>> for more 122e5c31af7Sopenharmony_ciinformation. 123e5c31af7Sopenharmony_ci 124e5c31af7Sopenharmony_ci 125e5c31af7Sopenharmony_ci[[sparsememory-fully-resident]] 126e5c31af7Sopenharmony_ci== Sparse Buffers and Fully-Resident Images 127e5c31af7Sopenharmony_ci 128e5c31af7Sopenharmony_ciBoth sname:VkBuffer and sname:VkImage objects created with the 129e5c31af7Sopenharmony_ciename:VK_IMAGE_CREATE_SPARSE_BINDING_BIT or 130e5c31af7Sopenharmony_ciename:VK_BUFFER_CREATE_SPARSE_BINDING_BIT bits can: be thought of as a 131e5c31af7Sopenharmony_cilinear region of address space. 132e5c31af7Sopenharmony_ciIn the sname:VkImage case if ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT is 133e5c31af7Sopenharmony_cinot used, this linear region is entirely opaque, meaning that there is no 134e5c31af7Sopenharmony_ciapplication-visible mapping between texel location and memory offset. 135e5c31af7Sopenharmony_ci 136e5c31af7Sopenharmony_ciUnless ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or 137e5c31af7Sopenharmony_ciename:VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT are also used, the entire 138e5c31af7Sopenharmony_ciresource must: be bound to one or more sname:VkDeviceMemory objects before 139e5c31af7Sopenharmony_ciuse. 140e5c31af7Sopenharmony_ci 141e5c31af7Sopenharmony_ci 142e5c31af7Sopenharmony_ci=== Sparse Buffer and Fully-Resident Image Block Size 143e5c31af7Sopenharmony_ci 144e5c31af7Sopenharmony_ciThe sparse block size in bytes for sparse buffers and fully-resident images 145e5c31af7Sopenharmony_ciis reported as sname:VkMemoryRequirements::pname:alignment. 146e5c31af7Sopenharmony_cipname:alignment represents both the memory alignment requirement and the 147e5c31af7Sopenharmony_cibinding granularity (in bytes) for sparse resources. 148e5c31af7Sopenharmony_ci 149e5c31af7Sopenharmony_ci 150e5c31af7Sopenharmony_ci[[sparsememory-partially-resident-buffers]] 151e5c31af7Sopenharmony_ci== Sparse Partially-Resident Buffers 152e5c31af7Sopenharmony_ci 153e5c31af7Sopenharmony_cisname:VkBuffer objects created with the 154e5c31af7Sopenharmony_ciename:VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT bit allow the buffer to be made 155e5c31af7Sopenharmony_cionly partially resident. 156e5c31af7Sopenharmony_ciPartially resident sname:VkBuffer objects are allocated and bound 157e5c31af7Sopenharmony_ciidentically to sname:VkBuffer objects using only the 158e5c31af7Sopenharmony_ciename:VK_BUFFER_CREATE_SPARSE_BINDING_BIT feature. 159e5c31af7Sopenharmony_ciThe only difference is the ability for some regions of the buffer to be 160e5c31af7Sopenharmony_ciunbound during device use. 161e5c31af7Sopenharmony_ci 162e5c31af7Sopenharmony_ci 163e5c31af7Sopenharmony_ci[[sparsememory-partially-resident-images]] 164e5c31af7Sopenharmony_ci== Sparse Partially-Resident Images 165e5c31af7Sopenharmony_ci 166e5c31af7Sopenharmony_cisname:VkImage objects created with the 167e5c31af7Sopenharmony_ciename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT bit allow specific rectangular 168e5c31af7Sopenharmony_ciregions of the image called sparse image blocks to be bound to specific 169e5c31af7Sopenharmony_ciranges of memory. 170e5c31af7Sopenharmony_ciThis allows the application to manage residency at either image subresource 171e5c31af7Sopenharmony_cior sparse image block granularity. 172e5c31af7Sopenharmony_ciEach image subresource (outside of the <<sparsememory-miptail,mip tail>>) 173e5c31af7Sopenharmony_cistarts on a sparse block boundary and has dimensions that are integer 174e5c31af7Sopenharmony_cimultiples of the corresponding dimensions of the sparse image block. 175e5c31af7Sopenharmony_ci 176e5c31af7Sopenharmony_ci[NOTE] 177e5c31af7Sopenharmony_ci.Note 178e5c31af7Sopenharmony_ci==== 179e5c31af7Sopenharmony_ciApplications can: use these types of images to control LOD based on total 180e5c31af7Sopenharmony_cimemory consumption. 181e5c31af7Sopenharmony_ciIf memory pressure becomes an issue the application can: unbind and disable 182e5c31af7Sopenharmony_cispecific mipmap levels of images without having to recreate resources or 183e5c31af7Sopenharmony_cimodify texel data of unaffected levels. 184e5c31af7Sopenharmony_ci 185e5c31af7Sopenharmony_ciThe application can: also use this functionality to access subregions of the 186e5c31af7Sopenharmony_ciimage in a "`megatexture`" fashion. 187e5c31af7Sopenharmony_ciThe application can: create a large image and only populate the region of 188e5c31af7Sopenharmony_cithe image that is currently being used in the scene. 189e5c31af7Sopenharmony_ci==== 190e5c31af7Sopenharmony_ci 191e5c31af7Sopenharmony_ci 192e5c31af7Sopenharmony_ci[[sparsememory-accessing-unbound]] 193e5c31af7Sopenharmony_ci=== Accessing Unbound Regions 194e5c31af7Sopenharmony_ci 195e5c31af7Sopenharmony_ciThe following member of sname:VkPhysicalDeviceSparseProperties affects how 196e5c31af7Sopenharmony_cidata in unbound regions of sparse resources are handled by the 197e5c31af7Sopenharmony_ciimplementation: 198e5c31af7Sopenharmony_ci 199e5c31af7Sopenharmony_ci * pname:residencyNonResidentStrict 200e5c31af7Sopenharmony_ci 201e5c31af7Sopenharmony_ciIf this property is not present, reads of unbound regions of the image will 202e5c31af7Sopenharmony_cireturn undefined: values. 203e5c31af7Sopenharmony_ciBoth reads and writes are still considered _safe_ and will not affect other 204e5c31af7Sopenharmony_ciresources or populated regions of the image. 205e5c31af7Sopenharmony_ci 206e5c31af7Sopenharmony_ciIf this property is present, all reads of unbound regions of the image will 207e5c31af7Sopenharmony_cibehave as if the region was bound to memory populated with all zeros; writes 208e5c31af7Sopenharmony_ciwill be discarded. 209e5c31af7Sopenharmony_ci 210e5c31af7Sopenharmony_ciFormatted accesses to unbound memory may: still alter some component values 211e5c31af7Sopenharmony_ciin the natural way for those accesses, e.g. substituting a value of one for 212e5c31af7Sopenharmony_cialpha in formats that do not have an alpha component. 213e5c31af7Sopenharmony_ci 214e5c31af7Sopenharmony_ci==== 215e5c31af7Sopenharmony_ciExample: Reading the alpha component of an unbacked ename:VK_FORMAT_R8_UNORM 216e5c31af7Sopenharmony_ciimage will return a value of [eq]#1.0f#. 217e5c31af7Sopenharmony_ci==== 218e5c31af7Sopenharmony_ci 219e5c31af7Sopenharmony_ciSee <<devsandqueues-physical-device-enumeration,Physical Device 220e5c31af7Sopenharmony_ciEnumeration>> for instructions for retrieving physical device properties. 221e5c31af7Sopenharmony_ci 222e5c31af7Sopenharmony_ciifdef::implementation-guide[] 223e5c31af7Sopenharmony_ci.Implementor's Note 224e5c31af7Sopenharmony_ci**** 225e5c31af7Sopenharmony_ciFor implementations that cannot: natively handle access to unbound regions 226e5c31af7Sopenharmony_ciof a resource, the implementation may: allocate and bind memory to the 227e5c31af7Sopenharmony_ciunbound regions. 228e5c31af7Sopenharmony_ciReads and writes to unbound regions will access the implementation-managed 229e5c31af7Sopenharmony_cimemory instead. 230e5c31af7Sopenharmony_ci 231e5c31af7Sopenharmony_ciGiven that the values resulting from reads of unbound regions are undefined: 232e5c31af7Sopenharmony_ciin this scenario, implementations may: use the same physical memory for all 233e5c31af7Sopenharmony_ciunbound regions of multiple resources within the same process. 234e5c31af7Sopenharmony_ci**** 235e5c31af7Sopenharmony_ciendif::implementation-guide[] 236e5c31af7Sopenharmony_ci 237e5c31af7Sopenharmony_ci 238e5c31af7Sopenharmony_ci[[sparsememory-miptail]] 239e5c31af7Sopenharmony_ci=== Mip Tail Regions 240e5c31af7Sopenharmony_ci 241e5c31af7Sopenharmony_ciSparse images created using ename:VK_IMAGE_CREATE_SPARSE_BINDING_BIT 242e5c31af7Sopenharmony_ci(without also using ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) have no 243e5c31af7Sopenharmony_cispecific mapping of image region or image subresource to memory offset 244e5c31af7Sopenharmony_cidefined, so the entire image can: be thought of as a linear opaque address 245e5c31af7Sopenharmony_ciregion. 246e5c31af7Sopenharmony_ciHowever, images created with ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT do 247e5c31af7Sopenharmony_cihave a prescribed sparse image block layout, and hence each image 248e5c31af7Sopenharmony_cisubresource must: start on a sparse block boundary. 249e5c31af7Sopenharmony_ciWithin each array layer, the set of mip levels that have a smaller size than 250e5c31af7Sopenharmony_cithe sparse block size in bytes are grouped together into a _mip tail 251e5c31af7Sopenharmony_ciregion_. 252e5c31af7Sopenharmony_ci 253e5c31af7Sopenharmony_ciIf the ename:VK_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT flag is present in 254e5c31af7Sopenharmony_cithe pname:flags member of sname:VkSparseImageFormatProperties, for the 255e5c31af7Sopenharmony_ciimage's pname:format, then any mip level which has dimensions that are not 256e5c31af7Sopenharmony_ciinteger multiples of the corresponding dimensions of the sparse image block, 257e5c31af7Sopenharmony_ciand all subsequent mip levels, are also included in the mip tail region. 258e5c31af7Sopenharmony_ci 259e5c31af7Sopenharmony_ciThe following member of sname:VkPhysicalDeviceSparseProperties may: affect 260e5c31af7Sopenharmony_cihow the implementation places mip levels in the mip tail region: 261e5c31af7Sopenharmony_ci 262e5c31af7Sopenharmony_ci * pname:residencyAlignedMipSize 263e5c31af7Sopenharmony_ci 264e5c31af7Sopenharmony_ciEach mip tail region is bound to memory as an opaque region (i.e. must: be 265e5c31af7Sopenharmony_cibound using a slink:VkSparseImageOpaqueMemoryBindInfo structure) and may: be 266e5c31af7Sopenharmony_ciof a size greater than or equal to the sparse block size in bytes. 267e5c31af7Sopenharmony_ciThis size is guaranteed to be an integer multiple of the sparse block size 268e5c31af7Sopenharmony_ciin bytes. 269e5c31af7Sopenharmony_ci 270e5c31af7Sopenharmony_ciAn implementation may: choose to allow each array-layer's mip tail region to 271e5c31af7Sopenharmony_cibe bound to memory independently or require that all array-layer's mip tail 272e5c31af7Sopenharmony_ciregions be treated as one. 273e5c31af7Sopenharmony_ciThis is dictated by ename:VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT in 274e5c31af7Sopenharmony_cisname:VkSparseImageMemoryRequirements::pname:flags. 275e5c31af7Sopenharmony_ci 276e5c31af7Sopenharmony_ciThe following diagrams depict how 277e5c31af7Sopenharmony_ciename:VK_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT and 278e5c31af7Sopenharmony_ciename:VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT alter memory usage and 279e5c31af7Sopenharmony_cirequirements. 280e5c31af7Sopenharmony_ci 281e5c31af7Sopenharmony_ciimage::{images}/sparseimage.svg[align="center",title="Sparse Image",opts="{imageopts}"] 282e5c31af7Sopenharmony_ci 283e5c31af7Sopenharmony_ciIn the absence of ename:VK_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT and 284e5c31af7Sopenharmony_ciename:VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT, each array layer contains a 285e5c31af7Sopenharmony_cimip tail region containing texel data for all mip levels smaller than the 286e5c31af7Sopenharmony_cisparse image block in any dimension. 287e5c31af7Sopenharmony_ci 288e5c31af7Sopenharmony_ciMip levels that are as large or larger than a sparse image block in all 289e5c31af7Sopenharmony_cidimensions can: be bound individually. 290e5c31af7Sopenharmony_ciRight-edges and bottom-edges of each level are allowed to have partially 291e5c31af7Sopenharmony_ciused sparse blocks. 292e5c31af7Sopenharmony_ciAny bound partially-used-sparse-blocks must: still have their full sparse 293e5c31af7Sopenharmony_ciblock size in bytes allocated in memory. 294e5c31af7Sopenharmony_ci 295e5c31af7Sopenharmony_ciimage::{images}/sparseimage_singlemiptail.svg[align="center",title="Sparse Image with Single Mip Tail",opts="{imageopts}"] 296e5c31af7Sopenharmony_ci 297e5c31af7Sopenharmony_ciWhen ename:VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT is present all array 298e5c31af7Sopenharmony_cilayers will share a single mip tail region. 299e5c31af7Sopenharmony_ci 300e5c31af7Sopenharmony_ciimage::{images}/sparseimage_alignedmipsize.svg[align="center",title="Sparse Image with Aligned Mip Size",opts="{imageopts}"] 301e5c31af7Sopenharmony_ci 302e5c31af7Sopenharmony_ci[NOTE] 303e5c31af7Sopenharmony_ci.Note 304e5c31af7Sopenharmony_ci==== 305e5c31af7Sopenharmony_ciThe mip tail regions are presented here in 2D arrays simply for figure size 306e5c31af7Sopenharmony_cireasons. 307e5c31af7Sopenharmony_ciEach mip tail is logically a single array of sparse blocks with an 308e5c31af7Sopenharmony_ciimplementation-dependent mapping of texels or compressed texel blocks to 309e5c31af7Sopenharmony_cisparse blocks. 310e5c31af7Sopenharmony_ci==== 311e5c31af7Sopenharmony_ci 312e5c31af7Sopenharmony_ciWhen ename:VK_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT is present the first 313e5c31af7Sopenharmony_cimip level that would contain partially used sparse blocks begins the mip 314e5c31af7Sopenharmony_citail region. 315e5c31af7Sopenharmony_ciThis level and all subsequent levels are placed in the mip tail. 316e5c31af7Sopenharmony_ciOnly the first [eq]#N# mip levels whose dimensions are an exact multiple of 317e5c31af7Sopenharmony_cithe sparse image block dimensions can: be bound and unbound on a sparse 318e5c31af7Sopenharmony_ciblock basis. 319e5c31af7Sopenharmony_ci 320e5c31af7Sopenharmony_ciimage::{images}/sparseimage_alignedmipsize_singlemiptail.svg[align="center",title="Sparse Image with Aligned Mip Size and Single Mip Tail",opts="{imageopts}"] 321e5c31af7Sopenharmony_ci 322e5c31af7Sopenharmony_ci[NOTE] 323e5c31af7Sopenharmony_ci.Note 324e5c31af7Sopenharmony_ci==== 325e5c31af7Sopenharmony_ciThe mip tail region is presented here in a 2D array simply for figure size 326e5c31af7Sopenharmony_cireasons. 327e5c31af7Sopenharmony_ciIt is logically a single array of sparse blocks with an 328e5c31af7Sopenharmony_ciimplementation-dependent mapping of texels or compressed texel blocks to 329e5c31af7Sopenharmony_cisparse blocks. 330e5c31af7Sopenharmony_ci==== 331e5c31af7Sopenharmony_ci 332e5c31af7Sopenharmony_ciWhen both ename:VK_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT and 333e5c31af7Sopenharmony_ciename:VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT are present the constraints 334e5c31af7Sopenharmony_cifrom each of these flags are in effect. 335e5c31af7Sopenharmony_ci 336e5c31af7Sopenharmony_ci 337e5c31af7Sopenharmony_ci[[sparsememory-standard-shapes]] 338e5c31af7Sopenharmony_ci=== Standard Sparse Image Block Shapes 339e5c31af7Sopenharmony_ci 340e5c31af7Sopenharmony_ciStandard sparse image block shapes define a standard set of dimensions for 341e5c31af7Sopenharmony_cisparse image blocks that depend on the format of the image. 342e5c31af7Sopenharmony_ciLayout of texels or compressed texel blocks within a sparse image block is 343e5c31af7Sopenharmony_ciimplementation-dependent. 344e5c31af7Sopenharmony_ciAll currently defined standard sparse image block shapes are 64 KB in size. 345e5c31af7Sopenharmony_ci 346e5c31af7Sopenharmony_ciFor block-compressed formats (e.g. ename:VK_FORMAT_BC5_UNORM_BLOCK), the 347e5c31af7Sopenharmony_citexel size is the size of the compressed texel block (e.g. 128-bit for 348e5c31af7Sopenharmony_cietext:BC5) thus the dimensions of the standard sparse image block shapes 349e5c31af7Sopenharmony_ciapply in terms of compressed texel blocks. 350e5c31af7Sopenharmony_ci 351e5c31af7Sopenharmony_ci[NOTE] 352e5c31af7Sopenharmony_ci.Note 353e5c31af7Sopenharmony_ci==== 354e5c31af7Sopenharmony_ciFor block-compressed formats, the dimensions of a sparse image block in 355e5c31af7Sopenharmony_citerms of texels can: be calculated by multiplying the sparse image block 356e5c31af7Sopenharmony_cidimensions by the compressed texel block dimensions. 357e5c31af7Sopenharmony_ci==== 358e5c31af7Sopenharmony_ci 359e5c31af7Sopenharmony_ci<<< 360e5c31af7Sopenharmony_ci 361e5c31af7Sopenharmony_ci[[sparsememory-sparseblockshapessingle]] 362e5c31af7Sopenharmony_ci.Standard Sparse Image Block Shapes (Single Sample) 363e5c31af7Sopenharmony_ci[options="header"] 364e5c31af7Sopenharmony_ci|==== 365e5c31af7Sopenharmony_ci| TEXEL SIZE (bits) | Block Shape (2D) | Block Shape (3D) 366e5c31af7Sopenharmony_ci| *8-Bit* | 256 {times} 256 {times} 1 | 64 {times} 32 {times} 32 367e5c31af7Sopenharmony_ci| *16-Bit* | 256 {times} 128 {times} 1 | 32 {times} 32 {times} 32 368e5c31af7Sopenharmony_ci| *32-Bit* | 128 {times} 128 {times} 1 | 32 {times} 32 {times} 16 369e5c31af7Sopenharmony_ci| *64-Bit* | 128 {times} 64 {times} 1 | 32 {times} 16 {times} 16 370e5c31af7Sopenharmony_ci| *128-Bit* | 64 {times} 64 {times} 1 | 16 {times} 16 {times} 16 371e5c31af7Sopenharmony_ci|==== 372e5c31af7Sopenharmony_ci 373e5c31af7Sopenharmony_ci[[sparsememory-sparseblockshapesmsaa]] 374e5c31af7Sopenharmony_ci.Standard Sparse Image Block Shapes (MSAA) 375e5c31af7Sopenharmony_ci[options="header"] 376e5c31af7Sopenharmony_ci|==== 377e5c31af7Sopenharmony_ci| TEXEL SIZE (bits)| Block Shape (2X) | Block Shape (4X) | Block Shape (8X) | Block Shape (16X) 378e5c31af7Sopenharmony_ci| *8-Bit* | 128 {times} 256 {times} 1 | 128 {times} 128 {times} 1 | 64 {times} 128 {times} 1 | 64 {times} 64 {times} 1 379e5c31af7Sopenharmony_ci| *16-Bit* | 128 {times} 128 {times} 1 | 128 {times} 64 {times} 1 | 64 {times} 64 {times} 1 | 64 {times} 32 {times} 1 380e5c31af7Sopenharmony_ci| *32-Bit* | 64 {times} 128 {times} 1 | 64 {times} 64 {times} 1 | 32 {times} 64 {times} 1 | 32 {times} 32 {times} 1 381e5c31af7Sopenharmony_ci| *64-Bit* | 64 {times} 64 {times} 1 | 64 {times} 32 {times} 1 | 32 {times} 32 {times} 1 | 32 {times} 16 {times} 1 382e5c31af7Sopenharmony_ci| *128-Bit* | 32 {times} 64 {times} 1 | 32 {times} 32 {times} 1 | 16 {times} 32 {times} 1 | 16 {times} 16 {times} 1 383e5c31af7Sopenharmony_ci|==== 384e5c31af7Sopenharmony_ci 385e5c31af7Sopenharmony_ci 386e5c31af7Sopenharmony_ciImplementations that support the standard sparse image block shape for all 387e5c31af7Sopenharmony_ciformats listed in the <<sparsememory-sparseblockshapessingle>> and 388e5c31af7Sopenharmony_ci<<sparsememory-sparseblockshapesmsaa>> tables may: advertise the following 389e5c31af7Sopenharmony_cisname:VkPhysicalDeviceSparseProperties: 390e5c31af7Sopenharmony_ci 391e5c31af7Sopenharmony_ci * pname:residencyStandard2DBlockShape 392e5c31af7Sopenharmony_ci * pname:residencyStandard2DMultisampleBlockShape 393e5c31af7Sopenharmony_ci * pname:residencyStandard3DBlockShape 394e5c31af7Sopenharmony_ci 395e5c31af7Sopenharmony_ciReporting each of these features does _not_ imply that all possible image 396e5c31af7Sopenharmony_citypes are supported as sparse. 397e5c31af7Sopenharmony_ciInstead, this indicates that no supported sparse image of the corresponding 398e5c31af7Sopenharmony_citype will use custom sparse image block dimensions for any formats that have 399e5c31af7Sopenharmony_cia corresponding standard sparse image block shape. 400e5c31af7Sopenharmony_ci 401e5c31af7Sopenharmony_ci 402e5c31af7Sopenharmony_ci[[sparsememory-custom-shapes]] 403e5c31af7Sopenharmony_ci=== Custom Sparse Image Block Shapes 404e5c31af7Sopenharmony_ci 405e5c31af7Sopenharmony_ciAn implementation that does not support a standard image block shape for a 406e5c31af7Sopenharmony_ciparticular sparse partially-resident image may: choose to support a custom 407e5c31af7Sopenharmony_cisparse image block shape for it instead. 408e5c31af7Sopenharmony_ciThe dimensions of such a custom sparse image block shape are reported in 409e5c31af7Sopenharmony_cisname:VkSparseImageFormatProperties::pname:imageGranularity. 410e5c31af7Sopenharmony_ciAs with standard sparse image block shapes, the size in bytes of the custom 411e5c31af7Sopenharmony_cisparse image block shape will be reported in 412e5c31af7Sopenharmony_cisname:VkMemoryRequirements::pname:alignment. 413e5c31af7Sopenharmony_ci 414e5c31af7Sopenharmony_ciCustom sparse image block dimensions are reported through 415e5c31af7Sopenharmony_cifname:vkGetPhysicalDeviceSparseImageFormatProperties and 416e5c31af7Sopenharmony_cifname:vkGetImageSparseMemoryRequirements. 417e5c31af7Sopenharmony_ci 418e5c31af7Sopenharmony_ciAn implementation must: not support both the standard sparse image block 419e5c31af7Sopenharmony_cishape and a custom sparse image block shape for the same image. 420e5c31af7Sopenharmony_ciThe standard sparse image block shape must: be used if it is supported. 421e5c31af7Sopenharmony_ci 422e5c31af7Sopenharmony_ci 423e5c31af7Sopenharmony_ci[[sparsememory-multiaspect]] 424e5c31af7Sopenharmony_ci=== Multiple Aspects 425e5c31af7Sopenharmony_ci 426e5c31af7Sopenharmony_ciPartially resident images are allowed to report separate sparse properties 427e5c31af7Sopenharmony_cifor different aspects of the image. 428e5c31af7Sopenharmony_ciOne example is for depth/stencil images where the implementation separates 429e5c31af7Sopenharmony_cithe depth and stencil data into separate planes. 430e5c31af7Sopenharmony_ciAnother reason for multiple aspects is to allow the application to manage 431e5c31af7Sopenharmony_cimemory allocation for implementation-private _metadata_ associated with the 432e5c31af7Sopenharmony_ciimage. 433e5c31af7Sopenharmony_ciSee the figure below: 434e5c31af7Sopenharmony_ci 435e5c31af7Sopenharmony_ciimage::{images}/sparseimage_multiaspect.svg[align="center",title="Multiple Aspect Sparse Image",opts="{imageopts}"] 436e5c31af7Sopenharmony_ci 437e5c31af7Sopenharmony_ci[NOTE] 438e5c31af7Sopenharmony_ci.Note 439e5c31af7Sopenharmony_ci==== 440e5c31af7Sopenharmony_ciThe mip tail regions are presented here in 2D arrays simply for figure size 441e5c31af7Sopenharmony_cireasons. 442e5c31af7Sopenharmony_ciEach mip tail is logically a single array of sparse blocks with an 443e5c31af7Sopenharmony_ciimplementation-dependent mapping of texels or compressed texel blocks to 444e5c31af7Sopenharmony_cisparse blocks. 445e5c31af7Sopenharmony_ci==== 446e5c31af7Sopenharmony_ci 447e5c31af7Sopenharmony_ciIn the figure above the depth, stencil, and metadata aspects all have unique 448e5c31af7Sopenharmony_cisparse properties. 449e5c31af7Sopenharmony_ciThe per-texel stencil data is [eq]#{onequarter}# the size of the depth data, 450e5c31af7Sopenharmony_cihence the stencil sparse blocks include [eq]#4 {times}# the number of 451e5c31af7Sopenharmony_citexels. 452e5c31af7Sopenharmony_ciThe sparse block size in bytes for all of the aspects is identical and 453e5c31af7Sopenharmony_cidefined by sname:VkMemoryRequirements::pname:alignment. 454e5c31af7Sopenharmony_ci 455e5c31af7Sopenharmony_ci 456e5c31af7Sopenharmony_ci==== Metadata 457e5c31af7Sopenharmony_ci 458e5c31af7Sopenharmony_ciThe metadata aspect of an image has the following constraints: 459e5c31af7Sopenharmony_ci 460e5c31af7Sopenharmony_ci * All metadata is reported in the mip tail region of the metadata aspect. 461e5c31af7Sopenharmony_ci * All metadata must: be bound prior to device use of the sparse image. 462e5c31af7Sopenharmony_ci 463e5c31af7Sopenharmony_ci 464e5c31af7Sopenharmony_ci[[sparsememory-sparse-memory-aliasing]] 465e5c31af7Sopenharmony_ci== Sparse Memory Aliasing 466e5c31af7Sopenharmony_ci 467e5c31af7Sopenharmony_ciBy default sparse resources have the same aliasing rules as non-sparse 468e5c31af7Sopenharmony_ciresources. 469e5c31af7Sopenharmony_ciSee <<resources-memory-aliasing,Memory Aliasing>> for more information. 470e5c31af7Sopenharmony_ci 471e5c31af7Sopenharmony_cisname:VkDevice objects that have the 472e5c31af7Sopenharmony_ci<<features-sparseResidencyAliased,sparseResidencyAliased>> feature enabled 473e5c31af7Sopenharmony_ciare able to use the ename:VK_BUFFER_CREATE_SPARSE_ALIASED_BIT and 474e5c31af7Sopenharmony_ciename:VK_IMAGE_CREATE_SPARSE_ALIASED_BIT flags for resource creation. 475e5c31af7Sopenharmony_ciThese flags allow resources to access physical memory bound into multiple 476e5c31af7Sopenharmony_cilocations within one or more sparse resources in a _data consistent_ 477e5c31af7Sopenharmony_cifashion. 478e5c31af7Sopenharmony_ciThis means that reading physical memory from multiple aliased locations will 479e5c31af7Sopenharmony_cireturn the same value. 480e5c31af7Sopenharmony_ci 481e5c31af7Sopenharmony_ciCare must: be taken when performing a write operation to aliased physical 482e5c31af7Sopenharmony_cimemory. 483e5c31af7Sopenharmony_ciMemory dependencies must: be used to separate writes to one alias from reads 484e5c31af7Sopenharmony_cior writes to another alias. 485e5c31af7Sopenharmony_ciWrites to aliased memory that are not properly guarded against accesses to 486e5c31af7Sopenharmony_cidifferent aliases will have undefined: results for all accesses to the 487e5c31af7Sopenharmony_cialiased memory. 488e5c31af7Sopenharmony_ci 489e5c31af7Sopenharmony_ciApplications that wish to make use of data consistent sparse memory aliasing 490e5c31af7Sopenharmony_cimust: abide by the following guidelines: 491e5c31af7Sopenharmony_ci 492e5c31af7Sopenharmony_ci * All sparse resources that are bound to aliased physical memory must: be 493e5c31af7Sopenharmony_ci created with the ename:VK_BUFFER_CREATE_SPARSE_ALIASED_BIT / 494e5c31af7Sopenharmony_ci ename:VK_IMAGE_CREATE_SPARSE_ALIASED_BIT flag. 495e5c31af7Sopenharmony_ci * All resources that access aliased physical memory must: interpret the 496e5c31af7Sopenharmony_ci memory in the same way. 497e5c31af7Sopenharmony_ci This implies the following: 498e5c31af7Sopenharmony_ci ** Buffers and images cannot: alias the same physical memory in a data 499e5c31af7Sopenharmony_ci consistent fashion. 500e5c31af7Sopenharmony_ci The physical memory ranges must: be used exclusively by buffers or used 501e5c31af7Sopenharmony_ci exclusively by images for data consistency to be guaranteed. 502e5c31af7Sopenharmony_ci ** Memory in sparse image mip tail regions cannot: access aliased memory 503e5c31af7Sopenharmony_ci in a data consistent fashion. 504e5c31af7Sopenharmony_ci ** Sparse images that alias the same physical memory must: have compatible 505e5c31af7Sopenharmony_ci formats and be using the same sparse image block shape in order to 506e5c31af7Sopenharmony_ci access aliased memory in a data consistent fashion. 507e5c31af7Sopenharmony_ci 508e5c31af7Sopenharmony_ciFailure to follow any of the above guidelines will require the application 509e5c31af7Sopenharmony_cito abide by the normal, non-sparse resource <<resources-memory-aliasing, 510e5c31af7Sopenharmony_cialiasing rules>>. 511e5c31af7Sopenharmony_ciIn this case memory cannot: be accessed in a data consistent fashion. 512e5c31af7Sopenharmony_ci 513e5c31af7Sopenharmony_ci[NOTE] 514e5c31af7Sopenharmony_ci.Note 515e5c31af7Sopenharmony_ci==== 516e5c31af7Sopenharmony_ciEnabling sparse resource memory aliasing can: be a way to lower physical 517e5c31af7Sopenharmony_cimemory use, but it may: reduce performance on some implementations. 518e5c31af7Sopenharmony_ciAn application developer can: test on their target HW and balance the memory 519e5c31af7Sopenharmony_ci/ performance trade-offs measured. 520e5c31af7Sopenharmony_ci==== 521e5c31af7Sopenharmony_ci 522e5c31af7Sopenharmony_ci 523e5c31af7Sopenharmony_ciifdef::implementation-guide[] 524e5c31af7Sopenharmony_ci== Sparse Resource Implementation Guidelines (Informative) 525e5c31af7Sopenharmony_ci 526e5c31af7Sopenharmony_ci**** 527e5c31af7Sopenharmony_ciThis section is Informative. 528e5c31af7Sopenharmony_ciIt is included to aid in implementors`' understanding of sparse resources. 529e5c31af7Sopenharmony_ci 530e5c31af7Sopenharmony_ci.Device Virtual Address 531e5c31af7Sopenharmony_ci 532e5c31af7Sopenharmony_ciThe basic pname:sparseBinding feature allows the resource to reserve its own 533e5c31af7Sopenharmony_cidevice virtual address range at resource creation time rather than relying 534e5c31af7Sopenharmony_cion a bind operation to set this. 535e5c31af7Sopenharmony_ciWithout any other creation flags, no other constraints are relaxed compared 536e5c31af7Sopenharmony_cito normal resources. 537e5c31af7Sopenharmony_ciAll pages must: be bound to physical memory before the device accesses the 538e5c31af7Sopenharmony_ciresource. 539e5c31af7Sopenharmony_ci 540e5c31af7Sopenharmony_ciThe <<features-sparseResidency,sparse residency>> features allow sparse 541e5c31af7Sopenharmony_ciresources to be used even when not all pages are bound to memory. 542e5c31af7Sopenharmony_ciImplementations that support access to unbound pages without causing a fault 543e5c31af7Sopenharmony_cimay: support pname:residencyNonResidentStrict. 544e5c31af7Sopenharmony_ci 545e5c31af7Sopenharmony_ciNot faulting on access to unbound pages is not enough to support 546e5c31af7Sopenharmony_cipname:residencyNonResidentStrict. 547e5c31af7Sopenharmony_ciAn implementation must: also guarantee that reads after writes to unbound 548e5c31af7Sopenharmony_ciregions of the resource always return data for the read as if the memory 549e5c31af7Sopenharmony_cicontains zeros. 550e5c31af7Sopenharmony_ciDepending on any caching hierarchy of the implementation this may: not 551e5c31af7Sopenharmony_cialways be possible. 552e5c31af7Sopenharmony_ci 553e5c31af7Sopenharmony_ciAny implementation that does not fault, but does not guarantee correct read 554e5c31af7Sopenharmony_civalues must: not support pname:residencyNonResidentStrict. 555e5c31af7Sopenharmony_ci 556e5c31af7Sopenharmony_ciAny implementation that cannot: access unbound pages without causing a fault 557e5c31af7Sopenharmony_ciwill require the implementation to bind the entire device virtual address 558e5c31af7Sopenharmony_cirange to physical memory. 559e5c31af7Sopenharmony_ciAny pages that the application does not bind to memory may: be bound to one 560e5c31af7Sopenharmony_ci(or more) "`placeholder" physical page(s) allocated by the implementation. 561e5c31af7Sopenharmony_ciGiven the following properties: 562e5c31af7Sopenharmony_ci 563e5c31af7Sopenharmony_ci * A process must: not access memory from another process 564e5c31af7Sopenharmony_ci * Reads return undefined: values 565e5c31af7Sopenharmony_ci 566e5c31af7Sopenharmony_ciIt is sufficient for each host process to allocate these placeholder pages 567e5c31af7Sopenharmony_ciand use them for all resources in that process. 568e5c31af7Sopenharmony_ciImplementations may: allocate more often (per instance, per device, or per 569e5c31af7Sopenharmony_ciresource). 570e5c31af7Sopenharmony_ci 571e5c31af7Sopenharmony_ci 572e5c31af7Sopenharmony_ci.Binding Memory 573e5c31af7Sopenharmony_ci 574e5c31af7Sopenharmony_ciThe byte size reported in sname:VkMemoryRequirements::pname:size must: be 575e5c31af7Sopenharmony_cigreater than or equal to the amount of physical memory required: to fully 576e5c31af7Sopenharmony_cipopulate the resource. 577e5c31af7Sopenharmony_ciSome implementations require "`holes`" in the device virtual address range 578e5c31af7Sopenharmony_cithat are never accessed. 579e5c31af7Sopenharmony_ciThese holes may: be included in the pname:size reported for the resource. 580e5c31af7Sopenharmony_ci 581e5c31af7Sopenharmony_ciIncluding or not including the device virtual address holes in the resource 582e5c31af7Sopenharmony_cisize will alter how the implementation provides support for 583e5c31af7Sopenharmony_cisname:VkSparseImageOpaqueMemoryBindInfo. 584e5c31af7Sopenharmony_ciThis operation must: be supported for all sparse images, even ones created 585e5c31af7Sopenharmony_ciwith ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT. 586e5c31af7Sopenharmony_ci 587e5c31af7Sopenharmony_ciifdef::editing-notes[] 588e5c31af7Sopenharmony_ci[NOTE] 589e5c31af7Sopenharmony_ci.editing-note 590e5c31af7Sopenharmony_ci==== 591e5c31af7Sopenharmony_ci@ntrevett suggested expanding the NOTE tag below to encompass everything 592e5c31af7Sopenharmony_cifrom "`The cost is...`" in the first bullet point through the current note. 593e5c31af7Sopenharmony_ciTBD. 594e5c31af7Sopenharmony_ci==== 595e5c31af7Sopenharmony_ciendif::editing-notes[] 596e5c31af7Sopenharmony_ci 597e5c31af7Sopenharmony_ci * If the holes are included in the size, this bind function becomes very 598e5c31af7Sopenharmony_ci easy. 599e5c31af7Sopenharmony_ci In most cases the pname:resourceOffset is simply a device virtual 600e5c31af7Sopenharmony_ci address offset and the implementation can easily determine what device 601e5c31af7Sopenharmony_ci virtual address to bind. 602e5c31af7Sopenharmony_ci The cost is that the application may: allocate more physical memory for 603e5c31af7Sopenharmony_ci the resource than it needs. 604e5c31af7Sopenharmony_ci * If the holes are not included in the size, the application can: allocate 605e5c31af7Sopenharmony_ci less physical memory than otherwise for the resource. 606e5c31af7Sopenharmony_ci However, in this case the implementation must: account for the holes 607e5c31af7Sopenharmony_ci when mapping pname:resourceOffset to the actual device virtual address 608e5c31af7Sopenharmony_ci intended to be mapped. 609e5c31af7Sopenharmony_ci 610e5c31af7Sopenharmony_ci[NOTE] 611e5c31af7Sopenharmony_ci.Note 612e5c31af7Sopenharmony_ci==== 613e5c31af7Sopenharmony_ciIf the application always uses sname:VkSparseImageMemoryBindInfo to bind 614e5c31af7Sopenharmony_cimemory for the non-tail mip levels, any holes that are present in the 615e5c31af7Sopenharmony_ciresource size may: never be bound. 616e5c31af7Sopenharmony_ci 617e5c31af7Sopenharmony_ciSince sname:VkSparseImageMemoryBindInfo uses texel locations to determine 618e5c31af7Sopenharmony_ciwhich device virtual addresses to bind, it is impossible to bind device 619e5c31af7Sopenharmony_civirtual address holes with this operation. 620e5c31af7Sopenharmony_ci==== 621e5c31af7Sopenharmony_ci 622e5c31af7Sopenharmony_ci.Binding Metadata Memory 623e5c31af7Sopenharmony_ci 624e5c31af7Sopenharmony_ciAll metadata for sparse images have their own sparse properties and are 625e5c31af7Sopenharmony_ciembedded in the mip tail region for said properties. 626e5c31af7Sopenharmony_ciSee the <<sparsememory-multiaspect,Multiaspect>> section for details. 627e5c31af7Sopenharmony_ci 628e5c31af7Sopenharmony_ciGiven that metadata is in a mip tail region, and the mip tail region must: 629e5c31af7Sopenharmony_cibe reported as contiguous (either globally or per-array-layer), some 630e5c31af7Sopenharmony_ciimplementations will have to resort to complicated offset -> device virtual 631e5c31af7Sopenharmony_ciaddress mapping for handling sname:VkSparseImageOpaqueMemoryBindInfo. 632e5c31af7Sopenharmony_ci 633e5c31af7Sopenharmony_ciTo make this easier on the implementation, the 634e5c31af7Sopenharmony_ciename:VK_SPARSE_MEMORY_BIND_METADATA_BIT explicitly specifies when metadata 635e5c31af7Sopenharmony_ciis bound with sname:VkSparseImageOpaqueMemoryBindInfo. 636e5c31af7Sopenharmony_ciWhen this flag is not present, the pname:resourceOffset may: be treated as a 637e5c31af7Sopenharmony_cistrict device virtual address offset. 638e5c31af7Sopenharmony_ci 639e5c31af7Sopenharmony_ciWhen ename:VK_SPARSE_MEMORY_BIND_METADATA_BIT is present, the 640e5c31af7Sopenharmony_cipname:resourceOffset must: have been derived explicitly from the 641e5c31af7Sopenharmony_cipname:imageMipTailOffset in the sparse resource properties returned for the 642e5c31af7Sopenharmony_cimetadata aspect. 643e5c31af7Sopenharmony_ciBy manipulating the value returned for pname:imageMipTailOffset, the 644e5c31af7Sopenharmony_cipname:resourceOffset does not have to correlate directly to a device virtual 645e5c31af7Sopenharmony_ciaddress offset, and may: instead be whatever value makes it easiest for the 646e5c31af7Sopenharmony_ciimplementation to derive the correct device virtual address. 647e5c31af7Sopenharmony_ci 648e5c31af7Sopenharmony_ci**** 649e5c31af7Sopenharmony_ciendif::implementation-guide[] 650e5c31af7Sopenharmony_ci 651e5c31af7Sopenharmony_ci 652e5c31af7Sopenharmony_ci[[sparsememory-resourceapi]] 653e5c31af7Sopenharmony_ci== Sparse Resource API 654e5c31af7Sopenharmony_ci 655e5c31af7Sopenharmony_ciThe APIs related to sparse resources are grouped into the following 656e5c31af7Sopenharmony_cicategories: 657e5c31af7Sopenharmony_ci 658e5c31af7Sopenharmony_ci * <<sparsememory-physicalfeatures,Physical Device Features>> 659e5c31af7Sopenharmony_ci * <<sparsememory-physicalprops,Physical Device Sparse Properties>> 660e5c31af7Sopenharmony_ci * <<sparsememory-format-props,Sparse Image Format Properties>> 661e5c31af7Sopenharmony_ci * <<sparsememory-resource-creation,Sparse Resource Creation>> 662e5c31af7Sopenharmony_ci * <<sparsememory-memory-requirements,Sparse Resource Memory Requirements>> 663e5c31af7Sopenharmony_ci * <<sparsememory-resource-binding,Binding Resource Memory>> 664e5c31af7Sopenharmony_ci 665e5c31af7Sopenharmony_ci 666e5c31af7Sopenharmony_ci[[sparsememory-physicalfeatures]] 667e5c31af7Sopenharmony_ci=== Physical Device Features 668e5c31af7Sopenharmony_ci 669e5c31af7Sopenharmony_ciSome sparse-resource related features are reported and enabled in 670e5c31af7Sopenharmony_cisname:VkPhysicalDeviceFeatures. 671e5c31af7Sopenharmony_ciThese features must: be supported and enabled on the sname:VkDevice object 672e5c31af7Sopenharmony_cibefore applications can: use them. 673e5c31af7Sopenharmony_ciSee <<features,Physical Device Features>> for information on how to get and 674e5c31af7Sopenharmony_ciset enabled device features, and for more detailed explanations of these 675e5c31af7Sopenharmony_cifeatures. 676e5c31af7Sopenharmony_ci 677e5c31af7Sopenharmony_ci 678e5c31af7Sopenharmony_ci==== Sparse Physical Device Features 679e5c31af7Sopenharmony_ci 680e5c31af7Sopenharmony_ci * pname:sparseBinding: Support for creating slink:VkBuffer and 681e5c31af7Sopenharmony_ci sname:VkImage objects with the ename:VK_BUFFER_CREATE_SPARSE_BINDING_BIT 682e5c31af7Sopenharmony_ci and ename:VK_IMAGE_CREATE_SPARSE_BINDING_BIT flags, respectively. 683e5c31af7Sopenharmony_ci * pname:sparseResidencyBuffer: Support for creating slink:VkBuffer objects 684e5c31af7Sopenharmony_ci with the ename:VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT flag. 685e5c31af7Sopenharmony_ci * pname:sparseResidencyImage2D: Support for creating 2D single-sampled 686e5c31af7Sopenharmony_ci sname:VkImage objects with ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT. 687e5c31af7Sopenharmony_ci * pname:sparseResidencyImage3D: Support for creating 3D slink:VkImage 688e5c31af7Sopenharmony_ci objects with ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT. 689e5c31af7Sopenharmony_ci * pname:sparseResidency2Samples: Support for creating 2D slink:VkImage 690e5c31af7Sopenharmony_ci objects with 2 samples and ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT. 691e5c31af7Sopenharmony_ci * pname:sparseResidency4Samples: Support for creating 2D slink:VkImage 692e5c31af7Sopenharmony_ci objects with 4 samples and ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT. 693e5c31af7Sopenharmony_ci * pname:sparseResidency8Samples: Support for creating 2D slink:VkImage 694e5c31af7Sopenharmony_ci objects with 8 samples and ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT. 695e5c31af7Sopenharmony_ci * pname:sparseResidency16Samples: Support for creating 2D slink:VkImage 696e5c31af7Sopenharmony_ci objects with 16 samples and ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT. 697e5c31af7Sopenharmony_ci * pname:sparseResidencyAliased: Support for creating slink:VkBuffer and 698e5c31af7Sopenharmony_ci sname:VkImage objects with the ename:VK_BUFFER_CREATE_SPARSE_ALIASED_BIT 699e5c31af7Sopenharmony_ci and ename:VK_IMAGE_CREATE_SPARSE_ALIASED_BIT flags, respectively. 700e5c31af7Sopenharmony_ci 701e5c31af7Sopenharmony_ci 702e5c31af7Sopenharmony_ci[[sparsememory-physicalprops]] 703e5c31af7Sopenharmony_ci=== Physical Device Sparse Properties 704e5c31af7Sopenharmony_ci 705e5c31af7Sopenharmony_ciSome features of the implementation are not possible to disable, and are 706e5c31af7Sopenharmony_cireported to allow applications to alter their sparse resource usage 707e5c31af7Sopenharmony_ciaccordingly. 708e5c31af7Sopenharmony_ciThese read-only capabilities are reported in the 709e5c31af7Sopenharmony_cislink:VkPhysicalDeviceProperties::pname:sparseProperties member, which is a 710e5c31af7Sopenharmony_cisname:VkPhysicalDeviceSparseProperties structure. 711e5c31af7Sopenharmony_ci 712e5c31af7Sopenharmony_ci[open,refpage='VkPhysicalDeviceSparseProperties',desc='Structure specifying physical device sparse memory properties',type='structs'] 713e5c31af7Sopenharmony_ci-- 714e5c31af7Sopenharmony_ciThe sname:VkPhysicalDeviceSparseProperties structure is defined as: 715e5c31af7Sopenharmony_ci 716e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPhysicalDeviceSparseProperties.txt[] 717e5c31af7Sopenharmony_ci 718e5c31af7Sopenharmony_ci * pname:residencyStandard2DBlockShape is ename:VK_TRUE if the physical 719e5c31af7Sopenharmony_ci device will access all single-sample 2D sparse resources using the 720e5c31af7Sopenharmony_ci standard sparse image block shapes (based on image format), as described 721e5c31af7Sopenharmony_ci in the <<sparsememory-sparseblockshapessingle,Standard Sparse Image 722e5c31af7Sopenharmony_ci Block Shapes (Single Sample)>> table. 723e5c31af7Sopenharmony_ci If this property is not supported the value returned in the 724e5c31af7Sopenharmony_ci pname:imageGranularity member of the sname:VkSparseImageFormatProperties 725e5c31af7Sopenharmony_ci structure for single-sample 2D images is not required: to match the 726e5c31af7Sopenharmony_ci standard sparse image block dimensions listed in the table. 727e5c31af7Sopenharmony_ci * pname:residencyStandard2DMultisampleBlockShape is ename:VK_TRUE if the 728e5c31af7Sopenharmony_ci physical device will access all multisample 2D sparse resources using 729e5c31af7Sopenharmony_ci the standard sparse image block shapes (based on image format), as 730e5c31af7Sopenharmony_ci described in the <<sparsememory-sparseblockshapesmsaa,Standard Sparse 731e5c31af7Sopenharmony_ci Image Block Shapes (MSAA)>> table. 732e5c31af7Sopenharmony_ci If this property is not supported, the value returned in the 733e5c31af7Sopenharmony_ci pname:imageGranularity member of the sname:VkSparseImageFormatProperties 734e5c31af7Sopenharmony_ci structure for multisample 2D images is not required: to match the 735e5c31af7Sopenharmony_ci standard sparse image block dimensions listed in the table. 736e5c31af7Sopenharmony_ci * pname:residencyStandard3DBlockShape is ename:VK_TRUE if the physical 737e5c31af7Sopenharmony_ci device will access all 3D sparse resources using the standard sparse 738e5c31af7Sopenharmony_ci image block shapes (based on image format), as described in the 739e5c31af7Sopenharmony_ci <<sparsememory-sparseblockshapessingle,Standard Sparse Image Block 740e5c31af7Sopenharmony_ci Shapes (Single Sample)>> table. 741e5c31af7Sopenharmony_ci If this property is not supported, the value returned in the 742e5c31af7Sopenharmony_ci pname:imageGranularity member of the sname:VkSparseImageFormatProperties 743e5c31af7Sopenharmony_ci structure for 3D images is not required: to match the standard sparse 744e5c31af7Sopenharmony_ci image block dimensions listed in the table. 745e5c31af7Sopenharmony_ci * pname:residencyAlignedMipSize is ename:VK_TRUE if images with mip level 746e5c31af7Sopenharmony_ci dimensions that are not integer multiples of the corresponding 747e5c31af7Sopenharmony_ci dimensions of the sparse image block may: be placed in the mip tail. 748e5c31af7Sopenharmony_ci If this property is not reported, only mip levels with dimensions 749e5c31af7Sopenharmony_ci smaller than the pname:imageGranularity member of the 750e5c31af7Sopenharmony_ci sname:VkSparseImageFormatProperties structure will be placed in the mip 751e5c31af7Sopenharmony_ci tail. 752e5c31af7Sopenharmony_ci If this property is reported the implementation is allowed to return 753e5c31af7Sopenharmony_ci ename:VK_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT in the pname:flags 754e5c31af7Sopenharmony_ci member of sname:VkSparseImageFormatProperties, indicating that mip level 755e5c31af7Sopenharmony_ci dimensions that are not integer multiples of the corresponding 756e5c31af7Sopenharmony_ci dimensions of the sparse image block will be placed in the mip tail. 757e5c31af7Sopenharmony_ci * pname:residencyNonResidentStrict specifies whether the physical device 758e5c31af7Sopenharmony_ci can: consistently access non-resident regions of a resource. 759e5c31af7Sopenharmony_ci If this property is ename:VK_TRUE, access to non-resident regions of 760e5c31af7Sopenharmony_ci resources will be guaranteed to return values as if the resource was 761e5c31af7Sopenharmony_ci populated with 0; writes to non-resident regions will be discarded. 762e5c31af7Sopenharmony_ci 763e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPhysicalDeviceSparseProperties.txt[] 764e5c31af7Sopenharmony_ci-- 765e5c31af7Sopenharmony_ci 766e5c31af7Sopenharmony_ci 767e5c31af7Sopenharmony_ci[[sparsememory-format-props]] 768e5c31af7Sopenharmony_ci=== Sparse Image Format Properties 769e5c31af7Sopenharmony_ci 770e5c31af7Sopenharmony_ciGiven that certain aspects of sparse image support, including the sparse 771e5c31af7Sopenharmony_ciimage block dimensions, may: be implementation-dependent, 772e5c31af7Sopenharmony_ciflink:vkGetPhysicalDeviceSparseImageFormatProperties can: be used to query 773e5c31af7Sopenharmony_cifor sparse image format properties prior to resource creation. 774e5c31af7Sopenharmony_ciThis command is used to check whether a given set of sparse image parameters 775e5c31af7Sopenharmony_ciis supported and what the sparse image block shape will be. 776e5c31af7Sopenharmony_ci 777e5c31af7Sopenharmony_ci 778e5c31af7Sopenharmony_ci==== Sparse Image Format Properties API 779e5c31af7Sopenharmony_ci 780e5c31af7Sopenharmony_ci[open,refpage='VkSparseImageFormatProperties',desc='Structure specifying sparse image format properties',type='structs'] 781e5c31af7Sopenharmony_ci-- 782e5c31af7Sopenharmony_ciThe sname:VkSparseImageFormatProperties structure is defined as: 783e5c31af7Sopenharmony_ci 784e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkSparseImageFormatProperties.txt[] 785e5c31af7Sopenharmony_ci 786e5c31af7Sopenharmony_ci * pname:aspectMask is a bitmask elink:VkImageAspectFlagBits specifying 787e5c31af7Sopenharmony_ci which aspects of the image the properties apply to. 788e5c31af7Sopenharmony_ci * pname:imageGranularity is the width, height, and depth of the sparse 789e5c31af7Sopenharmony_ci image block in texels or compressed texel blocks. 790e5c31af7Sopenharmony_ci * pname:flags is a bitmask of elink:VkSparseImageFormatFlagBits specifying 791e5c31af7Sopenharmony_ci additional information about the sparse resource. 792e5c31af7Sopenharmony_ci 793e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkSparseImageFormatProperties.txt[] 794e5c31af7Sopenharmony_ci-- 795e5c31af7Sopenharmony_ci 796e5c31af7Sopenharmony_ci[open,refpage='VkSparseImageFormatFlagBits',desc='Bitmask specifying additional information about a sparse image resource',type='enums'] 797e5c31af7Sopenharmony_ci-- 798e5c31af7Sopenharmony_ciBits which may: be set in slink:VkSparseImageFormatProperties::pname:flags, 799e5c31af7Sopenharmony_cispecifying additional information about the sparse resource, are: 800e5c31af7Sopenharmony_ci 801e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkSparseImageFormatFlagBits.txt[] 802e5c31af7Sopenharmony_ci 803e5c31af7Sopenharmony_ci * ename:VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT specifies that the image 804e5c31af7Sopenharmony_ci uses a single mip tail region for all array layers. 805e5c31af7Sopenharmony_ci * ename:VK_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT specifies that the 806e5c31af7Sopenharmony_ci first mip level whose dimensions are not integer multiples of the 807e5c31af7Sopenharmony_ci corresponding dimensions of the sparse image block begins the mip tail 808e5c31af7Sopenharmony_ci region. 809e5c31af7Sopenharmony_ci * ename:VK_SPARSE_IMAGE_FORMAT_NONSTANDARD_BLOCK_SIZE_BIT specifies that 810e5c31af7Sopenharmony_ci the image uses non-standard sparse image block dimensions, and the 811e5c31af7Sopenharmony_ci pname:imageGranularity values do not match the standard sparse image 812e5c31af7Sopenharmony_ci block dimensions for the given format. 813e5c31af7Sopenharmony_ci-- 814e5c31af7Sopenharmony_ci 815e5c31af7Sopenharmony_ci[open,refpage='VkSparseImageFormatFlags',desc='Bitmask of VkSparseImageFormatFlagBits',type='flags'] 816e5c31af7Sopenharmony_ci-- 817e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkSparseImageFormatFlags.txt[] 818e5c31af7Sopenharmony_ci 819e5c31af7Sopenharmony_citname:VkSparseImageFormatFlags is a bitmask type for setting a mask of zero 820e5c31af7Sopenharmony_cior more elink:VkSparseImageFormatFlagBits. 821e5c31af7Sopenharmony_ci-- 822e5c31af7Sopenharmony_ci 823e5c31af7Sopenharmony_ci[open,refpage='vkGetPhysicalDeviceSparseImageFormatProperties',desc='Retrieve properties of an image format applied to sparse images',type='protos'] 824e5c31af7Sopenharmony_ci-- 825e5c31af7Sopenharmony_cifname:vkGetPhysicalDeviceSparseImageFormatProperties returns an array of 826e5c31af7Sopenharmony_cislink:VkSparseImageFormatProperties. 827e5c31af7Sopenharmony_ciEach element will describe properties for one set of image aspects that are 828e5c31af7Sopenharmony_cibound simultaneously in the image. 829e5c31af7Sopenharmony_ciThis is usually one element for each aspect in the image, but for 830e5c31af7Sopenharmony_ciinterleaved depth/stencil images there is only one element describing the 831e5c31af7Sopenharmony_cicombined aspects. 832e5c31af7Sopenharmony_ci 833e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetPhysicalDeviceSparseImageFormatProperties.txt[] 834e5c31af7Sopenharmony_ci 835e5c31af7Sopenharmony_ci * pname:physicalDevice is the physical device from which to query the 836e5c31af7Sopenharmony_ci sparse image format properties. 837e5c31af7Sopenharmony_ci * pname:format is the image format. 838e5c31af7Sopenharmony_ci * pname:type is the dimensionality of image. 839e5c31af7Sopenharmony_ci * pname:samples is a elink:VkSampleCountFlagBits value specifying the 840e5c31af7Sopenharmony_ci number of samples per texel. 841e5c31af7Sopenharmony_ci * pname:usage is a bitmask describing the intended usage of the image. 842e5c31af7Sopenharmony_ci * pname:tiling is the tiling arrangement of the texel blocks in memory. 843e5c31af7Sopenharmony_ci * pname:pPropertyCount is a pointer to an integer related to the number of 844e5c31af7Sopenharmony_ci sparse format properties available or queried, as described below. 845e5c31af7Sopenharmony_ci * pname:pProperties is either `NULL` or a pointer to an array of 846e5c31af7Sopenharmony_ci slink:VkSparseImageFormatProperties structures. 847e5c31af7Sopenharmony_ci 848e5c31af7Sopenharmony_ciIf pname:pProperties is `NULL`, then the number of sparse format properties 849e5c31af7Sopenharmony_ciavailable is returned in pname:pPropertyCount. 850e5c31af7Sopenharmony_ciOtherwise, pname:pPropertyCount must: point to a variable set by the user to 851e5c31af7Sopenharmony_cithe number of elements in the pname:pProperties array, and on return the 852e5c31af7Sopenharmony_civariable is overwritten with the number of structures actually written to 853e5c31af7Sopenharmony_cipname:pProperties. 854e5c31af7Sopenharmony_ciIf pname:pPropertyCount is less than the number of sparse format properties 855e5c31af7Sopenharmony_ciavailable, at most pname:pPropertyCount structures will be written. 856e5c31af7Sopenharmony_ci 857e5c31af7Sopenharmony_ciIf ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT is not supported for the given 858e5c31af7Sopenharmony_ciarguments, pname:pPropertyCount will be set to zero upon return, and no data 859e5c31af7Sopenharmony_ciwill be written to pname:pProperties. 860e5c31af7Sopenharmony_ci 861e5c31af7Sopenharmony_ciMultiple aspects are returned for depth/stencil images that are implemented 862e5c31af7Sopenharmony_cias separate planes by the implementation. 863e5c31af7Sopenharmony_ciThe depth and stencil data planes each have unique 864e5c31af7Sopenharmony_cisname:VkSparseImageFormatProperties data. 865e5c31af7Sopenharmony_ci 866e5c31af7Sopenharmony_ciDepth/stencil images with depth and stencil data interleaved into a single 867e5c31af7Sopenharmony_ciplane will return a single sname:VkSparseImageFormatProperties structure 868e5c31af7Sopenharmony_ciwith the pname:aspectMask set to ename:VK_IMAGE_ASPECT_DEPTH_BIT | 869e5c31af7Sopenharmony_ciename:VK_IMAGE_ASPECT_STENCIL_BIT. 870e5c31af7Sopenharmony_ci 871e5c31af7Sopenharmony_ci.Valid Usage 872e5c31af7Sopenharmony_ci**** 873e5c31af7Sopenharmony_ci * [[VUID-vkGetPhysicalDeviceSparseImageFormatProperties-samples-01094]] 874e5c31af7Sopenharmony_ci pname:samples must: be a bit value that is set in 875e5c31af7Sopenharmony_ci sname:VkImageFormatProperties::pname:sampleCounts returned by 876e5c31af7Sopenharmony_ci fname:vkGetPhysicalDeviceImageFormatProperties with pname:format, 877e5c31af7Sopenharmony_ci pname:type, pname:tiling, and pname:usage equal to those in this command 878e5c31af7Sopenharmony_ci and pname:flags equal to the value that is set in 879e5c31af7Sopenharmony_ci slink:VkImageCreateInfo::pname:flags when the image is created 880e5c31af7Sopenharmony_ci**** 881e5c31af7Sopenharmony_ci 882e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetPhysicalDeviceSparseImageFormatProperties.txt[] 883e5c31af7Sopenharmony_ci-- 884e5c31af7Sopenharmony_ci 885e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_get_physical_device_properties2[] 886e5c31af7Sopenharmony_ci[open,refpage='vkGetPhysicalDeviceSparseImageFormatProperties2',desc='Retrieve properties of an image format applied to sparse images',type='protos'] 887e5c31af7Sopenharmony_ci-- 888e5c31af7Sopenharmony_cifname:vkGetPhysicalDeviceSparseImageFormatProperties2 returns an array of 889e5c31af7Sopenharmony_cislink:VkSparseImageFormatProperties2. 890e5c31af7Sopenharmony_ciEach element will describe properties for one set of image aspects that are 891e5c31af7Sopenharmony_cibound simultaneously in the image. 892e5c31af7Sopenharmony_ciThis is usually one element for each aspect in the image, but for 893e5c31af7Sopenharmony_ciinterleaved depth/stencil images there is only one element describing the 894e5c31af7Sopenharmony_cicombined aspects. 895e5c31af7Sopenharmony_ci 896e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[] 897e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetPhysicalDeviceSparseImageFormatProperties2.txt[] 898e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[] 899e5c31af7Sopenharmony_ci 900e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1+VK_KHR_get_physical_device_properties2[or the equivalent command] 901e5c31af7Sopenharmony_ci 902e5c31af7Sopenharmony_ciifdef::VK_KHR_get_physical_device_properties2[] 903e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetPhysicalDeviceSparseImageFormatProperties2KHR.txt[] 904e5c31af7Sopenharmony_ciendif::VK_KHR_get_physical_device_properties2[] 905e5c31af7Sopenharmony_ci 906e5c31af7Sopenharmony_ci * pname:physicalDevice is the physical device from which to query the 907e5c31af7Sopenharmony_ci sparse image format properties. 908e5c31af7Sopenharmony_ci * pname:pFormatInfo is a pointer to a 909e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceSparseImageFormatInfo2 structure containing input 910e5c31af7Sopenharmony_ci parameters to the command. 911e5c31af7Sopenharmony_ci * pname:pPropertyCount is a pointer to an integer related to the number of 912e5c31af7Sopenharmony_ci sparse format properties available or queried, as described below. 913e5c31af7Sopenharmony_ci * pname:pProperties is either `NULL` or a pointer to an array of 914e5c31af7Sopenharmony_ci slink:VkSparseImageFormatProperties2 structures. 915e5c31af7Sopenharmony_ci 916e5c31af7Sopenharmony_cifname:vkGetPhysicalDeviceSparseImageFormatProperties2 behaves identically to 917e5c31af7Sopenharmony_ciflink:vkGetPhysicalDeviceSparseImageFormatProperties, with the ability to 918e5c31af7Sopenharmony_cireturn extended information by adding extending structures to the 919e5c31af7Sopenharmony_cipname:pNext chain of its pname:pProperties parameter. 920e5c31af7Sopenharmony_ci 921e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetPhysicalDeviceSparseImageFormatProperties2.txt[] 922e5c31af7Sopenharmony_ci-- 923e5c31af7Sopenharmony_ci 924e5c31af7Sopenharmony_ci[open,refpage='VkPhysicalDeviceSparseImageFormatInfo2',desc='Structure specifying sparse image format inputs',type='structs'] 925e5c31af7Sopenharmony_ci-- 926e5c31af7Sopenharmony_ciThe sname:VkPhysicalDeviceSparseImageFormatInfo2 structure is defined as: 927e5c31af7Sopenharmony_ci 928e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPhysicalDeviceSparseImageFormatInfo2.txt[] 929e5c31af7Sopenharmony_ci 930e5c31af7Sopenharmony_ciifdef::VK_KHR_get_physical_device_properties2[] 931e5c31af7Sopenharmony_cior the equivalent 932e5c31af7Sopenharmony_ci 933e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPhysicalDeviceSparseImageFormatInfo2KHR.txt[] 934e5c31af7Sopenharmony_ciendif::VK_KHR_get_physical_device_properties2[] 935e5c31af7Sopenharmony_ci 936e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 937e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 938e5c31af7Sopenharmony_ci structure. 939e5c31af7Sopenharmony_ci * pname:format is the image format. 940e5c31af7Sopenharmony_ci * pname:type is the dimensionality of image. 941e5c31af7Sopenharmony_ci * pname:samples is a elink:VkSampleCountFlagBits value specifying the 942e5c31af7Sopenharmony_ci number of samples per texel. 943e5c31af7Sopenharmony_ci * pname:usage is a bitmask describing the intended usage of the image. 944e5c31af7Sopenharmony_ci * pname:tiling is the tiling arrangement of the texel blocks in memory. 945e5c31af7Sopenharmony_ci 946e5c31af7Sopenharmony_ci.Valid Usage 947e5c31af7Sopenharmony_ci**** 948e5c31af7Sopenharmony_ci * [[VUID-VkPhysicalDeviceSparseImageFormatInfo2-samples-01095]] 949e5c31af7Sopenharmony_ci pname:samples must: be a bit value that is set in 950e5c31af7Sopenharmony_ci sname:VkImageFormatProperties::pname:sampleCounts returned by 951e5c31af7Sopenharmony_ci fname:vkGetPhysicalDeviceImageFormatProperties with pname:format, 952e5c31af7Sopenharmony_ci pname:type, pname:tiling, and pname:usage equal to those in this command 953e5c31af7Sopenharmony_ci and pname:flags equal to the value that is set in 954e5c31af7Sopenharmony_ci slink:VkImageCreateInfo::pname:flags when the image is created 955e5c31af7Sopenharmony_ci**** 956e5c31af7Sopenharmony_ci 957e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPhysicalDeviceSparseImageFormatInfo2.txt[] 958e5c31af7Sopenharmony_ci-- 959e5c31af7Sopenharmony_ci 960e5c31af7Sopenharmony_ci[open,refpage='VkSparseImageFormatProperties2',desc='Structure specifying sparse image format properties',type='structs'] 961e5c31af7Sopenharmony_ci-- 962e5c31af7Sopenharmony_ciThe sname:VkSparseImageFormatProperties2 structure is defined as: 963e5c31af7Sopenharmony_ci 964e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkSparseImageFormatProperties2.txt[] 965e5c31af7Sopenharmony_ci 966e5c31af7Sopenharmony_ciifdef::VK_KHR_get_physical_device_properties2[] 967e5c31af7Sopenharmony_cior the equivalent 968e5c31af7Sopenharmony_ci 969e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkSparseImageFormatProperties2KHR.txt[] 970e5c31af7Sopenharmony_ciendif::VK_KHR_get_physical_device_properties2[] 971e5c31af7Sopenharmony_ci 972e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 973e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 974e5c31af7Sopenharmony_ci structure. 975e5c31af7Sopenharmony_ci * pname:properties is a slink:VkSparseImageFormatProperties structure 976e5c31af7Sopenharmony_ci which is populated with the same values as in 977e5c31af7Sopenharmony_ci flink:vkGetPhysicalDeviceSparseImageFormatProperties. 978e5c31af7Sopenharmony_ci 979e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkSparseImageFormatProperties2.txt[] 980e5c31af7Sopenharmony_ci-- 981e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_get_physical_device_properties2[] 982e5c31af7Sopenharmony_ci 983e5c31af7Sopenharmony_ci 984e5c31af7Sopenharmony_ci[[sparsememory-resource-creation]] 985e5c31af7Sopenharmony_ci=== Sparse Resource Creation 986e5c31af7Sopenharmony_ci 987e5c31af7Sopenharmony_ciSparse resources require that one or more sparse feature flags be specified 988e5c31af7Sopenharmony_ci(as part of the sname:VkPhysicalDeviceFeatures structure described 989e5c31af7Sopenharmony_cipreviously in the <<sparsememory-physicalfeatures,Physical Device Features>> 990e5c31af7Sopenharmony_cisection) when calling flink:vkCreateDevice. 991e5c31af7Sopenharmony_ciWhen the appropriate device features are enabled, the 992e5c31af7Sopenharmony_cietext:VK_BUFFER_CREATE_SPARSE_* and etext:VK_IMAGE_CREATE_SPARSE_* flags 993e5c31af7Sopenharmony_cican: be used. 994e5c31af7Sopenharmony_ciSee flink:vkCreateBuffer and flink:vkCreateImage for details of the resource 995e5c31af7Sopenharmony_cicreation APIs. 996e5c31af7Sopenharmony_ci 997e5c31af7Sopenharmony_ci[NOTE] 998e5c31af7Sopenharmony_ci.Note 999e5c31af7Sopenharmony_ci==== 1000e5c31af7Sopenharmony_ciSpecifying ename:VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or 1001e5c31af7Sopenharmony_ciename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT requires specifying 1002e5c31af7Sopenharmony_ciename:VK_BUFFER_CREATE_SPARSE_BINDING_BIT or 1003e5c31af7Sopenharmony_ciename:VK_IMAGE_CREATE_SPARSE_BINDING_BIT, respectively, as well. 1004e5c31af7Sopenharmony_ciThis means that resources must: be created with the appropriate 1005e5c31af7Sopenharmony_cietext:*_SPARSE_BINDING_BIT to be used with the sparse binding command 1006e5c31af7Sopenharmony_ci(fname:vkQueueBindSparse). 1007e5c31af7Sopenharmony_ci==== 1008e5c31af7Sopenharmony_ci 1009e5c31af7Sopenharmony_ci 1010e5c31af7Sopenharmony_ci[[sparsememory-memory-requirements]] 1011e5c31af7Sopenharmony_ci=== Sparse Resource Memory Requirements 1012e5c31af7Sopenharmony_ci 1013e5c31af7Sopenharmony_ciSparse resources have specific memory requirements related to binding sparse 1014e5c31af7Sopenharmony_cimemory. 1015e5c31af7Sopenharmony_ciThese memory requirements are reported differently for sname:VkBuffer 1016e5c31af7Sopenharmony_ciobjects and sname:VkImage objects. 1017e5c31af7Sopenharmony_ci 1018e5c31af7Sopenharmony_ci 1019e5c31af7Sopenharmony_ci[[sparsememory-memory-buffer-fully-resident]] 1020e5c31af7Sopenharmony_ci==== Buffer and Fully-Resident Images 1021e5c31af7Sopenharmony_ci 1022e5c31af7Sopenharmony_ciBuffers (both fully and partially resident) and fully-resident images can: 1023e5c31af7Sopenharmony_cibe bound to memory using only the data from sname:VkMemoryRequirements. 1024e5c31af7Sopenharmony_ciFor all sparse resources the sname:VkMemoryRequirements::pname:alignment 1025e5c31af7Sopenharmony_cimember specifies both the bindable sparse block size in bytes and required: 1026e5c31af7Sopenharmony_cialignment of sname:VkDeviceMemory. 1027e5c31af7Sopenharmony_ci 1028e5c31af7Sopenharmony_ci 1029e5c31af7Sopenharmony_ci[[sparsememory-memory-partially-resident]] 1030e5c31af7Sopenharmony_ci==== Partially Resident Images 1031e5c31af7Sopenharmony_ci 1032e5c31af7Sopenharmony_ciPartially resident images have a different method for binding memory. 1033e5c31af7Sopenharmony_ciAs with buffers and fully resident images, the 1034e5c31af7Sopenharmony_cisname:VkMemoryRequirements::pname:alignment field specifies the bindable 1035e5c31af7Sopenharmony_cisparse block size in bytes for the image. 1036e5c31af7Sopenharmony_ci 1037e5c31af7Sopenharmony_ciRequesting sparse memory requirements for sname:VkImage objects using 1038e5c31af7Sopenharmony_cifname:vkGetImageSparseMemoryRequirements will return an array of one or more 1039e5c31af7Sopenharmony_cisname:VkSparseImageMemoryRequirements structures. 1040e5c31af7Sopenharmony_ciEach structure describes the sparse memory requirements for a group of 1041e5c31af7Sopenharmony_ciaspects of the image. 1042e5c31af7Sopenharmony_ci 1043e5c31af7Sopenharmony_ciThe sparse image must: have been created using the 1044e5c31af7Sopenharmony_ciename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT flag to retrieve valid sparse 1045e5c31af7Sopenharmony_ciimage memory requirements. 1046e5c31af7Sopenharmony_ci 1047e5c31af7Sopenharmony_ci 1048e5c31af7Sopenharmony_ci==== Sparse Image Memory Requirements 1049e5c31af7Sopenharmony_ci 1050e5c31af7Sopenharmony_ci[open,refpage='VkSparseImageMemoryRequirements',desc='Structure specifying sparse image memory requirements',type='structs'] 1051e5c31af7Sopenharmony_ci-- 1052e5c31af7Sopenharmony_ciThe sname:VkSparseImageMemoryRequirements structure is defined as: 1053e5c31af7Sopenharmony_ci 1054e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkSparseImageMemoryRequirements.txt[] 1055e5c31af7Sopenharmony_ci 1056e5c31af7Sopenharmony_ci * pname:formatProperties is a slink:VkSparseImageFormatProperties 1057e5c31af7Sopenharmony_ci structure specifying properties of the image format. 1058e5c31af7Sopenharmony_ci * pname:imageMipTailFirstLod is the first mip level at which image 1059e5c31af7Sopenharmony_ci subresources are included in the mip tail region. 1060e5c31af7Sopenharmony_ci * pname:imageMipTailSize is the memory size (in bytes) of the mip tail 1061e5c31af7Sopenharmony_ci region. 1062e5c31af7Sopenharmony_ci If pname:formatProperties.flags contains 1063e5c31af7Sopenharmony_ci ename:VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT, this is the size of the 1064e5c31af7Sopenharmony_ci whole mip tail, otherwise this is the size of the mip tail of a single 1065e5c31af7Sopenharmony_ci array layer. 1066e5c31af7Sopenharmony_ci This value is guaranteed to be a multiple of the sparse block size in 1067e5c31af7Sopenharmony_ci bytes. 1068e5c31af7Sopenharmony_ci * pname:imageMipTailOffset is the opaque memory offset used with 1069e5c31af7Sopenharmony_ci slink:VkSparseImageOpaqueMemoryBindInfo to bind the mip tail region(s). 1070e5c31af7Sopenharmony_ci * pname:imageMipTailStride is the offset stride between each array-layer's 1071e5c31af7Sopenharmony_ci mip tail, if pname:formatProperties.flags does not contain 1072e5c31af7Sopenharmony_ci ename:VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT (otherwise the value is 1073e5c31af7Sopenharmony_ci undefined:). 1074e5c31af7Sopenharmony_ci 1075e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkSparseImageMemoryRequirements.txt[] 1076e5c31af7Sopenharmony_ci-- 1077e5c31af7Sopenharmony_ci 1078e5c31af7Sopenharmony_ci[open,refpage='vkGetImageSparseMemoryRequirements',desc='Query the memory requirements for a sparse image',type='protos'] 1079e5c31af7Sopenharmony_ci-- 1080e5c31af7Sopenharmony_ciTo query sparse memory requirements for an image, call: 1081e5c31af7Sopenharmony_ci 1082e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetImageSparseMemoryRequirements.txt[] 1083e5c31af7Sopenharmony_ci 1084e5c31af7Sopenharmony_ci * pname:device is the logical device that owns the image. 1085e5c31af7Sopenharmony_ci * pname:image is the slink:VkImage object to get the memory requirements 1086e5c31af7Sopenharmony_ci for. 1087e5c31af7Sopenharmony_ci * pname:pSparseMemoryRequirementCount is a pointer to an integer related 1088e5c31af7Sopenharmony_ci to the number of sparse memory requirements available or queried, as 1089e5c31af7Sopenharmony_ci described below. 1090e5c31af7Sopenharmony_ci * pname:pSparseMemoryRequirements is either `NULL` or a pointer to an 1091e5c31af7Sopenharmony_ci array of sname:VkSparseImageMemoryRequirements structures. 1092e5c31af7Sopenharmony_ci 1093e5c31af7Sopenharmony_ciIf pname:pSparseMemoryRequirements is `NULL`, then the number of sparse 1094e5c31af7Sopenharmony_cimemory requirements available is returned in 1095e5c31af7Sopenharmony_cipname:pSparseMemoryRequirementCount. 1096e5c31af7Sopenharmony_ciOtherwise, pname:pSparseMemoryRequirementCount must: point to a variable set 1097e5c31af7Sopenharmony_ciby the user to the number of elements in the pname:pSparseMemoryRequirements 1098e5c31af7Sopenharmony_ciarray, and on return the variable is overwritten with the number of 1099e5c31af7Sopenharmony_cistructures actually written to pname:pSparseMemoryRequirements. 1100e5c31af7Sopenharmony_ciIf pname:pSparseMemoryRequirementCount is less than the number of sparse 1101e5c31af7Sopenharmony_cimemory requirements available, at most pname:pSparseMemoryRequirementCount 1102e5c31af7Sopenharmony_cistructures will be written. 1103e5c31af7Sopenharmony_ci 1104e5c31af7Sopenharmony_ciIf the image was not created with ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT 1105e5c31af7Sopenharmony_cithen pname:pSparseMemoryRequirementCount will be set to zero and 1106e5c31af7Sopenharmony_cipname:pSparseMemoryRequirements will not be written to. 1107e5c31af7Sopenharmony_ci 1108e5c31af7Sopenharmony_ci[NOTE] 1109e5c31af7Sopenharmony_ci.Note 1110e5c31af7Sopenharmony_ci==== 1111e5c31af7Sopenharmony_ciIt is legal for an implementation to report a larger value in 1112e5c31af7Sopenharmony_cisname:VkMemoryRequirements::pname:size than would be obtained by adding 1113e5c31af7Sopenharmony_citogether memory sizes for all sname:VkSparseImageMemoryRequirements returned 1114e5c31af7Sopenharmony_ciby fname:vkGetImageSparseMemoryRequirements. 1115e5c31af7Sopenharmony_ciThis may: occur when the implementation requires unused padding in the 1116e5c31af7Sopenharmony_ciaddress range describing the resource. 1117e5c31af7Sopenharmony_ci==== 1118e5c31af7Sopenharmony_ci 1119e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetImageSparseMemoryRequirements.txt[] 1120e5c31af7Sopenharmony_ci-- 1121e5c31af7Sopenharmony_ci 1122e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_get_memory_requirements2[] 1123e5c31af7Sopenharmony_ci[open,refpage='vkGetImageSparseMemoryRequirements2',desc='Query the memory requirements for a sparse image',type='protos'] 1124e5c31af7Sopenharmony_ci-- 1125e5c31af7Sopenharmony_ciTo query sparse memory requirements for an image, call: 1126e5c31af7Sopenharmony_ci 1127e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[] 1128e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetImageSparseMemoryRequirements2.txt[] 1129e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[] 1130e5c31af7Sopenharmony_ci 1131e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1+VK_KHR_get_memory_requirements2[or the equivalent command] 1132e5c31af7Sopenharmony_ci 1133e5c31af7Sopenharmony_ciifdef::VK_KHR_get_memory_requirements2[] 1134e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetImageSparseMemoryRequirements2KHR.txt[] 1135e5c31af7Sopenharmony_ciendif::VK_KHR_get_memory_requirements2[] 1136e5c31af7Sopenharmony_ci 1137e5c31af7Sopenharmony_ci * pname:device is the logical device that owns the image. 1138e5c31af7Sopenharmony_ci * pname:pInfo is a pointer to a sname:VkImageSparseMemoryRequirementsInfo2 1139e5c31af7Sopenharmony_ci structure containing parameters required for the memory requirements 1140e5c31af7Sopenharmony_ci query. 1141e5c31af7Sopenharmony_ci * pname:pSparseMemoryRequirementCount is a pointer to an integer related 1142e5c31af7Sopenharmony_ci to the number of sparse memory requirements available or queried, as 1143e5c31af7Sopenharmony_ci described below. 1144e5c31af7Sopenharmony_ci * pname:pSparseMemoryRequirements is either `NULL` or a pointer to an 1145e5c31af7Sopenharmony_ci array of sname:VkSparseImageMemoryRequirements2 structures. 1146e5c31af7Sopenharmony_ci 1147e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetImageSparseMemoryRequirements2.txt[] 1148e5c31af7Sopenharmony_ci-- 1149e5c31af7Sopenharmony_ci 1150e5c31af7Sopenharmony_ciifdef::VK_KHR_maintenance4[] 1151e5c31af7Sopenharmony_ci[open,refpage='vkGetDeviceImageSparseMemoryRequirementsKHR',desc='Query the memory requirements for a sparse image',type='protos'] 1152e5c31af7Sopenharmony_ci-- 1153e5c31af7Sopenharmony_ciTo determine the sparse memory requirements for an image resource without 1154e5c31af7Sopenharmony_cicreating an object, call: 1155e5c31af7Sopenharmony_ci 1156e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetDeviceImageSparseMemoryRequirementsKHR.txt[] 1157e5c31af7Sopenharmony_ci 1158e5c31af7Sopenharmony_ci * pname:device is the logical device intended to own the image. 1159e5c31af7Sopenharmony_ci * pname:pInfo is a pointer to a slink:VkDeviceImageMemoryRequirementsKHR 1160e5c31af7Sopenharmony_ci structure containing parameters required for the memory requirements 1161e5c31af7Sopenharmony_ci query. 1162e5c31af7Sopenharmony_ci * pname:pSparseMemoryRequirementCount is a pointer to an integer related 1163e5c31af7Sopenharmony_ci to the number of sparse memory requirements available or queried, as 1164e5c31af7Sopenharmony_ci described below. 1165e5c31af7Sopenharmony_ci * pname:pSparseMemoryRequirements is either `NULL` or a pointer to an 1166e5c31af7Sopenharmony_ci array of sname:VkSparseImageMemoryRequirements2 structures. 1167e5c31af7Sopenharmony_ci 1168e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetDeviceImageSparseMemoryRequirementsKHR.txt[] 1169e5c31af7Sopenharmony_ci-- 1170e5c31af7Sopenharmony_ciendif::VK_KHR_maintenance4[] 1171e5c31af7Sopenharmony_ci 1172e5c31af7Sopenharmony_ci[open,refpage='VkImageSparseMemoryRequirementsInfo2',desc='(None)',type='structs'] 1173e5c31af7Sopenharmony_ci-- 1174e5c31af7Sopenharmony_ciThe sname:VkImageSparseMemoryRequirementsInfo2 structure is defined as: 1175e5c31af7Sopenharmony_ci 1176e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkImageSparseMemoryRequirementsInfo2.txt[] 1177e5c31af7Sopenharmony_ci 1178e5c31af7Sopenharmony_ciifdef::VK_KHR_get_memory_requirements2[] 1179e5c31af7Sopenharmony_cior the equivalent 1180e5c31af7Sopenharmony_ci 1181e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkImageSparseMemoryRequirementsInfo2KHR.txt[] 1182e5c31af7Sopenharmony_ciendif::VK_KHR_get_memory_requirements2[] 1183e5c31af7Sopenharmony_ci 1184e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 1185e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 1186e5c31af7Sopenharmony_ci structure. 1187e5c31af7Sopenharmony_ci * pname:image is the image to query. 1188e5c31af7Sopenharmony_ci 1189e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkImageSparseMemoryRequirementsInfo2.txt[] 1190e5c31af7Sopenharmony_ci-- 1191e5c31af7Sopenharmony_ci 1192e5c31af7Sopenharmony_ci[open,refpage='VkSparseImageMemoryRequirements2',desc='(None)',type='structs'] 1193e5c31af7Sopenharmony_ci-- 1194e5c31af7Sopenharmony_ciThe sname:VkSparseImageMemoryRequirements2 structure is defined as: 1195e5c31af7Sopenharmony_ci 1196e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkSparseImageMemoryRequirements2.txt[] 1197e5c31af7Sopenharmony_ci 1198e5c31af7Sopenharmony_ciifdef::VK_KHR_get_memory_requirements2[] 1199e5c31af7Sopenharmony_cior the equivalent 1200e5c31af7Sopenharmony_ci 1201e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkSparseImageMemoryRequirements2KHR.txt[] 1202e5c31af7Sopenharmony_ciendif::VK_KHR_get_memory_requirements2[] 1203e5c31af7Sopenharmony_ci 1204e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 1205e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 1206e5c31af7Sopenharmony_ci structure. 1207e5c31af7Sopenharmony_ci * pname:memoryRequirements is a slink:VkSparseImageMemoryRequirements 1208e5c31af7Sopenharmony_ci structure describing the memory requirements of the sparse image. 1209e5c31af7Sopenharmony_ci 1210e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkSparseImageMemoryRequirements2.txt[] 1211e5c31af7Sopenharmony_ci-- 1212e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_get_memory_requirements2[] 1213e5c31af7Sopenharmony_ci 1214e5c31af7Sopenharmony_ci 1215e5c31af7Sopenharmony_ci[[sparsememory-resource-binding]] 1216e5c31af7Sopenharmony_ci=== Binding Resource Memory 1217e5c31af7Sopenharmony_ci 1218e5c31af7Sopenharmony_ciNon-sparse resources are backed by a single physical allocation prior to 1219e5c31af7Sopenharmony_cidevice use (via fname:vkBindImageMemory or fname:vkBindBufferMemory), and 1220e5c31af7Sopenharmony_citheir backing must: not be changed. 1221e5c31af7Sopenharmony_ciOn the other hand, sparse resources can: be bound to memory non-contiguously 1222e5c31af7Sopenharmony_ciand these bindings can: be altered during the lifetime of the resource. 1223e5c31af7Sopenharmony_ci 1224e5c31af7Sopenharmony_ci[NOTE] 1225e5c31af7Sopenharmony_ci.Note 1226e5c31af7Sopenharmony_ci==== 1227e5c31af7Sopenharmony_ciIt is important to note that freeing a sname:VkDeviceMemory object with 1228e5c31af7Sopenharmony_cifname:vkFreeMemory will not cause resources (or resource regions) bound to 1229e5c31af7Sopenharmony_cithe memory object to become unbound. 1230e5c31af7Sopenharmony_ciApplications must: not access resources bound to memory that has been freed. 1231e5c31af7Sopenharmony_ci==== 1232e5c31af7Sopenharmony_ci 1233e5c31af7Sopenharmony_ciSparse memory bindings execute on a queue that includes the 1234e5c31af7Sopenharmony_ciename:VK_QUEUE_SPARSE_BINDING_BIT bit. 1235e5c31af7Sopenharmony_ciApplications must: use <<synchronization,synchronization primitives>> to 1236e5c31af7Sopenharmony_ciguarantee that other queues do not access ranges of memory concurrently with 1237e5c31af7Sopenharmony_cia binding change. 1238e5c31af7Sopenharmony_ciApplications can: access other ranges of the same resource while a bind 1239e5c31af7Sopenharmony_cioperation is executing. 1240e5c31af7Sopenharmony_ci 1241e5c31af7Sopenharmony_ci[NOTE] 1242e5c31af7Sopenharmony_ci.Note 1243e5c31af7Sopenharmony_ci==== 1244e5c31af7Sopenharmony_ciImplementations must: provide a guarantee that simultaneously binding sparse 1245e5c31af7Sopenharmony_ciblocks while another queue accesses those same sparse blocks via a sparse 1246e5c31af7Sopenharmony_ciresource must: not access memory owned by another process or otherwise 1247e5c31af7Sopenharmony_cicorrupt the system. 1248e5c31af7Sopenharmony_ci==== 1249e5c31af7Sopenharmony_ci 1250e5c31af7Sopenharmony_ciWhile some implementations may: include ename:VK_QUEUE_SPARSE_BINDING_BIT 1251e5c31af7Sopenharmony_cisupport in queue families that also include graphics and compute support, 1252e5c31af7Sopenharmony_ciother implementations may: only expose a 1253e5c31af7Sopenharmony_ciename:VK_QUEUE_SPARSE_BINDING_BIT-only queue family. 1254e5c31af7Sopenharmony_ciIn either case, applications must: use <<synchronization,synchronization 1255e5c31af7Sopenharmony_ciprimitives>> to explicitly request any ordering dependencies between sparse 1256e5c31af7Sopenharmony_cimemory binding operations and other graphics/compute/transfer operations, as 1257e5c31af7Sopenharmony_cisparse binding operations are not automatically ordered against command 1258e5c31af7Sopenharmony_cibuffer execution, even within a single queue. 1259e5c31af7Sopenharmony_ci 1260e5c31af7Sopenharmony_ciWhen binding memory explicitly for the ename:VK_IMAGE_ASPECT_METADATA_BIT 1261e5c31af7Sopenharmony_cithe application must: use the ename:VK_SPARSE_MEMORY_BIND_METADATA_BIT in 1262e5c31af7Sopenharmony_cithe sname:VkSparseMemoryBind::pname:flags field when binding memory. 1263e5c31af7Sopenharmony_ciBinding memory for metadata is done the same way as binding memory for the 1264e5c31af7Sopenharmony_cimip tail, with the addition of the ename:VK_SPARSE_MEMORY_BIND_METADATA_BIT 1265e5c31af7Sopenharmony_ciflag. 1266e5c31af7Sopenharmony_ci 1267e5c31af7Sopenharmony_ciBinding the mip tail for any aspect must: only be performed using 1268e5c31af7Sopenharmony_cislink:VkSparseImageOpaqueMemoryBindInfo. 1269e5c31af7Sopenharmony_ciIf pname:formatProperties.flags contains 1270e5c31af7Sopenharmony_ciename:VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT, then it can: be bound with 1271e5c31af7Sopenharmony_cia single slink:VkSparseMemoryBind structure, with pname:resourceOffset = 1272e5c31af7Sopenharmony_cipname:imageMipTailOffset and pname:size = pname:imageMipTailSize. 1273e5c31af7Sopenharmony_ci 1274e5c31af7Sopenharmony_ciIf pname:formatProperties.flags does not contain 1275e5c31af7Sopenharmony_ciename:VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT then the offset for the mip 1276e5c31af7Sopenharmony_citail in each array layer is given as: 1277e5c31af7Sopenharmony_ci 1278e5c31af7Sopenharmony_ci[source,c++] 1279e5c31af7Sopenharmony_ci--------------------------------------------------- 1280e5c31af7Sopenharmony_ciarrayMipTailOffset = imageMipTailOffset + arrayLayer * imageMipTailStride; 1281e5c31af7Sopenharmony_ci--------------------------------------------------- 1282e5c31af7Sopenharmony_ci 1283e5c31af7Sopenharmony_ciand the mip tail can: be bound with code:layerCount slink:VkSparseMemoryBind 1284e5c31af7Sopenharmony_cistructures, each using pname:size = pname:imageMipTailSize and 1285e5c31af7Sopenharmony_cipname:resourceOffset = ptext:arrayMipTailOffset as defined above. 1286e5c31af7Sopenharmony_ci 1287e5c31af7Sopenharmony_ciSparse memory binding is handled by the following APIs and related data 1288e5c31af7Sopenharmony_cistructures. 1289e5c31af7Sopenharmony_ci 1290e5c31af7Sopenharmony_ci 1291e5c31af7Sopenharmony_ci[[sparsemem-memory-binding]] 1292e5c31af7Sopenharmony_ci==== Sparse Memory Binding Functions 1293e5c31af7Sopenharmony_ci 1294e5c31af7Sopenharmony_ci[open,refpage='VkSparseMemoryBind',desc='Structure specifying a sparse memory bind operation',type='structs'] 1295e5c31af7Sopenharmony_ci-- 1296e5c31af7Sopenharmony_ciThe sname:VkSparseMemoryBind structure is defined as: 1297e5c31af7Sopenharmony_ci 1298e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkSparseMemoryBind.txt[] 1299e5c31af7Sopenharmony_ci 1300e5c31af7Sopenharmony_ci * pname:resourceOffset is the offset into the resource. 1301e5c31af7Sopenharmony_ci * pname:size is the size of the memory region to be bound. 1302e5c31af7Sopenharmony_ci * pname:memory is the slink:VkDeviceMemory object that the range of the 1303e5c31af7Sopenharmony_ci resource is bound to. 1304e5c31af7Sopenharmony_ci If pname:memory is dlink:VK_NULL_HANDLE, the range is unbound. 1305e5c31af7Sopenharmony_ci * pname:memoryOffset is the offset into the slink:VkDeviceMemory object to 1306e5c31af7Sopenharmony_ci bind the resource range to. 1307e5c31af7Sopenharmony_ci If pname:memory is dlink:VK_NULL_HANDLE, this value is ignored. 1308e5c31af7Sopenharmony_ci * pname:flags is a bitmask of elink:VkSparseMemoryBindFlagBits specifying 1309e5c31af7Sopenharmony_ci usage of the binding operation. 1310e5c31af7Sopenharmony_ci 1311e5c31af7Sopenharmony_ciThe _binding range_ [eq]#[pname:resourceOffset, pname:resourceOffset {plus} 1312e5c31af7Sopenharmony_cipname:size)# has different constraints based on pname:flags. 1313e5c31af7Sopenharmony_ciIf pname:flags contains ename:VK_SPARSE_MEMORY_BIND_METADATA_BIT, the 1314e5c31af7Sopenharmony_cibinding range must: be within the mip tail region of the metadata aspect. 1315e5c31af7Sopenharmony_ciThis metadata region is defined by: 1316e5c31af7Sopenharmony_ci 1317e5c31af7Sopenharmony_ci {empty}:: [eq]#metadataRegion = [base, base {plus} 1318e5c31af7Sopenharmony_ci pname:imageMipTailSize)# 1319e5c31af7Sopenharmony_ci {empty}:: [eq]#base = pname:imageMipTailOffset {plus} 1320e5c31af7Sopenharmony_ci pname:imageMipTailStride {times} n# 1321e5c31af7Sopenharmony_ci 1322e5c31af7Sopenharmony_ciand pname:imageMipTailOffset, pname:imageMipTailSize, and 1323e5c31af7Sopenharmony_cipname:imageMipTailStride values are from the 1324e5c31af7Sopenharmony_cislink:VkSparseImageMemoryRequirements corresponding to the metadata aspect 1325e5c31af7Sopenharmony_ciof the image, and [eq]#n# is a valid array layer index for the image, 1326e5c31af7Sopenharmony_ci 1327e5c31af7Sopenharmony_cipname:imageMipTailStride is considered to be zero for aspects where 1328e5c31af7Sopenharmony_cisname:VkSparseImageMemoryRequirements::pname:formatProperties.flags contains 1329e5c31af7Sopenharmony_ciename:VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT. 1330e5c31af7Sopenharmony_ci 1331e5c31af7Sopenharmony_ciIf pname:flags does not contain ename:VK_SPARSE_MEMORY_BIND_METADATA_BIT, 1332e5c31af7Sopenharmony_cithe binding range must: be within the range 1333e5c31af7Sopenharmony_ci[eq]#[0,slink:VkMemoryRequirements::pname:size)#. 1334e5c31af7Sopenharmony_ci 1335e5c31af7Sopenharmony_ci.Valid Usage 1336e5c31af7Sopenharmony_ci**** 1337e5c31af7Sopenharmony_ci * [[VUID-VkSparseMemoryBind-memory-01096]] 1338e5c31af7Sopenharmony_ci If pname:memory is not dlink:VK_NULL_HANDLE, pname:memory and 1339e5c31af7Sopenharmony_ci pname:memoryOffset must: match the memory requirements of the resource, 1340e5c31af7Sopenharmony_ci as described in section <<resources-association>> 1341e5c31af7Sopenharmony_ci * [[VUID-VkSparseMemoryBind-memory-01097]] 1342e5c31af7Sopenharmony_ci If pname:memory is not dlink:VK_NULL_HANDLE, pname:memory must: not have 1343e5c31af7Sopenharmony_ci been created with a memory type that reports 1344e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT bit set 1345e5c31af7Sopenharmony_ci * [[VUID-VkSparseMemoryBind-size-01098]] 1346e5c31af7Sopenharmony_ci pname:size must: be greater than `0` 1347e5c31af7Sopenharmony_ci * [[VUID-VkSparseMemoryBind-resourceOffset-01099]] 1348e5c31af7Sopenharmony_ci pname:resourceOffset must: be less than the size of the resource 1349e5c31af7Sopenharmony_ci * [[VUID-VkSparseMemoryBind-size-01100]] 1350e5c31af7Sopenharmony_ci pname:size must: be less than or equal to the size of the resource minus 1351e5c31af7Sopenharmony_ci pname:resourceOffset 1352e5c31af7Sopenharmony_ci * [[VUID-VkSparseMemoryBind-memoryOffset-01101]] 1353e5c31af7Sopenharmony_ci pname:memoryOffset must: be less than the size of pname:memory 1354e5c31af7Sopenharmony_ci * [[VUID-VkSparseMemoryBind-size-01102]] 1355e5c31af7Sopenharmony_ci pname:size must: be less than or equal to the size of pname:memory minus 1356e5c31af7Sopenharmony_ci pname:memoryOffset 1357e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 1358e5c31af7Sopenharmony_ci * [[VUID-VkSparseMemoryBind-memory-02730]] 1359e5c31af7Sopenharmony_ci If pname:memory was created with 1360e5c31af7Sopenharmony_ci slink:VkExportMemoryAllocateInfo::pname:handleTypes not equal to `0`, at 1361e5c31af7Sopenharmony_ci least one handle type it contained must: also have been set in 1362e5c31af7Sopenharmony_ci slink:VkExternalMemoryBufferCreateInfo::pname:handleTypes or 1363e5c31af7Sopenharmony_ci slink:VkExternalMemoryImageCreateInfo::pname:handleTypes when the 1364e5c31af7Sopenharmony_ci resource was created 1365e5c31af7Sopenharmony_ci * [[VUID-VkSparseMemoryBind-memory-02731]] 1366e5c31af7Sopenharmony_ci If pname:memory was created by a memory import operation, the external 1367e5c31af7Sopenharmony_ci handle type of the imported memory must: also have been set in 1368e5c31af7Sopenharmony_ci slink:VkExternalMemoryBufferCreateInfo::pname:handleTypes or 1369e5c31af7Sopenharmony_ci slink:VkExternalMemoryImageCreateInfo::pname:handleTypes when the 1370e5c31af7Sopenharmony_ci resource was created 1371e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_external_memory[] 1372e5c31af7Sopenharmony_ci**** 1373e5c31af7Sopenharmony_ci 1374e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkSparseMemoryBind.txt[] 1375e5c31af7Sopenharmony_ci-- 1376e5c31af7Sopenharmony_ci 1377e5c31af7Sopenharmony_ci[open,refpage='VkSparseMemoryBindFlagBits',desc='Bitmask specifying usage of a sparse memory binding operation',type='enums'] 1378e5c31af7Sopenharmony_ci-- 1379e5c31af7Sopenharmony_ciBits which can: be set in slink:VkSparseMemoryBind::pname:flags, specifying 1380e5c31af7Sopenharmony_ciusage of a sparse memory binding operation, are: 1381e5c31af7Sopenharmony_ci 1382e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkSparseMemoryBindFlagBits.txt[] 1383e5c31af7Sopenharmony_ci 1384e5c31af7Sopenharmony_ci * ename:VK_SPARSE_MEMORY_BIND_METADATA_BIT specifies that the memory being 1385e5c31af7Sopenharmony_ci bound is only for the metadata aspect. 1386e5c31af7Sopenharmony_ci-- 1387e5c31af7Sopenharmony_ci 1388e5c31af7Sopenharmony_ci[open,refpage='VkSparseMemoryBindFlags',desc='Bitmask of VkSparseMemoryBindFlagBits',type='flags'] 1389e5c31af7Sopenharmony_ci-- 1390e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkSparseMemoryBindFlags.txt[] 1391e5c31af7Sopenharmony_ci 1392e5c31af7Sopenharmony_citname:VkSparseMemoryBindFlags is a bitmask type for setting a mask of zero 1393e5c31af7Sopenharmony_cior more elink:VkSparseMemoryBindFlagBits. 1394e5c31af7Sopenharmony_ci-- 1395e5c31af7Sopenharmony_ci 1396e5c31af7Sopenharmony_ci[open,refpage='VkSparseBufferMemoryBindInfo',desc='Structure specifying a sparse buffer memory bind operation',type='structs'] 1397e5c31af7Sopenharmony_ci-- 1398e5c31af7Sopenharmony_ciMemory is bound to sname:VkBuffer objects created with the 1399e5c31af7Sopenharmony_ciename:VK_BUFFER_CREATE_SPARSE_BINDING_BIT flag using the following 1400e5c31af7Sopenharmony_cistructure: 1401e5c31af7Sopenharmony_ci 1402e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkSparseBufferMemoryBindInfo.txt[] 1403e5c31af7Sopenharmony_ci 1404e5c31af7Sopenharmony_ci * pname:buffer is the slink:VkBuffer object to be bound. 1405e5c31af7Sopenharmony_ci * pname:bindCount is the number of slink:VkSparseMemoryBind structures in 1406e5c31af7Sopenharmony_ci the pname:pBinds array. 1407e5c31af7Sopenharmony_ci * pname:pBinds is a pointer to an array of slink:VkSparseMemoryBind 1408e5c31af7Sopenharmony_ci structures. 1409e5c31af7Sopenharmony_ci 1410e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkSparseBufferMemoryBindInfo.txt[] 1411e5c31af7Sopenharmony_ci-- 1412e5c31af7Sopenharmony_ci 1413e5c31af7Sopenharmony_ci[open,refpage='VkSparseImageOpaqueMemoryBindInfo',desc='Structure specifying sparse image opaque memory bind information',type='structs'] 1414e5c31af7Sopenharmony_ci-- 1415e5c31af7Sopenharmony_ciMemory is bound to opaque regions of sname:VkImage objects created with the 1416e5c31af7Sopenharmony_ciename:VK_IMAGE_CREATE_SPARSE_BINDING_BIT flag using the following structure: 1417e5c31af7Sopenharmony_ci 1418e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkSparseImageOpaqueMemoryBindInfo.txt[] 1419e5c31af7Sopenharmony_ci 1420e5c31af7Sopenharmony_ci * pname:image is the slink:VkImage object to be bound. 1421e5c31af7Sopenharmony_ci * pname:bindCount is the number of slink:VkSparseMemoryBind structures in 1422e5c31af7Sopenharmony_ci the pname:pBinds array. 1423e5c31af7Sopenharmony_ci * pname:pBinds is a pointer to an array of slink:VkSparseMemoryBind 1424e5c31af7Sopenharmony_ci structures. 1425e5c31af7Sopenharmony_ci 1426e5c31af7Sopenharmony_ci.Valid Usage 1427e5c31af7Sopenharmony_ci**** 1428e5c31af7Sopenharmony_ci * [[VUID-VkSparseImageOpaqueMemoryBindInfo-pBinds-01103]] 1429e5c31af7Sopenharmony_ci If the pname:flags member of any element of pname:pBinds contains 1430e5c31af7Sopenharmony_ci ename:VK_SPARSE_MEMORY_BIND_METADATA_BIT, the binding range defined 1431e5c31af7Sopenharmony_ci must: be within the mip tail region of the metadata aspect of 1432e5c31af7Sopenharmony_ci pname:image 1433e5c31af7Sopenharmony_ci**** 1434e5c31af7Sopenharmony_ci 1435e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkSparseImageOpaqueMemoryBindInfo.txt[] 1436e5c31af7Sopenharmony_ci-- 1437e5c31af7Sopenharmony_ci 1438e5c31af7Sopenharmony_ci[NOTE] 1439e5c31af7Sopenharmony_ci.Note 1440e5c31af7Sopenharmony_ci==== 1441e5c31af7Sopenharmony_ciThis operation is normally used to bind memory to fully-resident sparse 1442e5c31af7Sopenharmony_ciimages or for mip tail regions of partially resident images. 1443e5c31af7Sopenharmony_ciHowever, it can: also be used to bind memory for the entire binding range of 1444e5c31af7Sopenharmony_cipartially resident images. 1445e5c31af7Sopenharmony_ci 1446e5c31af7Sopenharmony_ciIn case pname:flags does not contain 1447e5c31af7Sopenharmony_ciename:VK_SPARSE_MEMORY_BIND_METADATA_BIT, the pname:resourceOffset is in the 1448e5c31af7Sopenharmony_cirange [eq]#[0, slink:VkMemoryRequirements::pname:size)#, This range includes 1449e5c31af7Sopenharmony_cidata from all aspects of the image, including metadata. 1450e5c31af7Sopenharmony_ciFor most implementations this will probably mean that the 1451e5c31af7Sopenharmony_cipname:resourceOffset is a simple device address offset within the resource. 1452e5c31af7Sopenharmony_ciIt is possible for an application to bind a range of memory that includes 1453e5c31af7Sopenharmony_ciboth resource data and metadata. 1454e5c31af7Sopenharmony_ciHowever, the application would not know what part of the image the memory is 1455e5c31af7Sopenharmony_ciused for, or if any range is being used for metadata. 1456e5c31af7Sopenharmony_ci 1457e5c31af7Sopenharmony_ciWhen pname:flags contains ename:VK_SPARSE_MEMORY_BIND_METADATA_BIT, the 1458e5c31af7Sopenharmony_cibinding range specified must: be within the mip tail region of the metadata 1459e5c31af7Sopenharmony_ciaspect. 1460e5c31af7Sopenharmony_ciIn this case the pname:resourceOffset is not required: to be a simple device 1461e5c31af7Sopenharmony_ciaddress offset within the resource. 1462e5c31af7Sopenharmony_ciHowever, it _is_ defined to be within [eq]#[pname:imageMipTailOffset, 1463e5c31af7Sopenharmony_cipname:imageMipTailOffset {plus} pname:imageMipTailSize)# for the metadata 1464e5c31af7Sopenharmony_ciaspect. 1465e5c31af7Sopenharmony_ciSee slink:VkSparseMemoryBind for the full constraints on binding region with 1466e5c31af7Sopenharmony_cithis flag present. 1467e5c31af7Sopenharmony_ci==== 1468e5c31af7Sopenharmony_ci 1469e5c31af7Sopenharmony_ciifdef::editing-notes[] 1470e5c31af7Sopenharmony_ci[NOTE] 1471e5c31af7Sopenharmony_ci.editing-note 1472e5c31af7Sopenharmony_ci==== 1473e5c31af7Sopenharmony_ci(Jon) The preceding NOTE refers to pname:flags, which is presumably a 1474e5c31af7Sopenharmony_cireference to slink:VkSparseMemoryBind above, even though that is not 1475e5c31af7Sopenharmony_cicontextually clear. 1476e5c31af7Sopenharmony_ci==== 1477e5c31af7Sopenharmony_ciendif::editing-notes[] 1478e5c31af7Sopenharmony_ci 1479e5c31af7Sopenharmony_ci[open,refpage='VkSparseImageMemoryBindInfo',desc='Structure specifying sparse image memory bind information',type='structs'] 1480e5c31af7Sopenharmony_ci-- 1481e5c31af7Sopenharmony_ciMemory can: be bound to sparse image blocks of sname:VkImage objects created 1482e5c31af7Sopenharmony_ciwith the ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT flag using the following 1483e5c31af7Sopenharmony_cistructure: 1484e5c31af7Sopenharmony_ci 1485e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkSparseImageMemoryBindInfo.txt[] 1486e5c31af7Sopenharmony_ci 1487e5c31af7Sopenharmony_ci * pname:image is the slink:VkImage object to be bound 1488e5c31af7Sopenharmony_ci * pname:bindCount is the number of slink:VkSparseImageMemoryBind 1489e5c31af7Sopenharmony_ci structures in pname:pBinds array 1490e5c31af7Sopenharmony_ci * pname:pBinds is a pointer to an array of slink:VkSparseImageMemoryBind 1491e5c31af7Sopenharmony_ci structures 1492e5c31af7Sopenharmony_ci 1493e5c31af7Sopenharmony_ci.Valid Usage 1494e5c31af7Sopenharmony_ci**** 1495e5c31af7Sopenharmony_ci * [[VUID-VkSparseImageMemoryBindInfo-subresource-01722]] 1496e5c31af7Sopenharmony_ci The pname:subresource.mipLevel member of each element of pname:pBinds 1497e5c31af7Sopenharmony_ci must: be less than the pname:mipLevels specified in 1498e5c31af7Sopenharmony_ci slink:VkImageCreateInfo when pname:image was created 1499e5c31af7Sopenharmony_ci * [[VUID-VkSparseImageMemoryBindInfo-subresource-01723]] 1500e5c31af7Sopenharmony_ci The pname:subresource.arrayLayer member of each element of pname:pBinds 1501e5c31af7Sopenharmony_ci must: be less than the pname:arrayLayers specified in 1502e5c31af7Sopenharmony_ci slink:VkImageCreateInfo when pname:image was created 1503e5c31af7Sopenharmony_ci * [[VUID-VkSparseImageMemoryBindInfo-image-02901]] 1504e5c31af7Sopenharmony_ci pname:image must: have been created with 1505e5c31af7Sopenharmony_ci ename:VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set 1506e5c31af7Sopenharmony_ci**** 1507e5c31af7Sopenharmony_ci 1508e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkSparseImageMemoryBindInfo.txt[] 1509e5c31af7Sopenharmony_ci-- 1510e5c31af7Sopenharmony_ci 1511e5c31af7Sopenharmony_ci[open,refpage='VkSparseImageMemoryBind',desc='Structure specifying sparse image memory bind',type='structs'] 1512e5c31af7Sopenharmony_ci-- 1513e5c31af7Sopenharmony_ciThe sname:VkSparseImageMemoryBind structure is defined as: 1514e5c31af7Sopenharmony_ci 1515e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkSparseImageMemoryBind.txt[] 1516e5c31af7Sopenharmony_ci 1517e5c31af7Sopenharmony_ci * pname:subresource is the image _aspect_ and region of interest in the 1518e5c31af7Sopenharmony_ci image. 1519e5c31af7Sopenharmony_ci * pname:offset are the coordinates of the first texel within the image 1520e5c31af7Sopenharmony_ci subresource to bind. 1521e5c31af7Sopenharmony_ci * pname:extent is the size in texels of the region within the image 1522e5c31af7Sopenharmony_ci subresource to bind. 1523e5c31af7Sopenharmony_ci The extent must: be a multiple of the sparse image block dimensions, 1524e5c31af7Sopenharmony_ci except when binding sparse image blocks along the edge of an image 1525e5c31af7Sopenharmony_ci subresource it can: instead be such that any coordinate of 1526e5c31af7Sopenharmony_ci [eq]#pname:offset {plus} pname:extent# equals the corresponding 1527e5c31af7Sopenharmony_ci dimensions of the image subresource. 1528e5c31af7Sopenharmony_ci * pname:memory is the slink:VkDeviceMemory object that the sparse image 1529e5c31af7Sopenharmony_ci blocks of the image are bound to. 1530e5c31af7Sopenharmony_ci If pname:memory is dlink:VK_NULL_HANDLE, the sparse image blocks are 1531e5c31af7Sopenharmony_ci unbound. 1532e5c31af7Sopenharmony_ci * pname:memoryOffset is an offset into slink:VkDeviceMemory object. 1533e5c31af7Sopenharmony_ci If pname:memory is dlink:VK_NULL_HANDLE, this value is ignored. 1534e5c31af7Sopenharmony_ci * pname:flags are sparse memory binding flags. 1535e5c31af7Sopenharmony_ci 1536e5c31af7Sopenharmony_ci.Valid Usage 1537e5c31af7Sopenharmony_ci**** 1538e5c31af7Sopenharmony_ci * [[VUID-VkSparseImageMemoryBind-memory-01104]] 1539e5c31af7Sopenharmony_ci If the <<features-sparseResidencyAliased,sparse aliased residency>> 1540e5c31af7Sopenharmony_ci feature is not enabled, and if any other resources are bound to ranges 1541e5c31af7Sopenharmony_ci of pname:memory, the range of pname:memory being bound must: not overlap 1542e5c31af7Sopenharmony_ci with those bound ranges 1543e5c31af7Sopenharmony_ci * [[VUID-VkSparseImageMemoryBind-memory-01105]] 1544e5c31af7Sopenharmony_ci pname:memory and pname:memoryOffset must: match the memory requirements 1545e5c31af7Sopenharmony_ci of the calling command's pname:image, as described in section 1546e5c31af7Sopenharmony_ci <<resources-association>> 1547e5c31af7Sopenharmony_ci * [[VUID-VkSparseImageMemoryBind-subresource-01106]] 1548e5c31af7Sopenharmony_ci pname:subresource must: be a valid image subresource for pname:image 1549e5c31af7Sopenharmony_ci (see <<resources-image-views>>) 1550e5c31af7Sopenharmony_ci * [[VUID-VkSparseImageMemoryBind-offset-01107]] 1551e5c31af7Sopenharmony_ci pname:offset.x must: be a multiple of the sparse image block width 1552e5c31af7Sopenharmony_ci (sname:VkSparseImageFormatProperties::pname:imageGranularity.width) of 1553e5c31af7Sopenharmony_ci the image 1554e5c31af7Sopenharmony_ci * [[VUID-VkSparseImageMemoryBind-extent-01108]] 1555e5c31af7Sopenharmony_ci pname:extent.width must: either be a multiple of the sparse image block 1556e5c31af7Sopenharmony_ci width of the image, or else [eq]#(pname:extent.width {plus} 1557e5c31af7Sopenharmony_ci pname:offset.x)# must: equal the width of the image subresource 1558e5c31af7Sopenharmony_ci * [[VUID-VkSparseImageMemoryBind-offset-01109]] 1559e5c31af7Sopenharmony_ci pname:offset.y must: be a multiple of the sparse image block height 1560e5c31af7Sopenharmony_ci (sname:VkSparseImageFormatProperties::pname:imageGranularity.height) of 1561e5c31af7Sopenharmony_ci the image 1562e5c31af7Sopenharmony_ci * [[VUID-VkSparseImageMemoryBind-extent-01110]] 1563e5c31af7Sopenharmony_ci pname:extent.height must: either be a multiple of the sparse image block 1564e5c31af7Sopenharmony_ci height of the image, or else [eq]#(pname:extent.height {plus} 1565e5c31af7Sopenharmony_ci pname:offset.y)# must: equal the height of the image subresource 1566e5c31af7Sopenharmony_ci * [[VUID-VkSparseImageMemoryBind-offset-01111]] 1567e5c31af7Sopenharmony_ci pname:offset.z must: be a multiple of the sparse image block depth 1568e5c31af7Sopenharmony_ci (sname:VkSparseImageFormatProperties::pname:imageGranularity.depth) of 1569e5c31af7Sopenharmony_ci the image 1570e5c31af7Sopenharmony_ci * [[VUID-VkSparseImageMemoryBind-extent-01112]] 1571e5c31af7Sopenharmony_ci pname:extent.depth must: either be a multiple of the sparse image block 1572e5c31af7Sopenharmony_ci depth of the image, or else [eq]#(pname:extent.depth {plus} 1573e5c31af7Sopenharmony_ci pname:offset.z)# must: equal the depth of the image subresource 1574e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 1575e5c31af7Sopenharmony_ci * [[VUID-VkSparseImageMemoryBind-memory-02732]] 1576e5c31af7Sopenharmony_ci If pname:memory was created with 1577e5c31af7Sopenharmony_ci slink:VkExportMemoryAllocateInfo::pname:handleTypes not equal to `0`, at 1578e5c31af7Sopenharmony_ci least one handle type it contained must: also have been set in 1579e5c31af7Sopenharmony_ci slink:VkExternalMemoryImageCreateInfo::pname:handleTypes when the image 1580e5c31af7Sopenharmony_ci was created 1581e5c31af7Sopenharmony_ci * [[VUID-VkSparseImageMemoryBind-memory-02733]] 1582e5c31af7Sopenharmony_ci If pname:memory was created by a memory import operation, the external 1583e5c31af7Sopenharmony_ci handle type of the imported memory must: also have been set in 1584e5c31af7Sopenharmony_ci slink:VkExternalMemoryImageCreateInfo::pname:handleTypes when 1585e5c31af7Sopenharmony_ci pname:image was created 1586e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_external_memory[] 1587e5c31af7Sopenharmony_ci**** 1588e5c31af7Sopenharmony_ci 1589e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkSparseImageMemoryBind.txt[] 1590e5c31af7Sopenharmony_ci-- 1591e5c31af7Sopenharmony_ci 1592e5c31af7Sopenharmony_ci[open,refpage='vkQueueBindSparse',desc='Bind device memory to a sparse resource object',type='protos'] 1593e5c31af7Sopenharmony_ci-- 1594e5c31af7Sopenharmony_ciTo submit sparse binding operations to a queue, call: 1595e5c31af7Sopenharmony_ci 1596e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkQueueBindSparse.txt[] 1597e5c31af7Sopenharmony_ci 1598e5c31af7Sopenharmony_ci * pname:queue is the queue that the sparse binding operations will be 1599e5c31af7Sopenharmony_ci submitted to. 1600e5c31af7Sopenharmony_ci * pname:bindInfoCount is the number of elements in the pname:pBindInfo 1601e5c31af7Sopenharmony_ci array. 1602e5c31af7Sopenharmony_ci * pname:pBindInfo is a pointer to an array of slink:VkBindSparseInfo 1603e5c31af7Sopenharmony_ci structures, each specifying a sparse binding submission batch. 1604e5c31af7Sopenharmony_ci * pname:fence is an optional: handle to a fence to be signaled. 1605e5c31af7Sopenharmony_ci If pname:fence is not dlink:VK_NULL_HANDLE, it defines a 1606e5c31af7Sopenharmony_ci <<synchronization-fences-signaling, fence signal operation>>. 1607e5c31af7Sopenharmony_ci 1608e5c31af7Sopenharmony_cifname:vkQueueBindSparse is a <<devsandqueues-submission,queue submission 1609e5c31af7Sopenharmony_cicommand>>, with each batch defined by an element of pname:pBindInfo as a 1610e5c31af7Sopenharmony_cislink:VkBindSparseInfo structure. 1611e5c31af7Sopenharmony_ciBatches begin execution in the order they appear in pname:pBindInfo, but 1612e5c31af7Sopenharmony_cimay: complete out of order. 1613e5c31af7Sopenharmony_ci 1614e5c31af7Sopenharmony_ciWithin a batch, a given range of a resource must: not be bound more than 1615e5c31af7Sopenharmony_cionce. 1616e5c31af7Sopenharmony_ciAcross batches, if a range is to be bound to one allocation and offset and 1617e5c31af7Sopenharmony_cithen to another allocation and offset, then the application must: guarantee 1618e5c31af7Sopenharmony_ci(usually using semaphores) that the binding operations are executed in the 1619e5c31af7Sopenharmony_cicorrect order, as well as to order binding operations against the execution 1620e5c31af7Sopenharmony_ciof command buffer submissions. 1621e5c31af7Sopenharmony_ci 1622e5c31af7Sopenharmony_ciAs no operation to flink:vkQueueBindSparse causes any pipeline stage to 1623e5c31af7Sopenharmony_ciaccess memory, synchronization primitives used in this command effectively 1624e5c31af7Sopenharmony_cionly define execution dependencies. 1625e5c31af7Sopenharmony_ci 1626e5c31af7Sopenharmony_ciAdditional information about fence and semaphore operation is described in 1627e5c31af7Sopenharmony_ci<<synchronization, the synchronization chapter>>. 1628e5c31af7Sopenharmony_ci 1629e5c31af7Sopenharmony_ci.Valid Usage 1630e5c31af7Sopenharmony_ci**** 1631e5c31af7Sopenharmony_ci * [[VUID-vkQueueBindSparse-fence-01113]] 1632e5c31af7Sopenharmony_ci If pname:fence is not dlink:VK_NULL_HANDLE, pname:fence must: be 1633e5c31af7Sopenharmony_ci unsignaled 1634e5c31af7Sopenharmony_ci * [[VUID-vkQueueBindSparse-fence-01114]] 1635e5c31af7Sopenharmony_ci If pname:fence is not dlink:VK_NULL_HANDLE, pname:fence must: not be 1636e5c31af7Sopenharmony_ci associated with any other queue command that has not yet completed 1637e5c31af7Sopenharmony_ci execution on that queue 1638e5c31af7Sopenharmony_ci * [[VUID-vkQueueBindSparse-pSignalSemaphores-01115]] 1639e5c31af7Sopenharmony_ci Each element of the pname:pSignalSemaphores member of each element of 1640e5c31af7Sopenharmony_ci pname:pBindInfo must: be unsignaled when the semaphore signal operation 1641e5c31af7Sopenharmony_ci it defines is executed on the device 1642e5c31af7Sopenharmony_ci * [[VUID-vkQueueBindSparse-pWaitSemaphores-01116]] 1643e5c31af7Sopenharmony_ci When a semaphore wait operation referring to a binary semaphore defined 1644e5c31af7Sopenharmony_ci by any element of the pname:pWaitSemaphores member of any element of 1645e5c31af7Sopenharmony_ci pname:pBindInfo executes on pname:queue, there must: be no other queues 1646e5c31af7Sopenharmony_ci waiting on the same semaphore 1647e5c31af7Sopenharmony_ci * [[VUID-vkQueueBindSparse-pWaitSemaphores-01117]] 1648e5c31af7Sopenharmony_ci All elements of the pname:pWaitSemaphores member of all elements of the 1649e5c31af7Sopenharmony_ci pname:pBindInfo parameter referring to a binary semaphore must: be 1650e5c31af7Sopenharmony_ci semaphores that are signaled, or have 1651e5c31af7Sopenharmony_ci <<synchronization-semaphores-signaling, semaphore signal operations>> 1652e5c31af7Sopenharmony_ci previously submitted for execution 1653e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 1654e5c31af7Sopenharmony_ci * [[VUID-vkQueueBindSparse-pWaitSemaphores-03245]] 1655e5c31af7Sopenharmony_ci All elements of the pname:pWaitSemaphores member of all elements of 1656e5c31af7Sopenharmony_ci pname:pBindInfo created with a elink:VkSemaphoreType of 1657e5c31af7Sopenharmony_ci ename:VK_SEMAPHORE_TYPE_BINARY must: reference a semaphore signal 1658e5c31af7Sopenharmony_ci operation that has been submitted for execution and any semaphore signal 1659e5c31af7Sopenharmony_ci operations on which it depends (if any) must: have also been submitted 1660e5c31af7Sopenharmony_ci for execution 1661e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 1662e5c31af7Sopenharmony_ci**** 1663e5c31af7Sopenharmony_ci 1664e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkQueueBindSparse.txt[] 1665e5c31af7Sopenharmony_ci-- 1666e5c31af7Sopenharmony_ci 1667e5c31af7Sopenharmony_ci[open,refpage='VkBindSparseInfo',desc='Structure specifying a sparse binding operation',type='structs'] 1668e5c31af7Sopenharmony_ci-- 1669e5c31af7Sopenharmony_ciThe sname:VkBindSparseInfo structure is defined as: 1670e5c31af7Sopenharmony_ci 1671e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkBindSparseInfo.txt[] 1672e5c31af7Sopenharmony_ci 1673e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 1674e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 1675e5c31af7Sopenharmony_ci structure. 1676e5c31af7Sopenharmony_ci * pname:waitSemaphoreCount is the number of semaphores upon which to wait 1677e5c31af7Sopenharmony_ci before executing the sparse binding operations for the batch. 1678e5c31af7Sopenharmony_ci * pname:pWaitSemaphores is a pointer to an array of semaphores upon which 1679e5c31af7Sopenharmony_ci to wait on before the sparse binding operations for this batch begin 1680e5c31af7Sopenharmony_ci execution. 1681e5c31af7Sopenharmony_ci If semaphores to wait on are provided, they define a 1682e5c31af7Sopenharmony_ci <<synchronization-semaphores-waiting, semaphore wait operation>>. 1683e5c31af7Sopenharmony_ci * pname:bufferBindCount is the number of sparse buffer bindings to perform 1684e5c31af7Sopenharmony_ci in the batch. 1685e5c31af7Sopenharmony_ci * pname:pBufferBinds is a pointer to an array of 1686e5c31af7Sopenharmony_ci slink:VkSparseBufferMemoryBindInfo structures. 1687e5c31af7Sopenharmony_ci * pname:imageOpaqueBindCount is the number of opaque sparse image bindings 1688e5c31af7Sopenharmony_ci to perform. 1689e5c31af7Sopenharmony_ci * pname:pImageOpaqueBinds is a pointer to an array of 1690e5c31af7Sopenharmony_ci slink:VkSparseImageOpaqueMemoryBindInfo structures, indicating opaque 1691e5c31af7Sopenharmony_ci sparse image bindings to perform. 1692e5c31af7Sopenharmony_ci * pname:imageBindCount is the number of sparse image bindings to perform. 1693e5c31af7Sopenharmony_ci * pname:pImageBinds is a pointer to an array of 1694e5c31af7Sopenharmony_ci slink:VkSparseImageMemoryBindInfo structures, indicating sparse image 1695e5c31af7Sopenharmony_ci bindings to perform. 1696e5c31af7Sopenharmony_ci * pname:signalSemaphoreCount is the number of semaphores to be signaled 1697e5c31af7Sopenharmony_ci once the sparse binding operations specified by the structure have 1698e5c31af7Sopenharmony_ci completed execution. 1699e5c31af7Sopenharmony_ci * pname:pSignalSemaphores is a pointer to an array of semaphores which 1700e5c31af7Sopenharmony_ci will be signaled when the sparse binding operations for this batch have 1701e5c31af7Sopenharmony_ci completed execution. 1702e5c31af7Sopenharmony_ci If semaphores to be signaled are provided, they define a 1703e5c31af7Sopenharmony_ci <<synchronization-semaphores-signaling, semaphore signal operation>>. 1704e5c31af7Sopenharmony_ci 1705e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 1706e5c31af7Sopenharmony_ci.Valid Usage 1707e5c31af7Sopenharmony_ci**** 1708e5c31af7Sopenharmony_ci * [[VUID-VkBindSparseInfo-pWaitSemaphores-03246]] 1709e5c31af7Sopenharmony_ci If any element of pname:pWaitSemaphores or pname:pSignalSemaphores was 1710e5c31af7Sopenharmony_ci created with a elink:VkSemaphoreType of ename:VK_SEMAPHORE_TYPE_TIMELINE 1711e5c31af7Sopenharmony_ci then the pname:pNext chain must: include a 1712e5c31af7Sopenharmony_ci slink:VkTimelineSemaphoreSubmitInfo structure 1713e5c31af7Sopenharmony_ci * [[VUID-VkBindSparseInfo-pNext-03247]] 1714e5c31af7Sopenharmony_ci If the pname:pNext chain of this structure includes a 1715e5c31af7Sopenharmony_ci slink:VkTimelineSemaphoreSubmitInfo structure and any element of 1716e5c31af7Sopenharmony_ci pname:pWaitSemaphores was created with a elink:VkSemaphoreType of 1717e5c31af7Sopenharmony_ci ename:VK_SEMAPHORE_TYPE_TIMELINE then its pname:waitSemaphoreValueCount 1718e5c31af7Sopenharmony_ci member must: equal pname:waitSemaphoreCount 1719e5c31af7Sopenharmony_ci * [[VUID-VkBindSparseInfo-pNext-03248]] 1720e5c31af7Sopenharmony_ci If the pname:pNext chain of this structure includes a 1721e5c31af7Sopenharmony_ci slink:VkTimelineSemaphoreSubmitInfo structure and any element of 1722e5c31af7Sopenharmony_ci pname:pSignalSemaphores was created with a elink:VkSemaphoreType of 1723e5c31af7Sopenharmony_ci ename:VK_SEMAPHORE_TYPE_TIMELINE then its 1724e5c31af7Sopenharmony_ci pname:signalSemaphoreValueCount member must: equal 1725e5c31af7Sopenharmony_ci pname:signalSemaphoreCount 1726e5c31af7Sopenharmony_ci * [[VUID-VkBindSparseInfo-pSignalSemaphores-03249]] 1727e5c31af7Sopenharmony_ci For each element of pname:pSignalSemaphores created with a 1728e5c31af7Sopenharmony_ci elink:VkSemaphoreType of ename:VK_SEMAPHORE_TYPE_TIMELINE the 1729e5c31af7Sopenharmony_ci corresponding element of 1730e5c31af7Sopenharmony_ci slink:VkTimelineSemaphoreSubmitInfo::pname:pSignalSemaphoreValues must: 1731e5c31af7Sopenharmony_ci have a value greater than the current value of the semaphore when the 1732e5c31af7Sopenharmony_ci <<synchronization-semaphores-signaling,semaphore signal operation>> is 1733e5c31af7Sopenharmony_ci executed 1734e5c31af7Sopenharmony_ci * [[VUID-VkBindSparseInfo-pWaitSemaphores-03250]] 1735e5c31af7Sopenharmony_ci For each element of pname:pWaitSemaphores created with a 1736e5c31af7Sopenharmony_ci elink:VkSemaphoreType of ename:VK_SEMAPHORE_TYPE_TIMELINE the 1737e5c31af7Sopenharmony_ci corresponding element of 1738e5c31af7Sopenharmony_ci slink:VkTimelineSemaphoreSubmitInfo::pname:pWaitSemaphoreValues must: 1739e5c31af7Sopenharmony_ci have a value which does not differ from the current value of the 1740e5c31af7Sopenharmony_ci semaphore or from the value of any outstanding semaphore wait or signal 1741e5c31af7Sopenharmony_ci operation on that semaphore by more than 1742e5c31af7Sopenharmony_ci <<limits-maxTimelineSemaphoreValueDifference, 1743e5c31af7Sopenharmony_ci pname:maxTimelineSemaphoreValueDifference>> 1744e5c31af7Sopenharmony_ci * [[VUID-VkBindSparseInfo-pSignalSemaphores-03251]] 1745e5c31af7Sopenharmony_ci For each element of pname:pSignalSemaphores created with a 1746e5c31af7Sopenharmony_ci elink:VkSemaphoreType of ename:VK_SEMAPHORE_TYPE_TIMELINE the 1747e5c31af7Sopenharmony_ci corresponding element of 1748e5c31af7Sopenharmony_ci slink:VkTimelineSemaphoreSubmitInfo::pname:pSignalSemaphoreValues must: 1749e5c31af7Sopenharmony_ci have a value which does not differ from the current value of the 1750e5c31af7Sopenharmony_ci semaphore or from the value of any outstanding semaphore wait or signal 1751e5c31af7Sopenharmony_ci operation on that semaphore by more than 1752e5c31af7Sopenharmony_ci <<limits-maxTimelineSemaphoreValueDifference, 1753e5c31af7Sopenharmony_ci pname:maxTimelineSemaphoreValueDifference>> 1754e5c31af7Sopenharmony_ci**** 1755e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 1756e5c31af7Sopenharmony_ci 1757e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkBindSparseInfo.txt[] 1758e5c31af7Sopenharmony_ci-- 1759e5c31af7Sopenharmony_ci 1760e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 1761e5c31af7Sopenharmony_ciTo specify the values to use when waiting for and signaling semaphores 1762e5c31af7Sopenharmony_cicreated with a elink:VkSemaphoreType of ename:VK_SEMAPHORE_TYPE_TIMELINE, 1763e5c31af7Sopenharmony_ciadd a slink:VkTimelineSemaphoreSubmitInfo structure to the pname:pNext chain 1764e5c31af7Sopenharmony_ciof the slink:VkBindSparseInfo structure. 1765e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[] 1766e5c31af7Sopenharmony_ci 1767e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_device_group[] 1768e5c31af7Sopenharmony_ci[open,refpage='VkDeviceGroupBindSparseInfo',desc='Structure indicating which instances are bound',type='structs'] 1769e5c31af7Sopenharmony_ci-- 1770e5c31af7Sopenharmony_ciIf the pname:pNext chain of slink:VkBindSparseInfo includes a 1771e5c31af7Sopenharmony_cisname:VkDeviceGroupBindSparseInfo structure, then that structure includes 1772e5c31af7Sopenharmony_cidevice indices specifying which instance of the resources and memory are 1773e5c31af7Sopenharmony_cibound. 1774e5c31af7Sopenharmony_ci 1775e5c31af7Sopenharmony_ciThe sname:VkDeviceGroupBindSparseInfo structure is defined as: 1776e5c31af7Sopenharmony_ci 1777e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkDeviceGroupBindSparseInfo.txt[] 1778e5c31af7Sopenharmony_ci 1779e5c31af7Sopenharmony_ciifdef::VK_KHR_device_group[] 1780e5c31af7Sopenharmony_cior the equivalent 1781e5c31af7Sopenharmony_ci 1782e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkDeviceGroupBindSparseInfoKHR.txt[] 1783e5c31af7Sopenharmony_ciendif::VK_KHR_device_group[] 1784e5c31af7Sopenharmony_ci 1785e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 1786e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 1787e5c31af7Sopenharmony_ci structure. 1788e5c31af7Sopenharmony_ci * pname:resourceDeviceIndex is a device index indicating which instance of 1789e5c31af7Sopenharmony_ci the resource is bound. 1790e5c31af7Sopenharmony_ci * pname:memoryDeviceIndex is a device index indicating which instance of 1791e5c31af7Sopenharmony_ci the memory the resource instance is bound to. 1792e5c31af7Sopenharmony_ci 1793e5c31af7Sopenharmony_ciThese device indices apply to all buffer and image memory binds included in 1794e5c31af7Sopenharmony_cithe batch pointing to this structure. 1795e5c31af7Sopenharmony_ciThe semaphore waits and signals for the batch are executed only by the 1796e5c31af7Sopenharmony_ciphysical device specified by the pname:resourceDeviceIndex. 1797e5c31af7Sopenharmony_ci 1798e5c31af7Sopenharmony_ciIf this structure is not present, pname:resourceDeviceIndex and 1799e5c31af7Sopenharmony_cipname:memoryDeviceIndex are assumed to be zero. 1800e5c31af7Sopenharmony_ci 1801e5c31af7Sopenharmony_ci.Valid Usage 1802e5c31af7Sopenharmony_ci**** 1803e5c31af7Sopenharmony_ci * [[VUID-VkDeviceGroupBindSparseInfo-resourceDeviceIndex-01118]] 1804e5c31af7Sopenharmony_ci pname:resourceDeviceIndex and pname:memoryDeviceIndex must: both be 1805e5c31af7Sopenharmony_ci valid device indices 1806e5c31af7Sopenharmony_ci * [[VUID-VkDeviceGroupBindSparseInfo-memoryDeviceIndex-01119]] 1807e5c31af7Sopenharmony_ci Each memory allocation bound in this batch must: have allocated an 1808e5c31af7Sopenharmony_ci instance for pname:memoryDeviceIndex 1809e5c31af7Sopenharmony_ci**** 1810e5c31af7Sopenharmony_ci 1811e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkDeviceGroupBindSparseInfo.txt[] 1812e5c31af7Sopenharmony_ci-- 1813e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_device_group[] 1814