1e5c31af7Sopenharmony_ci// Copyright 2015-2021 The Khronos Group, Inc. 2e5c31af7Sopenharmony_ci// 3e5c31af7Sopenharmony_ci// SPDX-License-Identifier: CC-BY-4.0 4e5c31af7Sopenharmony_ci 5e5c31af7Sopenharmony_ci[[memory]] 6e5c31af7Sopenharmony_ci= Memory Allocation 7e5c31af7Sopenharmony_ci 8e5c31af7Sopenharmony_ciVulkan memory is broken up into two categories, _host memory_ and _device 9e5c31af7Sopenharmony_cimemory_. 10e5c31af7Sopenharmony_ci 11e5c31af7Sopenharmony_ci 12e5c31af7Sopenharmony_ci[[memory-host]] 13e5c31af7Sopenharmony_ci== Host Memory 14e5c31af7Sopenharmony_ci 15e5c31af7Sopenharmony_ciHost memory is memory needed by the Vulkan implementation for 16e5c31af7Sopenharmony_cinon-device-visible storage. 17e5c31af7Sopenharmony_ci 18e5c31af7Sopenharmony_ci[NOTE] 19e5c31af7Sopenharmony_ci.Note 20e5c31af7Sopenharmony_ci==== 21e5c31af7Sopenharmony_ciThis memory may: be used to store the implementation's representation and 22e5c31af7Sopenharmony_cistate of Vulkan objects. 23e5c31af7Sopenharmony_ci==== 24e5c31af7Sopenharmony_ci 25e5c31af7Sopenharmony_ci[[memory-allocation]] 26e5c31af7Sopenharmony_ciVulkan provides applications the opportunity to perform host memory 27e5c31af7Sopenharmony_ciallocations on behalf of the Vulkan implementation. 28e5c31af7Sopenharmony_ciIf this feature is not used, the implementation will perform its own memory 29e5c31af7Sopenharmony_ciallocations. 30e5c31af7Sopenharmony_ciSince most memory allocations are off the critical path, this is not meant 31e5c31af7Sopenharmony_cias a performance feature. 32e5c31af7Sopenharmony_ciRather, this can: be useful for certain embedded systems, for debugging 33e5c31af7Sopenharmony_cipurposes (e.g. putting a guard page after all host allocations), or for 34e5c31af7Sopenharmony_cimemory allocation logging. 35e5c31af7Sopenharmony_ci 36e5c31af7Sopenharmony_ci[open,refpage='VkAllocationCallbacks',desc='Structure containing callback function pointers for memory allocation',type='structs'] 37e5c31af7Sopenharmony_ci-- 38e5c31af7Sopenharmony_ciAllocators are provided by the application as a pointer to a 39e5c31af7Sopenharmony_cisname:VkAllocationCallbacks structure: 40e5c31af7Sopenharmony_ci 41e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkAllocationCallbacks.txt[] 42e5c31af7Sopenharmony_ci 43e5c31af7Sopenharmony_ci * pname:pUserData is a value to be interpreted by the implementation of 44e5c31af7Sopenharmony_ci the callbacks. 45e5c31af7Sopenharmony_ci When any of the callbacks in sname:VkAllocationCallbacks are called, the 46e5c31af7Sopenharmony_ci Vulkan implementation will pass this value as the first parameter to the 47e5c31af7Sopenharmony_ci callback. 48e5c31af7Sopenharmony_ci This value can: vary each time an allocator is passed into a command, 49e5c31af7Sopenharmony_ci even when the same object takes an allocator in multiple commands. 50e5c31af7Sopenharmony_ci * pname:pfnAllocation is a tlink:PFN_vkAllocationFunction pointer to an 51e5c31af7Sopenharmony_ci application-defined memory allocation function. 52e5c31af7Sopenharmony_ci * pname:pfnReallocation is a tlink:PFN_vkReallocationFunction pointer to 53e5c31af7Sopenharmony_ci an application-defined memory reallocation function. 54e5c31af7Sopenharmony_ci * pname:pfnFree is a tlink:PFN_vkFreeFunction pointer to an 55e5c31af7Sopenharmony_ci application-defined memory free function. 56e5c31af7Sopenharmony_ci * pname:pfnInternalAllocation is a 57e5c31af7Sopenharmony_ci tlink:PFN_vkInternalAllocationNotification pointer to an 58e5c31af7Sopenharmony_ci application-defined function that is called by the implementation when 59e5c31af7Sopenharmony_ci the implementation makes internal allocations. 60e5c31af7Sopenharmony_ci * pname:pfnInternalFree is a tlink:PFN_vkInternalFreeNotification pointer 61e5c31af7Sopenharmony_ci to an application-defined function that is called by the implementation 62e5c31af7Sopenharmony_ci when the implementation frees internal allocations. 63e5c31af7Sopenharmony_ci 64e5c31af7Sopenharmony_ci.Valid Usage 65e5c31af7Sopenharmony_ci**** 66e5c31af7Sopenharmony_ci * [[VUID-VkAllocationCallbacks-pfnAllocation-00632]] 67e5c31af7Sopenharmony_ci pname:pfnAllocation must: be a valid pointer to a valid user-defined 68e5c31af7Sopenharmony_ci tlink:PFN_vkAllocationFunction 69e5c31af7Sopenharmony_ci * [[VUID-VkAllocationCallbacks-pfnReallocation-00633]] 70e5c31af7Sopenharmony_ci pname:pfnReallocation must: be a valid pointer to a valid user-defined 71e5c31af7Sopenharmony_ci tlink:PFN_vkReallocationFunction 72e5c31af7Sopenharmony_ci * [[VUID-VkAllocationCallbacks-pfnFree-00634]] 73e5c31af7Sopenharmony_ci pname:pfnFree must: be a valid pointer to a valid user-defined 74e5c31af7Sopenharmony_ci tlink:PFN_vkFreeFunction 75e5c31af7Sopenharmony_ci * [[VUID-VkAllocationCallbacks-pfnInternalAllocation-00635]] 76e5c31af7Sopenharmony_ci If either of pname:pfnInternalAllocation or pname:pfnInternalFree is not 77e5c31af7Sopenharmony_ci `NULL`, both must: be valid callbacks 78e5c31af7Sopenharmony_ci**** 79e5c31af7Sopenharmony_ci 80e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkAllocationCallbacks.txt[] 81e5c31af7Sopenharmony_ci-- 82e5c31af7Sopenharmony_ci 83e5c31af7Sopenharmony_ci[open,refpage='PFN_vkAllocationFunction',desc='Application-defined memory allocation function',type='funcpointers',xrefs='VkAllocationCallbacks'] 84e5c31af7Sopenharmony_ci-- 85e5c31af7Sopenharmony_ciThe type of pname:pfnAllocation is: 86e5c31af7Sopenharmony_ci 87e5c31af7Sopenharmony_ciinclude::{generated}/api/funcpointers/PFN_vkAllocationFunction.txt[] 88e5c31af7Sopenharmony_ci 89e5c31af7Sopenharmony_ci * pname:pUserData is the value specified for 90e5c31af7Sopenharmony_ci slink:VkAllocationCallbacks::pname:pUserData in the allocator specified 91e5c31af7Sopenharmony_ci by the application. 92e5c31af7Sopenharmony_ci * pname:size is the size in bytes of the requested allocation. 93e5c31af7Sopenharmony_ci * pname:alignment is the requested alignment of the allocation in bytes 94e5c31af7Sopenharmony_ci and must: be a power of two. 95e5c31af7Sopenharmony_ci * pname:allocationScope is a elink:VkSystemAllocationScope value 96e5c31af7Sopenharmony_ci specifying the allocation scope of the lifetime of the allocation, as 97e5c31af7Sopenharmony_ci described <<memory-host-allocation-scope,here>>. 98e5c31af7Sopenharmony_ci 99e5c31af7Sopenharmony_ci[[vkAllocationFunction_return_rules]] 100e5c31af7Sopenharmony_ciIf pname:pfnAllocation is unable to allocate the requested memory, it must: 101e5c31af7Sopenharmony_cireturn `NULL`. 102e5c31af7Sopenharmony_ciIf the allocation was successful, it must: return a valid pointer to memory 103e5c31af7Sopenharmony_ciallocation containing at least pname:size bytes, and with the pointer value 104e5c31af7Sopenharmony_cibeing a multiple of pname:alignment. 105e5c31af7Sopenharmony_ci 106e5c31af7Sopenharmony_ci[NOTE] 107e5c31af7Sopenharmony_ci.Note 108e5c31af7Sopenharmony_ci==== 109e5c31af7Sopenharmony_ciCorrect Vulkan operation cannot: be assumed if the application does not 110e5c31af7Sopenharmony_cifollow these rules. 111e5c31af7Sopenharmony_ci 112e5c31af7Sopenharmony_ciFor example, pname:pfnAllocation (or pname:pfnReallocation) could cause 113e5c31af7Sopenharmony_citermination of running Vulkan instance(s) on a failed allocation for 114e5c31af7Sopenharmony_cidebugging purposes, either directly or indirectly. 115e5c31af7Sopenharmony_ciIn these circumstances, it cannot: be assumed that any part of any affected 116e5c31af7Sopenharmony_cislink:VkInstance objects are going to operate correctly (even 117e5c31af7Sopenharmony_ciflink:vkDestroyInstance), and the application must: ensure it cleans up 118e5c31af7Sopenharmony_ciproperly via other means (e.g. process termination). 119e5c31af7Sopenharmony_ci==== 120e5c31af7Sopenharmony_ci 121e5c31af7Sopenharmony_ciIf pname:pfnAllocation returns `NULL`, and if the implementation is unable 122e5c31af7Sopenharmony_cito continue correct processing of the current command without the requested 123e5c31af7Sopenharmony_ciallocation, it must: treat this as a runtime error, and generate 124e5c31af7Sopenharmony_ciename:VK_ERROR_OUT_OF_HOST_MEMORY at the appropriate time for the command in 125e5c31af7Sopenharmony_ciwhich the condition was detected, as described in <<fundamentals-errorcodes, 126e5c31af7Sopenharmony_ciReturn Codes>>. 127e5c31af7Sopenharmony_ci 128e5c31af7Sopenharmony_ciIf the implementation is able to continue correct processing of the current 129e5c31af7Sopenharmony_cicommand without the requested allocation, then it may: do so, and must: not 130e5c31af7Sopenharmony_cigenerate ename:VK_ERROR_OUT_OF_HOST_MEMORY as a result of this failed 131e5c31af7Sopenharmony_ciallocation. 132e5c31af7Sopenharmony_ci-- 133e5c31af7Sopenharmony_ci 134e5c31af7Sopenharmony_ci[open,refpage='PFN_vkReallocationFunction',desc='Application-defined memory reallocation function',type='funcpointers',xrefs='VkAllocationCallbacks'] 135e5c31af7Sopenharmony_ci-- 136e5c31af7Sopenharmony_ciThe type of pname:pfnReallocation is: 137e5c31af7Sopenharmony_ci 138e5c31af7Sopenharmony_ciinclude::{generated}/api/funcpointers/PFN_vkReallocationFunction.txt[] 139e5c31af7Sopenharmony_ci 140e5c31af7Sopenharmony_ci * pname:pUserData is the value specified for 141e5c31af7Sopenharmony_ci slink:VkAllocationCallbacks::pname:pUserData in the allocator specified 142e5c31af7Sopenharmony_ci by the application. 143e5c31af7Sopenharmony_ci * pname:pOriginal must: be either `NULL` or a pointer previously returned 144e5c31af7Sopenharmony_ci by pname:pfnReallocation or pname:pfnAllocation of a compatible 145e5c31af7Sopenharmony_ci allocator. 146e5c31af7Sopenharmony_ci * pname:size is the size in bytes of the requested allocation. 147e5c31af7Sopenharmony_ci * pname:alignment is the requested alignment of the allocation in bytes 148e5c31af7Sopenharmony_ci and must: be a power of two. 149e5c31af7Sopenharmony_ci * pname:allocationScope is a elink:VkSystemAllocationScope value 150e5c31af7Sopenharmony_ci specifying the allocation scope of the lifetime of the allocation, as 151e5c31af7Sopenharmony_ci described <<memory-host-allocation-scope,here>>. 152e5c31af7Sopenharmony_ci 153e5c31af7Sopenharmony_cipname:pfnReallocation must: return an allocation with enough space for 154e5c31af7Sopenharmony_cipname:size bytes, and the contents of the original allocation from bytes 155e5c31af7Sopenharmony_cizero to [eq]#min(original size, new size) - 1# must: be preserved in the 156e5c31af7Sopenharmony_cireturned allocation. 157e5c31af7Sopenharmony_ciIf pname:size is larger than the old size, the contents of the additional 158e5c31af7Sopenharmony_cispace are undefined:. 159e5c31af7Sopenharmony_ciIf satisfying these requirements involves creating a new allocation, then 160e5c31af7Sopenharmony_cithe old allocation should: be freed. 161e5c31af7Sopenharmony_ci 162e5c31af7Sopenharmony_ciIf pname:pOriginal is `NULL`, then pname:pfnReallocation must: behave 163e5c31af7Sopenharmony_ciequivalently to a call to tlink:PFN_vkAllocationFunction with the same 164e5c31af7Sopenharmony_ciparameter values (without pname:pOriginal). 165e5c31af7Sopenharmony_ci 166e5c31af7Sopenharmony_ciIf pname:size is zero, then pname:pfnReallocation must: behave equivalently 167e5c31af7Sopenharmony_cito a call to tlink:PFN_vkFreeFunction with the same pname:pUserData 168e5c31af7Sopenharmony_ciparameter value, and pname:pMemory equal to pname:pOriginal. 169e5c31af7Sopenharmony_ci 170e5c31af7Sopenharmony_ciIf pname:pOriginal is non-`NULL`, the implementation must: ensure that 171e5c31af7Sopenharmony_cipname:alignment is equal to the pname:alignment used to originally allocate 172e5c31af7Sopenharmony_cipname:pOriginal. 173e5c31af7Sopenharmony_ci 174e5c31af7Sopenharmony_ciIf this function fails and pname:pOriginal is non-`NULL` the application 175e5c31af7Sopenharmony_cimust: not free the old allocation. 176e5c31af7Sopenharmony_ci 177e5c31af7Sopenharmony_cipname:pfnReallocation must: follow the same 178e5c31af7Sopenharmony_ci<<vkAllocationFunction_return_rules, rules for return values as 179e5c31af7Sopenharmony_citname:PFN_vkAllocationFunction>>. 180e5c31af7Sopenharmony_ci-- 181e5c31af7Sopenharmony_ci 182e5c31af7Sopenharmony_ci[open,refpage='PFN_vkFreeFunction',desc='Application-defined memory free function',type='funcpointers',xrefs='VkAllocationCallbacks'] 183e5c31af7Sopenharmony_ci-- 184e5c31af7Sopenharmony_ciThe type of pname:pfnFree is: 185e5c31af7Sopenharmony_ci 186e5c31af7Sopenharmony_ciinclude::{generated}/api/funcpointers/PFN_vkFreeFunction.txt[] 187e5c31af7Sopenharmony_ci 188e5c31af7Sopenharmony_ci * pname:pUserData is the value specified for 189e5c31af7Sopenharmony_ci slink:VkAllocationCallbacks::pname:pUserData in the allocator specified 190e5c31af7Sopenharmony_ci by the application. 191e5c31af7Sopenharmony_ci * pname:pMemory is the allocation to be freed. 192e5c31af7Sopenharmony_ci 193e5c31af7Sopenharmony_cipname:pMemory may: be `NULL`, which the callback must: handle safely. 194e5c31af7Sopenharmony_ciIf pname:pMemory is non-`NULL`, it must: be a pointer previously allocated 195e5c31af7Sopenharmony_ciby pname:pfnAllocation or pname:pfnReallocation. 196e5c31af7Sopenharmony_ciThe application should: free this memory. 197e5c31af7Sopenharmony_ci-- 198e5c31af7Sopenharmony_ci 199e5c31af7Sopenharmony_ci[open,refpage='PFN_vkInternalAllocationNotification',desc='Application-defined memory allocation notification function',type='funcpointers',xrefs='VkAllocationCallbacks'] 200e5c31af7Sopenharmony_ci-- 201e5c31af7Sopenharmony_ciThe type of pname:pfnInternalAllocation is: 202e5c31af7Sopenharmony_ci 203e5c31af7Sopenharmony_ciinclude::{generated}/api/funcpointers/PFN_vkInternalAllocationNotification.txt[] 204e5c31af7Sopenharmony_ci 205e5c31af7Sopenharmony_ci * pname:pUserData is the value specified for 206e5c31af7Sopenharmony_ci slink:VkAllocationCallbacks::pname:pUserData in the allocator specified 207e5c31af7Sopenharmony_ci by the application. 208e5c31af7Sopenharmony_ci * pname:size is the requested size of an allocation. 209e5c31af7Sopenharmony_ci * pname:allocationType is a elink:VkInternalAllocationType value 210e5c31af7Sopenharmony_ci specifying the requested type of an allocation. 211e5c31af7Sopenharmony_ci * pname:allocationScope is a elink:VkSystemAllocationScope value 212e5c31af7Sopenharmony_ci specifying the allocation scope of the lifetime of the allocation, as 213e5c31af7Sopenharmony_ci described <<memory-host-allocation-scope,here>>. 214e5c31af7Sopenharmony_ci 215e5c31af7Sopenharmony_ciThis is a purely informational callback. 216e5c31af7Sopenharmony_ci-- 217e5c31af7Sopenharmony_ci 218e5c31af7Sopenharmony_ci[open,refpage='PFN_vkInternalFreeNotification',desc='Application-defined memory free notification function',type='funcpointers',xrefs='VkAllocationCallbacks'] 219e5c31af7Sopenharmony_ci-- 220e5c31af7Sopenharmony_ciThe type of pname:pfnInternalFree is: 221e5c31af7Sopenharmony_ci 222e5c31af7Sopenharmony_ciinclude::{generated}/api/funcpointers/PFN_vkInternalFreeNotification.txt[] 223e5c31af7Sopenharmony_ci 224e5c31af7Sopenharmony_ci * pname:pUserData is the value specified for 225e5c31af7Sopenharmony_ci slink:VkAllocationCallbacks::pname:pUserData in the allocator specified 226e5c31af7Sopenharmony_ci by the application. 227e5c31af7Sopenharmony_ci * pname:size is the requested size of an allocation. 228e5c31af7Sopenharmony_ci * pname:allocationType is a elink:VkInternalAllocationType value 229e5c31af7Sopenharmony_ci specifying the requested type of an allocation. 230e5c31af7Sopenharmony_ci * pname:allocationScope is a elink:VkSystemAllocationScope value 231e5c31af7Sopenharmony_ci specifying the allocation scope of the lifetime of the allocation, as 232e5c31af7Sopenharmony_ci described <<memory-host-allocation-scope,here>>. 233e5c31af7Sopenharmony_ci-- 234e5c31af7Sopenharmony_ci 235e5c31af7Sopenharmony_ci[open,refpage='VkSystemAllocationScope',desc='Allocation scope',type='enums',xrefs='VkAllocationCallbacks'] 236e5c31af7Sopenharmony_ci-- 237e5c31af7Sopenharmony_ci[[memory-host-allocation-scope]] 238e5c31af7Sopenharmony_ciEach allocation has an _allocation scope_ defining its lifetime and which 239e5c31af7Sopenharmony_ciobject it is associated with. 240e5c31af7Sopenharmony_ciPossible values passed to the pname:allocationScope parameter of the 241e5c31af7Sopenharmony_cicallback functions specified by slink:VkAllocationCallbacks, indicating the 242e5c31af7Sopenharmony_ciallocation scope, are: 243e5c31af7Sopenharmony_ci 244e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkSystemAllocationScope.txt[] 245e5c31af7Sopenharmony_ci 246e5c31af7Sopenharmony_ci * ename:VK_SYSTEM_ALLOCATION_SCOPE_COMMAND specifies that the allocation 247e5c31af7Sopenharmony_ci is scoped to the duration of the Vulkan command. 248e5c31af7Sopenharmony_ci * ename:VK_SYSTEM_ALLOCATION_SCOPE_OBJECT specifies that the allocation is 249e5c31af7Sopenharmony_ci scoped to the lifetime of the Vulkan object that is being created or 250e5c31af7Sopenharmony_ci used. 251e5c31af7Sopenharmony_ci * ename:VK_SYSTEM_ALLOCATION_SCOPE_CACHE specifies that the allocation is 252e5c31af7Sopenharmony_ci scoped to the lifetime of a sname:VkPipelineCache 253e5c31af7Sopenharmony_ciifdef::VK_EXT_validation_cache[] 254e5c31af7Sopenharmony_ci or sname:VkValidationCacheEXT 255e5c31af7Sopenharmony_ciendif::VK_EXT_validation_cache[] 256e5c31af7Sopenharmony_ci object. 257e5c31af7Sopenharmony_ci * ename:VK_SYSTEM_ALLOCATION_SCOPE_DEVICE specifies that the allocation is 258e5c31af7Sopenharmony_ci scoped to the lifetime of the Vulkan device. 259e5c31af7Sopenharmony_ci * ename:VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE specifies that the allocation 260e5c31af7Sopenharmony_ci is scoped to the lifetime of the Vulkan instance. 261e5c31af7Sopenharmony_ci 262e5c31af7Sopenharmony_ciMost Vulkan commands operate on a single object, or there is a sole object 263e5c31af7Sopenharmony_cithat is being created or manipulated. 264e5c31af7Sopenharmony_ciWhen an allocation uses an allocation scope of 265e5c31af7Sopenharmony_ciename:VK_SYSTEM_ALLOCATION_SCOPE_OBJECT or 266e5c31af7Sopenharmony_ciename:VK_SYSTEM_ALLOCATION_SCOPE_CACHE, the allocation is scoped to the 267e5c31af7Sopenharmony_ciobject being created or manipulated. 268e5c31af7Sopenharmony_ci 269e5c31af7Sopenharmony_ciWhen an implementation requires host memory, it will make callbacks to the 270e5c31af7Sopenharmony_ciapplication using the most specific allocator and allocation scope 271e5c31af7Sopenharmony_ciavailable: 272e5c31af7Sopenharmony_ci 273e5c31af7Sopenharmony_ci * If an allocation is scoped to the duration of a command, the allocator 274e5c31af7Sopenharmony_ci will use the ename:VK_SYSTEM_ALLOCATION_SCOPE_COMMAND allocation scope. 275e5c31af7Sopenharmony_ci The most specific allocator available is used: if the object being 276e5c31af7Sopenharmony_ci created or manipulated has an allocator, that object's allocator will be 277e5c31af7Sopenharmony_ci used, else if the parent sname:VkDevice has an allocator it will be 278e5c31af7Sopenharmony_ci used, else if the parent sname:VkInstance has an allocator it will be 279e5c31af7Sopenharmony_ci used. 280e5c31af7Sopenharmony_ci Else, 281e5c31af7Sopenharmony_ci * If an allocation is associated with a 282e5c31af7Sopenharmony_ciifdef::VK_EXT_validation_cache[] 283e5c31af7Sopenharmony_ci sname:VkValidationCacheEXT or 284e5c31af7Sopenharmony_ciendif::VK_EXT_validation_cache[] 285e5c31af7Sopenharmony_ci sname:VkPipelineCache object, the allocator will use the 286e5c31af7Sopenharmony_ci ename:VK_SYSTEM_ALLOCATION_SCOPE_CACHE allocation scope. 287e5c31af7Sopenharmony_ci The most specific allocator available is used (cache, else device, else 288e5c31af7Sopenharmony_ci instance). 289e5c31af7Sopenharmony_ci Else, 290e5c31af7Sopenharmony_ci * If an allocation is scoped to the lifetime of an object, that object is 291e5c31af7Sopenharmony_ci being created or manipulated by the command, and that object's type is 292e5c31af7Sopenharmony_ci not sname:VkDevice or sname:VkInstance, the allocator will use an 293e5c31af7Sopenharmony_ci allocation scope of ename:VK_SYSTEM_ALLOCATION_SCOPE_OBJECT. 294e5c31af7Sopenharmony_ci The most specific allocator available is used (object, else device, else 295e5c31af7Sopenharmony_ci instance). 296e5c31af7Sopenharmony_ci Else, 297e5c31af7Sopenharmony_ci * If an allocation is scoped to the lifetime of a device, the allocator 298e5c31af7Sopenharmony_ci will use an allocation scope of ename:VK_SYSTEM_ALLOCATION_SCOPE_DEVICE. 299e5c31af7Sopenharmony_ci The most specific allocator available is used (device, else instance). 300e5c31af7Sopenharmony_ci Else, 301e5c31af7Sopenharmony_ci * If the allocation is scoped to the lifetime of an instance and the 302e5c31af7Sopenharmony_ci instance has an allocator, its allocator will be used with an allocation 303e5c31af7Sopenharmony_ci scope of ename:VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE. 304e5c31af7Sopenharmony_ci * Otherwise an implementation will allocate memory through an alternative 305e5c31af7Sopenharmony_ci mechanism that is unspecified. 306e5c31af7Sopenharmony_ci 307e5c31af7Sopenharmony_ci-- 308e5c31af7Sopenharmony_ci 309e5c31af7Sopenharmony_ciObjects that are allocated from pools do not specify their own allocator. 310e5c31af7Sopenharmony_ciWhen an implementation requires host memory for such an object, that memory 311e5c31af7Sopenharmony_ciis sourced from the object's parent pool's allocator. 312e5c31af7Sopenharmony_ci 313e5c31af7Sopenharmony_ciThe application is not expected to handle allocating memory that is intended 314e5c31af7Sopenharmony_cifor execution by the host due to the complexities of differing security 315e5c31af7Sopenharmony_ciimplementations across multiple platforms. 316e5c31af7Sopenharmony_ciThe implementation will allocate such memory internally and invoke an 317e5c31af7Sopenharmony_ciapplication provided informational callback when these _internal 318e5c31af7Sopenharmony_ciallocations_ are allocated and freed. 319e5c31af7Sopenharmony_ciUpon allocation of executable memory, pname:pfnInternalAllocation will be 320e5c31af7Sopenharmony_cicalled. 321e5c31af7Sopenharmony_ciUpon freeing executable memory, pname:pfnInternalFree will be called. 322e5c31af7Sopenharmony_ciAn implementation will only call an informational callback for executable 323e5c31af7Sopenharmony_cimemory allocations and frees. 324e5c31af7Sopenharmony_ci 325e5c31af7Sopenharmony_ci[open,refpage='VkInternalAllocationType',desc='Allocation type',type='enums',xrefs='PFN_vkInternalAllocationNotification PFN_vkInternalFreeNotification'] 326e5c31af7Sopenharmony_ci-- 327e5c31af7Sopenharmony_ciThe pname:allocationType parameter to the pname:pfnInternalAllocation and 328e5c31af7Sopenharmony_cipname:pfnInternalFree functions may: be one of the following values: 329e5c31af7Sopenharmony_ci 330e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkInternalAllocationType.txt[] 331e5c31af7Sopenharmony_ci 332e5c31af7Sopenharmony_ci * ename:VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE specifies that the 333e5c31af7Sopenharmony_ci allocation is intended for execution by the host. 334e5c31af7Sopenharmony_ci-- 335e5c31af7Sopenharmony_ci 336e5c31af7Sopenharmony_ciAn implementation must: only make calls into an application-provided 337e5c31af7Sopenharmony_ciallocator during the execution of an API command. 338e5c31af7Sopenharmony_ciAn implementation must: only make calls into an application-provided 339e5c31af7Sopenharmony_ciallocator from the same thread that called the provoking API command. 340e5c31af7Sopenharmony_ciThe implementation should: not synchronize calls to any of the callbacks. 341e5c31af7Sopenharmony_ciIf synchronization is needed, the callbacks must: provide it themselves. 342e5c31af7Sopenharmony_ciThe informational callbacks are subject to the same restrictions as the 343e5c31af7Sopenharmony_ciallocation callbacks. 344e5c31af7Sopenharmony_ci 345e5c31af7Sopenharmony_ciIf an implementation intends to make calls through a 346e5c31af7Sopenharmony_cisname:VkAllocationCallbacks structure between the time a ftext:vkCreate* 347e5c31af7Sopenharmony_cicommand returns and the time a corresponding ftext:vkDestroy* command 348e5c31af7Sopenharmony_cibegins, that implementation must: save a copy of the allocator before the 349e5c31af7Sopenharmony_ciftext:vkCreate* command returns. 350e5c31af7Sopenharmony_ciThe callback functions and any data structures they rely upon must: remain 351e5c31af7Sopenharmony_civalid for the lifetime of the object they are associated with. 352e5c31af7Sopenharmony_ci 353e5c31af7Sopenharmony_ciIf an allocator is provided to a ftext:vkCreate* command, a _compatible_ 354e5c31af7Sopenharmony_ciallocator must: be provided to the corresponding ftext:vkDestroy* command. 355e5c31af7Sopenharmony_ciTwo sname:VkAllocationCallbacks structures are compatible if memory 356e5c31af7Sopenharmony_ciallocated with pname:pfnAllocation or pname:pfnReallocation in each can: be 357e5c31af7Sopenharmony_cifreed with pname:pfnReallocation or pname:pfnFree in the other. 358e5c31af7Sopenharmony_ciAn allocator must: not be provided to a ftext:vkDestroy* command if an 359e5c31af7Sopenharmony_ciallocator was not provided to the corresponding ftext:vkCreate* command. 360e5c31af7Sopenharmony_ci 361e5c31af7Sopenharmony_ciIf a non-`NULL` allocator is used, the pname:pfnAllocation, 362e5c31af7Sopenharmony_cipname:pfnReallocation and pname:pfnFree members must: be non-`NULL` and 363e5c31af7Sopenharmony_cipoint to valid implementations of the callbacks. 364e5c31af7Sopenharmony_ciAn application can: choose to not provide informational callbacks by setting 365e5c31af7Sopenharmony_ciboth pname:pfnInternalAllocation and pname:pfnInternalFree to `NULL`. 366e5c31af7Sopenharmony_cipname:pfnInternalAllocation and pname:pfnInternalFree must: either both be 367e5c31af7Sopenharmony_ci`NULL` or both be non-`NULL`. 368e5c31af7Sopenharmony_ci 369e5c31af7Sopenharmony_ciIf pname:pfnAllocation or pname:pfnReallocation fail, the implementation 370e5c31af7Sopenharmony_cimay: fail object creation and/or generate a 371e5c31af7Sopenharmony_ciename:VK_ERROR_OUT_OF_HOST_MEMORY error, as appropriate. 372e5c31af7Sopenharmony_ci 373e5c31af7Sopenharmony_ciAllocation callbacks must: not call any Vulkan commands. 374e5c31af7Sopenharmony_ci 375e5c31af7Sopenharmony_ciThe following sets of rules define when an implementation is permitted to 376e5c31af7Sopenharmony_cicall the allocator callbacks. 377e5c31af7Sopenharmony_ci 378e5c31af7Sopenharmony_cipname:pfnAllocation or pname:pfnReallocation may: be called in the following 379e5c31af7Sopenharmony_cisituations: 380e5c31af7Sopenharmony_ci 381e5c31af7Sopenharmony_ci * Allocations scoped to a sname:VkDevice or sname:VkInstance may: be 382e5c31af7Sopenharmony_ci allocated from any API command. 383e5c31af7Sopenharmony_ci * Allocations scoped to a command may: be allocated from any API command. 384e5c31af7Sopenharmony_ci * Allocations scoped to a sname:VkPipelineCache may: only be allocated 385e5c31af7Sopenharmony_ci from: 386e5c31af7Sopenharmony_ci ** fname:vkCreatePipelineCache 387e5c31af7Sopenharmony_ci ** fname:vkMergePipelineCaches for pname:dstCache 388e5c31af7Sopenharmony_ci ** fname:vkCreateGraphicsPipelines for pname:pipelineCache 389e5c31af7Sopenharmony_ci ** fname:vkCreateComputePipelines for pname:pipelineCache 390e5c31af7Sopenharmony_ciifdef::VK_EXT_validation_cache[] 391e5c31af7Sopenharmony_ci * Allocations scoped to a sname:VkValidationCacheEXT may: only be 392e5c31af7Sopenharmony_ci allocated from: 393e5c31af7Sopenharmony_ci ** fname:vkCreateValidationCacheEXT 394e5c31af7Sopenharmony_ci ** fname:vkMergeValidationCachesEXT for pname:dstCache 395e5c31af7Sopenharmony_ci ** fname:vkCreateShaderModule for pname:validationCache in 396e5c31af7Sopenharmony_ci slink:VkShaderModuleValidationCacheCreateInfoEXT 397e5c31af7Sopenharmony_ciendif::VK_EXT_validation_cache[] 398e5c31af7Sopenharmony_ci * Allocations scoped to a sname:VkDescriptorPool may: only be allocated 399e5c31af7Sopenharmony_ci from: 400e5c31af7Sopenharmony_ci ** any command that takes the pool as a direct argument 401e5c31af7Sopenharmony_ci ** fname:vkAllocateDescriptorSets for the pname:descriptorPool member of 402e5c31af7Sopenharmony_ci its pname:pAllocateInfo parameter 403e5c31af7Sopenharmony_ci ** fname:vkCreateDescriptorPool 404e5c31af7Sopenharmony_ci * Allocations scoped to a sname:VkCommandPool may: only be allocated from: 405e5c31af7Sopenharmony_ci ** any command that takes the pool as a direct argument 406e5c31af7Sopenharmony_ci ** fname:vkCreateCommandPool 407e5c31af7Sopenharmony_ci ** fname:vkAllocateCommandBuffers for the pname:commandPool member of its 408e5c31af7Sopenharmony_ci pname:pAllocateInfo parameter 409e5c31af7Sopenharmony_ci ** any ftext:vkCmd* command whose pname:commandBuffer was allocated from 410e5c31af7Sopenharmony_ci that sname:VkCommandPool 411e5c31af7Sopenharmony_ci * Allocations scoped to any other object may: only be allocated in that 412e5c31af7Sopenharmony_ci object's ftext:vkCreate* command. 413e5c31af7Sopenharmony_ci 414e5c31af7Sopenharmony_cipname:pfnFree, or pname:pfnReallocation with zero pname:size, may: be called 415e5c31af7Sopenharmony_ciin the following situations: 416e5c31af7Sopenharmony_ci 417e5c31af7Sopenharmony_ci * Allocations scoped to a sname:VkDevice or sname:VkInstance may: be freed 418e5c31af7Sopenharmony_ci from any API command. 419e5c31af7Sopenharmony_ci * Allocations scoped to a command must: be freed by any API command which 420e5c31af7Sopenharmony_ci allocates such memory. 421e5c31af7Sopenharmony_ci * Allocations scoped to a sname:VkPipelineCache may: be freed from 422e5c31af7Sopenharmony_ci fname:vkDestroyPipelineCache. 423e5c31af7Sopenharmony_ciifdef::VK_EXT_validation_cache[] 424e5c31af7Sopenharmony_ci * Allocations scoped to a sname:VkValidationCacheEXT may: be freed from 425e5c31af7Sopenharmony_ci fname:vkDestroyValidationCacheEXT. 426e5c31af7Sopenharmony_ciendif::VK_EXT_validation_cache[] 427e5c31af7Sopenharmony_ci * Allocations scoped to a sname:VkDescriptorPool may: be freed from 428e5c31af7Sopenharmony_ci ** any command that takes the pool as a direct argument 429e5c31af7Sopenharmony_ci * Allocations scoped to a sname:VkCommandPool may: be freed from: 430e5c31af7Sopenharmony_ci ** any command that takes the pool as a direct argument 431e5c31af7Sopenharmony_ci ** fname:vkResetCommandBuffer whose pname:commandBuffer was allocated from 432e5c31af7Sopenharmony_ci that sname:VkCommandPool 433e5c31af7Sopenharmony_ci * Allocations scoped to any other object may: be freed in that object's 434e5c31af7Sopenharmony_ci ftext:vkDestroy* command. 435e5c31af7Sopenharmony_ci * Any command that allocates host memory may: also free host memory of the 436e5c31af7Sopenharmony_ci same scope. 437e5c31af7Sopenharmony_ci 438e5c31af7Sopenharmony_ci 439e5c31af7Sopenharmony_ci[[memory-device]] 440e5c31af7Sopenharmony_ci== Device Memory 441e5c31af7Sopenharmony_ci 442e5c31af7Sopenharmony_ci_Device memory_ is memory that is visible to the device -- for example the 443e5c31af7Sopenharmony_cicontents of the image or buffer objects, which can: be natively used by the 444e5c31af7Sopenharmony_cidevice. 445e5c31af7Sopenharmony_ci 446e5c31af7Sopenharmony_ci[[memory-device-properties]] 447e5c31af7Sopenharmony_ci=== Device Memory Properties 448e5c31af7Sopenharmony_ci 449e5c31af7Sopenharmony_ciMemory properties of a physical device describe the memory heaps and memory 450e5c31af7Sopenharmony_citypes available. 451e5c31af7Sopenharmony_ci 452e5c31af7Sopenharmony_ci[open,refpage='vkGetPhysicalDeviceMemoryProperties',desc='Reports memory information for the specified physical device',type='protos'] 453e5c31af7Sopenharmony_ci-- 454e5c31af7Sopenharmony_ciTo query memory properties, call: 455e5c31af7Sopenharmony_ci 456e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetPhysicalDeviceMemoryProperties.txt[] 457e5c31af7Sopenharmony_ci 458e5c31af7Sopenharmony_ci * pname:physicalDevice is the handle to the device to query. 459e5c31af7Sopenharmony_ci * pname:pMemoryProperties is a pointer to a 460e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceMemoryProperties structure in which the properties 461e5c31af7Sopenharmony_ci are returned. 462e5c31af7Sopenharmony_ci 463e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetPhysicalDeviceMemoryProperties.txt[] 464e5c31af7Sopenharmony_ci-- 465e5c31af7Sopenharmony_ci 466e5c31af7Sopenharmony_ci[open,refpage='VkPhysicalDeviceMemoryProperties',desc='Structure specifying physical device memory properties',type='structs'] 467e5c31af7Sopenharmony_ci-- 468e5c31af7Sopenharmony_ciThe sname:VkPhysicalDeviceMemoryProperties structure is defined as: 469e5c31af7Sopenharmony_ci 470e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPhysicalDeviceMemoryProperties.txt[] 471e5c31af7Sopenharmony_ci 472e5c31af7Sopenharmony_ci * pname:memoryTypeCount is the number of valid elements in the 473e5c31af7Sopenharmony_ci pname:memoryTypes array. 474e5c31af7Sopenharmony_ci * pname:memoryTypes is an array of ename:VK_MAX_MEMORY_TYPES 475e5c31af7Sopenharmony_ci slink:VkMemoryType structures describing the _memory types_ that can: be 476e5c31af7Sopenharmony_ci used to access memory allocated from the heaps specified by 477e5c31af7Sopenharmony_ci pname:memoryHeaps. 478e5c31af7Sopenharmony_ci * pname:memoryHeapCount is the number of valid elements in the 479e5c31af7Sopenharmony_ci pname:memoryHeaps array. 480e5c31af7Sopenharmony_ci * pname:memoryHeaps is an array of ename:VK_MAX_MEMORY_HEAPS 481e5c31af7Sopenharmony_ci slink:VkMemoryHeap structures describing the _memory heaps_ from which 482e5c31af7Sopenharmony_ci memory can: be allocated. 483e5c31af7Sopenharmony_ci 484e5c31af7Sopenharmony_ciThe sname:VkPhysicalDeviceMemoryProperties structure describes a number of 485e5c31af7Sopenharmony_ci_memory heaps_ as well as a number of _memory types_ that can: be used to 486e5c31af7Sopenharmony_ciaccess memory allocated in those heaps. 487e5c31af7Sopenharmony_ciEach heap describes a memory resource of a particular size, and each memory 488e5c31af7Sopenharmony_citype describes a set of memory properties (e.g. host cached vs uncached) 489e5c31af7Sopenharmony_cithat can: be used with a given memory heap. 490e5c31af7Sopenharmony_ciAllocations using a particular memory type will consume resources from the 491e5c31af7Sopenharmony_ciheap indicated by that memory type's heap index. 492e5c31af7Sopenharmony_ciMore than one memory type may: share each heap, and the heaps and memory 493e5c31af7Sopenharmony_citypes provide a mechanism to advertise an accurate size of the physical 494e5c31af7Sopenharmony_cimemory resources while allowing the memory to be used with a variety of 495e5c31af7Sopenharmony_cidifferent properties. 496e5c31af7Sopenharmony_ci 497e5c31af7Sopenharmony_ciThe number of memory heaps is given by pname:memoryHeapCount and is less 498e5c31af7Sopenharmony_cithan or equal to ename:VK_MAX_MEMORY_HEAPS. 499e5c31af7Sopenharmony_ciEach heap is described by an element of the pname:memoryHeaps array as a 500e5c31af7Sopenharmony_cislink:VkMemoryHeap structure. 501e5c31af7Sopenharmony_ciThe number of memory types available across all memory heaps is given by 502e5c31af7Sopenharmony_cipname:memoryTypeCount and is less than or equal to 503e5c31af7Sopenharmony_ciename:VK_MAX_MEMORY_TYPES. 504e5c31af7Sopenharmony_ciEach memory type is described by an element of the pname:memoryTypes array 505e5c31af7Sopenharmony_cias a slink:VkMemoryType structure. 506e5c31af7Sopenharmony_ci 507e5c31af7Sopenharmony_ciAt least one heap must: include ename:VK_MEMORY_HEAP_DEVICE_LOCAL_BIT in 508e5c31af7Sopenharmony_cislink:VkMemoryHeap::pname:flags. 509e5c31af7Sopenharmony_ciIf there are multiple heaps that all have similar performance 510e5c31af7Sopenharmony_cicharacteristics, they may: all include 511e5c31af7Sopenharmony_ciename:VK_MEMORY_HEAP_DEVICE_LOCAL_BIT. 512e5c31af7Sopenharmony_ciIn a unified memory architecture (UMA) system there is often only a single 513e5c31af7Sopenharmony_cimemory heap which is considered to be equally "`local`" to the host and to 514e5c31af7Sopenharmony_cithe device, and such an implementation must: advertise the heap as 515e5c31af7Sopenharmony_cidevice-local. 516e5c31af7Sopenharmony_ci 517e5c31af7Sopenharmony_ci[[memory-device-bitmask-list]] 518e5c31af7Sopenharmony_ciEach memory type returned by flink:vkGetPhysicalDeviceMemoryProperties must: 519e5c31af7Sopenharmony_cihave its pname:propertyFlags set to one of the following values: 520e5c31af7Sopenharmony_ci 521e5c31af7Sopenharmony_ci * 0 522e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + 523e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT 524e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + 525e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_CACHED_BIT 526e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + 527e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_CACHED_BIT | + 528e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT 529e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT 530e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | + 531e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + 532e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT 533e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | + 534e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + 535e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_CACHED_BIT 536e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | + 537e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + 538e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_CACHED_BIT | + 539e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT 540e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | + 541e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT 542e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[] 543e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_PROTECTED_BIT 544e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_PROTECTED_BIT | 545e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT 546e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[] 547e5c31af7Sopenharmony_ciifdef::VK_AMD_device_coherent_memory[] 548e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + 549e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | + 550e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD 551e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + 552e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_CACHED_BIT | + 553e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | + 554e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD 555e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | + 556e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD 557e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | + 558e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + 559e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | + 560e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD 561e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | + 562e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + 563e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_CACHED_BIT | + 564e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | + 565e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD 566e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + 567e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | + 568e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD | + 569e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD 570e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + 571e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_CACHED_BIT | + 572e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | + 573e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD | + 574e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD 575e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | + 576e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD | + 577e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD 578e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | + 579e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + 580e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | + 581e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD | + 582e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD 583e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | + 584e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + 585e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_CACHED_BIT | + 586e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | + 587e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD | + 588e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD 589e5c31af7Sopenharmony_ciendif::VK_AMD_device_coherent_memory[] 590e5c31af7Sopenharmony_ciifdef::VK_NV_external_memory_rdma[] 591e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | + 592e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_RDMA_CAPABLE_BIT_NV 593e5c31af7Sopenharmony_ciendif::VK_NV_external_memory_rdma[] 594e5c31af7Sopenharmony_ci 595e5c31af7Sopenharmony_ciThere must: be at least one memory type with both the 596e5c31af7Sopenharmony_ciename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT and 597e5c31af7Sopenharmony_ciename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT bits set in its 598e5c31af7Sopenharmony_cipname:propertyFlags. 599e5c31af7Sopenharmony_ciThere must: be at least one memory type with the 600e5c31af7Sopenharmony_ciename:VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT bit set in its 601e5c31af7Sopenharmony_cipname:propertyFlags. 602e5c31af7Sopenharmony_ciifdef::VK_AMD_device_coherent_memory[] 603e5c31af7Sopenharmony_ciIf the <<features-deviceCoherentMemory, pname:deviceCoherentMemory>> feature 604e5c31af7Sopenharmony_ciis enabled, there must: be at least one memory type with the 605e5c31af7Sopenharmony_ciename:VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD bit set in its 606e5c31af7Sopenharmony_cipname:propertyFlags. 607e5c31af7Sopenharmony_ciendif::VK_AMD_device_coherent_memory[] 608e5c31af7Sopenharmony_ci 609e5c31af7Sopenharmony_ciFor each pair of elements *X* and *Y* returned in pname:memoryTypes, *X* 610e5c31af7Sopenharmony_cimust: be placed at a lower index position than *Y* if: 611e5c31af7Sopenharmony_ci 612e5c31af7Sopenharmony_ci * the set of bit flags returned in the pname:propertyFlags member of *X* 613e5c31af7Sopenharmony_ci is a strict subset of the set of bit flags returned in the 614e5c31af7Sopenharmony_ci pname:propertyFlags member of *Y*; or 615e5c31af7Sopenharmony_ci * the pname:propertyFlags members of *X* and *Y* are equal, and *X* 616e5c31af7Sopenharmony_ci belongs to a memory heap with greater performance (as determined in an 617e5c31af7Sopenharmony_ci implementation-specific manner) 618e5c31af7Sopenharmony_ciifdef::VK_AMD_device_coherent_memory[] 619e5c31af7Sopenharmony_ci ; or 620e5c31af7Sopenharmony_ci * the pname:propertyFlags members of *Y* includes 621e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD or 622e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD and *X* does not 623e5c31af7Sopenharmony_ciendif::VK_AMD_device_coherent_memory[] 624e5c31af7Sopenharmony_ci 625e5c31af7Sopenharmony_ci[NOTE] 626e5c31af7Sopenharmony_ci.Note 627e5c31af7Sopenharmony_ci==== 628e5c31af7Sopenharmony_ciThere is no ordering requirement between *X* and *Y* elements for the case 629e5c31af7Sopenharmony_citheir pname:propertyFlags members are not in a subset relation. 630e5c31af7Sopenharmony_ciThat potentially allows more than one possible way to order the same set of 631e5c31af7Sopenharmony_cimemory types. 632e5c31af7Sopenharmony_ciNotice that the <<memory-device-bitmask-list,list of all allowed memory 633e5c31af7Sopenharmony_ciproperty flag combinations>> is written in a valid order. 634e5c31af7Sopenharmony_ciBut if instead ename:VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT was before 635e5c31af7Sopenharmony_ciename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | 636e5c31af7Sopenharmony_ciename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, the list would still be in a 637e5c31af7Sopenharmony_civalid order. 638e5c31af7Sopenharmony_ciifdef::VK_AMD_device_coherent_memory[] 639e5c31af7Sopenharmony_ci 640e5c31af7Sopenharmony_ciThere may be a performance penalty for using device coherent or uncached 641e5c31af7Sopenharmony_cidevice memory types, and using these accidentally is undesirable. 642e5c31af7Sopenharmony_ciIn order to avoid this, memory types with these properties always appear at 643e5c31af7Sopenharmony_cithe end of the list; but are subject to the same rules otherwise. 644e5c31af7Sopenharmony_ciendif::VK_AMD_device_coherent_memory[] 645e5c31af7Sopenharmony_ci==== 646e5c31af7Sopenharmony_ci 647e5c31af7Sopenharmony_ciThis ordering requirement enables applications to use a simple search loop 648e5c31af7Sopenharmony_cito select the desired memory type along the lines of: 649e5c31af7Sopenharmony_ci 650e5c31af7Sopenharmony_ci[source,c++] 651e5c31af7Sopenharmony_ci~~~~ 652e5c31af7Sopenharmony_ci// Find a memory in `memoryTypeBitsRequirement` that includes all of `requiredProperties` 653e5c31af7Sopenharmony_ciint32_t findProperties(const VkPhysicalDeviceMemoryProperties* pMemoryProperties, 654e5c31af7Sopenharmony_ci uint32_t memoryTypeBitsRequirement, 655e5c31af7Sopenharmony_ci VkMemoryPropertyFlags requiredProperties) { 656e5c31af7Sopenharmony_ci const uint32_t memoryCount = pMemoryProperties->memoryTypeCount; 657e5c31af7Sopenharmony_ci for (uint32_t memoryIndex = 0; memoryIndex < memoryCount; ++memoryIndex) { 658e5c31af7Sopenharmony_ci const uint32_t memoryTypeBits = (1 << memoryIndex); 659e5c31af7Sopenharmony_ci const bool isRequiredMemoryType = memoryTypeBitsRequirement & memoryTypeBits; 660e5c31af7Sopenharmony_ci 661e5c31af7Sopenharmony_ci const VkMemoryPropertyFlags properties = 662e5c31af7Sopenharmony_ci pMemoryProperties->memoryTypes[memoryIndex].propertyFlags; 663e5c31af7Sopenharmony_ci const bool hasRequiredProperties = 664e5c31af7Sopenharmony_ci (properties & requiredProperties) == requiredProperties; 665e5c31af7Sopenharmony_ci 666e5c31af7Sopenharmony_ci if (isRequiredMemoryType && hasRequiredProperties) 667e5c31af7Sopenharmony_ci return static_cast<int32_t>(memoryIndex); 668e5c31af7Sopenharmony_ci } 669e5c31af7Sopenharmony_ci 670e5c31af7Sopenharmony_ci // failed to find memory type 671e5c31af7Sopenharmony_ci return -1; 672e5c31af7Sopenharmony_ci} 673e5c31af7Sopenharmony_ci 674e5c31af7Sopenharmony_ci// Try to find an optimal memory type, or if it does not exist try fallback memory type 675e5c31af7Sopenharmony_ci// `device` is the VkDevice 676e5c31af7Sopenharmony_ci// `image` is the VkImage that requires memory to be bound 677e5c31af7Sopenharmony_ci// `memoryProperties` properties as returned by vkGetPhysicalDeviceMemoryProperties 678e5c31af7Sopenharmony_ci// `requiredProperties` are the property flags that must be present 679e5c31af7Sopenharmony_ci// `optimalProperties` are the property flags that are preferred by the application 680e5c31af7Sopenharmony_ciVkMemoryRequirements memoryRequirements; 681e5c31af7Sopenharmony_civkGetImageMemoryRequirements(device, image, &memoryRequirements); 682e5c31af7Sopenharmony_ciint32_t memoryType = 683e5c31af7Sopenharmony_ci findProperties(&memoryProperties, memoryRequirements.memoryTypeBits, optimalProperties); 684e5c31af7Sopenharmony_ciif (memoryType == -1) // not found; try fallback properties 685e5c31af7Sopenharmony_ci memoryType = 686e5c31af7Sopenharmony_ci findProperties(&memoryProperties, memoryRequirements.memoryTypeBits, requiredProperties); 687e5c31af7Sopenharmony_ci~~~~ 688e5c31af7Sopenharmony_ci 689e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPhysicalDeviceMemoryProperties.txt[] 690e5c31af7Sopenharmony_ci-- 691e5c31af7Sopenharmony_ci 692e5c31af7Sopenharmony_ci[open,refpage='VK_MAX_MEMORY_TYPES',desc='Length of an array of memory types',type='consts'] 693e5c31af7Sopenharmony_ci-- 694e5c31af7Sopenharmony_ciename:VK_MAX_MEMORY_TYPES is the length of an array of slink:VkMemoryType 695e5c31af7Sopenharmony_cistructures describing memory types, as returned in 696e5c31af7Sopenharmony_cislink:VkPhysicalDeviceMemoryProperties::memoryTypes. 697e5c31af7Sopenharmony_ci 698e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VK_MAX_MEMORY_TYPES.txt[] 699e5c31af7Sopenharmony_ci-- 700e5c31af7Sopenharmony_ci 701e5c31af7Sopenharmony_ci[open,refpage='VK_MAX_MEMORY_HEAPS',desc='Length of an array of memory heaps',type='consts'] 702e5c31af7Sopenharmony_ci-- 703e5c31af7Sopenharmony_ciename:VK_MAX_MEMORY_HEAPS is the length of an array of slink:VkMemoryHeap 704e5c31af7Sopenharmony_cistructures describing memory heaps, as returned in 705e5c31af7Sopenharmony_cislink:VkPhysicalDeviceMemoryProperties::memoryHeaps. 706e5c31af7Sopenharmony_ci 707e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VK_MAX_MEMORY_HEAPS.txt[] 708e5c31af7Sopenharmony_ci-- 709e5c31af7Sopenharmony_ci 710e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_get_physical_device_properties2[] 711e5c31af7Sopenharmony_ci[open,refpage='vkGetPhysicalDeviceMemoryProperties2',desc='Reports memory information for the specified physical device',type='protos'] 712e5c31af7Sopenharmony_ci-- 713e5c31af7Sopenharmony_ciTo query memory properties, call: 714e5c31af7Sopenharmony_ci 715e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[] 716e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetPhysicalDeviceMemoryProperties2.txt[] 717e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[] 718e5c31af7Sopenharmony_ci 719e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1+VK_KHR_get_physical_device_properties2[or the equivalent command] 720e5c31af7Sopenharmony_ci 721e5c31af7Sopenharmony_ciifdef::VK_KHR_get_physical_device_properties2[] 722e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetPhysicalDeviceMemoryProperties2KHR.txt[] 723e5c31af7Sopenharmony_ciendif::VK_KHR_get_physical_device_properties2[] 724e5c31af7Sopenharmony_ci 725e5c31af7Sopenharmony_ci * pname:physicalDevice is the handle to the device to query. 726e5c31af7Sopenharmony_ci * pname:pMemoryProperties is a pointer to a 727e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceMemoryProperties2 structure in which the 728e5c31af7Sopenharmony_ci properties are returned. 729e5c31af7Sopenharmony_ci 730e5c31af7Sopenharmony_cifname:vkGetPhysicalDeviceMemoryProperties2 behaves similarly to 731e5c31af7Sopenharmony_ciflink:vkGetPhysicalDeviceMemoryProperties, with the ability to return 732e5c31af7Sopenharmony_ciextended information in a pname:pNext chain of output structures. 733e5c31af7Sopenharmony_ci 734e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetPhysicalDeviceMemoryProperties2.txt[] 735e5c31af7Sopenharmony_ci-- 736e5c31af7Sopenharmony_ci 737e5c31af7Sopenharmony_ci[open,refpage='VkPhysicalDeviceMemoryProperties2',desc='Structure specifying physical device memory properties',type='structs'] 738e5c31af7Sopenharmony_ci-- 739e5c31af7Sopenharmony_ciThe sname:VkPhysicalDeviceMemoryProperties2 structure is defined as: 740e5c31af7Sopenharmony_ci 741e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPhysicalDeviceMemoryProperties2.txt[] 742e5c31af7Sopenharmony_ci 743e5c31af7Sopenharmony_ciifdef::VK_KHR_get_physical_device_properties2[] 744e5c31af7Sopenharmony_cior the equivalent 745e5c31af7Sopenharmony_ci 746e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPhysicalDeviceMemoryProperties2KHR.txt[] 747e5c31af7Sopenharmony_ciendif::VK_KHR_get_physical_device_properties2[] 748e5c31af7Sopenharmony_ci 749e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 750e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 751e5c31af7Sopenharmony_ci structure. 752e5c31af7Sopenharmony_ci * pname:memoryProperties is a slink:VkPhysicalDeviceMemoryProperties 753e5c31af7Sopenharmony_ci structure which is populated with the same values as in 754e5c31af7Sopenharmony_ci flink:vkGetPhysicalDeviceMemoryProperties. 755e5c31af7Sopenharmony_ci 756e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPhysicalDeviceMemoryProperties2.txt[] 757e5c31af7Sopenharmony_ci-- 758e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_get_physical_device_properties2[] 759e5c31af7Sopenharmony_ci 760e5c31af7Sopenharmony_ci[open,refpage='VkMemoryHeap',desc='Structure specifying a memory heap',type='structs'] 761e5c31af7Sopenharmony_ci-- 762e5c31af7Sopenharmony_ciThe sname:VkMemoryHeap structure is defined as: 763e5c31af7Sopenharmony_ci 764e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkMemoryHeap.txt[] 765e5c31af7Sopenharmony_ci 766e5c31af7Sopenharmony_ci * pname:size is the total memory size in bytes in the heap. 767e5c31af7Sopenharmony_ci * pname:flags is a bitmask of elink:VkMemoryHeapFlagBits specifying 768e5c31af7Sopenharmony_ci attribute flags for the heap. 769e5c31af7Sopenharmony_ci 770e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkMemoryHeap.txt[] 771e5c31af7Sopenharmony_ci-- 772e5c31af7Sopenharmony_ci 773e5c31af7Sopenharmony_ci[open,refpage='VkMemoryHeapFlagBits',desc='Bitmask specifying attribute flags for a heap',type='enums'] 774e5c31af7Sopenharmony_ci-- 775e5c31af7Sopenharmony_ciBits which may: be set in slink:VkMemoryHeap::pname:flags, indicating 776e5c31af7Sopenharmony_ciattribute flags for the heap, are: 777e5c31af7Sopenharmony_ci 778e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkMemoryHeapFlagBits.txt[] 779e5c31af7Sopenharmony_ci 780e5c31af7Sopenharmony_ci * ename:VK_MEMORY_HEAP_DEVICE_LOCAL_BIT specifies that the heap 781e5c31af7Sopenharmony_ci corresponds to device-local memory. 782e5c31af7Sopenharmony_ci Device-local memory may: have different performance characteristics than 783e5c31af7Sopenharmony_ci host-local memory, and may: support different memory property flags. 784e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_device_group_creation[] 785e5c31af7Sopenharmony_ci * ename:VK_MEMORY_HEAP_MULTI_INSTANCE_BIT specifies that in a logical 786e5c31af7Sopenharmony_ci device representing more than one physical device, there is a 787e5c31af7Sopenharmony_ci per-physical device instance of the heap memory. 788e5c31af7Sopenharmony_ci By default, an allocation from such a heap will be replicated to each 789e5c31af7Sopenharmony_ci physical device's instance of the heap. 790e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_device_group_creation[] 791e5c31af7Sopenharmony_ci-- 792e5c31af7Sopenharmony_ci 793e5c31af7Sopenharmony_ci[open,refpage='VkMemoryHeapFlags',desc='Bitmask of VkMemoryHeapFlagBits',type='flags'] 794e5c31af7Sopenharmony_ci-- 795e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkMemoryHeapFlags.txt[] 796e5c31af7Sopenharmony_ci 797e5c31af7Sopenharmony_citname:VkMemoryHeapFlags is a bitmask type for setting a mask of zero or more 798e5c31af7Sopenharmony_cielink:VkMemoryHeapFlagBits. 799e5c31af7Sopenharmony_ci-- 800e5c31af7Sopenharmony_ci 801e5c31af7Sopenharmony_ci[open,refpage='VkMemoryType',desc='Structure specifying memory type',type='structs'] 802e5c31af7Sopenharmony_ci-- 803e5c31af7Sopenharmony_ciThe sname:VkMemoryType structure is defined as: 804e5c31af7Sopenharmony_ci 805e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkMemoryType.txt[] 806e5c31af7Sopenharmony_ci 807e5c31af7Sopenharmony_ci * pname:heapIndex describes which memory heap this memory type corresponds 808e5c31af7Sopenharmony_ci to, and must: be less than pname:memoryHeapCount from the 809e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceMemoryProperties structure. 810e5c31af7Sopenharmony_ci * pname:propertyFlags is a bitmask of elink:VkMemoryPropertyFlagBits of 811e5c31af7Sopenharmony_ci properties for this memory type. 812e5c31af7Sopenharmony_ci 813e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkMemoryType.txt[] 814e5c31af7Sopenharmony_ci-- 815e5c31af7Sopenharmony_ci 816e5c31af7Sopenharmony_ci[open,refpage='VkMemoryPropertyFlagBits',desc='Bitmask specifying properties for a memory type',type='enums'] 817e5c31af7Sopenharmony_ci-- 818e5c31af7Sopenharmony_ciBits which may: be set in slink:VkMemoryType::pname:propertyFlags, 819e5c31af7Sopenharmony_ciindicating properties of a memory heap, are: 820e5c31af7Sopenharmony_ci 821e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkMemoryPropertyFlagBits.txt[] 822e5c31af7Sopenharmony_ci 823e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT bit specifies that memory 824e5c31af7Sopenharmony_ci allocated with this type is the most efficient for device access. 825e5c31af7Sopenharmony_ci This property will be set if and only if the memory type belongs to a 826e5c31af7Sopenharmony_ci heap with the ename:VK_MEMORY_HEAP_DEVICE_LOCAL_BIT set. 827e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT bit specifies that memory 828e5c31af7Sopenharmony_ci allocated with this type can: be mapped for host access using 829e5c31af7Sopenharmony_ci flink:vkMapMemory. 830e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT bit specifies that the host 831e5c31af7Sopenharmony_ci cache management commands flink:vkFlushMappedMemoryRanges and 832e5c31af7Sopenharmony_ci flink:vkInvalidateMappedMemoryRanges are not needed to flush host writes 833e5c31af7Sopenharmony_ci to the device or make device writes visible to the host, respectively. 834e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_HOST_CACHED_BIT bit specifies that memory 835e5c31af7Sopenharmony_ci allocated with this type is cached on the host. 836e5c31af7Sopenharmony_ci Host memory accesses to uncached memory are slower than to cached 837e5c31af7Sopenharmony_ci memory, however uncached memory is always host coherent. 838e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT bit specifies that the 839e5c31af7Sopenharmony_ci memory type only allows device access to the memory. 840e5c31af7Sopenharmony_ci Memory types must: not have both 841e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT and 842e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT set. 843e5c31af7Sopenharmony_ci Additionally, the object's backing memory may: be provided by the 844e5c31af7Sopenharmony_ci implementation lazily as specified in <<memory-device-lazy_allocation, 845e5c31af7Sopenharmony_ci Lazily Allocated Memory>>. 846e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[] 847e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_PROTECTED_BIT bit specifies that the memory 848e5c31af7Sopenharmony_ci type only allows device access to the memory, and allows protected queue 849e5c31af7Sopenharmony_ci operations to access the memory. 850e5c31af7Sopenharmony_ci Memory types must: not have ename:VK_MEMORY_PROPERTY_PROTECTED_BIT set 851e5c31af7Sopenharmony_ci and any of ename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT set, or 852e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT set, or 853e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_CACHED_BIT set. 854e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[] 855e5c31af7Sopenharmony_ciifdef::VK_AMD_device_coherent_memory[] 856e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD bit specifies that 857e5c31af7Sopenharmony_ci device accesses to allocations of this memory type are automatically 858e5c31af7Sopenharmony_ci made available and visible. 859e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD bit specifies that 860e5c31af7Sopenharmony_ci memory allocated with this type is not cached on the device. 861e5c31af7Sopenharmony_ci Uncached device memory is always device coherent. 862e5c31af7Sopenharmony_ciendif::VK_AMD_device_coherent_memory[] 863e5c31af7Sopenharmony_ciifdef::VK_NV_external_memory_rdma[] 864e5c31af7Sopenharmony_ci * ename:VK_MEMORY_PROPERTY_RDMA_CAPABLE_BIT_NV bit specifies that external 865e5c31af7Sopenharmony_ci devices can access this memory directly. 866e5c31af7Sopenharmony_ciendif::VK_NV_external_memory_rdma[] 867e5c31af7Sopenharmony_ci 868e5c31af7Sopenharmony_ciifdef::VK_AMD_device_coherent_memory[] 869e5c31af7Sopenharmony_ciFor any memory allocated with both the 870e5c31af7Sopenharmony_ciename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT and the 871e5c31af7Sopenharmony_ciename:VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD, host or device accesses 872e5c31af7Sopenharmony_cialso perform automatic memory domain transfer operations, such that writes 873e5c31af7Sopenharmony_ciare always automatically available and visible to both host and device 874e5c31af7Sopenharmony_cimemory domains. 875e5c31af7Sopenharmony_ci 876e5c31af7Sopenharmony_ci[NOTE] 877e5c31af7Sopenharmony_ci.Note 878e5c31af7Sopenharmony_ci==== 879e5c31af7Sopenharmony_ciDevice coherence is a useful property for certain debugging use cases (e.g. 880e5c31af7Sopenharmony_cicrash analysis, where performing separate coherence actions could mean 881e5c31af7Sopenharmony_civalues are not reported correctly). 882e5c31af7Sopenharmony_ciHowever, device coherent accesses may be slower than equivalent accesses 883e5c31af7Sopenharmony_ciwithout device coherence, particularly if they are also device uncached. 884e5c31af7Sopenharmony_ciFor device uncached memory in particular, repeated accesses to the same or 885e5c31af7Sopenharmony_cineighbouring memory locations over a short time period (e.g. within a frame) 886e5c31af7Sopenharmony_cimay be slower than it would be for the equivalent cached memory type. 887e5c31af7Sopenharmony_ciAs such, it is generally inadvisable to use device coherent or device 888e5c31af7Sopenharmony_ciuncached memory except when really needed. 889e5c31af7Sopenharmony_ci==== 890e5c31af7Sopenharmony_ciendif::VK_AMD_device_coherent_memory[] 891e5c31af7Sopenharmony_ci-- 892e5c31af7Sopenharmony_ci 893e5c31af7Sopenharmony_ci[open,refpage='VkMemoryPropertyFlags',desc='Bitmask of VkMemoryPropertyFlagBits',type='flags'] 894e5c31af7Sopenharmony_ci-- 895e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkMemoryPropertyFlags.txt[] 896e5c31af7Sopenharmony_ci 897e5c31af7Sopenharmony_citname:VkMemoryPropertyFlags is a bitmask type for setting a mask of zero or 898e5c31af7Sopenharmony_cimore elink:VkMemoryPropertyFlagBits. 899e5c31af7Sopenharmony_ci-- 900e5c31af7Sopenharmony_ci 901e5c31af7Sopenharmony_ciifdef::VK_EXT_memory_budget[] 902e5c31af7Sopenharmony_ci[open,refpage='VkPhysicalDeviceMemoryBudgetPropertiesEXT',desc='Structure specifying physical device memory budget and usage',type='structs'] 903e5c31af7Sopenharmony_ci-- 904e5c31af7Sopenharmony_ciIf the sname:VkPhysicalDeviceMemoryBudgetPropertiesEXT structure is included 905e5c31af7Sopenharmony_ciin the pname:pNext chain of slink:VkPhysicalDeviceMemoryProperties2, it is 906e5c31af7Sopenharmony_cifilled with the current memory budgets and usages. 907e5c31af7Sopenharmony_ci 908e5c31af7Sopenharmony_ciThe sname:VkPhysicalDeviceMemoryBudgetPropertiesEXT structure is defined as: 909e5c31af7Sopenharmony_ci 910e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPhysicalDeviceMemoryBudgetPropertiesEXT.txt[] 911e5c31af7Sopenharmony_ci 912e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 913e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 914e5c31af7Sopenharmony_ci structure. 915e5c31af7Sopenharmony_ci * pname:heapBudget is an array of ename:VK_MAX_MEMORY_HEAPS 916e5c31af7Sopenharmony_ci basetype:VkDeviceSize values in which memory budgets are returned, with 917e5c31af7Sopenharmony_ci one element for each memory heap. 918e5c31af7Sopenharmony_ci A heap's budget is a rough estimate of how much memory the process can: 919e5c31af7Sopenharmony_ci allocate from that heap before allocations may: fail or cause 920e5c31af7Sopenharmony_ci performance degradation. 921e5c31af7Sopenharmony_ci The budget includes any currently allocated device memory. 922e5c31af7Sopenharmony_ci * pname:heapUsage is an array of ename:VK_MAX_MEMORY_HEAPS 923e5c31af7Sopenharmony_ci basetype:VkDeviceSize values in which memory usages are returned, with 924e5c31af7Sopenharmony_ci one element for each memory heap. 925e5c31af7Sopenharmony_ci A heap's usage is an estimate of how much memory the process is 926e5c31af7Sopenharmony_ci currently using in that heap. 927e5c31af7Sopenharmony_ci 928e5c31af7Sopenharmony_ciThe values returned in this structure are not invariant. 929e5c31af7Sopenharmony_ciThe pname:heapBudget and pname:heapUsage values must: be zero for array 930e5c31af7Sopenharmony_cielements greater than or equal to 931e5c31af7Sopenharmony_cislink:VkPhysicalDeviceMemoryProperties::pname:memoryHeapCount. 932e5c31af7Sopenharmony_ciThe pname:heapBudget value must: be non-zero for array elements less than 933e5c31af7Sopenharmony_cislink:VkPhysicalDeviceMemoryProperties::pname:memoryHeapCount. 934e5c31af7Sopenharmony_ciThe pname:heapBudget value must: be less than or equal to 935e5c31af7Sopenharmony_cislink:VkMemoryHeap::pname:size for each heap. 936e5c31af7Sopenharmony_ci 937e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPhysicalDeviceMemoryBudgetPropertiesEXT.txt[] 938e5c31af7Sopenharmony_ci-- 939e5c31af7Sopenharmony_ciendif::VK_EXT_memory_budget[] 940e5c31af7Sopenharmony_ci 941e5c31af7Sopenharmony_ci[[memory-device-objects]] 942e5c31af7Sopenharmony_ci=== Device Memory Objects 943e5c31af7Sopenharmony_ci 944e5c31af7Sopenharmony_ci[open,refpage='VkDeviceMemory',desc='Opaque handle to a device memory object',type='handles'] 945e5c31af7Sopenharmony_ci-- 946e5c31af7Sopenharmony_ciA Vulkan device operates on data in device memory via memory objects that 947e5c31af7Sopenharmony_ciare represented in the API by a sname:VkDeviceMemory handle: 948e5c31af7Sopenharmony_ci 949e5c31af7Sopenharmony_ciinclude::{generated}/api/handles/VkDeviceMemory.txt[] 950e5c31af7Sopenharmony_ci-- 951e5c31af7Sopenharmony_ci 952e5c31af7Sopenharmony_ci=== Device Memory Allocation 953e5c31af7Sopenharmony_ci 954e5c31af7Sopenharmony_ci[open,refpage='vkAllocateMemory',desc='Allocate device memory',type='protos'] 955e5c31af7Sopenharmony_ci-- 956e5c31af7Sopenharmony_ciTo allocate memory objects, call: 957e5c31af7Sopenharmony_ci 958e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkAllocateMemory.txt[] 959e5c31af7Sopenharmony_ci 960e5c31af7Sopenharmony_ci * pname:device is the logical device that owns the memory. 961e5c31af7Sopenharmony_ci * pname:pAllocateInfo is a pointer to a slink:VkMemoryAllocateInfo 962e5c31af7Sopenharmony_ci structure describing parameters of the allocation. 963e5c31af7Sopenharmony_ci A successfully returned allocation must: use the requested parameters -- 964e5c31af7Sopenharmony_ci no substitution is permitted by the implementation. 965e5c31af7Sopenharmony_ci * pname:pAllocator controls host memory allocation as described in the 966e5c31af7Sopenharmony_ci <<memory-allocation, Memory Allocation>> chapter. 967e5c31af7Sopenharmony_ci * pname:pMemory is a pointer to a slink:VkDeviceMemory handle in which 968e5c31af7Sopenharmony_ci information about the allocated memory is returned. 969e5c31af7Sopenharmony_ci 970e5c31af7Sopenharmony_ciAllocations returned by fname:vkAllocateMemory are guaranteed to meet any 971e5c31af7Sopenharmony_cialignment requirement of the implementation. 972e5c31af7Sopenharmony_ciFor example, if an implementation requires 128 byte alignment for images and 973e5c31af7Sopenharmony_ci64 byte alignment for buffers, the device memory returned through this 974e5c31af7Sopenharmony_cimechanism would be 128-byte aligned. 975e5c31af7Sopenharmony_ciThis ensures that applications can: correctly suballocate objects of 976e5c31af7Sopenharmony_cidifferent types (with potentially different alignment requirements) in the 977e5c31af7Sopenharmony_cisame memory object. 978e5c31af7Sopenharmony_ci 979e5c31af7Sopenharmony_ciifndef::VK_VERSION_1_1[] 980e5c31af7Sopenharmony_ciWhen memory is allocated, its contents are undefined:. 981e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[] 982e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[] 983e5c31af7Sopenharmony_ciWhen memory is allocated, its contents are undefined: with the following 984e5c31af7Sopenharmony_ciconstraint: 985e5c31af7Sopenharmony_ci 986e5c31af7Sopenharmony_ci * The contents of unprotected memory must: not be a function of the 987e5c31af7Sopenharmony_ci contents of data protected memory objects, even if those memory objects 988e5c31af7Sopenharmony_ci were previously freed. 989e5c31af7Sopenharmony_ci 990e5c31af7Sopenharmony_ci[NOTE] 991e5c31af7Sopenharmony_ci.Note 992e5c31af7Sopenharmony_ci==== 993e5c31af7Sopenharmony_ciThe contents of memory allocated by one application should: not be a 994e5c31af7Sopenharmony_cifunction of data from protected memory objects of another application, even 995e5c31af7Sopenharmony_ciif those memory objects were previously freed. 996e5c31af7Sopenharmony_ci==== 997e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[] 998e5c31af7Sopenharmony_ci 999e5c31af7Sopenharmony_ciThe maximum number of valid memory allocations that can: exist 1000e5c31af7Sopenharmony_cisimultaneously within a slink:VkDevice may: be restricted by implementation- 1001e5c31af7Sopenharmony_cior platform-dependent limits. 1002e5c31af7Sopenharmony_ciThe <<limits-maxMemoryAllocationCount,pname:maxMemoryAllocationCount>> 1003e5c31af7Sopenharmony_cifeature describes the number of allocations that can: exist simultaneously 1004e5c31af7Sopenharmony_cibefore encountering these internal limits. 1005e5c31af7Sopenharmony_ci 1006e5c31af7Sopenharmony_ci[NOTE] 1007e5c31af7Sopenharmony_ci.Note 1008e5c31af7Sopenharmony_ci==== 1009e5c31af7Sopenharmony_ciFor historical reasons, if pname:maxMemoryAllocationCount is exceeded, some 1010e5c31af7Sopenharmony_ciimplementations may return ename:VK_ERROR_TOO_MANY_OBJECTS. 1011e5c31af7Sopenharmony_ciExceeding this limit will result in undefined: behavior, and an application 1012e5c31af7Sopenharmony_cishould not rely on the use of the returned error code in order to identify 1013e5c31af7Sopenharmony_ciwhen the limit is reached. 1014e5c31af7Sopenharmony_ci==== 1015e5c31af7Sopenharmony_ci 1016e5c31af7Sopenharmony_ci[NOTE] 1017e5c31af7Sopenharmony_ci.Note 1018e5c31af7Sopenharmony_ci==== 1019e5c31af7Sopenharmony_ciMany protected memory implementations involve complex hardware and system 1020e5c31af7Sopenharmony_cisoftware support, and often have additional and much lower limits on the 1021e5c31af7Sopenharmony_cinumber of simultaneous protected memory allocations (from memory types with 1022e5c31af7Sopenharmony_cithe ename:VK_MEMORY_PROPERTY_PROTECTED_BIT property) than for non-protected 1023e5c31af7Sopenharmony_cimemory allocations. 1024e5c31af7Sopenharmony_ciThese limits can be system-wide, and depend on a variety of factors outside 1025e5c31af7Sopenharmony_ciof the Vulkan implementation, so they cannot be queried in Vulkan. 1026e5c31af7Sopenharmony_ciApplications should: use as few allocations as possible from such memory 1027e5c31af7Sopenharmony_citypes by suballocating aggressively, and be prepared for allocation failure 1028e5c31af7Sopenharmony_cieven when there is apparently plenty of capacity remaining in the memory 1029e5c31af7Sopenharmony_ciheap. 1030e5c31af7Sopenharmony_ciAs a guideline, the Vulkan conformance test suite requires that at least 80 1031e5c31af7Sopenharmony_ciminimum-size allocations can exist concurrently when no other uses of 1032e5c31af7Sopenharmony_ciprotected memory are active in the system. 1033e5c31af7Sopenharmony_ci==== 1034e5c31af7Sopenharmony_ci 1035e5c31af7Sopenharmony_ciSome platforms may: have a limit on the maximum size of a single allocation. 1036e5c31af7Sopenharmony_ciFor example, certain systems may: fail to create allocations with a size 1037e5c31af7Sopenharmony_cigreater than or equal to 4GB. 1038e5c31af7Sopenharmony_ciSuch a limit is implementation-dependent, and if such a failure occurs then 1039e5c31af7Sopenharmony_cithe error ename:VK_ERROR_OUT_OF_DEVICE_MEMORY must: be returned. 1040e5c31af7Sopenharmony_ciifdef::VK_KHR_maintenance3[] 1041e5c31af7Sopenharmony_ciThis limit is advertised in 1042e5c31af7Sopenharmony_cislink:VkPhysicalDeviceMaintenance3Properties::pname:maxMemoryAllocationSize. 1043e5c31af7Sopenharmony_ciendif::VK_KHR_maintenance3[] 1044e5c31af7Sopenharmony_ci 1045e5c31af7Sopenharmony_ciifdef::VK_AMD_memory_overallocation_behavior[] 1046e5c31af7Sopenharmony_ci 1047e5c31af7Sopenharmony_ciThe cumulative memory size allocated to a heap can: be limited by the size 1048e5c31af7Sopenharmony_ciof the specified heap. 1049e5c31af7Sopenharmony_ciIn such cases, allocated memory is tracked on a per-device and per-heap 1050e5c31af7Sopenharmony_cibasis. 1051e5c31af7Sopenharmony_ciSome platforms allow overallocation into other heaps. 1052e5c31af7Sopenharmony_ciThe overallocation behavior can: be specified through the 1053e5c31af7Sopenharmony_ci`apiext:VK_AMD_memory_overallocation_behavior` extension. 1054e5c31af7Sopenharmony_ci 1055e5c31af7Sopenharmony_ciendif::VK_AMD_memory_overallocation_behavior[] 1056e5c31af7Sopenharmony_ci 1057e5c31af7Sopenharmony_ciifdef::VK_EXT_pageable_device_local_memory[] 1058e5c31af7Sopenharmony_ci 1059e5c31af7Sopenharmony_ciIf the 1060e5c31af7Sopenharmony_cislink:VkPhysicalDevicePageableDeviceLocalMemoryFeaturesEXT::pname:pageableDeviceLocalMemory 1061e5c31af7Sopenharmony_cifeature is enabled, memory allocations made from a heap that includes 1062e5c31af7Sopenharmony_ciename:VK_MEMORY_HEAP_DEVICE_LOCAL_BIT in slink:VkMemoryHeap::pname:flags 1063e5c31af7Sopenharmony_cimay: be transparently moved to host-local memory allowing multiple 1064e5c31af7Sopenharmony_ciapplications to share device-local memory. 1065e5c31af7Sopenharmony_ciIf there is no space left in device-local memory when this new allocation is 1066e5c31af7Sopenharmony_cimade, other allocations may: be moved out transparently to make room. 1067e5c31af7Sopenharmony_ciThe operating system will determine which allocations to move to 1068e5c31af7Sopenharmony_cidevice-local memory or host-local memory based on platform-specific 1069e5c31af7Sopenharmony_cicriteria. 1070e5c31af7Sopenharmony_ciTo help the operating system make good choices, the application should: set 1071e5c31af7Sopenharmony_cithe appropriate memory priority with slink:VkMemoryPriorityAllocateInfoEXT 1072e5c31af7Sopenharmony_ciand adjust it as necessary with flink:vkSetDeviceMemoryPriorityEXT. 1073e5c31af7Sopenharmony_ciHigher priority allocations will moved to device-local memory first. 1074e5c31af7Sopenharmony_ci 1075e5c31af7Sopenharmony_ciMemory allocations made on heaps without the 1076e5c31af7Sopenharmony_ciename:VK_MEMORY_HEAP_DEVICE_LOCAL_BIT property will not be transparently 1077e5c31af7Sopenharmony_cipromoted to device-local memory by the operating system. 1078e5c31af7Sopenharmony_ci 1079e5c31af7Sopenharmony_ciendif::VK_EXT_pageable_device_local_memory[] 1080e5c31af7Sopenharmony_ci 1081e5c31af7Sopenharmony_ci.Valid Usage 1082e5c31af7Sopenharmony_ci**** 1083e5c31af7Sopenharmony_ci * [[VUID-vkAllocateMemory-pAllocateInfo-01713]] 1084e5c31af7Sopenharmony_ci pname:pAllocateInfo->allocationSize must: be less than or equal to 1085e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceMemoryProperties::pname:memoryHeaps[`memindex`].pname:size 1086e5c31af7Sopenharmony_ci where `memindex` = 1087e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceMemoryProperties::pname:memoryTypes[pname:pAllocateInfo->memoryTypeIndex].pname:heapIndex 1088e5c31af7Sopenharmony_ci as returned by flink:vkGetPhysicalDeviceMemoryProperties for the 1089e5c31af7Sopenharmony_ci slink:VkPhysicalDevice that pname:device was created from 1090e5c31af7Sopenharmony_ci * [[VUID-vkAllocateMemory-pAllocateInfo-01714]] 1091e5c31af7Sopenharmony_ci pname:pAllocateInfo->memoryTypeIndex must: be less than 1092e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceMemoryProperties::pname:memoryTypeCount as 1093e5c31af7Sopenharmony_ci returned by flink:vkGetPhysicalDeviceMemoryProperties for the 1094e5c31af7Sopenharmony_ci slink:VkPhysicalDevice that pname:device was created from 1095e5c31af7Sopenharmony_ciifdef::VK_AMD_device_coherent_memory[] 1096e5c31af7Sopenharmony_ci * [[VUID-vkAllocateMemory-deviceCoherentMemory-02790]] 1097e5c31af7Sopenharmony_ci If the <<features-deviceCoherentMemory,pname:deviceCoherentMemory>> 1098e5c31af7Sopenharmony_ci feature is not enabled, pname:pAllocateInfo->memoryTypeIndex must: not 1099e5c31af7Sopenharmony_ci identify a memory type supporting 1100e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD 1101e5c31af7Sopenharmony_ciendif::VK_AMD_device_coherent_memory[] 1102e5c31af7Sopenharmony_ci * [[VUID-vkAllocateMemory-maxMemoryAllocationCount-04101]] 1103e5c31af7Sopenharmony_ci There must: be less than 1104e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceLimits::pname:maxMemoryAllocationCount device 1105e5c31af7Sopenharmony_ci memory allocations currently allocated on the device 1106e5c31af7Sopenharmony_ci**** 1107e5c31af7Sopenharmony_ci 1108e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkAllocateMemory.txt[] 1109e5c31af7Sopenharmony_ci-- 1110e5c31af7Sopenharmony_ci 1111e5c31af7Sopenharmony_ci[open,refpage='VkMemoryAllocateInfo',desc='Structure containing parameters of a memory allocation',type='structs'] 1112e5c31af7Sopenharmony_ci-- 1113e5c31af7Sopenharmony_ciThe sname:VkMemoryAllocateInfo structure is defined as: 1114e5c31af7Sopenharmony_ci 1115e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkMemoryAllocateInfo.txt[] 1116e5c31af7Sopenharmony_ci 1117e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 1118e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 1119e5c31af7Sopenharmony_ci structure. 1120e5c31af7Sopenharmony_ci * pname:allocationSize is the size of the allocation in bytes. 1121e5c31af7Sopenharmony_ci * pname:memoryTypeIndex is an index identifying a memory type from the 1122e5c31af7Sopenharmony_ci pname:memoryTypes array of the slink:VkPhysicalDeviceMemoryProperties 1123e5c31af7Sopenharmony_ci structure. 1124e5c31af7Sopenharmony_ci 1125e5c31af7Sopenharmony_ciThe internal data of an allocated device memory object must: include a 1126e5c31af7Sopenharmony_cireference to implementation-specific resources, referred to as the memory 1127e5c31af7Sopenharmony_ciobject's _payload_. 1128e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory_win32,VK_KHR_external_memory_fd,VK_EXT_external_memory_host,VK_ANDROID_external_memory_android_hardware_buffer[] 1129e5c31af7Sopenharmony_ciApplications can: also import and export that internal data to and from 1130e5c31af7Sopenharmony_cidevice memory objects to share data between Vulkan instances and other 1131e5c31af7Sopenharmony_cicompatible APIs. 1132e5c31af7Sopenharmony_ciA sname:VkMemoryAllocateInfo structure defines a memory import operation if 1133e5c31af7Sopenharmony_ciits pname:pNext chain includes one of the following structures: 1134e5c31af7Sopenharmony_ci 1135e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory_win32[] 1136e5c31af7Sopenharmony_ci * slink:VkImportMemoryWin32HandleInfoKHR with a non-zero pname:handleType 1137e5c31af7Sopenharmony_ci value 1138e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory_win32[] 1139e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory_fd[] 1140e5c31af7Sopenharmony_ci * slink:VkImportMemoryFdInfoKHR with a non-zero pname:handleType value 1141e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory_fd[] 1142e5c31af7Sopenharmony_ciifdef::VK_EXT_external_memory_host[] 1143e5c31af7Sopenharmony_ci * slink:VkImportMemoryHostPointerInfoEXT with a non-zero pname:handleType 1144e5c31af7Sopenharmony_ci value 1145e5c31af7Sopenharmony_ciendif::VK_EXT_external_memory_host[] 1146e5c31af7Sopenharmony_ciifdef::VK_ANDROID_external_memory_android_hardware_buffer[] 1147e5c31af7Sopenharmony_ci * slink:VkImportAndroidHardwareBufferInfoANDROID with a non-`NULL` 1148e5c31af7Sopenharmony_ci pname:buffer value 1149e5c31af7Sopenharmony_ciendif::VK_ANDROID_external_memory_android_hardware_buffer[] 1150e5c31af7Sopenharmony_ciifdef::VK_FUCHSIA_external_memory[] 1151e5c31af7Sopenharmony_ci * slink:VkImportMemoryZirconHandleInfoFUCHSIA with a non-zero 1152e5c31af7Sopenharmony_ci pname:handleType value 1153e5c31af7Sopenharmony_ciendif::VK_FUCHSIA_external_memory[] 1154e5c31af7Sopenharmony_ciifdef::VK_FUCHSIA_buffer_collection[] 1155e5c31af7Sopenharmony_ci * slink:VkImportMemoryBufferCollectionFUCHSIA 1156e5c31af7Sopenharmony_ciendif::VK_FUCHSIA_buffer_collection[] 1157e5c31af7Sopenharmony_ci 1158e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory_win32[] 1159e5c31af7Sopenharmony_ciIf the parameters define an import operation and the external handle type is 1160e5c31af7Sopenharmony_ciename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT, 1161e5c31af7Sopenharmony_ciename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_KMT_BIT, or 1162e5c31af7Sopenharmony_ciename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT, 1163e5c31af7Sopenharmony_cipname:allocationSize is ignored. 1164e5c31af7Sopenharmony_ciThe implementation must: query the size of these allocations from the OS. 1165e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory_win32[] 1166e5c31af7Sopenharmony_ci 1167e5c31af7Sopenharmony_ciWhether device memory objects constructed via a memory import operation hold 1168e5c31af7Sopenharmony_cia reference to their payload depends on the properties of the handle type 1169e5c31af7Sopenharmony_ciused to perform the import, as defined below for each valid handle type. 1170e5c31af7Sopenharmony_ciImporting memory must: not modify the content of the memory. 1171e5c31af7Sopenharmony_ciImplementations must: ensure that importing memory does not enable the 1172e5c31af7Sopenharmony_ciimporting Vulkan instance to access any memory or resources in other Vulkan 1173e5c31af7Sopenharmony_ciinstances other than that corresponding to the memory object imported. 1174e5c31af7Sopenharmony_ciImplementations must: also ensure accessing imported memory which has not 1175e5c31af7Sopenharmony_cibeen initialized does not allow the importing Vulkan instance to obtain data 1176e5c31af7Sopenharmony_cifrom the exporting Vulkan instance or vice-versa. 1177e5c31af7Sopenharmony_ci 1178e5c31af7Sopenharmony_ci[NOTE] 1179e5c31af7Sopenharmony_ci.Note 1180e5c31af7Sopenharmony_ci==== 1181e5c31af7Sopenharmony_ciHow exported and imported memory is isolated is left to the implementation, 1182e5c31af7Sopenharmony_cibut applications should be aware that such isolation may: prevent 1183e5c31af7Sopenharmony_ciimplementations from placing multiple exportable memory objects in the same 1184e5c31af7Sopenharmony_ciphysical or virtual page. 1185e5c31af7Sopenharmony_ciHence, applications should: avoid creating many small external memory 1186e5c31af7Sopenharmony_ciobjects whenever possible. 1187e5c31af7Sopenharmony_ci==== 1188e5c31af7Sopenharmony_ci 1189e5c31af7Sopenharmony_ciImporting memory must: not increase overall heap usage within a system. 1190e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_maintenance3,VK_EXT_memory_budget[] 1191e5c31af7Sopenharmony_ciHowever, it must: affect the following per-process values: 1192e5c31af7Sopenharmony_ci 1193e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_maintenance3[] 1194e5c31af7Sopenharmony_ci * slink:VkPhysicalDeviceMaintenance3Properties::pname:maxMemoryAllocationCount 1195e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_maintenance3[] 1196e5c31af7Sopenharmony_ciifdef::VK_EXT_memory_budget[] 1197e5c31af7Sopenharmony_ci * slink:VkPhysicalDeviceMemoryBudgetPropertiesEXT::pname:heapUsage 1198e5c31af7Sopenharmony_ciendif::VK_EXT_memory_budget[] 1199e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_maintenance3,VK_EXT_memory_budget[] 1200e5c31af7Sopenharmony_ci 1201e5c31af7Sopenharmony_ciWhen performing a memory import operation, it is the responsibility of the 1202e5c31af7Sopenharmony_ciapplication to ensure the external handles and their associated payloads 1203e5c31af7Sopenharmony_cimeet all valid usage requirements. 1204e5c31af7Sopenharmony_ciHowever, implementations must: perform sufficient validation of external 1205e5c31af7Sopenharmony_cihandles and payloads to ensure that the operation results in a valid memory 1206e5c31af7Sopenharmony_ciobject which will not cause program termination, device loss, queue stalls, 1207e5c31af7Sopenharmony_cior corruption of other resources when used as allowed according to its 1208e5c31af7Sopenharmony_ciallocation parameters. 1209e5c31af7Sopenharmony_ciIf the external handle provided does not meet these requirements, the 1210e5c31af7Sopenharmony_ciimplementation must: fail the memory import operation with the error code 1211e5c31af7Sopenharmony_ciename:VK_ERROR_INVALID_EXTERNAL_HANDLE. 1212e5c31af7Sopenharmony_ci 1213e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory_win32,VK_KHR_external_memory_fd,VK_EXT_external_memory_host,VK_ANDROID_external_memory_android_hardware_buffer[] 1214e5c31af7Sopenharmony_ci 1215e5c31af7Sopenharmony_ci.Valid Usage 1216e5c31af7Sopenharmony_ci**** 1217e5c31af7Sopenharmony_ciifndef::VK_ANDROID_external_memory_android_hardware_buffer[] 1218e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-allocationSize-00638]] 1219e5c31af7Sopenharmony_ci pname:allocationSize must: be greater than `0` 1220e5c31af7Sopenharmony_ciendif::VK_ANDROID_external_memory_android_hardware_buffer[] 1221e5c31af7Sopenharmony_ciifdef::VK_FUCHSIA_buffer_collection[] 1222e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-buffer-06380]] 1223e5c31af7Sopenharmony_ci If the parameters define an import operation from an 1224e5c31af7Sopenharmony_ci slink:VkBufferCollectionFUCHSIA, and 1225e5c31af7Sopenharmony_ci slink:VkMemoryDedicatedAllocateInfo::pname:buffer is present and 1226e5c31af7Sopenharmony_ci non-NULL, slink:VkImportMemoryBufferCollectionFUCHSIA::pname:collection 1227e5c31af7Sopenharmony_ci and slink:VkImportMemoryBufferCollectionFUCHSIA::pname:index must match 1228e5c31af7Sopenharmony_ci slink:VkBufferCollectionBufferCreateInfoFUCHSIA::pname:collection and 1229e5c31af7Sopenharmony_ci slink:VkBufferCollectionBufferCreateInfoFUCHSIA::pname:index, 1230e5c31af7Sopenharmony_ci respectively, of the slink:VkBufferCollectionBufferCreateInfoFUCHSIA 1231e5c31af7Sopenharmony_ci structure used to create the 1232e5c31af7Sopenharmony_ci slink:VkMemoryDedicatedAllocateInfo::pname:buffer 1233e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-image-06381]] 1234e5c31af7Sopenharmony_ci If the parameters define an import operation from an 1235e5c31af7Sopenharmony_ci slink:VkBufferCollectionFUCHSIA, and 1236e5c31af7Sopenharmony_ci slink:VkMemoryDedicatedAllocateInfo::pname:image is present and 1237e5c31af7Sopenharmony_ci non-NULL, slink:VkImportMemoryBufferCollectionFUCHSIA::pname:collection 1238e5c31af7Sopenharmony_ci and slink:VkImportMemoryBufferCollectionFUCHSIA::pname:index must match 1239e5c31af7Sopenharmony_ci slink:VkBufferCollectionImageCreateInfoFUCHSIA::pname:collection and 1240e5c31af7Sopenharmony_ci slink:VkBufferCollectionImageCreateInfoFUCHSIA::pname:index, 1241e5c31af7Sopenharmony_ci respectively, of the slink:VkBufferCollectionImageCreateInfoFUCHSIA 1242e5c31af7Sopenharmony_ci structure used to create the 1243e5c31af7Sopenharmony_ci slink:VkMemoryDedicatedAllocateInfo::pname:image 1244e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-allocationSize-06382]] 1245e5c31af7Sopenharmony_ci If the parameters define an import operation from an 1246e5c31af7Sopenharmony_ci slink:VkBufferCollectionFUCHSIA, pname:allocationSize must: match 1247e5c31af7Sopenharmony_ci slink:VkMemoryRequirements::pname:size value retrieved by 1248e5c31af7Sopenharmony_ci flink:vkGetImageMemoryRequirements or 1249e5c31af7Sopenharmony_ci flink:vkGetBufferMemoryRequirements for image-based or buffer-based 1250e5c31af7Sopenharmony_ci collections respectively 1251e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-pNext-06383]] 1252e5c31af7Sopenharmony_ci If the parameters define an import operation from an 1253e5c31af7Sopenharmony_ci slink:VkBufferCollectionFUCHSIA, the pname:pNext chain must: include a 1254e5c31af7Sopenharmony_ci slink:VkMemoryDedicatedAllocateInfo structure with either its 1255e5c31af7Sopenharmony_ci pname:image or pname:buffer field set to a value other than 1256e5c31af7Sopenharmony_ci dlink:VK_NULL_HANDLE. 1257e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-image-06384]] 1258e5c31af7Sopenharmony_ci If the parameters define an import operation from an 1259e5c31af7Sopenharmony_ci slink:VkBufferCollectionFUCHSIA and 1260e5c31af7Sopenharmony_ci slink:VkMemoryDedicatedAllocateInfo::pname:image is not 1261e5c31af7Sopenharmony_ci dlink:VK_NULL_HANDLE, the pname:image must: be created with a 1262e5c31af7Sopenharmony_ci slink:VkBufferCollectionImageCreateInfoFUCHSIA structure chained to its 1263e5c31af7Sopenharmony_ci slink:VkImageCreateInfo::pname:pNext pointer 1264e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-buffer-06385]] 1265e5c31af7Sopenharmony_ci If the parameters define an import operation from an 1266e5c31af7Sopenharmony_ci slink:VkBufferCollectionFUCHSIA and 1267e5c31af7Sopenharmony_ci slink:VkMemoryDedicatedAllocateInfo::pname:buffer is not 1268e5c31af7Sopenharmony_ci dlink:VK_NULL_HANDLE, the pname:buffer must: be created with a 1269e5c31af7Sopenharmony_ci slink:VkBufferCollectionBufferCreateInfoFUCHSIA structure chained to its 1270e5c31af7Sopenharmony_ci slink:VkBufferCreateInfo::pname:pNext pointer 1271e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-memoryTypeIndex-06386]] 1272e5c31af7Sopenharmony_ci If the parameters define an import operation from an 1273e5c31af7Sopenharmony_ci slink:VkBufferCollectionFUCHSIA, pname:memoryTypeIndex must: be from 1274e5c31af7Sopenharmony_ci slink:VkBufferCollectionPropertiesFUCHSIA as retrieved by 1275e5c31af7Sopenharmony_ci flink:vkGetBufferCollectionPropertiesFUCHSIA. 1276e5c31af7Sopenharmony_ciendif::VK_FUCHSIA_buffer_collection[] 1277e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory[] 1278e5c31af7Sopenharmony_ciifdef::VK_KHR_dedicated_allocation,VK_NV_dedicated_allocation[] 1279e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-pNext-00639]] 1280e5c31af7Sopenharmony_ci If the pname:pNext chain includes a sname:VkExportMemoryAllocateInfo 1281e5c31af7Sopenharmony_ci structure, and any of the handle types specified in 1282e5c31af7Sopenharmony_ci sname:VkExportMemoryAllocateInfo::pname:handleTypes require a dedicated 1283e5c31af7Sopenharmony_ci allocation, as reported by 1284e5c31af7Sopenharmony_ci flink:vkGetPhysicalDeviceImageFormatProperties2 in 1285e5c31af7Sopenharmony_ci sname:VkExternalImageFormatProperties::pname:externalMemoryProperties.externalMemoryFeatures 1286e5c31af7Sopenharmony_ci or 1287e5c31af7Sopenharmony_ci sname:VkExternalBufferProperties::pname:externalMemoryProperties.externalMemoryFeatures, 1288e5c31af7Sopenharmony_ci the pname:pNext chain must: include a 1289e5c31af7Sopenharmony_ci sname:VkMemoryDedicatedAllocateInfo or 1290e5c31af7Sopenharmony_ci sname:VkDedicatedAllocationMemoryAllocateInfoNV structure with either 1291e5c31af7Sopenharmony_ci its pname:image or pname:buffer member set to a value other than 1292e5c31af7Sopenharmony_ci dlink:VK_NULL_HANDLE 1293e5c31af7Sopenharmony_ciendif::VK_KHR_dedicated_allocation,VK_NV_dedicated_allocation[] 1294e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory[] 1295e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory[] 1296e5c31af7Sopenharmony_ciifdef::VK_NV_external_memory[] 1297e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-pNext-00640]] 1298e5c31af7Sopenharmony_ci If the pname:pNext chain includes a slink:VkExportMemoryAllocateInfo 1299e5c31af7Sopenharmony_ci structure, it must: not include a slink:VkExportMemoryAllocateInfoNV or 1300e5c31af7Sopenharmony_ci slink:VkExportMemoryWin32HandleInfoNV structure 1301e5c31af7Sopenharmony_ciendif::VK_NV_external_memory[] 1302e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory[] 1303e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory_win32+VK_NV_external_memory_win32[] 1304e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-pNext-00641]] 1305e5c31af7Sopenharmony_ci If the pname:pNext chain includes a 1306e5c31af7Sopenharmony_ci slink:VkImportMemoryWin32HandleInfoKHR structure, it must: not include a 1307e5c31af7Sopenharmony_ci slink:VkImportMemoryWin32HandleInfoNV structure 1308e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory_win32+VK_NV_external_memory_win32[] 1309e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory_fd[] 1310e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-allocationSize-01742]] 1311e5c31af7Sopenharmony_ci If the parameters define an import operation, the external handle 1312e5c31af7Sopenharmony_ci specified was created by the Vulkan API, and the external handle type is 1313e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT, then the values of 1314e5c31af7Sopenharmony_ci pname:allocationSize and pname:memoryTypeIndex must: match those 1315e5c31af7Sopenharmony_ci specified when the payload being imported was created 1316e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory_fd[] 1317e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory+VK_KHR_device_group[] 1318e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-None-00643]] 1319e5c31af7Sopenharmony_ci If the parameters define an import operation and the external handle 1320e5c31af7Sopenharmony_ci specified was created by the Vulkan API, the device mask specified by 1321e5c31af7Sopenharmony_ci slink:VkMemoryAllocateFlagsInfo must: match the mask specified when the 1322e5c31af7Sopenharmony_ci payload being imported was allocated 1323e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-None-00644]] 1324e5c31af7Sopenharmony_ci If the parameters define an import operation and the external handle 1325e5c31af7Sopenharmony_ci specified was created by the Vulkan API, the list of physical devices 1326e5c31af7Sopenharmony_ci that comprise the logical device passed to flink:vkAllocateMemory must: 1327e5c31af7Sopenharmony_ci match the list of physical devices that comprise the logical device on 1328e5c31af7Sopenharmony_ci which the payload was originally allocated 1329e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory+VK_KHR_device_group[] 1330e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory_win32[] 1331e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-memoryTypeIndex-00645]] 1332e5c31af7Sopenharmony_ci If the parameters define an import operation and the external handle is 1333e5c31af7Sopenharmony_ci an NT handle or a global share handle created outside of the Vulkan API, 1334e5c31af7Sopenharmony_ci the value of pname:memoryTypeIndex must: be one of those returned by 1335e5c31af7Sopenharmony_ci flink:vkGetMemoryWin32HandlePropertiesKHR 1336e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-allocationSize-01743]] 1337e5c31af7Sopenharmony_ci If the parameters define an import operation, the external handle was 1338e5c31af7Sopenharmony_ci created by the Vulkan API, and the external handle type is 1339e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT or 1340e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, then the 1341e5c31af7Sopenharmony_ci values of pname:allocationSize and pname:memoryTypeIndex must: match 1342e5c31af7Sopenharmony_ci those specified when the payload being imported was created 1343e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-allocationSize-00647]] 1344e5c31af7Sopenharmony_ci If the parameters define an import operation and the external handle 1345e5c31af7Sopenharmony_ci type is ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT, 1346e5c31af7Sopenharmony_ci pname:allocationSize must: match the size specified when creating the 1347e5c31af7Sopenharmony_ci Direct3D 12 heap from which the payload was extracted 1348e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory_win32[] 1349e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory_fd[] 1350e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-memoryTypeIndex-00648]] 1351e5c31af7Sopenharmony_ci If the parameters define an import operation and the external handle is 1352e5c31af7Sopenharmony_ci a POSIX file descriptor created outside of the Vulkan API, the value of 1353e5c31af7Sopenharmony_ci pname:memoryTypeIndex must: be one of those returned by 1354e5c31af7Sopenharmony_ci flink:vkGetMemoryFdPropertiesKHR 1355e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory_fd[] 1356e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[] 1357e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-memoryTypeIndex-01872]] 1358e5c31af7Sopenharmony_ci If the protected memory feature is not enabled, the 1359e5c31af7Sopenharmony_ci sname:VkMemoryAllocateInfo::pname:memoryTypeIndex must: not indicate a 1360e5c31af7Sopenharmony_ci memory type that reports ename:VK_MEMORY_PROPERTY_PROTECTED_BIT 1361e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[] 1362e5c31af7Sopenharmony_ciifdef::VK_EXT_external_memory_host[] 1363e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-memoryTypeIndex-01744]] 1364e5c31af7Sopenharmony_ci If the parameters define an import operation and the external handle is 1365e5c31af7Sopenharmony_ci a host pointer, the value of pname:memoryTypeIndex must: be one of those 1366e5c31af7Sopenharmony_ci returned by flink:vkGetMemoryHostPointerPropertiesEXT 1367e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-allocationSize-01745]] 1368e5c31af7Sopenharmony_ci If the parameters define an import operation and the external handle is 1369e5c31af7Sopenharmony_ci a host pointer, pname:allocationSize must: be an integer multiple of 1370e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceExternalMemoryHostPropertiesEXT::pname:minImportedHostPointerAlignment 1371e5c31af7Sopenharmony_ciifdef::VK_NV_dedicated_allocation[] 1372e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-pNext-02805]] 1373e5c31af7Sopenharmony_ci If the parameters define an import operation and the external handle is 1374e5c31af7Sopenharmony_ci a host pointer, the pname:pNext chain must: not include a 1375e5c31af7Sopenharmony_ci slink:VkDedicatedAllocationMemoryAllocateInfoNV structure with either 1376e5c31af7Sopenharmony_ci its pname:image or pname:buffer field set to a value other than 1377e5c31af7Sopenharmony_ci dlink:VK_NULL_HANDLE 1378e5c31af7Sopenharmony_ciendif::VK_NV_dedicated_allocation[] 1379e5c31af7Sopenharmony_ciifdef::VK_KHR_dedicated_allocation[] 1380e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-pNext-02806]] 1381e5c31af7Sopenharmony_ci If the parameters define an import operation and the external handle is 1382e5c31af7Sopenharmony_ci a host pointer, the pname:pNext chain must: not include a 1383e5c31af7Sopenharmony_ci slink:VkMemoryDedicatedAllocateInfo structure with either its 1384e5c31af7Sopenharmony_ci pname:image or pname:buffer field set to a value other than 1385e5c31af7Sopenharmony_ci dlink:VK_NULL_HANDLE 1386e5c31af7Sopenharmony_ciendif::VK_KHR_dedicated_allocation[] 1387e5c31af7Sopenharmony_ciendif::VK_EXT_external_memory_host[] 1388e5c31af7Sopenharmony_ciifdef::VK_ANDROID_external_memory_android_hardware_buffer[] 1389e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-allocationSize-02383]] 1390e5c31af7Sopenharmony_ci If the parameters define an import operation and the external handle 1391e5c31af7Sopenharmony_ci type is 1392e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID, 1393e5c31af7Sopenharmony_ci pname:allocationSize must: be the size returned by 1394e5c31af7Sopenharmony_ci flink:vkGetAndroidHardwareBufferPropertiesANDROID for the Android 1395e5c31af7Sopenharmony_ci hardware buffer 1396e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-pNext-02384]] 1397e5c31af7Sopenharmony_ci If the parameters define an import operation and the external handle 1398e5c31af7Sopenharmony_ci type is 1399e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID, 1400e5c31af7Sopenharmony_ci and the pname:pNext chain does not include a 1401e5c31af7Sopenharmony_ci slink:VkMemoryDedicatedAllocateInfo structure or 1402e5c31af7Sopenharmony_ci slink:VkMemoryDedicatedAllocateInfo::pname:image is 1403e5c31af7Sopenharmony_ci dlink:VK_NULL_HANDLE, the Android hardware buffer must: have a 1404e5c31af7Sopenharmony_ci code:AHardwareBuffer_Desc::code:format of 1405e5c31af7Sopenharmony_ci code:AHARDWAREBUFFER_FORMAT_BLOB and a 1406e5c31af7Sopenharmony_ci code:AHardwareBuffer_Desc::code:usage that includes 1407e5c31af7Sopenharmony_ci code:AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER 1408e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-memoryTypeIndex-02385]] 1409e5c31af7Sopenharmony_ci If the parameters define an import operation and the external handle 1410e5c31af7Sopenharmony_ci type is 1411e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID, 1412e5c31af7Sopenharmony_ci pname:memoryTypeIndex must: be one of those returned by 1413e5c31af7Sopenharmony_ci flink:vkGetAndroidHardwareBufferPropertiesANDROID for the Android 1414e5c31af7Sopenharmony_ci hardware buffer 1415e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-pNext-01874]] 1416e5c31af7Sopenharmony_ci If the parameters do not define an import operation, and the pname:pNext 1417e5c31af7Sopenharmony_ci chain includes a sname:VkExportMemoryAllocateInfo structure with 1418e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID 1419e5c31af7Sopenharmony_ci included in its pname:handleTypes member, and the pname:pNext chain 1420e5c31af7Sopenharmony_ci includes a slink:VkMemoryDedicatedAllocateInfo structure with 1421e5c31af7Sopenharmony_ci pname:image not equal to dlink:VK_NULL_HANDLE, then pname:allocationSize 1422e5c31af7Sopenharmony_ci must: be `0`, otherwise pname:allocationSize must: be greater than `0` 1423e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-pNext-02386]] 1424e5c31af7Sopenharmony_ci If the parameters define an import operation, the external handle is an 1425e5c31af7Sopenharmony_ci Android hardware buffer, and the pname:pNext chain includes a 1426e5c31af7Sopenharmony_ci slink:VkMemoryDedicatedAllocateInfo with pname:image that is not 1427e5c31af7Sopenharmony_ci dlink:VK_NULL_HANDLE, the Android hardware buffer's 1428e5c31af7Sopenharmony_ci basetype:AHardwareBuffer::code:usage must: include at least one of 1429e5c31af7Sopenharmony_ci code:AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER or 1430e5c31af7Sopenharmony_ci code:AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE 1431e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-pNext-02387]] 1432e5c31af7Sopenharmony_ci If the parameters define an import operation, the external handle is an 1433e5c31af7Sopenharmony_ci Android hardware buffer, and the pname:pNext chain includes a 1434e5c31af7Sopenharmony_ci slink:VkMemoryDedicatedAllocateInfo with pname:image that is not 1435e5c31af7Sopenharmony_ci dlink:VK_NULL_HANDLE, the format of pname:image must: be 1436e5c31af7Sopenharmony_ci ename:VK_FORMAT_UNDEFINED or the format returned by 1437e5c31af7Sopenharmony_ci flink:vkGetAndroidHardwareBufferPropertiesANDROID in 1438e5c31af7Sopenharmony_ci slink:VkAndroidHardwareBufferFormatPropertiesANDROID::pname:format for 1439e5c31af7Sopenharmony_ci the Android hardware buffer 1440e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-pNext-02388]] 1441e5c31af7Sopenharmony_ci If the parameters define an import operation, the external handle is an 1442e5c31af7Sopenharmony_ci Android hardware buffer, and the pname:pNext chain includes a 1443e5c31af7Sopenharmony_ci slink:VkMemoryDedicatedAllocateInfo structure with pname:image that is 1444e5c31af7Sopenharmony_ci not dlink:VK_NULL_HANDLE, the width, height, and array layer dimensions 1445e5c31af7Sopenharmony_ci of pname:image and the Android hardware buffer's 1446e5c31af7Sopenharmony_ci code:AHardwareBuffer_Desc must: be identical 1447e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-pNext-02389]] 1448e5c31af7Sopenharmony_ci If the parameters define an import operation, the external handle is an 1449e5c31af7Sopenharmony_ci Android hardware buffer, and the pname:pNext chain includes a 1450e5c31af7Sopenharmony_ci slink:VkMemoryDedicatedAllocateInfo structure with pname:image that is 1451e5c31af7Sopenharmony_ci not dlink:VK_NULL_HANDLE, and the Android hardware buffer's 1452e5c31af7Sopenharmony_ci basetype:AHardwareBuffer::code:usage includes 1453e5c31af7Sopenharmony_ci code:AHARDWAREBUFFER_USAGE_GPU_MIPMAP_COMPLETE, the pname:image must: 1454e5c31af7Sopenharmony_ci have a complete mipmap chain 1455e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-pNext-02586]] 1456e5c31af7Sopenharmony_ci If the parameters define an import operation, the external handle is an 1457e5c31af7Sopenharmony_ci Android hardware buffer, and the pname:pNext chain includes a 1458e5c31af7Sopenharmony_ci slink:VkMemoryDedicatedAllocateInfo structure with pname:image that is 1459e5c31af7Sopenharmony_ci not dlink:VK_NULL_HANDLE, and the Android hardware buffer's 1460e5c31af7Sopenharmony_ci basetype:AHardwareBuffer::code:usage does not include 1461e5c31af7Sopenharmony_ci code:AHARDWAREBUFFER_USAGE_GPU_MIPMAP_COMPLETE, the pname:image must: 1462e5c31af7Sopenharmony_ci have exactly one mipmap level 1463e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-pNext-02390]] 1464e5c31af7Sopenharmony_ci If the parameters define an import operation, the external handle is an 1465e5c31af7Sopenharmony_ci Android hardware buffer, and the pname:pNext chain includes a 1466e5c31af7Sopenharmony_ci slink:VkMemoryDedicatedAllocateInfo structure with pname:image that is 1467e5c31af7Sopenharmony_ci not dlink:VK_NULL_HANDLE, each bit set in the usage of pname:image must: 1468e5c31af7Sopenharmony_ci be listed in 1469e5c31af7Sopenharmony_ci <<memory-external-android-hardware-buffer-usage,AHardwareBuffer Usage 1470e5c31af7Sopenharmony_ci Equivalence>>, and if there is a corresponding 1471e5c31af7Sopenharmony_ci code:AHARDWAREBUFFER_USAGE bit listed that bit must: be included in the 1472e5c31af7Sopenharmony_ci Android hardware buffer's code:AHardwareBuffer_Desc::code:usage 1473e5c31af7Sopenharmony_ciendif::VK_ANDROID_external_memory_android_hardware_buffer[] 1474e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_KHR_buffer_device_address[] 1475e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329]] 1476e5c31af7Sopenharmony_ci If 1477e5c31af7Sopenharmony_ci slink:VkMemoryOpaqueCaptureAddressAllocateInfo::pname:opaqueCaptureAddress 1478e5c31af7Sopenharmony_ci is not zero, sname:VkMemoryAllocateFlagsInfo::pname:flags must: include 1479e5c31af7Sopenharmony_ci ename:VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT 1480e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-flags-03330]] 1481e5c31af7Sopenharmony_ci If sname:VkMemoryAllocateFlagsInfo::pname:flags includes 1482e5c31af7Sopenharmony_ci ename:VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT, the 1483e5c31af7Sopenharmony_ci <<features-bufferDeviceAddressCaptureReplay,bufferDeviceAddressCaptureReplay>> 1484e5c31af7Sopenharmony_ci feature must: be enabled 1485e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-flags-03331]] 1486e5c31af7Sopenharmony_ci If sname:VkMemoryAllocateFlagsInfo::pname:flags includes 1487e5c31af7Sopenharmony_ci ename:VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT, the 1488e5c31af7Sopenharmony_ci <<features-bufferDeviceAddress,bufferDeviceAddress>> feature must: be 1489e5c31af7Sopenharmony_ci enabled 1490e5c31af7Sopenharmony_ciifdef::VK_EXT_external_memory_host[] 1491e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-pNext-03332]] 1492e5c31af7Sopenharmony_ci If the pname:pNext chain includes a 1493e5c31af7Sopenharmony_ci sname:VkImportMemoryHostPointerInfoEXT structure, 1494e5c31af7Sopenharmony_ci slink:VkMemoryOpaqueCaptureAddressAllocateInfo::pname:opaqueCaptureAddress 1495e5c31af7Sopenharmony_ci must: be zero 1496e5c31af7Sopenharmony_ciendif::VK_EXT_external_memory_host[] 1497e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333]] 1498e5c31af7Sopenharmony_ci If the parameters define an import operation, 1499e5c31af7Sopenharmony_ci slink:VkMemoryOpaqueCaptureAddressAllocateInfo::pname:opaqueCaptureAddress 1500e5c31af7Sopenharmony_ci must: be zero 1501e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_KHR_buffer_device_address[] 1502e5c31af7Sopenharmony_ciifdef::VK_FUCHSIA_external_memory[] 1503e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-None-04749]] 1504e5c31af7Sopenharmony_ci If the parameters define an import operation and the external handle 1505e5c31af7Sopenharmony_ci type is ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VMO_BIT_FUCHSIA, the 1506e5c31af7Sopenharmony_ci value of sname:memoryTypeIndex must: be an index identifying a memory 1507e5c31af7Sopenharmony_ci type from the sname:memoryTypeBits field of the 1508e5c31af7Sopenharmony_ci slink:VkMemoryZirconHandlePropertiesFUCHSIA structure populated by a 1509e5c31af7Sopenharmony_ci call to flink:vkGetMemoryZirconHandlePropertiesFUCHSIA 1510e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateInfo-allocationSize-04750]] 1511e5c31af7Sopenharmony_ci If the parameters define an import operation and the external handle 1512e5c31af7Sopenharmony_ci type is ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VMO_BIT_FUCHSIA, the 1513e5c31af7Sopenharmony_ci value of pname:allocationSize must: be greater than `0` and must: be 1514e5c31af7Sopenharmony_ci less than or equal to the size of the VMO as determined by 1515e5c31af7Sopenharmony_ci code:zx_vmo_get_size(pname:handle) where pname:handle is the VMO handle 1516e5c31af7Sopenharmony_ci to the imported external memory 1517e5c31af7Sopenharmony_ciendif::VK_FUCHSIA_external_memory[] 1518e5c31af7Sopenharmony_ci**** 1519e5c31af7Sopenharmony_ci 1520e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkMemoryAllocateInfo.txt[] 1521e5c31af7Sopenharmony_ci-- 1522e5c31af7Sopenharmony_ci 1523e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_dedicated_allocation[] 1524e5c31af7Sopenharmony_ci[open,refpage='VkMemoryDedicatedAllocateInfo',desc='Specify a dedicated memory allocation resource',type='structs'] 1525e5c31af7Sopenharmony_ci-- 1526e5c31af7Sopenharmony_ciIf the pname:pNext chain includes a sname:VkMemoryDedicatedAllocateInfo 1527e5c31af7Sopenharmony_cistructure, then that structure includes a handle of the sole buffer or image 1528e5c31af7Sopenharmony_ciresource that the memory can: be bound to. 1529e5c31af7Sopenharmony_ci 1530e5c31af7Sopenharmony_ciThe sname:VkMemoryDedicatedAllocateInfo structure is defined as: 1531e5c31af7Sopenharmony_ci 1532e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkMemoryDedicatedAllocateInfo.txt[] 1533e5c31af7Sopenharmony_ci 1534e5c31af7Sopenharmony_ciifdef::VK_KHR_dedicated_allocation[] 1535e5c31af7Sopenharmony_cior the equivalent 1536e5c31af7Sopenharmony_ci 1537e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkMemoryDedicatedAllocateInfoKHR.txt[] 1538e5c31af7Sopenharmony_ciendif::VK_KHR_dedicated_allocation[] 1539e5c31af7Sopenharmony_ci 1540e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 1541e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 1542e5c31af7Sopenharmony_ci structure. 1543e5c31af7Sopenharmony_ci * pname:image is dlink:VK_NULL_HANDLE or a handle of an image which this 1544e5c31af7Sopenharmony_ci memory will be bound to. 1545e5c31af7Sopenharmony_ci * pname:buffer is dlink:VK_NULL_HANDLE or a handle of a buffer which this 1546e5c31af7Sopenharmony_ci memory will be bound to. 1547e5c31af7Sopenharmony_ci 1548e5c31af7Sopenharmony_ci.Valid Usage 1549e5c31af7Sopenharmony_ci**** 1550e5c31af7Sopenharmony_ci * [[VUID-VkMemoryDedicatedAllocateInfo-image-01432]] 1551e5c31af7Sopenharmony_ci At least one of pname:image and pname:buffer must: be 1552e5c31af7Sopenharmony_ci dlink:VK_NULL_HANDLE 1553e5c31af7Sopenharmony_ciifndef::VK_ANDROID_external_memory_android_hardware_buffer[] 1554e5c31af7Sopenharmony_ci * [[VUID-VkMemoryDedicatedAllocateInfo-image-01433]] 1555e5c31af7Sopenharmony_ci If pname:image is not dlink:VK_NULL_HANDLE, 1556e5c31af7Sopenharmony_ci sname:VkMemoryAllocateInfo::pname:allocationSize must: equal the 1557e5c31af7Sopenharmony_ci sname:VkMemoryRequirements::pname:size of the image 1558e5c31af7Sopenharmony_ciendif::VK_ANDROID_external_memory_android_hardware_buffer[] 1559e5c31af7Sopenharmony_ciifdef::VK_ANDROID_external_memory_android_hardware_buffer[] 1560e5c31af7Sopenharmony_ci * [[VUID-VkMemoryDedicatedAllocateInfo-image-02964]] 1561e5c31af7Sopenharmony_ci If pname:image is not dlink:VK_NULL_HANDLE and the memory is not an 1562e5c31af7Sopenharmony_ci imported Android Hardware Buffer, 1563e5c31af7Sopenharmony_ci sname:VkMemoryAllocateInfo::pname:allocationSize must: equal the 1564e5c31af7Sopenharmony_ci sname:VkMemoryRequirements::pname:size of the image 1565e5c31af7Sopenharmony_ciendif::VK_ANDROID_external_memory_android_hardware_buffer[] 1566e5c31af7Sopenharmony_ci * [[VUID-VkMemoryDedicatedAllocateInfo-image-01434]] 1567e5c31af7Sopenharmony_ci If pname:image is not dlink:VK_NULL_HANDLE, pname:image must: have been 1568e5c31af7Sopenharmony_ci created without ename:VK_IMAGE_CREATE_SPARSE_BINDING_BIT set in 1569e5c31af7Sopenharmony_ci slink:VkImageCreateInfo::pname:flags 1570e5c31af7Sopenharmony_ciifndef::VK_ANDROID_external_memory_android_hardware_buffer[] 1571e5c31af7Sopenharmony_ci * [[VUID-VkMemoryDedicatedAllocateInfo-buffer-01435]] 1572e5c31af7Sopenharmony_ci If pname:buffer is not dlink:VK_NULL_HANDLE, 1573e5c31af7Sopenharmony_ci sname:VkMemoryAllocateInfo::pname:allocationSize must: equal the 1574e5c31af7Sopenharmony_ci sname:VkMemoryRequirements::pname:size of the buffer 1575e5c31af7Sopenharmony_ciendif::VK_ANDROID_external_memory_android_hardware_buffer[] 1576e5c31af7Sopenharmony_ciifdef::VK_ANDROID_external_memory_android_hardware_buffer[] 1577e5c31af7Sopenharmony_ci * [[VUID-VkMemoryDedicatedAllocateInfo-buffer-02965]] 1578e5c31af7Sopenharmony_ci If pname:buffer is not dlink:VK_NULL_HANDLE and the memory is not an 1579e5c31af7Sopenharmony_ci imported Android Hardware Buffer, 1580e5c31af7Sopenharmony_ci sname:VkMemoryAllocateInfo::pname:allocationSize must: equal the 1581e5c31af7Sopenharmony_ci sname:VkMemoryRequirements::pname:size of the buffer 1582e5c31af7Sopenharmony_ciendif::VK_ANDROID_external_memory_android_hardware_buffer[] 1583e5c31af7Sopenharmony_ci * [[VUID-VkMemoryDedicatedAllocateInfo-buffer-01436]] 1584e5c31af7Sopenharmony_ci If pname:buffer is not dlink:VK_NULL_HANDLE, pname:buffer must: have 1585e5c31af7Sopenharmony_ci been created without ename:VK_BUFFER_CREATE_SPARSE_BINDING_BIT set in 1586e5c31af7Sopenharmony_ci slink:VkBufferCreateInfo::pname:flags 1587e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory_win32[] 1588e5c31af7Sopenharmony_ci * [[VUID-VkMemoryDedicatedAllocateInfo-image-01876]] 1589e5c31af7Sopenharmony_ci If pname:image is not dlink:VK_NULL_HANDLE and 1590e5c31af7Sopenharmony_ci slink:VkMemoryAllocateInfo defines a memory import operation with handle 1591e5c31af7Sopenharmony_ci type ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT, 1592e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, 1593e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT, 1594e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_KMT_BIT, 1595e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT, or 1596e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT, and the 1597e5c31af7Sopenharmony_ci external handle was created by the Vulkan API, then the memory being 1598e5c31af7Sopenharmony_ci imported must: also be a dedicated image allocation and pname:image must 1599e5c31af7Sopenharmony_ci be identical to the image associated with the imported memory 1600e5c31af7Sopenharmony_ci * [[VUID-VkMemoryDedicatedAllocateInfo-buffer-01877]] 1601e5c31af7Sopenharmony_ci If pname:buffer is not dlink:VK_NULL_HANDLE and 1602e5c31af7Sopenharmony_ci slink:VkMemoryAllocateInfo defines a memory import operation with handle 1603e5c31af7Sopenharmony_ci type ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT, 1604e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, 1605e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT, 1606e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_KMT_BIT, 1607e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT, or 1608e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT, and the 1609e5c31af7Sopenharmony_ci external handle was created by the Vulkan API, then the memory being 1610e5c31af7Sopenharmony_ci imported must: also be a dedicated buffer allocation and pname:buffer 1611e5c31af7Sopenharmony_ci must: be identical to the buffer associated with the imported memory 1612e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory_win32[] 1613e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory_fd[] 1614e5c31af7Sopenharmony_ci * [[VUID-VkMemoryDedicatedAllocateInfo-image-01878]] 1615e5c31af7Sopenharmony_ci If pname:image is not dlink:VK_NULL_HANDLE and 1616e5c31af7Sopenharmony_ci slink:VkMemoryAllocateInfo defines a memory import operation with handle 1617e5c31af7Sopenharmony_ci type ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT, the memory 1618e5c31af7Sopenharmony_ci being imported must: also be a dedicated image allocation and 1619e5c31af7Sopenharmony_ci pname:image must: be identical to the image associated with the imported 1620e5c31af7Sopenharmony_ci memory 1621e5c31af7Sopenharmony_ci * [[VUID-VkMemoryDedicatedAllocateInfo-buffer-01879]] 1622e5c31af7Sopenharmony_ci If pname:buffer is not dlink:VK_NULL_HANDLE and 1623e5c31af7Sopenharmony_ci slink:VkMemoryAllocateInfo defines a memory import operation with handle 1624e5c31af7Sopenharmony_ci type ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT, the memory 1625e5c31af7Sopenharmony_ci being imported must: also be a dedicated buffer allocation and 1626e5c31af7Sopenharmony_ci pname:buffer must: be identical to the buffer associated with the 1627e5c31af7Sopenharmony_ci imported memory 1628e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory_fd[] 1629e5c31af7Sopenharmony_ciifdef::VK_KHR_sampler_ycbcr_conversion[] 1630e5c31af7Sopenharmony_ci * [[VUID-VkMemoryDedicatedAllocateInfo-image-01797]] 1631e5c31af7Sopenharmony_ci If pname:image is not dlink:VK_NULL_HANDLE, pname:image must: not have 1632e5c31af7Sopenharmony_ci been created with ename:VK_IMAGE_CREATE_DISJOINT_BIT set in 1633e5c31af7Sopenharmony_ci slink:VkImageCreateInfo::pname:flags 1634e5c31af7Sopenharmony_ciendif::VK_KHR_sampler_ycbcr_conversion[] 1635e5c31af7Sopenharmony_ciifdef::VK_FUCHSIA_external_memory[] 1636e5c31af7Sopenharmony_ci * [[VUID-VkMemoryDedicatedAllocateInfo-image-04751]] 1637e5c31af7Sopenharmony_ci If pname:image is not dlink:VK_NULL_HANDLE and 1638e5c31af7Sopenharmony_ci slink:VkMemoryAllocateInfo defines a memory import operation with handle 1639e5c31af7Sopenharmony_ci type ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VMO_BIT_FUCHSIA, the 1640e5c31af7Sopenharmony_ci memory being imported must: also be a dedicated image allocation and 1641e5c31af7Sopenharmony_ci pname:image must: be identical to the image associated with the imported 1642e5c31af7Sopenharmony_ci memory 1643e5c31af7Sopenharmony_ci * [[VUID-VkMemoryDedicatedAllocateInfo-buffer-04752]] 1644e5c31af7Sopenharmony_ci If pname:buffer is not dlink:VK_NULL_HANDLE and 1645e5c31af7Sopenharmony_ci slink:VkMemoryAllocateInfo defines a memory import operation with handle 1646e5c31af7Sopenharmony_ci type ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VMO_BIT_FUCHSIA, the 1647e5c31af7Sopenharmony_ci memory being imported must: also be a dedicated buffer allocation and 1648e5c31af7Sopenharmony_ci pname:buffer must: be identical to the buffer associated with the 1649e5c31af7Sopenharmony_ci imported memory 1650e5c31af7Sopenharmony_ciendif::VK_FUCHSIA_external_memory[] 1651e5c31af7Sopenharmony_ci**** 1652e5c31af7Sopenharmony_ci 1653e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkMemoryDedicatedAllocateInfo.txt[] 1654e5c31af7Sopenharmony_ci-- 1655e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_dedicated_allocation[] 1656e5c31af7Sopenharmony_ci 1657e5c31af7Sopenharmony_ciifdef::VK_NV_dedicated_allocation[] 1658e5c31af7Sopenharmony_ci[open,refpage='VkDedicatedAllocationMemoryAllocateInfoNV',desc='Specify a dedicated memory allocation resource',type='structs'] 1659e5c31af7Sopenharmony_ci-- 1660e5c31af7Sopenharmony_ciIf the pname:pNext chain includes a 1661e5c31af7Sopenharmony_cisname:VkDedicatedAllocationMemoryAllocateInfoNV structure, then that 1662e5c31af7Sopenharmony_cistructure includes a handle of the sole buffer or image resource that the 1663e5c31af7Sopenharmony_cimemory can: be bound to. 1664e5c31af7Sopenharmony_ci 1665e5c31af7Sopenharmony_ciThe sname:VkDedicatedAllocationMemoryAllocateInfoNV structure is defined as: 1666e5c31af7Sopenharmony_ci 1667e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkDedicatedAllocationMemoryAllocateInfoNV.txt[] 1668e5c31af7Sopenharmony_ci 1669e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 1670e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 1671e5c31af7Sopenharmony_ci structure. 1672e5c31af7Sopenharmony_ci * pname:image is dlink:VK_NULL_HANDLE or a handle of an image which this 1673e5c31af7Sopenharmony_ci memory will be bound to. 1674e5c31af7Sopenharmony_ci * pname:buffer is dlink:VK_NULL_HANDLE or a handle of a buffer which this 1675e5c31af7Sopenharmony_ci memory will be bound to. 1676e5c31af7Sopenharmony_ci 1677e5c31af7Sopenharmony_ci.Valid Usage 1678e5c31af7Sopenharmony_ci**** 1679e5c31af7Sopenharmony_ci * [[VUID-VkDedicatedAllocationMemoryAllocateInfoNV-image-00649]] 1680e5c31af7Sopenharmony_ci At least one of pname:image and pname:buffer must: be 1681e5c31af7Sopenharmony_ci dlink:VK_NULL_HANDLE 1682e5c31af7Sopenharmony_ci * [[VUID-VkDedicatedAllocationMemoryAllocateInfoNV-image-00650]] 1683e5c31af7Sopenharmony_ci If pname:image is not dlink:VK_NULL_HANDLE, the image must: have been 1684e5c31af7Sopenharmony_ci created with 1685e5c31af7Sopenharmony_ci slink:VkDedicatedAllocationImageCreateInfoNV::pname:dedicatedAllocation 1686e5c31af7Sopenharmony_ci equal to ename:VK_TRUE 1687e5c31af7Sopenharmony_ci * [[VUID-VkDedicatedAllocationMemoryAllocateInfoNV-buffer-00651]] 1688e5c31af7Sopenharmony_ci If pname:buffer is not dlink:VK_NULL_HANDLE, the buffer must: have been 1689e5c31af7Sopenharmony_ci created with 1690e5c31af7Sopenharmony_ci slink:VkDedicatedAllocationBufferCreateInfoNV::pname:dedicatedAllocation 1691e5c31af7Sopenharmony_ci equal to ename:VK_TRUE 1692e5c31af7Sopenharmony_ci * [[VUID-VkDedicatedAllocationMemoryAllocateInfoNV-image-00652]] 1693e5c31af7Sopenharmony_ci If pname:image is not dlink:VK_NULL_HANDLE, 1694e5c31af7Sopenharmony_ci sname:VkMemoryAllocateInfo::pname:allocationSize must: equal the 1695e5c31af7Sopenharmony_ci sname:VkMemoryRequirements::pname:size of the image 1696e5c31af7Sopenharmony_ci * [[VUID-VkDedicatedAllocationMemoryAllocateInfoNV-buffer-00653]] 1697e5c31af7Sopenharmony_ci If pname:buffer is not dlink:VK_NULL_HANDLE, 1698e5c31af7Sopenharmony_ci sname:VkMemoryAllocateInfo::pname:allocationSize must: equal the 1699e5c31af7Sopenharmony_ci sname:VkMemoryRequirements::pname:size of the buffer 1700e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory_win32,VK_KHR_external_memory_fd[] 1701e5c31af7Sopenharmony_ci * [[VUID-VkDedicatedAllocationMemoryAllocateInfoNV-image-00654]] 1702e5c31af7Sopenharmony_ci If pname:image is not dlink:VK_NULL_HANDLE and 1703e5c31af7Sopenharmony_ci slink:VkMemoryAllocateInfo defines a memory import operation, the memory 1704e5c31af7Sopenharmony_ci being imported must: also be a dedicated image allocation and 1705e5c31af7Sopenharmony_ci pname:image must: be identical to the image associated with the imported 1706e5c31af7Sopenharmony_ci memory 1707e5c31af7Sopenharmony_ci * [[VUID-VkDedicatedAllocationMemoryAllocateInfoNV-buffer-00655]] 1708e5c31af7Sopenharmony_ci If pname:buffer is not dlink:VK_NULL_HANDLE and 1709e5c31af7Sopenharmony_ci slink:VkMemoryAllocateInfo defines a memory import operation, the memory 1710e5c31af7Sopenharmony_ci being imported must: also be a dedicated buffer allocation and 1711e5c31af7Sopenharmony_ci pname:buffer must: be identical to the buffer associated with the 1712e5c31af7Sopenharmony_ci imported memory 1713e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory_win32,VK_KHR_external_memory_fd[] 1714e5c31af7Sopenharmony_ci**** 1715e5c31af7Sopenharmony_ci 1716e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkDedicatedAllocationMemoryAllocateInfoNV.txt[] 1717e5c31af7Sopenharmony_ci-- 1718e5c31af7Sopenharmony_ciendif::VK_NV_dedicated_allocation[] 1719e5c31af7Sopenharmony_ci 1720e5c31af7Sopenharmony_ciifdef::VK_EXT_memory_priority[] 1721e5c31af7Sopenharmony_ci[open,refpage='VkMemoryPriorityAllocateInfoEXT',desc='Specify a memory allocation priority',type='structs'] 1722e5c31af7Sopenharmony_ci-- 1723e5c31af7Sopenharmony_ciIf the pname:pNext chain includes a sname:VkMemoryPriorityAllocateInfoEXT 1724e5c31af7Sopenharmony_cistructure, then that structure includes a priority for the memory. 1725e5c31af7Sopenharmony_ci 1726e5c31af7Sopenharmony_ciThe sname:VkMemoryPriorityAllocateInfoEXT structure is defined as: 1727e5c31af7Sopenharmony_ci 1728e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkMemoryPriorityAllocateInfoEXT.txt[] 1729e5c31af7Sopenharmony_ci 1730e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 1731e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 1732e5c31af7Sopenharmony_ci structure. 1733e5c31af7Sopenharmony_ci * pname:priority is a floating-point value between `0` and `1`, indicating 1734e5c31af7Sopenharmony_ci the priority of the allocation relative to other memory allocations. 1735e5c31af7Sopenharmony_ci Larger values are higher priority. 1736e5c31af7Sopenharmony_ci The granularity of the priorities is implementation-dependent. 1737e5c31af7Sopenharmony_ci 1738e5c31af7Sopenharmony_ciMemory allocations with higher priority may: be more likely to stay in 1739e5c31af7Sopenharmony_cidevice-local memory when the system is under memory pressure. 1740e5c31af7Sopenharmony_ci 1741e5c31af7Sopenharmony_ciIf this structure is not included, it is as if the pname:priority value were 1742e5c31af7Sopenharmony_ci`0.5`. 1743e5c31af7Sopenharmony_ci 1744e5c31af7Sopenharmony_ci.Valid Usage 1745e5c31af7Sopenharmony_ci**** 1746e5c31af7Sopenharmony_ci * [[VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602]] 1747e5c31af7Sopenharmony_ci pname:priority must: be between `0` and `1`, inclusive 1748e5c31af7Sopenharmony_ci**** 1749e5c31af7Sopenharmony_ci 1750e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkMemoryPriorityAllocateInfoEXT.txt[] 1751e5c31af7Sopenharmony_ci-- 1752e5c31af7Sopenharmony_ciendif::VK_EXT_memory_priority[] 1753e5c31af7Sopenharmony_ci 1754e5c31af7Sopenharmony_ciifdef::VK_EXT_pageable_device_local_memory[] 1755e5c31af7Sopenharmony_ci[open,refpage='vkSetDeviceMemoryPriorityEXT',desc='Change a memory allocation priority',type='protos'] 1756e5c31af7Sopenharmony_ci-- 1757e5c31af7Sopenharmony_ci 1758e5c31af7Sopenharmony_ciTo modify the priority of an existing memory allocation, call: 1759e5c31af7Sopenharmony_ci 1760e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkSetDeviceMemoryPriorityEXT.txt[] 1761e5c31af7Sopenharmony_ci 1762e5c31af7Sopenharmony_ci * pname:device is the logical device that owns the memory. 1763e5c31af7Sopenharmony_ci * pname:memory is the slink:VkDeviceMemory object to which the new 1764e5c31af7Sopenharmony_ci priority will be applied. 1765e5c31af7Sopenharmony_ci * pname:priority is a floating-point value between `0` and `1`, indicating 1766e5c31af7Sopenharmony_ci the priority of the allocation relative to other memory allocations. 1767e5c31af7Sopenharmony_ci Larger values are higher priority. 1768e5c31af7Sopenharmony_ci The granularity of the priorities is implementation-dependent. 1769e5c31af7Sopenharmony_ci 1770e5c31af7Sopenharmony_ciMemory allocations with higher priority may: be more likely to stay in 1771e5c31af7Sopenharmony_cidevice-local memory when the system is under memory pressure. 1772e5c31af7Sopenharmony_ci 1773e5c31af7Sopenharmony_ci.Valid Usage 1774e5c31af7Sopenharmony_ci**** 1775e5c31af7Sopenharmony_ci * [[VUID-vkSetDeviceMemoryPriorityEXT-priority-06258]] 1776e5c31af7Sopenharmony_ci pname:priority must: be between `0` and `1`, inclusive 1777e5c31af7Sopenharmony_ci**** 1778e5c31af7Sopenharmony_ci 1779e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkSetDeviceMemoryPriorityEXT.txt[] 1780e5c31af7Sopenharmony_ci-- 1781e5c31af7Sopenharmony_ciendif::VK_EXT_pageable_device_local_memory[] 1782e5c31af7Sopenharmony_ci 1783e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_external_memory[] 1784e5c31af7Sopenharmony_ci[open,refpage='VkExportMemoryAllocateInfo',desc='Specify exportable handle types for a device memory object',type='structs'] 1785e5c31af7Sopenharmony_ci-- 1786e5c31af7Sopenharmony_ciWhen allocating memory whose payload may: be exported to another process or 1787e5c31af7Sopenharmony_ciVulkan instance, add a slink:VkExportMemoryAllocateInfo structure to the 1788e5c31af7Sopenharmony_cipname:pNext chain of the slink:VkMemoryAllocateInfo structure, specifying 1789e5c31af7Sopenharmony_cithe handle types that may: be exported. 1790e5c31af7Sopenharmony_ci 1791e5c31af7Sopenharmony_ciThe slink:VkExportMemoryAllocateInfo structure is defined as: 1792e5c31af7Sopenharmony_ci 1793e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkExportMemoryAllocateInfo.txt[] 1794e5c31af7Sopenharmony_ci 1795e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory[] 1796e5c31af7Sopenharmony_cior the equivalent 1797e5c31af7Sopenharmony_ci 1798e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkExportMemoryAllocateInfoKHR.txt[] 1799e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory[] 1800e5c31af7Sopenharmony_ci 1801e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 1802e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 1803e5c31af7Sopenharmony_ci structure. 1804e5c31af7Sopenharmony_ci * pname:handleTypes is a bitmask of 1805e5c31af7Sopenharmony_ci elink:VkExternalMemoryHandleTypeFlagBits specifying one or more memory 1806e5c31af7Sopenharmony_ci handle types the application can: export from the resulting allocation. 1807e5c31af7Sopenharmony_ci The application can: request multiple handle types for the same 1808e5c31af7Sopenharmony_ci allocation. 1809e5c31af7Sopenharmony_ci 1810e5c31af7Sopenharmony_ci.Valid Usage 1811e5c31af7Sopenharmony_ci**** 1812e5c31af7Sopenharmony_ci * [[VUID-VkExportMemoryAllocateInfo-handleTypes-00656]] 1813e5c31af7Sopenharmony_ci The bits in pname:handleTypes must: be supported and compatible, as 1814e5c31af7Sopenharmony_ci reported by slink:VkExternalImageFormatProperties or 1815e5c31af7Sopenharmony_ci slink:VkExternalBufferProperties 1816e5c31af7Sopenharmony_ci**** 1817e5c31af7Sopenharmony_ci 1818e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkExportMemoryAllocateInfo.txt[] 1819e5c31af7Sopenharmony_ci-- 1820e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_external_memory[] 1821e5c31af7Sopenharmony_ci 1822e5c31af7Sopenharmony_ciifdef::VK_NV_external_memory[] 1823e5c31af7Sopenharmony_ciinclude::{chapters}/VK_NV_external_memory/allocate_memory.txt[] 1824e5c31af7Sopenharmony_ciendif::VK_NV_external_memory[] 1825e5c31af7Sopenharmony_ci 1826e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory_win32,VK_NV_external_memory_win32[] 1827e5c31af7Sopenharmony_ci=== Win32 External Memory 1828e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory_win32,VK_NV_external_memory_win32[] 1829e5c31af7Sopenharmony_ci 1830e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory_win32[] 1831e5c31af7Sopenharmony_ci[open,refpage='VkExportMemoryWin32HandleInfoKHR',desc='Structure specifying additional attributes of Windows handles exported from a memory',type='structs'] 1832e5c31af7Sopenharmony_ci-- 1833e5c31af7Sopenharmony_ciTo specify additional attributes of NT handles exported from a memory 1834e5c31af7Sopenharmony_ciobject, add a slink:VkExportMemoryWin32HandleInfoKHR structure to the 1835e5c31af7Sopenharmony_cipname:pNext chain of the slink:VkMemoryAllocateInfo structure. 1836e5c31af7Sopenharmony_ciThe sname:VkExportMemoryWin32HandleInfoKHR structure is defined as: 1837e5c31af7Sopenharmony_ci 1838e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkExportMemoryWin32HandleInfoKHR.txt[] 1839e5c31af7Sopenharmony_ci 1840e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 1841e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 1842e5c31af7Sopenharmony_ci structure. 1843e5c31af7Sopenharmony_ci * pname:pAttributes is a pointer to a Windows code:SECURITY_ATTRIBUTES 1844e5c31af7Sopenharmony_ci structure specifying security attributes of the handle. 1845e5c31af7Sopenharmony_ci * pname:dwAccess is a code:DWORD specifying access rights of the handle. 1846e5c31af7Sopenharmony_ci * pname:name is a null-terminated UTF-16 string to associate with the 1847e5c31af7Sopenharmony_ci payload referenced by NT handles exported from the created memory. 1848e5c31af7Sopenharmony_ci 1849e5c31af7Sopenharmony_ciIf slink:VkExportMemoryAllocateInfo is not included in the same pname:pNext 1850e5c31af7Sopenharmony_cichain, this structure is ignored. 1851e5c31af7Sopenharmony_ci 1852e5c31af7Sopenharmony_ciIf slink:VkExportMemoryAllocateInfo is included in the pname:pNext chain of 1853e5c31af7Sopenharmony_cislink:VkMemoryAllocateInfo with a Windows pname:handleType, but either 1854e5c31af7Sopenharmony_cisname:VkExportMemoryWin32HandleInfoKHR is not included in the pname:pNext 1855e5c31af7Sopenharmony_cichain, or if it is but pname:pAttributes is set to `NULL`, default security 1856e5c31af7Sopenharmony_cidescriptor values will be used, and child processes created by the 1857e5c31af7Sopenharmony_ciapplication will not inherit the handle, as described in the MSDN 1858e5c31af7Sopenharmony_cidocumentation for "`Synchronization Object Security and Access Rights`"^1^. 1859e5c31af7Sopenharmony_ciFurther, if the structure is not present, the access rights used depend on 1860e5c31af7Sopenharmony_cithe handle type. 1861e5c31af7Sopenharmony_ci 1862e5c31af7Sopenharmony_ciFor handles of the following types: 1863e5c31af7Sopenharmony_ci 1864e5c31af7Sopenharmony_ci * ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT 1865e5c31af7Sopenharmony_ci 1866e5c31af7Sopenharmony_ciThe implementation must: ensure the access rights allow read and write 1867e5c31af7Sopenharmony_ciaccess to the memory. 1868e5c31af7Sopenharmony_ci 1869e5c31af7Sopenharmony_ci1:: 1870e5c31af7Sopenharmony_ci https://docs.microsoft.com/en-us/windows/win32/sync/synchronization-object-security-and-access-rights 1871e5c31af7Sopenharmony_ci 1872e5c31af7Sopenharmony_ci.Valid Usage 1873e5c31af7Sopenharmony_ci**** 1874e5c31af7Sopenharmony_ci * [[VUID-VkExportMemoryWin32HandleInfoKHR-handleTypes-00657]] 1875e5c31af7Sopenharmony_ci If slink:VkExportMemoryAllocateInfo::pname:handleTypes does not include 1876e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT, a 1877e5c31af7Sopenharmony_ci sname:VkExportMemoryWin32HandleInfoKHR structure must: not be included 1878e5c31af7Sopenharmony_ci in the pname:pNext chain of slink:VkMemoryAllocateInfo 1879e5c31af7Sopenharmony_ci**** 1880e5c31af7Sopenharmony_ci 1881e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkExportMemoryWin32HandleInfoKHR.txt[] 1882e5c31af7Sopenharmony_ci-- 1883e5c31af7Sopenharmony_ci 1884e5c31af7Sopenharmony_ci[open,refpage='VkImportMemoryWin32HandleInfoKHR',desc='Import Win32 memory created on the same physical device',type='structs'] 1885e5c31af7Sopenharmony_ci-- 1886e5c31af7Sopenharmony_ciTo import memory from a Windows handle, add a 1887e5c31af7Sopenharmony_cislink:VkImportMemoryWin32HandleInfoKHR structure to the pname:pNext chain of 1888e5c31af7Sopenharmony_cithe slink:VkMemoryAllocateInfo structure. 1889e5c31af7Sopenharmony_ci 1890e5c31af7Sopenharmony_ciThe sname:VkImportMemoryWin32HandleInfoKHR structure is defined as: 1891e5c31af7Sopenharmony_ci 1892e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkImportMemoryWin32HandleInfoKHR.txt[] 1893e5c31af7Sopenharmony_ci 1894e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 1895e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 1896e5c31af7Sopenharmony_ci structure. 1897e5c31af7Sopenharmony_ci * pname:handleType is a elink:VkExternalMemoryHandleTypeFlagBits value 1898e5c31af7Sopenharmony_ci specifying the type of pname:handle or pname:name. 1899e5c31af7Sopenharmony_ci * pname:handle is `NULL` or the external handle to import. 1900e5c31af7Sopenharmony_ci * pname:name is `NULL` or a null-terminated UTF-16 string naming the 1901e5c31af7Sopenharmony_ci payload to import. 1902e5c31af7Sopenharmony_ci 1903e5c31af7Sopenharmony_ciImporting memory object payloads from Windows handles does not transfer 1904e5c31af7Sopenharmony_ciownership of the handle to the Vulkan implementation. 1905e5c31af7Sopenharmony_ciFor handle types defined as NT handles, the application must: release handle 1906e5c31af7Sopenharmony_ciownership using the code:CloseHandle system call when the handle is no 1907e5c31af7Sopenharmony_cilonger needed. 1908e5c31af7Sopenharmony_ciFor handle types defined as NT handles, the imported memory object holds a 1909e5c31af7Sopenharmony_cireference to its payload. 1910e5c31af7Sopenharmony_ci 1911e5c31af7Sopenharmony_ci[NOTE] 1912e5c31af7Sopenharmony_ci.Note 1913e5c31af7Sopenharmony_ci==== 1914e5c31af7Sopenharmony_ciNon-NT handle import operations do not add a reference to their associated 1915e5c31af7Sopenharmony_cipayload. 1916e5c31af7Sopenharmony_ciIf the original object owning the payload is destroyed, all resources and 1917e5c31af7Sopenharmony_cihandles sharing that payload will become invalid. 1918e5c31af7Sopenharmony_ci==== 1919e5c31af7Sopenharmony_ci 1920e5c31af7Sopenharmony_ciApplications can: import the same payload into multiple instances of Vulkan, 1921e5c31af7Sopenharmony_ciinto the same instance from which it was exported, and multiple times into a 1922e5c31af7Sopenharmony_cigiven Vulkan instance. 1923e5c31af7Sopenharmony_ciIn all cases, each import operation must: create a distinct 1924e5c31af7Sopenharmony_cisname:VkDeviceMemory object. 1925e5c31af7Sopenharmony_ci 1926e5c31af7Sopenharmony_ci.Valid Usage 1927e5c31af7Sopenharmony_ci**** 1928e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryWin32HandleInfoKHR-handleType-00658]] 1929e5c31af7Sopenharmony_ci If pname:handleType is not `0`, it must: be supported for import, as 1930e5c31af7Sopenharmony_ci reported by slink:VkExternalImageFormatProperties or 1931e5c31af7Sopenharmony_ci slink:VkExternalBufferProperties 1932e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryWin32HandleInfoKHR-handle-00659]] 1933e5c31af7Sopenharmony_ci The memory from which pname:handle was exported, or the memory named by 1934e5c31af7Sopenharmony_ci pname:name must: have been created on the same underlying physical 1935e5c31af7Sopenharmony_ci device as pname:device 1936e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryWin32HandleInfoKHR-handleType-00660]] 1937e5c31af7Sopenharmony_ci If pname:handleType is not `0`, it must: be defined as an NT handle or a 1938e5c31af7Sopenharmony_ci global share handle 1939e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryWin32HandleInfoKHR-handleType-01439]] 1940e5c31af7Sopenharmony_ci If pname:handleType is not 1941e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT, 1942e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT, 1943e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT, or 1944e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT, pname:name 1945e5c31af7Sopenharmony_ci must: be `NULL` 1946e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryWin32HandleInfoKHR-handleType-01440]] 1947e5c31af7Sopenharmony_ci If pname:handleType is not `0` and pname:handle is `NULL`, pname:name 1948e5c31af7Sopenharmony_ci must: name a valid memory resource of the type specified by 1949e5c31af7Sopenharmony_ci pname:handleType 1950e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryWin32HandleInfoKHR-handleType-00661]] 1951e5c31af7Sopenharmony_ci If pname:handleType is not `0` and pname:name is `NULL`, pname:handle 1952e5c31af7Sopenharmony_ci must: be a valid handle of the type specified by pname:handleType 1953e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryWin32HandleInfoKHR-handle-01441]] 1954e5c31af7Sopenharmony_ci if pname:handle is not `NULL`, pname:name must: be `NULL` 1955e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryWin32HandleInfoKHR-handle-01518]] 1956e5c31af7Sopenharmony_ci If pname:handle is not `NULL`, it must: obey any requirements listed for 1957e5c31af7Sopenharmony_ci pname:handleType in 1958e5c31af7Sopenharmony_ci <<external-memory-handle-types-compatibility,external memory handle 1959e5c31af7Sopenharmony_ci types compatibility>> 1960e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryWin32HandleInfoKHR-name-01519]] 1961e5c31af7Sopenharmony_ci If pname:name is not `NULL`, it must: obey any requirements listed for 1962e5c31af7Sopenharmony_ci pname:handleType in 1963e5c31af7Sopenharmony_ci <<external-memory-handle-types-compatibility,external memory handle 1964e5c31af7Sopenharmony_ci types compatibility>> 1965e5c31af7Sopenharmony_ci**** 1966e5c31af7Sopenharmony_ci 1967e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkImportMemoryWin32HandleInfoKHR.txt[] 1968e5c31af7Sopenharmony_ci-- 1969e5c31af7Sopenharmony_ci 1970e5c31af7Sopenharmony_ci[open,refpage='vkGetMemoryWin32HandleKHR',desc='Get a Windows HANDLE for a memory object',type='protos'] 1971e5c31af7Sopenharmony_ci-- 1972e5c31af7Sopenharmony_ciTo export a Windows handle representing the payload of a Vulkan device 1973e5c31af7Sopenharmony_cimemory object, call: 1974e5c31af7Sopenharmony_ci 1975e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetMemoryWin32HandleKHR.txt[] 1976e5c31af7Sopenharmony_ci 1977e5c31af7Sopenharmony_ci * pname:device is the logical device that created the device memory being 1978e5c31af7Sopenharmony_ci exported. 1979e5c31af7Sopenharmony_ci * pname:pGetWin32HandleInfo is a pointer to a 1980e5c31af7Sopenharmony_ci slink:VkMemoryGetWin32HandleInfoKHR structure containing parameters of 1981e5c31af7Sopenharmony_ci the export operation. 1982e5c31af7Sopenharmony_ci * pname:pHandle will return the Windows handle representing the payload of 1983e5c31af7Sopenharmony_ci the device memory object. 1984e5c31af7Sopenharmony_ci 1985e5c31af7Sopenharmony_ciFor handle types defined as NT handles, the handles returned by 1986e5c31af7Sopenharmony_cifname:vkGetMemoryWin32HandleKHR are owned by the application and hold a 1987e5c31af7Sopenharmony_cireference to their payload. 1988e5c31af7Sopenharmony_ciTo avoid leaking resources, the application must: release ownership of them 1989e5c31af7Sopenharmony_ciusing the code:CloseHandle system call when they are no longer needed. 1990e5c31af7Sopenharmony_ci 1991e5c31af7Sopenharmony_ci[NOTE] 1992e5c31af7Sopenharmony_ci.Note 1993e5c31af7Sopenharmony_ci==== 1994e5c31af7Sopenharmony_ciNon-NT handle types do not add a reference to their associated payload. 1995e5c31af7Sopenharmony_ciIf the original object owning the payload is destroyed, all resources and 1996e5c31af7Sopenharmony_cihandles sharing that payload will become invalid. 1997e5c31af7Sopenharmony_ci==== 1998e5c31af7Sopenharmony_ci 1999e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetMemoryWin32HandleKHR.txt[] 2000e5c31af7Sopenharmony_ci-- 2001e5c31af7Sopenharmony_ci 2002e5c31af7Sopenharmony_ci[open,refpage='VkMemoryGetWin32HandleInfoKHR',desc='Structure describing a Win32 handle semaphore export operation',type='structs'] 2003e5c31af7Sopenharmony_ci-- 2004e5c31af7Sopenharmony_ciThe sname:VkMemoryGetWin32HandleInfoKHR structure is defined as: 2005e5c31af7Sopenharmony_ci 2006e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkMemoryGetWin32HandleInfoKHR.txt[] 2007e5c31af7Sopenharmony_ci 2008e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 2009e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 2010e5c31af7Sopenharmony_ci structure. 2011e5c31af7Sopenharmony_ci * pname:memory is the memory object from which the handle will be 2012e5c31af7Sopenharmony_ci exported. 2013e5c31af7Sopenharmony_ci * pname:handleType is a elink:VkExternalMemoryHandleTypeFlagBits value 2014e5c31af7Sopenharmony_ci specifying the type of handle requested. 2015e5c31af7Sopenharmony_ci 2016e5c31af7Sopenharmony_ciThe properties of the handle returned depend on the value of 2017e5c31af7Sopenharmony_cipname:handleType. 2018e5c31af7Sopenharmony_ciSee elink:VkExternalMemoryHandleTypeFlagBits for a description of the 2019e5c31af7Sopenharmony_ciproperties of the defined external memory handle types. 2020e5c31af7Sopenharmony_ci 2021e5c31af7Sopenharmony_ci.Valid Usage 2022e5c31af7Sopenharmony_ci**** 2023e5c31af7Sopenharmony_ci * [[VUID-VkMemoryGetWin32HandleInfoKHR-handleType-00662]] 2024e5c31af7Sopenharmony_ci pname:handleType must: have been included in 2025e5c31af7Sopenharmony_ci slink:VkExportMemoryAllocateInfo::pname:handleTypes when pname:memory 2026e5c31af7Sopenharmony_ci was created 2027e5c31af7Sopenharmony_ci * [[VUID-VkMemoryGetWin32HandleInfoKHR-handleType-00663]] 2028e5c31af7Sopenharmony_ci If pname:handleType is defined as an NT handle, 2029e5c31af7Sopenharmony_ci flink:vkGetMemoryWin32HandleKHR must: be called no more than once for 2030e5c31af7Sopenharmony_ci each valid unique combination of pname:memory and pname:handleType 2031e5c31af7Sopenharmony_ci * [[VUID-VkMemoryGetWin32HandleInfoKHR-handleType-00664]] 2032e5c31af7Sopenharmony_ci pname:handleType must: be defined as an NT handle or a global share 2033e5c31af7Sopenharmony_ci handle 2034e5c31af7Sopenharmony_ci**** 2035e5c31af7Sopenharmony_ci 2036e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkMemoryGetWin32HandleInfoKHR.txt[] 2037e5c31af7Sopenharmony_ci-- 2038e5c31af7Sopenharmony_ci 2039e5c31af7Sopenharmony_ci[open,refpage='vkGetMemoryWin32HandlePropertiesKHR',desc='Get Properties of External Memory Win32 Handles',type='protos'] 2040e5c31af7Sopenharmony_ci-- 2041e5c31af7Sopenharmony_ciWindows memory handles compatible with Vulkan may: also be created by 2042e5c31af7Sopenharmony_cinon-Vulkan APIs using methods beyond the scope of this specification. 2043e5c31af7Sopenharmony_ciTo determine the correct parameters to use when importing such handles, 2044e5c31af7Sopenharmony_cicall: 2045e5c31af7Sopenharmony_ci 2046e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetMemoryWin32HandlePropertiesKHR.txt[] 2047e5c31af7Sopenharmony_ci 2048e5c31af7Sopenharmony_ci * pname:device is the logical device that will be importing pname:handle. 2049e5c31af7Sopenharmony_ci * pname:handleType is a elink:VkExternalMemoryHandleTypeFlagBits value 2050e5c31af7Sopenharmony_ci specifying the type of the handle pname:handle. 2051e5c31af7Sopenharmony_ci * pname:handle is the handle which will be imported. 2052e5c31af7Sopenharmony_ci * pname:pMemoryWin32HandleProperties is a pointer to a 2053e5c31af7Sopenharmony_ci slink:VkMemoryWin32HandlePropertiesKHR structure in which properties of 2054e5c31af7Sopenharmony_ci pname:handle are returned. 2055e5c31af7Sopenharmony_ci 2056e5c31af7Sopenharmony_ci.Valid Usage 2057e5c31af7Sopenharmony_ci**** 2058e5c31af7Sopenharmony_ci * [[VUID-vkGetMemoryWin32HandlePropertiesKHR-handle-00665]] 2059e5c31af7Sopenharmony_ci pname:handle must: be an external memory handle created outside of the 2060e5c31af7Sopenharmony_ci Vulkan API 2061e5c31af7Sopenharmony_ci * [[VUID-vkGetMemoryWin32HandlePropertiesKHR-handleType-00666]] 2062e5c31af7Sopenharmony_ci pname:handleType must: not be one of the handle types defined as opaque 2063e5c31af7Sopenharmony_ci**** 2064e5c31af7Sopenharmony_ci 2065e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetMemoryWin32HandlePropertiesKHR.txt[] 2066e5c31af7Sopenharmony_ci-- 2067e5c31af7Sopenharmony_ci 2068e5c31af7Sopenharmony_ci[open,refpage='VkMemoryWin32HandlePropertiesKHR',desc='Properties of External Memory Windows Handles',type='structs'] 2069e5c31af7Sopenharmony_ci-- 2070e5c31af7Sopenharmony_ciThe sname:VkMemoryWin32HandlePropertiesKHR structure returned is defined as: 2071e5c31af7Sopenharmony_ci 2072e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkMemoryWin32HandlePropertiesKHR.txt[] 2073e5c31af7Sopenharmony_ci 2074e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 2075e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 2076e5c31af7Sopenharmony_ci structure. 2077e5c31af7Sopenharmony_ci * pname:memoryTypeBits is a bitmask containing one bit set for every 2078e5c31af7Sopenharmony_ci memory type which the specified windows handle can: be imported as. 2079e5c31af7Sopenharmony_ci 2080e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkMemoryWin32HandlePropertiesKHR.txt[] 2081e5c31af7Sopenharmony_ci-- 2082e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory_win32[] 2083e5c31af7Sopenharmony_ci 2084e5c31af7Sopenharmony_ciifdef::VK_NV_external_memory_win32[] 2085e5c31af7Sopenharmony_ciinclude::{chapters}/VK_NV_external_memory_win32/handle_permissions.txt[] 2086e5c31af7Sopenharmony_ci 2087e5c31af7Sopenharmony_ciinclude::{chapters}/VK_NV_external_memory_win32/import_memory_win32.txt[] 2088e5c31af7Sopenharmony_ci 2089e5c31af7Sopenharmony_ciinclude::{chapters}/VK_NV_external_memory_win32/get_handle_win32.txt[] 2090e5c31af7Sopenharmony_ciendif::VK_NV_external_memory_win32[] 2091e5c31af7Sopenharmony_ci 2092e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory_fd[] 2093e5c31af7Sopenharmony_ci=== File Descriptor External Memory 2094e5c31af7Sopenharmony_ci 2095e5c31af7Sopenharmony_ci[open,refpage='VkImportMemoryFdInfoKHR',desc='Import memory created on the same physical device from a file descriptor',type='structs'] 2096e5c31af7Sopenharmony_ci-- 2097e5c31af7Sopenharmony_ciTo import memory from a POSIX file descriptor handle, add a 2098e5c31af7Sopenharmony_cislink:VkImportMemoryFdInfoKHR structure to the pname:pNext chain of the 2099e5c31af7Sopenharmony_cislink:VkMemoryAllocateInfo structure. 2100e5c31af7Sopenharmony_ciThe sname:VkImportMemoryFdInfoKHR structure is defined as: 2101e5c31af7Sopenharmony_ci 2102e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkImportMemoryFdInfoKHR.txt[] 2103e5c31af7Sopenharmony_ci 2104e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 2105e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 2106e5c31af7Sopenharmony_ci structure. 2107e5c31af7Sopenharmony_ci * pname:handleType is a elink:VkExternalMemoryHandleTypeFlagBits value 2108e5c31af7Sopenharmony_ci specifying the handle type of pname:fd. 2109e5c31af7Sopenharmony_ci * pname:fd is the external handle to import. 2110e5c31af7Sopenharmony_ci 2111e5c31af7Sopenharmony_ciImporting memory from a file descriptor transfers ownership of the file 2112e5c31af7Sopenharmony_cidescriptor from the application to the Vulkan implementation. 2113e5c31af7Sopenharmony_ciThe application must: not perform any operations on the file descriptor 2114e5c31af7Sopenharmony_ciafter a successful import. 2115e5c31af7Sopenharmony_ciThe imported memory object holds a reference to its payload. 2116e5c31af7Sopenharmony_ci 2117e5c31af7Sopenharmony_ciApplications can: import the same payload into multiple instances of Vulkan, 2118e5c31af7Sopenharmony_ciinto the same instance from which it was exported, and multiple times into a 2119e5c31af7Sopenharmony_cigiven Vulkan instance. 2120e5c31af7Sopenharmony_ciIn all cases, each import operation must: create a distinct 2121e5c31af7Sopenharmony_cisname:VkDeviceMemory object. 2122e5c31af7Sopenharmony_ci 2123e5c31af7Sopenharmony_ci.Valid Usage 2124e5c31af7Sopenharmony_ci**** 2125e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryFdInfoKHR-handleType-00667]] 2126e5c31af7Sopenharmony_ci If pname:handleType is not `0`, it must: be supported for import, as 2127e5c31af7Sopenharmony_ci reported by slink:VkExternalImageFormatProperties or 2128e5c31af7Sopenharmony_ci slink:VkExternalBufferProperties 2129e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryFdInfoKHR-fd-00668]] 2130e5c31af7Sopenharmony_ci The memory from which pname:fd was exported must: have been created on 2131e5c31af7Sopenharmony_ci the same underlying physical device as pname:device 2132e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryFdInfoKHR-handleType-00669]] 2133e5c31af7Sopenharmony_ci If pname:handleType is not `0`, it must: be 2134e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT or 2135e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT 2136e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryFdInfoKHR-handleType-00670]] 2137e5c31af7Sopenharmony_ci If pname:handleType is not `0`, pname:fd must: be a valid handle of the 2138e5c31af7Sopenharmony_ci type specified by pname:handleType 2139e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryFdInfoKHR-fd-01746]] 2140e5c31af7Sopenharmony_ci The memory represented by pname:fd must: have been created from a 2141e5c31af7Sopenharmony_ci physical device and driver that is compatible with pname:device and 2142e5c31af7Sopenharmony_ci pname:handleType, as described in 2143e5c31af7Sopenharmony_ci <<external-memory-handle-types-compatibility>> 2144e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryFdInfoKHR-fd-01520]] 2145e5c31af7Sopenharmony_ci pname:fd must: obey any requirements listed for pname:handleType in 2146e5c31af7Sopenharmony_ci <<external-memory-handle-types-compatibility,external memory handle 2147e5c31af7Sopenharmony_ci types compatibility>> 2148e5c31af7Sopenharmony_ci**** 2149e5c31af7Sopenharmony_ci 2150e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkImportMemoryFdInfoKHR.txt[] 2151e5c31af7Sopenharmony_ci-- 2152e5c31af7Sopenharmony_ci 2153e5c31af7Sopenharmony_ci[open,refpage='vkGetMemoryFdKHR',desc='Get a POSIX file descriptor for a memory object',type='protos'] 2154e5c31af7Sopenharmony_ci-- 2155e5c31af7Sopenharmony_ciTo export a POSIX file descriptor referencing the payload of a Vulkan device 2156e5c31af7Sopenharmony_cimemory object, call: 2157e5c31af7Sopenharmony_ci 2158e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetMemoryFdKHR.txt[] 2159e5c31af7Sopenharmony_ci 2160e5c31af7Sopenharmony_ci * pname:device is the logical device that created the device memory being 2161e5c31af7Sopenharmony_ci exported. 2162e5c31af7Sopenharmony_ci * pname:pGetFdInfo is a pointer to a slink:VkMemoryGetFdInfoKHR structure 2163e5c31af7Sopenharmony_ci containing parameters of the export operation. 2164e5c31af7Sopenharmony_ci * pname:pFd will return a file descriptor referencing the payload of the 2165e5c31af7Sopenharmony_ci device memory object. 2166e5c31af7Sopenharmony_ci 2167e5c31af7Sopenharmony_ciEach call to fname:vkGetMemoryFdKHR must: create a new file descriptor 2168e5c31af7Sopenharmony_ciholding a reference to the memory object's payload and transfer ownership of 2169e5c31af7Sopenharmony_cithe file descriptor to the application. 2170e5c31af7Sopenharmony_ciTo avoid leaking resources, the application must: release ownership of the 2171e5c31af7Sopenharmony_cifile descriptor using the code:close system call when it is no longer 2172e5c31af7Sopenharmony_cineeded, or by importing a Vulkan memory object from it. 2173e5c31af7Sopenharmony_ciWhere supported by the operating system, the implementation must: set the 2174e5c31af7Sopenharmony_cifile descriptor to be closed automatically when an code:execve system call 2175e5c31af7Sopenharmony_ciis made. 2176e5c31af7Sopenharmony_ci 2177e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetMemoryFdKHR.txt[] 2178e5c31af7Sopenharmony_ci-- 2179e5c31af7Sopenharmony_ci 2180e5c31af7Sopenharmony_ci[open,refpage='VkMemoryGetFdInfoKHR',desc='Structure describing a POSIX FD semaphore export operation',type='structs'] 2181e5c31af7Sopenharmony_ci-- 2182e5c31af7Sopenharmony_ciThe sname:VkMemoryGetFdInfoKHR structure is defined as: 2183e5c31af7Sopenharmony_ci 2184e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkMemoryGetFdInfoKHR.txt[] 2185e5c31af7Sopenharmony_ci 2186e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 2187e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 2188e5c31af7Sopenharmony_ci structure. 2189e5c31af7Sopenharmony_ci * pname:memory is the memory object from which the handle will be 2190e5c31af7Sopenharmony_ci exported. 2191e5c31af7Sopenharmony_ci * pname:handleType is a elink:VkExternalMemoryHandleTypeFlagBits value 2192e5c31af7Sopenharmony_ci specifying the type of handle requested. 2193e5c31af7Sopenharmony_ci 2194e5c31af7Sopenharmony_ciThe properties of the file descriptor exported depend on the value of 2195e5c31af7Sopenharmony_cipname:handleType. 2196e5c31af7Sopenharmony_ciSee elink:VkExternalMemoryHandleTypeFlagBits for a description of the 2197e5c31af7Sopenharmony_ciproperties of the defined external memory handle types. 2198e5c31af7Sopenharmony_ci 2199e5c31af7Sopenharmony_ciifdef::VK_EXT_external_memory_dma_buf[] 2200e5c31af7Sopenharmony_ci[NOTE] 2201e5c31af7Sopenharmony_ci.Note 2202e5c31af7Sopenharmony_ci==== 2203e5c31af7Sopenharmony_ciThe size of the exported file may: be larger than the size requested by 2204e5c31af7Sopenharmony_cislink:VkMemoryAllocateInfo::pname:allocationSize. 2205e5c31af7Sopenharmony_ciIf pname:handleType is ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT, 2206e5c31af7Sopenharmony_cithen the application can: query the file's actual size with 2207e5c31af7Sopenharmony_cilink:https://man7.org/linux/man-pages/man2/lseek.2.html[`lseek`]. 2208e5c31af7Sopenharmony_ci==== 2209e5c31af7Sopenharmony_ciendif::VK_EXT_external_memory_dma_buf[] 2210e5c31af7Sopenharmony_ci 2211e5c31af7Sopenharmony_ci.Valid Usage 2212e5c31af7Sopenharmony_ci**** 2213e5c31af7Sopenharmony_ci * [[VUID-VkMemoryGetFdInfoKHR-handleType-00671]] 2214e5c31af7Sopenharmony_ci pname:handleType must: have been included in 2215e5c31af7Sopenharmony_ci slink:VkExportMemoryAllocateInfo::pname:handleTypes when pname:memory 2216e5c31af7Sopenharmony_ci was created 2217e5c31af7Sopenharmony_ci * [[VUID-VkMemoryGetFdInfoKHR-handleType-00672]] 2218e5c31af7Sopenharmony_ci pname:handleType must: be 2219e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT or 2220e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT 2221e5c31af7Sopenharmony_ci**** 2222e5c31af7Sopenharmony_ci 2223e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkMemoryGetFdInfoKHR.txt[] 2224e5c31af7Sopenharmony_ci-- 2225e5c31af7Sopenharmony_ci 2226e5c31af7Sopenharmony_ci[open,refpage='vkGetMemoryFdPropertiesKHR',desc='Get Properties of External Memory File Descriptors',type='protos'] 2227e5c31af7Sopenharmony_ci-- 2228e5c31af7Sopenharmony_ciPOSIX file descriptor memory handles compatible with Vulkan may: also be 2229e5c31af7Sopenharmony_cicreated by non-Vulkan APIs using methods beyond the scope of this 2230e5c31af7Sopenharmony_cispecification. 2231e5c31af7Sopenharmony_ciTo determine the correct parameters to use when importing such handles, 2232e5c31af7Sopenharmony_cicall: 2233e5c31af7Sopenharmony_ci 2234e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetMemoryFdPropertiesKHR.txt[] 2235e5c31af7Sopenharmony_ci 2236e5c31af7Sopenharmony_ci * pname:device is the logical device that will be importing pname:fd. 2237e5c31af7Sopenharmony_ci * pname:handleType is a elink:VkExternalMemoryHandleTypeFlagBits value 2238e5c31af7Sopenharmony_ci specifying the type of the handle pname:fd. 2239e5c31af7Sopenharmony_ci * pname:fd is the handle which will be imported. 2240e5c31af7Sopenharmony_ci * pname:pMemoryFdProperties is a pointer to a 2241e5c31af7Sopenharmony_ci slink:VkMemoryFdPropertiesKHR structure in which the properties of the 2242e5c31af7Sopenharmony_ci handle pname:fd are returned. 2243e5c31af7Sopenharmony_ci 2244e5c31af7Sopenharmony_ci.Valid Usage 2245e5c31af7Sopenharmony_ci**** 2246e5c31af7Sopenharmony_ci * [[VUID-vkGetMemoryFdPropertiesKHR-fd-00673]] 2247e5c31af7Sopenharmony_ci pname:fd must: be an external memory handle created outside of the 2248e5c31af7Sopenharmony_ci Vulkan API 2249e5c31af7Sopenharmony_ci * [[VUID-vkGetMemoryFdPropertiesKHR-handleType-00674]] 2250e5c31af7Sopenharmony_ci pname:handleType must: not be 2251e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT 2252e5c31af7Sopenharmony_ci**** 2253e5c31af7Sopenharmony_ci 2254e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetMemoryFdPropertiesKHR.txt[] 2255e5c31af7Sopenharmony_ci-- 2256e5c31af7Sopenharmony_ci 2257e5c31af7Sopenharmony_ci[open,refpage='VkMemoryFdPropertiesKHR',desc='Properties of External Memory File Descriptors',type='structs'] 2258e5c31af7Sopenharmony_ci-- 2259e5c31af7Sopenharmony_ciThe sname:VkMemoryFdPropertiesKHR structure returned is defined as: 2260e5c31af7Sopenharmony_ci 2261e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkMemoryFdPropertiesKHR.txt[] 2262e5c31af7Sopenharmony_ci 2263e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 2264e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 2265e5c31af7Sopenharmony_ci structure. 2266e5c31af7Sopenharmony_ci * pname:memoryTypeBits is a bitmask containing one bit set for every 2267e5c31af7Sopenharmony_ci memory type which the specified file descriptor can: be imported as. 2268e5c31af7Sopenharmony_ci 2269e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkMemoryFdPropertiesKHR.txt[] 2270e5c31af7Sopenharmony_ci-- 2271e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory_fd[] 2272e5c31af7Sopenharmony_ci 2273e5c31af7Sopenharmony_ciifdef::VK_EXT_external_memory_host[] 2274e5c31af7Sopenharmony_ci=== Host External Memory 2275e5c31af7Sopenharmony_ci 2276e5c31af7Sopenharmony_ci[open,refpage='VkImportMemoryHostPointerInfoEXT',desc='Import memory from a host pointer',type='structs'] 2277e5c31af7Sopenharmony_ci-- 2278e5c31af7Sopenharmony_ciTo import memory from a host pointer, add a 2279e5c31af7Sopenharmony_cislink:VkImportMemoryHostPointerInfoEXT structure to the pname:pNext chain of 2280e5c31af7Sopenharmony_cithe slink:VkMemoryAllocateInfo structure. 2281e5c31af7Sopenharmony_ciThe sname:VkImportMemoryHostPointerInfoEXT structure is defined as: 2282e5c31af7Sopenharmony_ci 2283e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkImportMemoryHostPointerInfoEXT.txt[] 2284e5c31af7Sopenharmony_ci 2285e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 2286e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 2287e5c31af7Sopenharmony_ci structure. 2288e5c31af7Sopenharmony_ci * pname:handleType is a elink:VkExternalMemoryHandleTypeFlagBits value 2289e5c31af7Sopenharmony_ci specifying the handle type. 2290e5c31af7Sopenharmony_ci * pname:pHostPointer is the host pointer to import from. 2291e5c31af7Sopenharmony_ci 2292e5c31af7Sopenharmony_ciImporting memory from a host pointer shares ownership of the memory between 2293e5c31af7Sopenharmony_cithe host and the Vulkan implementation. 2294e5c31af7Sopenharmony_ciThe application can: continue to access the memory through the host pointer 2295e5c31af7Sopenharmony_cibut it is the application's responsibility to synchronize device and 2296e5c31af7Sopenharmony_cinon-device access to the payload as defined in 2297e5c31af7Sopenharmony_ci<<memory-device-hostaccess,Host Access to Device Memory Objects>>. 2298e5c31af7Sopenharmony_ci 2299e5c31af7Sopenharmony_ciApplications can: import the same payload into multiple instances of Vulkan 2300e5c31af7Sopenharmony_ciand multiple times into a given Vulkan instance. 2301e5c31af7Sopenharmony_ciHowever, implementations may: fail to import the same payload multiple times 2302e5c31af7Sopenharmony_ciinto a given physical device due to platform constraints. 2303e5c31af7Sopenharmony_ci 2304e5c31af7Sopenharmony_ciImporting memory from a particular host pointer may: not be possible due to 2305e5c31af7Sopenharmony_ciadditional platform-specific restrictions beyond the scope of this 2306e5c31af7Sopenharmony_cispecification in which case the implementation must: fail the memory import 2307e5c31af7Sopenharmony_cioperation with the error code ename:VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR. 2308e5c31af7Sopenharmony_ci 2309e5c31af7Sopenharmony_ciWhether device memory objects imported from a host pointer hold a reference 2310e5c31af7Sopenharmony_cito their payload is undefined:. 2311e5c31af7Sopenharmony_ciAs such, the application must: ensure that the imported memory range remains 2312e5c31af7Sopenharmony_civalid and accessible for the lifetime of the imported memory object. 2313e5c31af7Sopenharmony_ci 2314e5c31af7Sopenharmony_ci.Valid Usage 2315e5c31af7Sopenharmony_ci**** 2316e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryHostPointerInfoEXT-handleType-01747]] 2317e5c31af7Sopenharmony_ci If pname:handleType is not `0`, it must: be supported for import, as 2318e5c31af7Sopenharmony_ci reported in slink:VkExternalMemoryProperties 2319e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryHostPointerInfoEXT-handleType-01748]] 2320e5c31af7Sopenharmony_ci If pname:handleType is not `0`, it must: be 2321e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT or 2322e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_MAPPED_FOREIGN_MEMORY_BIT_EXT 2323e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryHostPointerInfoEXT-pHostPointer-01749]] 2324e5c31af7Sopenharmony_ci pname:pHostPointer must: be a pointer aligned to an integer multiple of 2325e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceExternalMemoryHostPropertiesEXT::pname:minImportedHostPointerAlignment 2326e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryHostPointerInfoEXT-handleType-01750]] 2327e5c31af7Sopenharmony_ci If pname:handleType is 2328e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT, 2329e5c31af7Sopenharmony_ci pname:pHostPointer must: be a pointer to pname:allocationSize number of 2330e5c31af7Sopenharmony_ci bytes of host memory, where pname:allocationSize is the member of the 2331e5c31af7Sopenharmony_ci sname:VkMemoryAllocateInfo structure this structure is chained to 2332e5c31af7Sopenharmony_ci * [[VUID-VkImportMemoryHostPointerInfoEXT-handleType-01751]] 2333e5c31af7Sopenharmony_ci If pname:handleType is 2334e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_MAPPED_FOREIGN_MEMORY_BIT_EXT, 2335e5c31af7Sopenharmony_ci pname:pHostPointer must: be a pointer to pname:allocationSize number of 2336e5c31af7Sopenharmony_ci bytes of host mapped foreign memory, where pname:allocationSize is the 2337e5c31af7Sopenharmony_ci member of the sname:VkMemoryAllocateInfo structure this structure is 2338e5c31af7Sopenharmony_ci chained to 2339e5c31af7Sopenharmony_ci**** 2340e5c31af7Sopenharmony_ci 2341e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkImportMemoryHostPointerInfoEXT.txt[] 2342e5c31af7Sopenharmony_ci-- 2343e5c31af7Sopenharmony_ci 2344e5c31af7Sopenharmony_ci[open,refpage='vkGetMemoryHostPointerPropertiesEXT',desc='Get properties of external memory host pointer',type='protos'] 2345e5c31af7Sopenharmony_ci-- 2346e5c31af7Sopenharmony_ciTo determine the correct parameters to use when importing host pointers, 2347e5c31af7Sopenharmony_cicall: 2348e5c31af7Sopenharmony_ci 2349e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetMemoryHostPointerPropertiesEXT.txt[] 2350e5c31af7Sopenharmony_ci 2351e5c31af7Sopenharmony_ci * pname:device is the logical device that will be importing 2352e5c31af7Sopenharmony_ci pname:pHostPointer. 2353e5c31af7Sopenharmony_ci * pname:handleType is a elink:VkExternalMemoryHandleTypeFlagBits value 2354e5c31af7Sopenharmony_ci specifying the type of the handle pname:pHostPointer. 2355e5c31af7Sopenharmony_ci * pname:pHostPointer is the host pointer to import from. 2356e5c31af7Sopenharmony_ci * pname:pMemoryHostPointerProperties is a pointer to a 2357e5c31af7Sopenharmony_ci slink:VkMemoryHostPointerPropertiesEXT structure in which the host 2358e5c31af7Sopenharmony_ci pointer properties are returned. 2359e5c31af7Sopenharmony_ci 2360e5c31af7Sopenharmony_ci.Valid Usage 2361e5c31af7Sopenharmony_ci**** 2362e5c31af7Sopenharmony_ci * [[VUID-vkGetMemoryHostPointerPropertiesEXT-handleType-01752]] 2363e5c31af7Sopenharmony_ci pname:handleType must: be 2364e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT or 2365e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_MAPPED_FOREIGN_MEMORY_BIT_EXT 2366e5c31af7Sopenharmony_ci * [[VUID-vkGetMemoryHostPointerPropertiesEXT-pHostPointer-01753]] 2367e5c31af7Sopenharmony_ci pname:pHostPointer must: be a pointer aligned to an integer multiple of 2368e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceExternalMemoryHostPropertiesEXT::pname:minImportedHostPointerAlignment 2369e5c31af7Sopenharmony_ci * [[VUID-vkGetMemoryHostPointerPropertiesEXT-handleType-01754]] 2370e5c31af7Sopenharmony_ci If pname:handleType is 2371e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT, 2372e5c31af7Sopenharmony_ci pname:pHostPointer must: be a pointer to host memory 2373e5c31af7Sopenharmony_ci * [[VUID-vkGetMemoryHostPointerPropertiesEXT-handleType-01755]] 2374e5c31af7Sopenharmony_ci If pname:handleType is 2375e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_MAPPED_FOREIGN_MEMORY_BIT_EXT, 2376e5c31af7Sopenharmony_ci pname:pHostPointer must: be a pointer to host mapped foreign memory 2377e5c31af7Sopenharmony_ci**** 2378e5c31af7Sopenharmony_ci 2379e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetMemoryHostPointerPropertiesEXT.txt[] 2380e5c31af7Sopenharmony_ci-- 2381e5c31af7Sopenharmony_ci 2382e5c31af7Sopenharmony_ci[open,refpage='VkMemoryHostPointerPropertiesEXT',desc='Properties of external memory host pointer',type='structs'] 2383e5c31af7Sopenharmony_ci-- 2384e5c31af7Sopenharmony_ciThe sname:VkMemoryHostPointerPropertiesEXT structure is defined as: 2385e5c31af7Sopenharmony_ci 2386e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkMemoryHostPointerPropertiesEXT.txt[] 2387e5c31af7Sopenharmony_ci 2388e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 2389e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 2390e5c31af7Sopenharmony_ci structure. 2391e5c31af7Sopenharmony_ci * pname:memoryTypeBits is a bitmask containing one bit set for every 2392e5c31af7Sopenharmony_ci memory type which the specified host pointer can: be imported as. 2393e5c31af7Sopenharmony_ci 2394e5c31af7Sopenharmony_ciThe value returned by pname:memoryTypeBits must: only include bits that 2395e5c31af7Sopenharmony_ciidentify memory types which are host visible. 2396e5c31af7Sopenharmony_ci 2397e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkMemoryHostPointerPropertiesEXT.txt[] 2398e5c31af7Sopenharmony_ci-- 2399e5c31af7Sopenharmony_ci 2400e5c31af7Sopenharmony_ciendif::VK_EXT_external_memory_host[] 2401e5c31af7Sopenharmony_ci 2402e5c31af7Sopenharmony_ciifdef::VK_ANDROID_external_memory_android_hardware_buffer[] 2403e5c31af7Sopenharmony_ci=== Android Hardware Buffer External Memory 2404e5c31af7Sopenharmony_ci 2405e5c31af7Sopenharmony_ci[open,refpage='VkImportAndroidHardwareBufferInfoANDROID',desc='Import memory from an Android hardware buffer',type='structs'] 2406e5c31af7Sopenharmony_ci-- 2407e5c31af7Sopenharmony_ciTo import memory created outside of the current Vulkan instance from an 2408e5c31af7Sopenharmony_ciAndroid hardware buffer, add a 2409e5c31af7Sopenharmony_cisname:VkImportAndroidHardwareBufferInfoANDROID structure to the pname:pNext 2410e5c31af7Sopenharmony_cichain of the slink:VkMemoryAllocateInfo structure. 2411e5c31af7Sopenharmony_ciThe sname:VkImportAndroidHardwareBufferInfoANDROID structure is defined as: 2412e5c31af7Sopenharmony_ci 2413e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkImportAndroidHardwareBufferInfoANDROID.txt[] 2414e5c31af7Sopenharmony_ci 2415e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 2416e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 2417e5c31af7Sopenharmony_ci structure. 2418e5c31af7Sopenharmony_ci * pname:buffer is the Android hardware buffer to import. 2419e5c31af7Sopenharmony_ci 2420e5c31af7Sopenharmony_ciIf the flink:vkAllocateMemory command succeeds, the implementation must: 2421e5c31af7Sopenharmony_ciacquire a reference to the imported hardware buffer, which it must: release 2422e5c31af7Sopenharmony_ciwhen the device memory object is freed. 2423e5c31af7Sopenharmony_ciIf the command fails, the implementation must: not retain a reference. 2424e5c31af7Sopenharmony_ci 2425e5c31af7Sopenharmony_ci.Valid Usage 2426e5c31af7Sopenharmony_ci**** 2427e5c31af7Sopenharmony_ci * [[VUID-VkImportAndroidHardwareBufferInfoANDROID-buffer-01880]] 2428e5c31af7Sopenharmony_ci If pname:buffer is not `NULL`, Android hardware buffers must: be 2429e5c31af7Sopenharmony_ci supported for import, as reported by 2430e5c31af7Sopenharmony_ci slink:VkExternalImageFormatProperties or 2431e5c31af7Sopenharmony_ci slink:VkExternalBufferProperties 2432e5c31af7Sopenharmony_ci * [[VUID-VkImportAndroidHardwareBufferInfoANDROID-buffer-01881]] 2433e5c31af7Sopenharmony_ci If pname:buffer is not `NULL`, it must: be a valid Android hardware 2434e5c31af7Sopenharmony_ci buffer object with code:AHardwareBuffer_Desc::code:usage compatible with 2435e5c31af7Sopenharmony_ci Vulkan as described in <<memory-external-android-hardware-buffer,Android 2436e5c31af7Sopenharmony_ci Hardware Buffers>> 2437e5c31af7Sopenharmony_ci**** 2438e5c31af7Sopenharmony_ci 2439e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkImportAndroidHardwareBufferInfoANDROID.txt[] 2440e5c31af7Sopenharmony_ci-- 2441e5c31af7Sopenharmony_ci 2442e5c31af7Sopenharmony_ci[open,refpage='vkGetMemoryAndroidHardwareBufferANDROID',desc='Get an Android hardware buffer for a memory object',type='protos'] 2443e5c31af7Sopenharmony_ci-- 2444e5c31af7Sopenharmony_ciTo export an Android hardware buffer referencing the payload of a Vulkan 2445e5c31af7Sopenharmony_cidevice memory object, call: 2446e5c31af7Sopenharmony_ci 2447e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetMemoryAndroidHardwareBufferANDROID.txt[] 2448e5c31af7Sopenharmony_ci 2449e5c31af7Sopenharmony_ci * pname:device is the logical device that created the device memory being 2450e5c31af7Sopenharmony_ci exported. 2451e5c31af7Sopenharmony_ci * pname:pInfo is a pointer to a 2452e5c31af7Sopenharmony_ci slink:VkMemoryGetAndroidHardwareBufferInfoANDROID structure containing 2453e5c31af7Sopenharmony_ci parameters of the export operation. 2454e5c31af7Sopenharmony_ci * pname:pBuffer will return an Android hardware buffer referencing the 2455e5c31af7Sopenharmony_ci payload of the device memory object. 2456e5c31af7Sopenharmony_ci 2457e5c31af7Sopenharmony_ciEach call to fname:vkGetMemoryAndroidHardwareBufferANDROID must: return an 2458e5c31af7Sopenharmony_ciAndroid hardware buffer with a new reference acquired in addition to the 2459e5c31af7Sopenharmony_cireference held by the slink:VkDeviceMemory. 2460e5c31af7Sopenharmony_ciTo avoid leaking resources, the application must: release the reference by 2461e5c31af7Sopenharmony_cicalling code:AHardwareBuffer_release when it is no longer needed. 2462e5c31af7Sopenharmony_ciWhen called with the same handle in 2463e5c31af7Sopenharmony_cislink:VkMemoryGetAndroidHardwareBufferInfoANDROID::pname:memory, 2464e5c31af7Sopenharmony_cifname:vkGetMemoryAndroidHardwareBufferANDROID must: return the same Android 2465e5c31af7Sopenharmony_cihardware buffer object. 2466e5c31af7Sopenharmony_ciIf the device memory was created by importing an Android hardware buffer, 2467e5c31af7Sopenharmony_cifname:vkGetMemoryAndroidHardwareBufferANDROID must: return that same Android 2468e5c31af7Sopenharmony_cihardware buffer object. 2469e5c31af7Sopenharmony_ci 2470e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetMemoryAndroidHardwareBufferANDROID.txt[] 2471e5c31af7Sopenharmony_ci-- 2472e5c31af7Sopenharmony_ci 2473e5c31af7Sopenharmony_ci[open,refpage='VkMemoryGetAndroidHardwareBufferInfoANDROID',desc='Structure describing an Android hardware buffer memory export operation',type='structs'] 2474e5c31af7Sopenharmony_ci-- 2475e5c31af7Sopenharmony_ciThe sname:VkMemoryGetAndroidHardwareBufferInfoANDROID structure is defined 2476e5c31af7Sopenharmony_cias: 2477e5c31af7Sopenharmony_ci 2478e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkMemoryGetAndroidHardwareBufferInfoANDROID.txt[] 2479e5c31af7Sopenharmony_ci 2480e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 2481e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 2482e5c31af7Sopenharmony_ci structure. 2483e5c31af7Sopenharmony_ci * pname:memory is the memory object from which the Android hardware buffer 2484e5c31af7Sopenharmony_ci will be exported. 2485e5c31af7Sopenharmony_ci 2486e5c31af7Sopenharmony_ci.Valid Usage 2487e5c31af7Sopenharmony_ci**** 2488e5c31af7Sopenharmony_ci * [[VUID-VkMemoryGetAndroidHardwareBufferInfoANDROID-handleTypes-01882]] 2489e5c31af7Sopenharmony_ci ename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID 2490e5c31af7Sopenharmony_ci must: have been included in 2491e5c31af7Sopenharmony_ci slink:VkExportMemoryAllocateInfo::pname:handleTypes when pname:memory 2492e5c31af7Sopenharmony_ci was created 2493e5c31af7Sopenharmony_ci * [[VUID-VkMemoryGetAndroidHardwareBufferInfoANDROID-pNext-01883]] 2494e5c31af7Sopenharmony_ci If the pname:pNext chain of the slink:VkMemoryAllocateInfo used to 2495e5c31af7Sopenharmony_ci allocate pname:memory included a slink:VkMemoryDedicatedAllocateInfo 2496e5c31af7Sopenharmony_ci with non-`NULL` pname:image member, then that pname:image must: already 2497e5c31af7Sopenharmony_ci be bound to pname:memory 2498e5c31af7Sopenharmony_ci**** 2499e5c31af7Sopenharmony_ci 2500e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkMemoryGetAndroidHardwareBufferInfoANDROID.txt[] 2501e5c31af7Sopenharmony_ci-- 2502e5c31af7Sopenharmony_ci 2503e5c31af7Sopenharmony_ci[open,refpage='vkGetAndroidHardwareBufferPropertiesANDROID',desc='Get Properties of External Memory Android Hardware Buffers',type='protos'] 2504e5c31af7Sopenharmony_ci-- 2505e5c31af7Sopenharmony_ciTo determine the memory parameters to use when importing an Android hardware 2506e5c31af7Sopenharmony_cibuffer, call: 2507e5c31af7Sopenharmony_ci 2508e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetAndroidHardwareBufferPropertiesANDROID.txt[] 2509e5c31af7Sopenharmony_ci 2510e5c31af7Sopenharmony_ci * pname:device is the logical device that will be importing pname:buffer. 2511e5c31af7Sopenharmony_ci * pname:buffer is the Android hardware buffer which will be imported. 2512e5c31af7Sopenharmony_ci * pname:pProperties is a pointer to a 2513e5c31af7Sopenharmony_ci slink:VkAndroidHardwareBufferPropertiesANDROID structure in which the 2514e5c31af7Sopenharmony_ci properties of pname:buffer are returned. 2515e5c31af7Sopenharmony_ci 2516e5c31af7Sopenharmony_ci.Valid Usage 2517e5c31af7Sopenharmony_ci**** 2518e5c31af7Sopenharmony_ci * [[VUID-vkGetAndroidHardwareBufferPropertiesANDROID-buffer-01884]] 2519e5c31af7Sopenharmony_ci pname:buffer must: be a valid Android hardware buffer object with at 2520e5c31af7Sopenharmony_ci least one of the code:AHARDWAREBUFFER_USAGE_GPU_* flags in its 2521e5c31af7Sopenharmony_ci code:AHardwareBuffer_Desc::code:usage 2522e5c31af7Sopenharmony_ci**** 2523e5c31af7Sopenharmony_ci 2524e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetAndroidHardwareBufferPropertiesANDROID.txt[] 2525e5c31af7Sopenharmony_ci-- 2526e5c31af7Sopenharmony_ci 2527e5c31af7Sopenharmony_ci[open,refpage='VkAndroidHardwareBufferPropertiesANDROID',desc='Properties of External Memory Android Hardware Buffers',type='structs'] 2528e5c31af7Sopenharmony_ci-- 2529e5c31af7Sopenharmony_ciThe sname:VkAndroidHardwareBufferPropertiesANDROID structure returned is 2530e5c31af7Sopenharmony_cidefined as: 2531e5c31af7Sopenharmony_ci 2532e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkAndroidHardwareBufferPropertiesANDROID.txt[] 2533e5c31af7Sopenharmony_ci 2534e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 2535e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 2536e5c31af7Sopenharmony_ci structure. 2537e5c31af7Sopenharmony_ci * pname:allocationSize is the size of the external memory 2538e5c31af7Sopenharmony_ci * pname:memoryTypeBits is a bitmask containing one bit set for every 2539e5c31af7Sopenharmony_ci memory type which the specified Android hardware buffer can: be imported 2540e5c31af7Sopenharmony_ci as. 2541e5c31af7Sopenharmony_ci 2542e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkAndroidHardwareBufferPropertiesANDROID.txt[] 2543e5c31af7Sopenharmony_ci-- 2544e5c31af7Sopenharmony_ci 2545e5c31af7Sopenharmony_ci[open,refpage='VkAndroidHardwareBufferFormatPropertiesANDROID',desc='Structure describing the image format properties of an Android hardware buffer',type='structs'] 2546e5c31af7Sopenharmony_ci-- 2547e5c31af7Sopenharmony_ciTo obtain format properties of an Android hardware buffer, include a 2548e5c31af7Sopenharmony_cisname:VkAndroidHardwareBufferFormatPropertiesANDROID structure in the 2549e5c31af7Sopenharmony_cipname:pNext chain of the slink:VkAndroidHardwareBufferPropertiesANDROID 2550e5c31af7Sopenharmony_cistructure passed to flink:vkGetAndroidHardwareBufferPropertiesANDROID. 2551e5c31af7Sopenharmony_ciThis structure is defined as: 2552e5c31af7Sopenharmony_ci 2553e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkAndroidHardwareBufferFormatPropertiesANDROID.txt[] 2554e5c31af7Sopenharmony_ci 2555e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 2556e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 2557e5c31af7Sopenharmony_ci structure. 2558e5c31af7Sopenharmony_ci * pname:format is the Vulkan format corresponding to the Android hardware 2559e5c31af7Sopenharmony_ci buffer's format, or ename:VK_FORMAT_UNDEFINED if there is not an 2560e5c31af7Sopenharmony_ci equivalent Vulkan format. 2561e5c31af7Sopenharmony_ci * pname:externalFormat is an implementation-defined external format 2562e5c31af7Sopenharmony_ci identifier for use with slink:VkExternalFormatANDROID. 2563e5c31af7Sopenharmony_ci It must: not be zero. 2564e5c31af7Sopenharmony_ci * pname:formatFeatures describes the capabilities of this external format 2565e5c31af7Sopenharmony_ci when used with an image bound to memory imported from pname:buffer. 2566e5c31af7Sopenharmony_ci * pname:samplerYcbcrConversionComponents is the component swizzle that 2567e5c31af7Sopenharmony_ci should: be used in slink:VkSamplerYcbcrConversionCreateInfo. 2568e5c31af7Sopenharmony_ci * pname:suggestedYcbcrModel is a suggested color model to use in the 2569e5c31af7Sopenharmony_ci slink:VkSamplerYcbcrConversionCreateInfo. 2570e5c31af7Sopenharmony_ci * pname:suggestedYcbcrRange is a suggested numerical value range to use in 2571e5c31af7Sopenharmony_ci slink:VkSamplerYcbcrConversionCreateInfo. 2572e5c31af7Sopenharmony_ci * pname:suggestedXChromaOffset is a suggested X chroma offset to use in 2573e5c31af7Sopenharmony_ci slink:VkSamplerYcbcrConversionCreateInfo. 2574e5c31af7Sopenharmony_ci * pname:suggestedYChromaOffset is a suggested Y chroma offset to use in 2575e5c31af7Sopenharmony_ci slink:VkSamplerYcbcrConversionCreateInfo. 2576e5c31af7Sopenharmony_ci 2577e5c31af7Sopenharmony_ciIf the Android hardware buffer has one of the formats listed in the 2578e5c31af7Sopenharmony_ci<<memory-external-android-hardware-buffer-formats,Format Equivalence 2579e5c31af7Sopenharmony_citable>>, then pname:format must: have the equivalent Vulkan format listed in 2580e5c31af7Sopenharmony_cithe table. 2581e5c31af7Sopenharmony_ciOtherwise, pname:format may: be ename:VK_FORMAT_UNDEFINED, indicating the 2582e5c31af7Sopenharmony_ciAndroid hardware buffer can: only be used with an external format. 2583e5c31af7Sopenharmony_ci 2584e5c31af7Sopenharmony_ciThe pname:formatFeatures member must: include 2585e5c31af7Sopenharmony_ciename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT and at least one of 2586e5c31af7Sopenharmony_ciename:VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT or 2587e5c31af7Sopenharmony_ciename:VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT, and should: include 2588e5c31af7Sopenharmony_ciename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT and 2589e5c31af7Sopenharmony_ciename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT. 2590e5c31af7Sopenharmony_ci 2591e5c31af7Sopenharmony_ci[NOTE] 2592e5c31af7Sopenharmony_ci.Note 2593e5c31af7Sopenharmony_ci==== 2594e5c31af7Sopenharmony_ciThe pname:formatFeatures member only indicates the features available when 2595e5c31af7Sopenharmony_ciusing an 2596e5c31af7Sopenharmony_ci<<memory-external-android-hardware-buffer-external-formats,external-format 2597e5c31af7Sopenharmony_ciimage>> created from the Android hardware buffer. 2598e5c31af7Sopenharmony_ciImages from Android hardware buffers with a format other than 2599e5c31af7Sopenharmony_ciename:VK_FORMAT_UNDEFINED are subject to the format capabilities obtained 2600e5c31af7Sopenharmony_cifrom flink:vkGetPhysicalDeviceFormatProperties2, and 2601e5c31af7Sopenharmony_ciflink:vkGetPhysicalDeviceImageFormatProperties2 with appropriate parameters. 2602e5c31af7Sopenharmony_ciThese sets of features are independent of each other, e.g. the external 2603e5c31af7Sopenharmony_ciformat will support sampler {YCbCr} conversion even if the non-external 2604e5c31af7Sopenharmony_ciformat does not, and writing to non-external format images is possible but 2605e5c31af7Sopenharmony_ciwriting to external format images is not. 2606e5c31af7Sopenharmony_ci==== 2607e5c31af7Sopenharmony_ci 2608e5c31af7Sopenharmony_ciAndroid hardware buffers with the same external format must: have the same 2609e5c31af7Sopenharmony_cisupport for ename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT, 2610e5c31af7Sopenharmony_ciename:VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT, 2611e5c31af7Sopenharmony_ciename:VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT, 2612e5c31af7Sopenharmony_ciename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT, 2613e5c31af7Sopenharmony_ciename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT, 2614e5c31af7Sopenharmony_ciand 2615e5c31af7Sopenharmony_ciename:VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT. 2616e5c31af7Sopenharmony_ciin pname:formatFeatures. 2617e5c31af7Sopenharmony_ciOther format features may: differ between Android hardware buffers that have 2618e5c31af7Sopenharmony_cithe same external format. 2619e5c31af7Sopenharmony_ciThis allows applications to use the same slink:VkSamplerYcbcrConversion 2620e5c31af7Sopenharmony_ciobject (and samplers and pipelines created from them) for any Android 2621e5c31af7Sopenharmony_cihardware buffers that have the same external format. 2622e5c31af7Sopenharmony_ci 2623e5c31af7Sopenharmony_ciIf pname:format is not ename:VK_FORMAT_UNDEFINED, then the value of 2624e5c31af7Sopenharmony_cipname:samplerYcbcrConversionComponents must: be valid when used as the 2625e5c31af7Sopenharmony_cipname:components member of slink:VkSamplerYcbcrConversionCreateInfo with 2626e5c31af7Sopenharmony_cithat format. 2627e5c31af7Sopenharmony_ciIf pname:format is ename:VK_FORMAT_UNDEFINED, all members of 2628e5c31af7Sopenharmony_cipname:samplerYcbcrConversionComponents must: be the 2629e5c31af7Sopenharmony_ci<<resources-image-views-identity-mappings,identity swizzle>>. 2630e5c31af7Sopenharmony_ci 2631e5c31af7Sopenharmony_ciImplementations may: not always be able to determine the color model, 2632e5c31af7Sopenharmony_cinumerical range, or chroma offsets of the image contents, so the values in 2633e5c31af7Sopenharmony_cisname:VkAndroidHardwareBufferFormatPropertiesANDROID are only suggestions. 2634e5c31af7Sopenharmony_ciApplications should: treat these values as sensible defaults to use in the 2635e5c31af7Sopenharmony_ciabsence of more reliable information obtained through some other means. 2636e5c31af7Sopenharmony_ciIf the underlying physical device is also usable via OpenGL ES with the 2637e5c31af7Sopenharmony_cihttps://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image_external.txt[`GL_OES_EGL_image_external`] 2638e5c31af7Sopenharmony_ciextension, the implementation should: suggest values that will produce 2639e5c31af7Sopenharmony_cisimilar sampled values as would be obtained by sampling the same external 2640e5c31af7Sopenharmony_ciimage via code:samplerExternalOES in OpenGL ES using equivalent sampler 2641e5c31af7Sopenharmony_ciparameters. 2642e5c31af7Sopenharmony_ci 2643e5c31af7Sopenharmony_ci[NOTE] 2644e5c31af7Sopenharmony_ci.Note 2645e5c31af7Sopenharmony_ci==== 2646e5c31af7Sopenharmony_ciSince 2647e5c31af7Sopenharmony_cihttps://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image_external.txt[`GL_OES_EGL_image_external`] 2648e5c31af7Sopenharmony_cidoes not require the same sampling and conversion calculations as Vulkan 2649e5c31af7Sopenharmony_cidoes, achieving identical results between APIs may: not be possible on some 2650e5c31af7Sopenharmony_ciimplementations. 2651e5c31af7Sopenharmony_ci==== 2652e5c31af7Sopenharmony_ci 2653e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkAndroidHardwareBufferFormatPropertiesANDROID.txt[] 2654e5c31af7Sopenharmony_ci-- 2655e5c31af7Sopenharmony_ci 2656e5c31af7Sopenharmony_ciifdef::VK_KHR_format_feature_flags2[] 2657e5c31af7Sopenharmony_ci[open,refpage='VkAndroidHardwareBufferFormatProperties2ANDROID',desc='Structure describing the image format properties of an Android hardware buffer',type='structs'] 2658e5c31af7Sopenharmony_ci-- 2659e5c31af7Sopenharmony_ciThe format properties of an Android hardware buffer can: be obtained by 2660e5c31af7Sopenharmony_ciincluding a sname:VkAndroidHardwareBufferFormatProperties2ANDROID structure 2661e5c31af7Sopenharmony_ciin the pname:pNext chain of the 2662e5c31af7Sopenharmony_cislink:VkAndroidHardwareBufferPropertiesANDROID structure passed to 2663e5c31af7Sopenharmony_ciflink:vkGetAndroidHardwareBufferPropertiesANDROID. 2664e5c31af7Sopenharmony_ciThis structure is defined as: 2665e5c31af7Sopenharmony_ci 2666e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkAndroidHardwareBufferFormatProperties2ANDROID.txt[] 2667e5c31af7Sopenharmony_ci 2668e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 2669e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 2670e5c31af7Sopenharmony_ci structure. 2671e5c31af7Sopenharmony_ci * pname:format is the Vulkan format corresponding to the Android hardware 2672e5c31af7Sopenharmony_ci buffer's format, or ename:VK_FORMAT_UNDEFINED if there is not an 2673e5c31af7Sopenharmony_ci equivalent Vulkan format. 2674e5c31af7Sopenharmony_ci * pname:externalFormat is an implementation-defined external format 2675e5c31af7Sopenharmony_ci identifier for use with slink:VkExternalFormatANDROID. 2676e5c31af7Sopenharmony_ci It must: not be zero. 2677e5c31af7Sopenharmony_ci * pname:formatFeatures describes the capabilities of this external format 2678e5c31af7Sopenharmony_ci when used with an image bound to memory imported from pname:buffer. 2679e5c31af7Sopenharmony_ci * pname:samplerYcbcrConversionComponents is the component swizzle that 2680e5c31af7Sopenharmony_ci should: be used in slink:VkSamplerYcbcrConversionCreateInfo. 2681e5c31af7Sopenharmony_ci * pname:suggestedYcbcrModel is a suggested color model to use in the 2682e5c31af7Sopenharmony_ci slink:VkSamplerYcbcrConversionCreateInfo. 2683e5c31af7Sopenharmony_ci * pname:suggestedYcbcrRange is a suggested numerical value range to use in 2684e5c31af7Sopenharmony_ci slink:VkSamplerYcbcrConversionCreateInfo. 2685e5c31af7Sopenharmony_ci * pname:suggestedXChromaOffset is a suggested X chroma offset to use in 2686e5c31af7Sopenharmony_ci slink:VkSamplerYcbcrConversionCreateInfo. 2687e5c31af7Sopenharmony_ci * pname:suggestedYChromaOffset is a suggested Y chroma offset to use in 2688e5c31af7Sopenharmony_ci slink:VkSamplerYcbcrConversionCreateInfo. 2689e5c31af7Sopenharmony_ci 2690e5c31af7Sopenharmony_ciThe bits reported in pname:formatFeatures must: include the bits reported in 2691e5c31af7Sopenharmony_cithe corresponding fields of 2692e5c31af7Sopenharmony_cisname:VkAndroidHardwareBufferFormatPropertiesANDROID::pname:formatFeatures. 2693e5c31af7Sopenharmony_ci 2694e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkAndroidHardwareBufferFormatProperties2ANDROID.txt[] 2695e5c31af7Sopenharmony_ci-- 2696e5c31af7Sopenharmony_ciendif::VK_KHR_format_feature_flags2[] 2697e5c31af7Sopenharmony_ciendif::VK_ANDROID_external_memory_android_hardware_buffer[] 2698e5c31af7Sopenharmony_ci 2699e5c31af7Sopenharmony_ciifdef::VK_NV_external_memory_rdma[] 2700e5c31af7Sopenharmony_ci[open,refpage='vkGetMemoryRemoteAddressNV',desc='Get an address for a memory object accessible by remote devices',type='protos'] 2701e5c31af7Sopenharmony_ci-- 2702e5c31af7Sopenharmony_ciTo export an address representing the payload of a Vulkan device memory 2703e5c31af7Sopenharmony_ciobject accessible by remote devices, call: 2704e5c31af7Sopenharmony_ci 2705e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetMemoryRemoteAddressNV.txt[] 2706e5c31af7Sopenharmony_ci 2707e5c31af7Sopenharmony_ci * pname:device is the logical device that created the device memory being 2708e5c31af7Sopenharmony_ci exported. 2709e5c31af7Sopenharmony_ci * pname:pMemoryGetRemoteAddressInfo is a pointer to a 2710e5c31af7Sopenharmony_ci slink:VkMemoryGetRemoteAddressInfoNV structure containing parameters of 2711e5c31af7Sopenharmony_ci the export operation. 2712e5c31af7Sopenharmony_ci * pname:pAddress will return the address representing the payload of the 2713e5c31af7Sopenharmony_ci device memory object. 2714e5c31af7Sopenharmony_ci 2715e5c31af7Sopenharmony_ciMore communication may be required between the kernel-mode drivers of the 2716e5c31af7Sopenharmony_cidevices involved. 2717e5c31af7Sopenharmony_ciThis information is out of scope of this documentation and should be 2718e5c31af7Sopenharmony_cirequested from the vendors of the devices. 2719e5c31af7Sopenharmony_ci 2720e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetMemoryRemoteAddressNV.txt[] 2721e5c31af7Sopenharmony_ci-- 2722e5c31af7Sopenharmony_ci 2723e5c31af7Sopenharmony_ci[open,refpage='VkMemoryGetRemoteAddressInfoNV',desc='Structure describing a remote accessible address export operation',type='structs'] 2724e5c31af7Sopenharmony_ci-- 2725e5c31af7Sopenharmony_ciThe sname:VkMemoryGetRemoteAddressInfoNV structure is defined as: 2726e5c31af7Sopenharmony_ci 2727e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkMemoryGetRemoteAddressInfoNV.txt[] 2728e5c31af7Sopenharmony_ci 2729e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 2730e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 2731e5c31af7Sopenharmony_ci structure. 2732e5c31af7Sopenharmony_ci * pname:memory is the memory object from which the remote accessible 2733e5c31af7Sopenharmony_ci address will be exported. 2734e5c31af7Sopenharmony_ci * pname:handleType is the type of handle requested. 2735e5c31af7Sopenharmony_ci 2736e5c31af7Sopenharmony_ci.Valid Usage 2737e5c31af7Sopenharmony_ci**** 2738e5c31af7Sopenharmony_ci * [[VUID-VkMemoryGetRemoteAddressInfoNV-handleType-04966]] 2739e5c31af7Sopenharmony_ci pname:handleType must: have been included in 2740e5c31af7Sopenharmony_ci slink:VkExportMemoryAllocateInfo::pname:handleTypes when pname:memory 2741e5c31af7Sopenharmony_ci was created 2742e5c31af7Sopenharmony_ci**** 2743e5c31af7Sopenharmony_ci 2744e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkMemoryGetRemoteAddressInfoNV.txt[] 2745e5c31af7Sopenharmony_ci-- 2746e5c31af7Sopenharmony_ciendif::VK_NV_external_memory_rdma[] 2747e5c31af7Sopenharmony_ci 2748e5c31af7Sopenharmony_ciifdef::VK_FUCHSIA_external_memory[] 2749e5c31af7Sopenharmony_ciinclude::{chapters}/VK_FUCHSIA_external_memory/device_memory.txt[] 2750e5c31af7Sopenharmony_ciendif::VK_FUCHSIA_external_memory[] 2751e5c31af7Sopenharmony_ci 2752e5c31af7Sopenharmony_ci 2753e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_device_group[] 2754e5c31af7Sopenharmony_ci=== Device Group Memory Allocations 2755e5c31af7Sopenharmony_ci 2756e5c31af7Sopenharmony_ci[open,refpage='VkMemoryAllocateFlagsInfo',desc='Structure controlling how many instances of memory will be allocated',type='structs'] 2757e5c31af7Sopenharmony_ci-- 2758e5c31af7Sopenharmony_ciIf the pname:pNext chain of slink:VkMemoryAllocateInfo includes a 2759e5c31af7Sopenharmony_cisname:VkMemoryAllocateFlagsInfo structure, then that structure includes 2760e5c31af7Sopenharmony_ciflags and a device mask controlling how many instances of the memory will be 2761e5c31af7Sopenharmony_ciallocated. 2762e5c31af7Sopenharmony_ci 2763e5c31af7Sopenharmony_ciThe sname:VkMemoryAllocateFlagsInfo structure is defined as: 2764e5c31af7Sopenharmony_ci 2765e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkMemoryAllocateFlagsInfo.txt[] 2766e5c31af7Sopenharmony_ci 2767e5c31af7Sopenharmony_ciifdef::VK_KHR_device_group[] 2768e5c31af7Sopenharmony_cior the equivalent 2769e5c31af7Sopenharmony_ci 2770e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkMemoryAllocateFlagsInfoKHR.txt[] 2771e5c31af7Sopenharmony_ciendif::VK_KHR_device_group[] 2772e5c31af7Sopenharmony_ci 2773e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 2774e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 2775e5c31af7Sopenharmony_ci structure. 2776e5c31af7Sopenharmony_ci * pname:flags is a bitmask of elink:VkMemoryAllocateFlagBits controlling 2777e5c31af7Sopenharmony_ci the allocation. 2778e5c31af7Sopenharmony_ci * pname:deviceMask is a mask of physical devices in the logical device, 2779e5c31af7Sopenharmony_ci indicating that memory must: be allocated on each device in the mask, if 2780e5c31af7Sopenharmony_ci ename:VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT is set in pname:flags. 2781e5c31af7Sopenharmony_ci 2782e5c31af7Sopenharmony_ciIf ename:VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT is not set, the number of 2783e5c31af7Sopenharmony_ciinstances allocated depends on whether 2784e5c31af7Sopenharmony_ciename:VK_MEMORY_HEAP_MULTI_INSTANCE_BIT is set in the memory heap. 2785e5c31af7Sopenharmony_ciIf ename:VK_MEMORY_HEAP_MULTI_INSTANCE_BIT is set, then memory is allocated 2786e5c31af7Sopenharmony_cifor every physical device in the logical device (as if pname:deviceMask has 2787e5c31af7Sopenharmony_cibits set for all device indices). 2788e5c31af7Sopenharmony_ciIf ename:VK_MEMORY_HEAP_MULTI_INSTANCE_BIT is not set, then a single 2789e5c31af7Sopenharmony_ciinstance of memory is allocated (as if pname:deviceMask is set to one). 2790e5c31af7Sopenharmony_ci 2791e5c31af7Sopenharmony_ciOn some implementations, allocations from a multi-instance heap may: consume 2792e5c31af7Sopenharmony_cimemory on all physical devices even if the pname:deviceMask excludes some 2793e5c31af7Sopenharmony_cidevices. 2794e5c31af7Sopenharmony_ciIf slink:VkPhysicalDeviceGroupProperties::pname:subsetAllocation is 2795e5c31af7Sopenharmony_ciename:VK_TRUE, then memory is only consumed for the devices in the device 2796e5c31af7Sopenharmony_cimask. 2797e5c31af7Sopenharmony_ci 2798e5c31af7Sopenharmony_ci[NOTE] 2799e5c31af7Sopenharmony_ci.Note 2800e5c31af7Sopenharmony_ci==== 2801e5c31af7Sopenharmony_ciIn practice, most allocations on a multi-instance heap will be allocated 2802e5c31af7Sopenharmony_ciacross all physical devices. 2803e5c31af7Sopenharmony_ciUnicast allocation support is an optional optimization for a minority of 2804e5c31af7Sopenharmony_ciallocations. 2805e5c31af7Sopenharmony_ci==== 2806e5c31af7Sopenharmony_ci 2807e5c31af7Sopenharmony_ci.Valid Usage 2808e5c31af7Sopenharmony_ci**** 2809e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateFlagsInfo-deviceMask-00675]] 2810e5c31af7Sopenharmony_ci If ename:VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT is set, pname:deviceMask 2811e5c31af7Sopenharmony_ci must: be a valid device mask 2812e5c31af7Sopenharmony_ci * [[VUID-VkMemoryAllocateFlagsInfo-deviceMask-00676]] 2813e5c31af7Sopenharmony_ci If ename:VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT is set, pname:deviceMask 2814e5c31af7Sopenharmony_ci must: not be zero 2815e5c31af7Sopenharmony_ci**** 2816e5c31af7Sopenharmony_ci 2817e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkMemoryAllocateFlagsInfo.txt[] 2818e5c31af7Sopenharmony_ci-- 2819e5c31af7Sopenharmony_ci 2820e5c31af7Sopenharmony_ci[open,refpage='VkMemoryAllocateFlagBits',desc='Bitmask specifying flags for a device memory allocation',type='enums'] 2821e5c31af7Sopenharmony_ci-- 2822e5c31af7Sopenharmony_ciBits which can: be set in slink:VkMemoryAllocateFlagsInfo::pname:flags, 2823e5c31af7Sopenharmony_cicontrolling device memory allocation, are: 2824e5c31af7Sopenharmony_ci 2825e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkMemoryAllocateFlagBits.txt[] 2826e5c31af7Sopenharmony_ci 2827e5c31af7Sopenharmony_ciifdef::VK_KHR_device_group[] 2828e5c31af7Sopenharmony_cior the equivalent 2829e5c31af7Sopenharmony_ci 2830e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkMemoryAllocateFlagBitsKHR.txt[] 2831e5c31af7Sopenharmony_ciendif::VK_KHR_device_group[] 2832e5c31af7Sopenharmony_ci 2833e5c31af7Sopenharmony_ci * ename:VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT specifies that memory will be 2834e5c31af7Sopenharmony_ci allocated for the devices in 2835e5c31af7Sopenharmony_ci slink:VkMemoryAllocateFlagsInfo::pname:deviceMask. 2836e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_KHR_buffer_device_address[] 2837e5c31af7Sopenharmony_ci * ename:VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT specifies that the memory 2838e5c31af7Sopenharmony_ci can: be attached to a buffer object created with the 2839e5c31af7Sopenharmony_ci ename:VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT bit set in pname:usage, 2840e5c31af7Sopenharmony_ci and that the memory handle can: be used to retrieve an opaque address 2841e5c31af7Sopenharmony_ci via flink:vkGetDeviceMemoryOpaqueCaptureAddress. 2842e5c31af7Sopenharmony_ci * ename:VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT specifies 2843e5c31af7Sopenharmony_ci that the memory's address can: be saved and reused on a subsequent run 2844e5c31af7Sopenharmony_ci (e.g. for trace capture and replay), see 2845e5c31af7Sopenharmony_ci slink:VkBufferOpaqueCaptureAddressCreateInfo for more detail. 2846e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_KHR_buffer_device_address[] 2847e5c31af7Sopenharmony_ci-- 2848e5c31af7Sopenharmony_ci 2849e5c31af7Sopenharmony_ci[open,refpage='VkMemoryAllocateFlags',desc='Bitmask of VkMemoryAllocateFlagBits',type='flags'] 2850e5c31af7Sopenharmony_ci-- 2851e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkMemoryAllocateFlags.txt[] 2852e5c31af7Sopenharmony_ci 2853e5c31af7Sopenharmony_ciifdef::VK_KHR_device_group[] 2854e5c31af7Sopenharmony_cior the equivalent 2855e5c31af7Sopenharmony_ci 2856e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkMemoryAllocateFlagsKHR.txt[] 2857e5c31af7Sopenharmony_ciendif::VK_KHR_device_group[] 2858e5c31af7Sopenharmony_ci 2859e5c31af7Sopenharmony_citname:VkMemoryAllocateFlags is a bitmask type for setting a mask of zero or 2860e5c31af7Sopenharmony_cimore elink:VkMemoryAllocateFlagBits. 2861e5c31af7Sopenharmony_ci-- 2862e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_device_group[] 2863e5c31af7Sopenharmony_ci 2864e5c31af7Sopenharmony_ci 2865e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_KHR_buffer_device_address[] 2866e5c31af7Sopenharmony_ci=== Opaque Capture Address Allocation 2867e5c31af7Sopenharmony_ci 2868e5c31af7Sopenharmony_ci[open,refpage='VkMemoryOpaqueCaptureAddressAllocateInfo',desc='Request a specific address for a memory allocation',type='structs',alias='VkMemoryOpaqueCaptureAddressAllocateInfoKHR'] 2869e5c31af7Sopenharmony_ci-- 2870e5c31af7Sopenharmony_ciTo request a specific device address for a memory allocation, add a 2871e5c31af7Sopenharmony_cislink:VkMemoryOpaqueCaptureAddressAllocateInfo structure to the pname:pNext 2872e5c31af7Sopenharmony_cichain of the slink:VkMemoryAllocateInfo structure. 2873e5c31af7Sopenharmony_ciThe sname:VkMemoryOpaqueCaptureAddressAllocateInfo structure is defined as: 2874e5c31af7Sopenharmony_ci 2875e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkMemoryOpaqueCaptureAddressAllocateInfo.txt[] 2876e5c31af7Sopenharmony_ci 2877e5c31af7Sopenharmony_ciifdef::VK_KHR_buffer_device_address[] 2878e5c31af7Sopenharmony_cior the equivalent 2879e5c31af7Sopenharmony_ci 2880e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkMemoryOpaqueCaptureAddressAllocateInfoKHR.txt[] 2881e5c31af7Sopenharmony_ciendif::VK_KHR_buffer_device_address[] 2882e5c31af7Sopenharmony_ci 2883e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 2884e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 2885e5c31af7Sopenharmony_ci structure. 2886e5c31af7Sopenharmony_ci * pname:opaqueCaptureAddress is the opaque capture address requested for 2887e5c31af7Sopenharmony_ci the memory allocation. 2888e5c31af7Sopenharmony_ci 2889e5c31af7Sopenharmony_ciIf pname:opaqueCaptureAddress is zero, no specific address is requested. 2890e5c31af7Sopenharmony_ci 2891e5c31af7Sopenharmony_ciIf pname:opaqueCaptureAddress is not zero, it should: be an address 2892e5c31af7Sopenharmony_ciretrieved from flink:vkGetDeviceMemoryOpaqueCaptureAddress on an identically 2893e5c31af7Sopenharmony_cicreated memory allocation on the same implementation. 2894e5c31af7Sopenharmony_ci 2895e5c31af7Sopenharmony_ci[NOTE] 2896e5c31af7Sopenharmony_ci.Note 2897e5c31af7Sopenharmony_ci==== 2898e5c31af7Sopenharmony_ciIn most cases, it is expected that a non-zero pname:opaqueAddress is an 2899e5c31af7Sopenharmony_ciaddress retrieved from flink:vkGetDeviceMemoryOpaqueCaptureAddress on an 2900e5c31af7Sopenharmony_ciidentically created memory allocation. 2901e5c31af7Sopenharmony_ciIf this is not the case, it is likely that 2902e5c31af7Sopenharmony_ciename:VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS errors will occur. 2903e5c31af7Sopenharmony_ci 2904e5c31af7Sopenharmony_ciThis is, however, not a strict requirement because trace capture/replay 2905e5c31af7Sopenharmony_citools may need to adjust memory allocation parameters for imported memory. 2906e5c31af7Sopenharmony_ci==== 2907e5c31af7Sopenharmony_ci 2908e5c31af7Sopenharmony_ciIf this structure is not present, it is as if pname:opaqueCaptureAddress is 2909e5c31af7Sopenharmony_cizero. 2910e5c31af7Sopenharmony_ci 2911e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkMemoryOpaqueCaptureAddressAllocateInfo.txt[] 2912e5c31af7Sopenharmony_ci-- 2913e5c31af7Sopenharmony_ci 2914e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_KHR_buffer_device_address[] 2915e5c31af7Sopenharmony_ci 2916e5c31af7Sopenharmony_ci 2917e5c31af7Sopenharmony_ci=== Freeing Device Memory 2918e5c31af7Sopenharmony_ci 2919e5c31af7Sopenharmony_ci[open,refpage='vkFreeMemory',desc='Free device memory',type='protos'] 2920e5c31af7Sopenharmony_ci-- 2921e5c31af7Sopenharmony_ciTo free a memory object, call: 2922e5c31af7Sopenharmony_ci 2923e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkFreeMemory.txt[] 2924e5c31af7Sopenharmony_ci 2925e5c31af7Sopenharmony_ci * pname:device is the logical device that owns the memory. 2926e5c31af7Sopenharmony_ci * pname:memory is the slink:VkDeviceMemory object to be freed. 2927e5c31af7Sopenharmony_ci * pname:pAllocator controls host memory allocation as described in the 2928e5c31af7Sopenharmony_ci <<memory-allocation, Memory Allocation>> chapter. 2929e5c31af7Sopenharmony_ci 2930e5c31af7Sopenharmony_ciBefore freeing a memory object, an application must: ensure the memory 2931e5c31af7Sopenharmony_ciobject is no longer in use by the device -- for example by command buffers 2932e5c31af7Sopenharmony_ciin the _pending state_. 2933e5c31af7Sopenharmony_ciMemory can: be freed whilst still bound to resources, but those resources 2934e5c31af7Sopenharmony_cimust: not be used afterwards. 2935e5c31af7Sopenharmony_ciFreeing a memory object releases the reference it held, if any, to its 2936e5c31af7Sopenharmony_cipayload. 2937e5c31af7Sopenharmony_ciIf there are still any bound images or buffers, the memory object's payload 2938e5c31af7Sopenharmony_cimay: not be immediately released by the implementation, but must: be 2939e5c31af7Sopenharmony_cireleased by the time all bound images and buffers have been destroyed. 2940e5c31af7Sopenharmony_ciOnce all references to a payload are released, it is returned to the heap 2941e5c31af7Sopenharmony_cifrom which it was allocated. 2942e5c31af7Sopenharmony_ci 2943e5c31af7Sopenharmony_ciHow memory objects are bound to Images and Buffers is described in detail in 2944e5c31af7Sopenharmony_cithe <<resources-association, Resource Memory Association>> section. 2945e5c31af7Sopenharmony_ci 2946e5c31af7Sopenharmony_ciIf a memory object is mapped at the time it is freed, it is implicitly 2947e5c31af7Sopenharmony_ciunmapped. 2948e5c31af7Sopenharmony_ci 2949e5c31af7Sopenharmony_ci[NOTE] 2950e5c31af7Sopenharmony_ci.Note 2951e5c31af7Sopenharmony_ci==== 2952e5c31af7Sopenharmony_ciAs described <<memory-device-unmap-does-not-flush, below>>, host writes are 2953e5c31af7Sopenharmony_cinot implicitly flushed when the memory object is unmapped, but the 2954e5c31af7Sopenharmony_ciimplementation must: guarantee that writes that have not been flushed do not 2955e5c31af7Sopenharmony_ciaffect any other memory. 2956e5c31af7Sopenharmony_ci==== 2957e5c31af7Sopenharmony_ci 2958e5c31af7Sopenharmony_ci.Valid Usage 2959e5c31af7Sopenharmony_ci**** 2960e5c31af7Sopenharmony_ci * [[VUID-vkFreeMemory-memory-00677]] 2961e5c31af7Sopenharmony_ci All submitted commands that refer to pname:memory (via images or 2962e5c31af7Sopenharmony_ci buffers) must: have completed execution 2963e5c31af7Sopenharmony_ci**** 2964e5c31af7Sopenharmony_ci 2965e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkFreeMemory.txt[] 2966e5c31af7Sopenharmony_ci-- 2967e5c31af7Sopenharmony_ci 2968e5c31af7Sopenharmony_ci 2969e5c31af7Sopenharmony_ci[[memory-device-hostaccess]] 2970e5c31af7Sopenharmony_ci=== Host Access to Device Memory Objects 2971e5c31af7Sopenharmony_ci 2972e5c31af7Sopenharmony_ciMemory objects created with flink:vkAllocateMemory are not directly host 2973e5c31af7Sopenharmony_ciaccessible. 2974e5c31af7Sopenharmony_ci 2975e5c31af7Sopenharmony_ciMemory objects created with the memory property 2976e5c31af7Sopenharmony_ciename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT are considered _mappable_. 2977e5c31af7Sopenharmony_ciMemory objects must: be mappable in order to be successfully mapped on the 2978e5c31af7Sopenharmony_cihost. 2979e5c31af7Sopenharmony_ci 2980e5c31af7Sopenharmony_ci[open,refpage='vkMapMemory',desc='Map a memory object into application address space',type='protos'] 2981e5c31af7Sopenharmony_ci-- 2982e5c31af7Sopenharmony_ciTo retrieve a host virtual address pointer to a region of a mappable memory 2983e5c31af7Sopenharmony_ciobject, call: 2984e5c31af7Sopenharmony_ci 2985e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkMapMemory.txt[] 2986e5c31af7Sopenharmony_ci 2987e5c31af7Sopenharmony_ci * pname:device is the logical device that owns the memory. 2988e5c31af7Sopenharmony_ci * pname:memory is the slink:VkDeviceMemory object to be mapped. 2989e5c31af7Sopenharmony_ci * pname:offset is a zero-based byte offset from the beginning of the 2990e5c31af7Sopenharmony_ci memory object. 2991e5c31af7Sopenharmony_ci * pname:size is the size of the memory range to map, or 2992e5c31af7Sopenharmony_ci ename:VK_WHOLE_SIZE to map from pname:offset to the end of the 2993e5c31af7Sopenharmony_ci allocation. 2994e5c31af7Sopenharmony_ci * pname:flags is reserved for future use. 2995e5c31af7Sopenharmony_ci * pname:ppData is a pointer to a `void *` variable in which is returned a 2996e5c31af7Sopenharmony_ci host-accessible pointer to the beginning of the mapped range. 2997e5c31af7Sopenharmony_ci This pointer minus pname:offset must: be aligned to at least 2998e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceLimits::pname:minMemoryMapAlignment. 2999e5c31af7Sopenharmony_ci 3000e5c31af7Sopenharmony_ciAfter a successful call to fname:vkMapMemory the memory object pname:memory 3001e5c31af7Sopenharmony_ciis considered to be currently _host mapped_. 3002e5c31af7Sopenharmony_ci 3003e5c31af7Sopenharmony_ci[NOTE] 3004e5c31af7Sopenharmony_ci.Note 3005e5c31af7Sopenharmony_ci==== 3006e5c31af7Sopenharmony_ciIt is an application error to call fname:vkMapMemory on a memory object that 3007e5c31af7Sopenharmony_ciis already _host mapped_. 3008e5c31af7Sopenharmony_ci==== 3009e5c31af7Sopenharmony_ci 3010e5c31af7Sopenharmony_ci[NOTE] 3011e5c31af7Sopenharmony_ci.Note 3012e5c31af7Sopenharmony_ci==== 3013e5c31af7Sopenharmony_cifname:vkMapMemory will fail if the implementation is unable to allocate an 3014e5c31af7Sopenharmony_ciappropriately sized contiguous virtual address range, e.g. due to virtual 3015e5c31af7Sopenharmony_ciaddress space fragmentation or platform limits. 3016e5c31af7Sopenharmony_ciIn such cases, fname:vkMapMemory must: return 3017e5c31af7Sopenharmony_ciename:VK_ERROR_MEMORY_MAP_FAILED. 3018e5c31af7Sopenharmony_ciThe application can: improve the likelihood of success by reducing the size 3019e5c31af7Sopenharmony_ciof the mapped range and/or removing unneeded mappings using 3020e5c31af7Sopenharmony_ciflink:vkUnmapMemory. 3021e5c31af7Sopenharmony_ci==== 3022e5c31af7Sopenharmony_ci 3023e5c31af7Sopenharmony_ci[[memory-device-hostaccess-hazards]] 3024e5c31af7Sopenharmony_cifname:vkMapMemory does not check whether the device memory is currently in 3025e5c31af7Sopenharmony_ciuse before returning the host-accessible pointer. 3026e5c31af7Sopenharmony_ciThe application must: guarantee that any previously submitted command that 3027e5c31af7Sopenharmony_ciwrites to this range has completed before the host reads from or writes to 3028e5c31af7Sopenharmony_cithat range, and that any previously submitted command that reads from that 3029e5c31af7Sopenharmony_cirange has completed before the host writes to that region (see 3030e5c31af7Sopenharmony_ci<<synchronization-submission-host-writes, here>> for details on fulfilling 3031e5c31af7Sopenharmony_cisuch a guarantee). 3032e5c31af7Sopenharmony_ciIf the device memory was allocated without the 3033e5c31af7Sopenharmony_ciename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT set, these guarantees must: be 3034e5c31af7Sopenharmony_cimade for an extended range: the application must: round down the start of 3035e5c31af7Sopenharmony_cithe range to the nearest multiple of 3036e5c31af7Sopenharmony_cislink:VkPhysicalDeviceLimits::pname:nonCoherentAtomSize, and round the end 3037e5c31af7Sopenharmony_ciof the range up to the nearest multiple of 3038e5c31af7Sopenharmony_cislink:VkPhysicalDeviceLimits::pname:nonCoherentAtomSize. 3039e5c31af7Sopenharmony_ci 3040e5c31af7Sopenharmony_ciWhile a range of device memory is host mapped, the application is 3041e5c31af7Sopenharmony_ciresponsible for synchronizing both device and host access to that memory 3042e5c31af7Sopenharmony_cirange. 3043e5c31af7Sopenharmony_ci 3044e5c31af7Sopenharmony_ci[NOTE] 3045e5c31af7Sopenharmony_ci.Note 3046e5c31af7Sopenharmony_ci==== 3047e5c31af7Sopenharmony_ciIt is important for the application developer to become meticulously 3048e5c31af7Sopenharmony_cifamiliar with all of the mechanisms described in the chapter on 3049e5c31af7Sopenharmony_ci<<synchronization, Synchronization and Cache Control>> as they are crucial 3050e5c31af7Sopenharmony_cito maintaining memory access ordering. 3051e5c31af7Sopenharmony_ci==== 3052e5c31af7Sopenharmony_ci 3053e5c31af7Sopenharmony_ci.Valid Usage 3054e5c31af7Sopenharmony_ci**** 3055e5c31af7Sopenharmony_ci * [[VUID-vkMapMemory-memory-00678]] 3056e5c31af7Sopenharmony_ci pname:memory must: not be currently host mapped 3057e5c31af7Sopenharmony_ci * [[VUID-vkMapMemory-offset-00679]] 3058e5c31af7Sopenharmony_ci pname:offset must: be less than the size of pname:memory 3059e5c31af7Sopenharmony_ci * [[VUID-vkMapMemory-size-00680]] 3060e5c31af7Sopenharmony_ci If pname:size is not equal to ename:VK_WHOLE_SIZE, pname:size must: be 3061e5c31af7Sopenharmony_ci greater than `0` 3062e5c31af7Sopenharmony_ci * [[VUID-vkMapMemory-size-00681]] 3063e5c31af7Sopenharmony_ci If pname:size is not equal to ename:VK_WHOLE_SIZE, pname:size must: be 3064e5c31af7Sopenharmony_ci less than or equal to the size of the pname:memory minus pname:offset 3065e5c31af7Sopenharmony_ci * [[VUID-vkMapMemory-memory-00682]] 3066e5c31af7Sopenharmony_ci pname:memory must: have been created with a memory type that reports 3067e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT 3068e5c31af7Sopenharmony_ciifdef::VK_KHR_device_group[] 3069e5c31af7Sopenharmony_ci * [[VUID-vkMapMemory-memory-00683]] 3070e5c31af7Sopenharmony_ci pname:memory must: not have been allocated with multiple instances 3071e5c31af7Sopenharmony_ciendif::VK_KHR_device_group[] 3072e5c31af7Sopenharmony_ci**** 3073e5c31af7Sopenharmony_ci 3074e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkMapMemory.txt[] 3075e5c31af7Sopenharmony_ci-- 3076e5c31af7Sopenharmony_ci 3077e5c31af7Sopenharmony_ci[open,refpage='VkMemoryMapFlags',desc='Reserved for future use',type='flags'] 3078e5c31af7Sopenharmony_ci-- 3079e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkMemoryMapFlags.txt[] 3080e5c31af7Sopenharmony_ci 3081e5c31af7Sopenharmony_citname:VkMemoryMapFlags is a bitmask type for setting a mask, but is 3082e5c31af7Sopenharmony_cicurrently reserved for future use. 3083e5c31af7Sopenharmony_ci-- 3084e5c31af7Sopenharmony_ci 3085e5c31af7Sopenharmony_ciTwo commands are provided to enable applications to work with non-coherent 3086e5c31af7Sopenharmony_cimemory allocations: fname:vkFlushMappedMemoryRanges and 3087e5c31af7Sopenharmony_cifname:vkInvalidateMappedMemoryRanges. 3088e5c31af7Sopenharmony_ci 3089e5c31af7Sopenharmony_ci[NOTE] 3090e5c31af7Sopenharmony_ci.Note 3091e5c31af7Sopenharmony_ci==== 3092e5c31af7Sopenharmony_ciIf the memory object was created with the 3093e5c31af7Sopenharmony_ciename:VK_MEMORY_PROPERTY_HOST_COHERENT_BIT set, 3094e5c31af7Sopenharmony_cifname:vkFlushMappedMemoryRanges and fname:vkInvalidateMappedMemoryRanges are 3095e5c31af7Sopenharmony_ciunnecessary and may: have a performance cost. 3096e5c31af7Sopenharmony_ciHowever, <<synchronization-dependencies-available-and-visible, availability 3097e5c31af7Sopenharmony_ciand visibility operations>> still need to be managed on the device. 3098e5c31af7Sopenharmony_ciSee the description of <<synchronization-host-access-types, host access 3099e5c31af7Sopenharmony_citypes>> for more information. 3100e5c31af7Sopenharmony_ci==== 3101e5c31af7Sopenharmony_ci 3102e5c31af7Sopenharmony_ciifdef::VK_EXT_external_memory_host[] 3103e5c31af7Sopenharmony_ci[NOTE] 3104e5c31af7Sopenharmony_ci.Note 3105e5c31af7Sopenharmony_ci==== 3106e5c31af7Sopenharmony_ciWhile memory objects imported from a handle type of 3107e5c31af7Sopenharmony_ciename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT or 3108e5c31af7Sopenharmony_ciename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_MAPPED_FOREIGN_MEMORY_BIT_EXT are 3109e5c31af7Sopenharmony_ciinherently mapped to host address space, they are not considered to be host 3110e5c31af7Sopenharmony_cimapped device memory unless they are explicitly host mapped using 3111e5c31af7Sopenharmony_ciflink:vkMapMemory. 3112e5c31af7Sopenharmony_ciThat means flushing or invalidating host caches with respect to host 3113e5c31af7Sopenharmony_ciaccesses performed on such memory through the original host pointer 3114e5c31af7Sopenharmony_cispecified at import time is the responsibility of the application and must: 3115e5c31af7Sopenharmony_cibe performed with appropriate synchronization primitives provided by the 3116e5c31af7Sopenharmony_ciplatform which are outside the scope of Vulkan. 3117e5c31af7Sopenharmony_cifname:vkFlushMappedMemoryRanges and fname:vkInvalidateMappedMemoryRanges, 3118e5c31af7Sopenharmony_cihowever, can: still be used on such memory objects to synchronize host 3119e5c31af7Sopenharmony_ciaccesses performed through the host pointer of the host mapped device memory 3120e5c31af7Sopenharmony_cirange returned by flink:vkMapMemory. 3121e5c31af7Sopenharmony_ci==== 3122e5c31af7Sopenharmony_ciendif::VK_EXT_external_memory_host[] 3123e5c31af7Sopenharmony_ci 3124e5c31af7Sopenharmony_ci[open,refpage='vkFlushMappedMemoryRanges',desc='Flush mapped memory ranges',type='protos'] 3125e5c31af7Sopenharmony_ci-- 3126e5c31af7Sopenharmony_ciTo flush ranges of non-coherent memory from the host caches, call: 3127e5c31af7Sopenharmony_ci 3128e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkFlushMappedMemoryRanges.txt[] 3129e5c31af7Sopenharmony_ci 3130e5c31af7Sopenharmony_ci * pname:device is the logical device that owns the memory ranges. 3131e5c31af7Sopenharmony_ci * pname:memoryRangeCount is the length of the pname:pMemoryRanges array. 3132e5c31af7Sopenharmony_ci * pname:pMemoryRanges is a pointer to an array of 3133e5c31af7Sopenharmony_ci slink:VkMappedMemoryRange structures describing the memory ranges to 3134e5c31af7Sopenharmony_ci flush. 3135e5c31af7Sopenharmony_ci 3136e5c31af7Sopenharmony_cifname:vkFlushMappedMemoryRanges guarantees that host writes to the memory 3137e5c31af7Sopenharmony_ciranges described by pname:pMemoryRanges are made available to the host 3138e5c31af7Sopenharmony_cimemory domain, such that they can: be made available to the device memory 3139e5c31af7Sopenharmony_cidomain via <<synchronization-dependencies-available-and-visible, memory 3140e5c31af7Sopenharmony_cidomain operations>> using the ename:VK_ACCESS_HOST_WRITE_BIT 3141e5c31af7Sopenharmony_ci<<synchronization-access-types,access type>>. 3142e5c31af7Sopenharmony_ci 3143e5c31af7Sopenharmony_ciWithin each range described by pname:pMemoryRanges, each set of 3144e5c31af7Sopenharmony_cipname:nonCoherentAtomSize bytes in that range is flushed if any byte in that 3145e5c31af7Sopenharmony_ciset has been written by the host since it was first host mapped, or the last 3146e5c31af7Sopenharmony_citime it was flushed. 3147e5c31af7Sopenharmony_ciIf pname:pMemoryRanges includes sets of pname:nonCoherentAtomSize bytes 3148e5c31af7Sopenharmony_ciwhere no bytes have been written by the host, those bytes must: not be 3149e5c31af7Sopenharmony_ciflushed. 3150e5c31af7Sopenharmony_ci 3151e5c31af7Sopenharmony_ci[[memory-device-unmap-does-not-flush]] 3152e5c31af7Sopenharmony_ciUnmapping non-coherent memory does not implicitly flush the host mapped 3153e5c31af7Sopenharmony_cimemory, and host writes that have not been flushed may: not ever be visible 3154e5c31af7Sopenharmony_cito the device. 3155e5c31af7Sopenharmony_ciHowever, implementations must: ensure that writes that have not been flushed 3156e5c31af7Sopenharmony_cido not become visible to any other memory. 3157e5c31af7Sopenharmony_ci 3158e5c31af7Sopenharmony_ci[NOTE] 3159e5c31af7Sopenharmony_ci.Note 3160e5c31af7Sopenharmony_ci==== 3161e5c31af7Sopenharmony_ciThe above guarantee avoids a potential memory corruption in scenarios where 3162e5c31af7Sopenharmony_cihost writes to a mapped memory object have not been flushed before the 3163e5c31af7Sopenharmony_cimemory is unmapped (or freed), and the virtual address range is subsequently 3164e5c31af7Sopenharmony_cireused for a different mapping (or memory allocation). 3165e5c31af7Sopenharmony_ci==== 3166e5c31af7Sopenharmony_ci 3167e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkFlushMappedMemoryRanges.txt[] 3168e5c31af7Sopenharmony_ci-- 3169e5c31af7Sopenharmony_ci 3170e5c31af7Sopenharmony_ci[open,refpage='vkInvalidateMappedMemoryRanges',desc='Invalidate ranges of mapped memory objects',type='protos'] 3171e5c31af7Sopenharmony_ci-- 3172e5c31af7Sopenharmony_ciTo invalidate ranges of non-coherent memory from the host caches, call: 3173e5c31af7Sopenharmony_ci 3174e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkInvalidateMappedMemoryRanges.txt[] 3175e5c31af7Sopenharmony_ci 3176e5c31af7Sopenharmony_ci * pname:device is the logical device that owns the memory ranges. 3177e5c31af7Sopenharmony_ci * pname:memoryRangeCount is the length of the pname:pMemoryRanges array. 3178e5c31af7Sopenharmony_ci * pname:pMemoryRanges is a pointer to an array of 3179e5c31af7Sopenharmony_ci slink:VkMappedMemoryRange structures describing the memory ranges to 3180e5c31af7Sopenharmony_ci invalidate. 3181e5c31af7Sopenharmony_ci 3182e5c31af7Sopenharmony_cifname:vkInvalidateMappedMemoryRanges guarantees that device writes to the 3183e5c31af7Sopenharmony_cimemory ranges described by pname:pMemoryRanges, which have been made 3184e5c31af7Sopenharmony_ciavailable to the host memory domain using the ename:VK_ACCESS_HOST_WRITE_BIT 3185e5c31af7Sopenharmony_ciand ename:VK_ACCESS_HOST_READ_BIT <<synchronization-access-types, access 3186e5c31af7Sopenharmony_citypes>>, are made visible to the host. 3187e5c31af7Sopenharmony_ciIf a range of non-coherent memory is written by the host and then 3188e5c31af7Sopenharmony_ciinvalidated without first being flushed, its contents are undefined:. 3189e5c31af7Sopenharmony_ci 3190e5c31af7Sopenharmony_ciWithin each range described by pname:pMemoryRanges, each set of 3191e5c31af7Sopenharmony_cipname:nonCoherentAtomSize bytes in that range is invalidated if any byte in 3192e5c31af7Sopenharmony_cithat set has been written by the device since it was first host mapped, or 3193e5c31af7Sopenharmony_cithe last time it was invalidated. 3194e5c31af7Sopenharmony_ci 3195e5c31af7Sopenharmony_ci[NOTE] 3196e5c31af7Sopenharmony_ci.Note 3197e5c31af7Sopenharmony_ci==== 3198e5c31af7Sopenharmony_ciMapping non-coherent memory does not implicitly invalidate that memory. 3199e5c31af7Sopenharmony_ci==== 3200e5c31af7Sopenharmony_ci 3201e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkInvalidateMappedMemoryRanges.txt[] 3202e5c31af7Sopenharmony_ci-- 3203e5c31af7Sopenharmony_ci 3204e5c31af7Sopenharmony_ci[open,refpage='VkMappedMemoryRange',desc='Structure specifying a mapped memory range',type='structs'] 3205e5c31af7Sopenharmony_ci-- 3206e5c31af7Sopenharmony_ciThe sname:VkMappedMemoryRange structure is defined as: 3207e5c31af7Sopenharmony_ci 3208e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkMappedMemoryRange.txt[] 3209e5c31af7Sopenharmony_ci 3210e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 3211e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 3212e5c31af7Sopenharmony_ci structure. 3213e5c31af7Sopenharmony_ci * pname:memory is the memory object to which this range belongs. 3214e5c31af7Sopenharmony_ci * pname:offset is the zero-based byte offset from the beginning of the 3215e5c31af7Sopenharmony_ci memory object. 3216e5c31af7Sopenharmony_ci * pname:size is either the size of range, or ename:VK_WHOLE_SIZE to affect 3217e5c31af7Sopenharmony_ci the range from pname:offset to the end of the current mapping of the 3218e5c31af7Sopenharmony_ci allocation. 3219e5c31af7Sopenharmony_ci 3220e5c31af7Sopenharmony_ci.Valid Usage 3221e5c31af7Sopenharmony_ci**** 3222e5c31af7Sopenharmony_ci * [[VUID-VkMappedMemoryRange-memory-00684]] 3223e5c31af7Sopenharmony_ci pname:memory must: be currently host mapped 3224e5c31af7Sopenharmony_ci * [[VUID-VkMappedMemoryRange-size-00685]] 3225e5c31af7Sopenharmony_ci If pname:size is not equal to ename:VK_WHOLE_SIZE, pname:offset and 3226e5c31af7Sopenharmony_ci pname:size must: specify a range contained within the currently mapped 3227e5c31af7Sopenharmony_ci range of pname:memory 3228e5c31af7Sopenharmony_ci * [[VUID-VkMappedMemoryRange-size-00686]] 3229e5c31af7Sopenharmony_ci If pname:size is equal to ename:VK_WHOLE_SIZE, pname:offset must: be 3230e5c31af7Sopenharmony_ci within the currently mapped range of pname:memory 3231e5c31af7Sopenharmony_ci * [[VUID-VkMappedMemoryRange-offset-00687]] 3232e5c31af7Sopenharmony_ci pname:offset must: be a multiple of 3233e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceLimits::pname:nonCoherentAtomSize 3234e5c31af7Sopenharmony_ci * [[VUID-VkMappedMemoryRange-size-01389]] 3235e5c31af7Sopenharmony_ci If pname:size is equal to ename:VK_WHOLE_SIZE, the end of the current 3236e5c31af7Sopenharmony_ci mapping of pname:memory must: either be a multiple of 3237e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceLimits::pname:nonCoherentAtomSize bytes from the 3238e5c31af7Sopenharmony_ci beginning of the memory object, or be equal to the end of the memory 3239e5c31af7Sopenharmony_ci object 3240e5c31af7Sopenharmony_ci * [[VUID-VkMappedMemoryRange-size-01390]] 3241e5c31af7Sopenharmony_ci If pname:size is not equal to ename:VK_WHOLE_SIZE, pname:size must: 3242e5c31af7Sopenharmony_ci either be a multiple of 3243e5c31af7Sopenharmony_ci slink:VkPhysicalDeviceLimits::pname:nonCoherentAtomSize, or pname:offset 3244e5c31af7Sopenharmony_ci plus pname:size must: equal the size of pname:memory 3245e5c31af7Sopenharmony_ci**** 3246e5c31af7Sopenharmony_ci 3247e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkMappedMemoryRange.txt[] 3248e5c31af7Sopenharmony_ci-- 3249e5c31af7Sopenharmony_ci 3250e5c31af7Sopenharmony_ci 3251e5c31af7Sopenharmony_ci[open,refpage='vkUnmapMemory',desc='Unmap a previously mapped memory object',type='protos'] 3252e5c31af7Sopenharmony_ci-- 3253e5c31af7Sopenharmony_ciTo unmap a memory object once host access to it is no longer needed by the 3254e5c31af7Sopenharmony_ciapplication, call: 3255e5c31af7Sopenharmony_ci 3256e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkUnmapMemory.txt[] 3257e5c31af7Sopenharmony_ci 3258e5c31af7Sopenharmony_ci * pname:device is the logical device that owns the memory. 3259e5c31af7Sopenharmony_ci * pname:memory is the memory object to be unmapped. 3260e5c31af7Sopenharmony_ci 3261e5c31af7Sopenharmony_ci.Valid Usage 3262e5c31af7Sopenharmony_ci**** 3263e5c31af7Sopenharmony_ci * [[VUID-vkUnmapMemory-memory-00689]] 3264e5c31af7Sopenharmony_ci pname:memory must: be currently host mapped 3265e5c31af7Sopenharmony_ci**** 3266e5c31af7Sopenharmony_ci 3267e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkUnmapMemory.txt[] 3268e5c31af7Sopenharmony_ci-- 3269e5c31af7Sopenharmony_ci 3270e5c31af7Sopenharmony_ci 3271e5c31af7Sopenharmony_ci[[memory-device-lazy_allocation]] 3272e5c31af7Sopenharmony_ci=== Lazily Allocated Memory 3273e5c31af7Sopenharmony_ci 3274e5c31af7Sopenharmony_ciIf the memory object is allocated from a heap with the 3275e5c31af7Sopenharmony_ciename:VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT bit set, that object's backing 3276e5c31af7Sopenharmony_cimemory may: be provided by the implementation lazily. 3277e5c31af7Sopenharmony_ciThe actual committed size of the memory may: initially be as small as zero 3278e5c31af7Sopenharmony_ci(or as large as the requested size), and monotonically increases as 3279e5c31af7Sopenharmony_ciadditional memory is needed. 3280e5c31af7Sopenharmony_ci 3281e5c31af7Sopenharmony_ciA memory type with this flag set is only allowed to be bound to a 3282e5c31af7Sopenharmony_cisname:VkImage whose usage flags include 3283e5c31af7Sopenharmony_ciename:VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT. 3284e5c31af7Sopenharmony_ci 3285e5c31af7Sopenharmony_ci[NOTE] 3286e5c31af7Sopenharmony_ci.Note 3287e5c31af7Sopenharmony_ci==== 3288e5c31af7Sopenharmony_ciUsing lazily allocated memory objects for framebuffer attachments that are 3289e5c31af7Sopenharmony_cinot needed once a render pass instance has completed may: allow some 3290e5c31af7Sopenharmony_ciimplementations to never allocate memory for such attachments. 3291e5c31af7Sopenharmony_ci==== 3292e5c31af7Sopenharmony_ci 3293e5c31af7Sopenharmony_ci[open,refpage='vkGetDeviceMemoryCommitment',desc='Query the current commitment for a VkDeviceMemory',type='protos'] 3294e5c31af7Sopenharmony_ci-- 3295e5c31af7Sopenharmony_ciTo determine the amount of lazily-allocated memory that is currently 3296e5c31af7Sopenharmony_cicommitted for a memory object, call: 3297e5c31af7Sopenharmony_ci 3298e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetDeviceMemoryCommitment.txt[] 3299e5c31af7Sopenharmony_ci 3300e5c31af7Sopenharmony_ci * pname:device is the logical device that owns the memory. 3301e5c31af7Sopenharmony_ci * pname:memory is the memory object being queried. 3302e5c31af7Sopenharmony_ci * pname:pCommittedMemoryInBytes is a pointer to a basetype:VkDeviceSize 3303e5c31af7Sopenharmony_ci value in which the number of bytes currently committed is returned, on 3304e5c31af7Sopenharmony_ci success. 3305e5c31af7Sopenharmony_ci 3306e5c31af7Sopenharmony_ciThe implementation may: update the commitment at any time, and the value 3307e5c31af7Sopenharmony_cireturned by this query may: be out of date. 3308e5c31af7Sopenharmony_ci 3309e5c31af7Sopenharmony_ciThe implementation guarantees to allocate any committed memory from the 3310e5c31af7Sopenharmony_cipname:heapIndex indicated by the memory type that the memory object was 3311e5c31af7Sopenharmony_cicreated with. 3312e5c31af7Sopenharmony_ci 3313e5c31af7Sopenharmony_ci.Valid Usage 3314e5c31af7Sopenharmony_ci**** 3315e5c31af7Sopenharmony_ci * [[VUID-vkGetDeviceMemoryCommitment-memory-00690]] 3316e5c31af7Sopenharmony_ci pname:memory must: have been created with a memory type that reports 3317e5c31af7Sopenharmony_ci ename:VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT 3318e5c31af7Sopenharmony_ci**** 3319e5c31af7Sopenharmony_ci 3320e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetDeviceMemoryCommitment.txt[] 3321e5c31af7Sopenharmony_ci-- 3322e5c31af7Sopenharmony_ci 3323e5c31af7Sopenharmony_ci 3324e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[] 3325e5c31af7Sopenharmony_ci[[memory-protected-memory]] 3326e5c31af7Sopenharmony_ci=== Protected Memory 3327e5c31af7Sopenharmony_ci 3328e5c31af7Sopenharmony_ci_Protected memory_ divides device memory into protected device memory and 3329e5c31af7Sopenharmony_ciunprotected device memory. 3330e5c31af7Sopenharmony_ci 3331e5c31af7Sopenharmony_ciProtected memory adds the following concepts: 3332e5c31af7Sopenharmony_ci 3333e5c31af7Sopenharmony_ci * Memory: 3334e5c31af7Sopenharmony_ci ** Unprotected device memory, which can: be visible to the device and can: 3335e5c31af7Sopenharmony_ci be visible to the host 3336e5c31af7Sopenharmony_ci ** Protected device memory, which can: be visible to the device but must: 3337e5c31af7Sopenharmony_ci not be visible to the host 3338e5c31af7Sopenharmony_ci * Resources: 3339e5c31af7Sopenharmony_ci ** Unprotected images and unprotected buffers, to which unprotected memory 3340e5c31af7Sopenharmony_ci can: be bound 3341e5c31af7Sopenharmony_ci ** Protected images and protected buffers, to which protected memory can: 3342e5c31af7Sopenharmony_ci be bound 3343e5c31af7Sopenharmony_ci * Command buffers: 3344e5c31af7Sopenharmony_ci ** Unprotected command buffers, which can: be submitted to a device queue 3345e5c31af7Sopenharmony_ci to execute unprotected queue operations 3346e5c31af7Sopenharmony_ci ** Protected command buffers, which can: be submitted to a 3347e5c31af7Sopenharmony_ci protected-capable device queue to execute protected queue operations 3348e5c31af7Sopenharmony_ci * Device queues: 3349e5c31af7Sopenharmony_ci ** Unprotected device queues, to which unprotected command buffers can: be 3350e5c31af7Sopenharmony_ci submitted 3351e5c31af7Sopenharmony_ci ** Protected-capable device queues, to which unprotected command buffers 3352e5c31af7Sopenharmony_ci or protected command buffers can: be submitted 3353e5c31af7Sopenharmony_ci * Queue submissions 3354e5c31af7Sopenharmony_ci ** Unprotected queue submissions, through which unprotected command 3355e5c31af7Sopenharmony_ci buffers can: be submitted 3356e5c31af7Sopenharmony_ci ** Protected queue submissions, through which protected command buffers 3357e5c31af7Sopenharmony_ci can: be submitted 3358e5c31af7Sopenharmony_ci * Queue operations 3359e5c31af7Sopenharmony_ci ** Unprotected queue operations 3360e5c31af7Sopenharmony_ci ** Protected queue operations 3361e5c31af7Sopenharmony_ci 3362e5c31af7Sopenharmony_ci[[memory-protected-access-rules]] 3363e5c31af7Sopenharmony_ci==== Protected Memory Access Rules 3364e5c31af7Sopenharmony_ci 3365e5c31af7Sopenharmony_ciIf slink:VkPhysicalDeviceProtectedMemoryProperties::pname:protectedNoFault 3366e5c31af7Sopenharmony_ciis ename:VK_FALSE, applications must: not perform any of the following 3367e5c31af7Sopenharmony_cioperations: 3368e5c31af7Sopenharmony_ci 3369e5c31af7Sopenharmony_ci * Write to unprotected memory within protected queue operations. 3370e5c31af7Sopenharmony_ci * Access protected memory within protected queue operations other than in 3371e5c31af7Sopenharmony_ci framebuffer-space pipeline stages, the compute shader stage, or the 3372e5c31af7Sopenharmony_ci transfer stage. 3373e5c31af7Sopenharmony_ci * Perform a query within protected queue operations. 3374e5c31af7Sopenharmony_ci 3375e5c31af7Sopenharmony_ciIf slink:VkPhysicalDeviceProtectedMemoryProperties::pname:protectedNoFault 3376e5c31af7Sopenharmony_ciis ename:VK_TRUE, these operations are valid, but reads will return 3377e5c31af7Sopenharmony_ciundefined: values, and writes will either be dropped or store undefined: 3378e5c31af7Sopenharmony_civalues. 3379e5c31af7Sopenharmony_ci 3380e5c31af7Sopenharmony_ciAdditionally, indirect operations must: not be performed within protected 3381e5c31af7Sopenharmony_ciqueue operations. 3382e5c31af7Sopenharmony_ci 3383e5c31af7Sopenharmony_ciWhether these operations are valid or not, or if any other invalid usage is 3384e5c31af7Sopenharmony_ciperformed, the implementation must: guarantee that: 3385e5c31af7Sopenharmony_ci 3386e5c31af7Sopenharmony_ci * Protected device memory must: never be visible to the host. 3387e5c31af7Sopenharmony_ci * Values written to unprotected device memory must: not be a function of 3388e5c31af7Sopenharmony_ci values from protected memory. 3389e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[] 3390e5c31af7Sopenharmony_ci 3391e5c31af7Sopenharmony_ci 3392e5c31af7Sopenharmony_ciifdef::VK_KHR_external_memory_capabilities+VK_ANDROID_external_memory_android_hardware_buffer[] 3393e5c31af7Sopenharmony_ci[[memory-external-handle-types]] 3394e5c31af7Sopenharmony_ci=== External Memory Handle Types 3395e5c31af7Sopenharmony_ci 3396e5c31af7Sopenharmony_ci 3397e5c31af7Sopenharmony_ci[[memory-external-android-hardware-buffer]] 3398e5c31af7Sopenharmony_ci==== Android Hardware Buffer 3399e5c31af7Sopenharmony_ci 3400e5c31af7Sopenharmony_ciAndroid's NDK defines basetype:AHardwareBuffer objects, which represent 3401e5c31af7Sopenharmony_cidevice memory that is shareable across processes and that can: be accessed 3402e5c31af7Sopenharmony_ciby a variety of media APIs and the hardware used to implement them. 3403e5c31af7Sopenharmony_ciThese Android hardware buffer objects may: be imported into 3404e5c31af7Sopenharmony_cislink:VkDeviceMemory objects for access via Vulkan, or exported from Vulkan. 3405e5c31af7Sopenharmony_ciAn slink:VkImage or slink:VkBuffer can: be bound to the imported or exported 3406e5c31af7Sopenharmony_cislink:VkDeviceMemory object if it is created with 3407e5c31af7Sopenharmony_ciename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID. 3408e5c31af7Sopenharmony_ci 3409e5c31af7Sopenharmony_ci[open,refpage='AHardwareBuffer',desc='Android hardware buffer type',type='basetypes'] 3410e5c31af7Sopenharmony_ci-- 3411e5c31af7Sopenharmony_ciTo remove an unnecessary compile-time dependency, an incomplete type 3412e5c31af7Sopenharmony_cidefinition of basetype:AHardwareBuffer is provided in the Vulkan headers: 3413e5c31af7Sopenharmony_ci 3414e5c31af7Sopenharmony_ciinclude::{generated}/api/basetypes/AHardwareBuffer.txt[] 3415e5c31af7Sopenharmony_ci 3416e5c31af7Sopenharmony_ciThe actual basetype:AHardwareBuffer type is defined in Android NDK headers. 3417e5c31af7Sopenharmony_ci-- 3418e5c31af7Sopenharmony_ci 3419e5c31af7Sopenharmony_ci[NOTE] 3420e5c31af7Sopenharmony_ci.Note 3421e5c31af7Sopenharmony_ci==== 3422e5c31af7Sopenharmony_ciThe NDK format, usage, and size/dimensions of an basetype:AHardwareBuffer 3423e5c31af7Sopenharmony_ciobject can be obtained with the code:AHardwareBuffer_describe function. 3424e5c31af7Sopenharmony_ciWhile Android hardware buffers can be imported to or exported from Vulkan 3425e5c31af7Sopenharmony_ciwithout using that function, valid usage and implementation behavior is 3426e5c31af7Sopenharmony_cidefined in terms of the code:AHardwareBuffer_Desc properties it returns. 3427e5c31af7Sopenharmony_ci==== 3428e5c31af7Sopenharmony_ci 3429e5c31af7Sopenharmony_ciAndroid hardware buffer objects are reference-counted using Android NDK 3430e5c31af7Sopenharmony_cifunctions outside of the scope of this specification. 3431e5c31af7Sopenharmony_ciA slink:VkDeviceMemory imported from an Android hardware buffer or that can: 3432e5c31af7Sopenharmony_cibe exported to an Android hardware buffer must: acquire a reference to its 3433e5c31af7Sopenharmony_cibasetype:AHardwareBuffer object, and must: release this reference when the 3434e5c31af7Sopenharmony_cidevice memory is freed. 3435e5c31af7Sopenharmony_ciDuring the host execution of a Vulkan command that has an Android hardware 3436e5c31af7Sopenharmony_cibuffer as a parameter (including indirect parameters via pname:pNext 3437e5c31af7Sopenharmony_cichains), the application must: not decrement the Android hardware buffer's 3438e5c31af7Sopenharmony_cireference count to zero. 3439e5c31af7Sopenharmony_ci 3440e5c31af7Sopenharmony_ciAndroid hardware buffers can: be mapped and unmapped for CPU access using 3441e5c31af7Sopenharmony_cithe NDK functions. 3442e5c31af7Sopenharmony_ciThese lock and unlock APIs are considered to acquire and release ownership 3443e5c31af7Sopenharmony_ciof the Android hardware buffer, and applications must: follow the rules 3444e5c31af7Sopenharmony_cidescribed in <<resources-external-sharing,External Resource Sharing>> to 3445e5c31af7Sopenharmony_citransfer ownership between the Vulkan instance and these native APIs. 3446e5c31af7Sopenharmony_ci 3447e5c31af7Sopenharmony_ciAndroid hardware buffers can: be shared with external APIs and Vulkan 3448e5c31af7Sopenharmony_ciinstances on the same device, and also with foreign devices. 3449e5c31af7Sopenharmony_ciWhen transferring ownership of the Android hardware buffer, the external and 3450e5c31af7Sopenharmony_ciforeign special queue families described in 3451e5c31af7Sopenharmony_ci<<synchronization-queue-transfers>> are not identical. 3452e5c31af7Sopenharmony_ciAll APIs which produce or consume Android hardware buffers are considered to 3453e5c31af7Sopenharmony_ciuse foreign devices, except OpenGL ES contexts and Vulkan logical devices 3454e5c31af7Sopenharmony_cithat have matching device and driver UUIDs. 3455e5c31af7Sopenharmony_ciImplementations may: treat a transfer to or from the foreign queue family as 3456e5c31af7Sopenharmony_ciif it were a transfer to or from the external queue family when the Android 3457e5c31af7Sopenharmony_cihardware buffer's usage only permits it to be used on the same physical 3458e5c31af7Sopenharmony_cidevice. 3459e5c31af7Sopenharmony_ci 3460e5c31af7Sopenharmony_ci 3461e5c31af7Sopenharmony_ci[[memory-external-android-hardware-buffer-optimal-usages]] 3462e5c31af7Sopenharmony_ci===== Android Hardware Buffer Optimal Usages ===== 3463e5c31af7Sopenharmony_ci 3464e5c31af7Sopenharmony_ciVulkan buffer and image usage flags do not correspond exactly to Android 3465e5c31af7Sopenharmony_cihardware buffer usage flags. 3466e5c31af7Sopenharmony_ciWhen allocating Android hardware buffers with non-Vulkan APIs, if any 3467e5c31af7Sopenharmony_cicode:AHARDWAREBUFFER_USAGE_GPU_* usage bits are included, by default the 3468e5c31af7Sopenharmony_ciallocator must: allocate the memory in such a way that it supports Vulkan 3469e5c31af7Sopenharmony_ciusages and creation flags in the 3470e5c31af7Sopenharmony_ci<<memory-external-android-hardware-buffer-usage, usage equivalence table>> 3471e5c31af7Sopenharmony_ciwhich do not have Android hardware buffer equivalents. 3472e5c31af7Sopenharmony_ci 3473e5c31af7Sopenharmony_ciAn slink:VkAndroidHardwareBufferUsageANDROID structure can: be included in 3474e5c31af7Sopenharmony_cithe pname:pNext chain of a slink:VkImageFormatProperties2 structure passed 3475e5c31af7Sopenharmony_cito flink:vkGetPhysicalDeviceImageFormatProperties2 to obtain optimal Android 3476e5c31af7Sopenharmony_cihardware buffer usage flags for specific Vulkan resource creation 3477e5c31af7Sopenharmony_ciparameters. 3478e5c31af7Sopenharmony_ciSome usage flags returned by these commands are required: based on the input 3479e5c31af7Sopenharmony_ciparameters, but additional vendor-specific usage flags 3480e5c31af7Sopenharmony_ci(code:AHARDWAREBUFFER_USAGE_VENDOR_*) may: also be returned. 3481e5c31af7Sopenharmony_ciAny Android hardware buffer allocated with these vendor-specific usage flags 3482e5c31af7Sopenharmony_ciand imported to Vulkan must: only be bound to resources created with 3483e5c31af7Sopenharmony_ciparameters that are a subset of the parameters used to obtain the Android 3484e5c31af7Sopenharmony_cihardware buffer usage, since the memory may: have been allocated in a way 3485e5c31af7Sopenharmony_ciincompatible with other parameters. 3486e5c31af7Sopenharmony_ciIf an Android hardware buffer is successfully allocated with additional 3487e5c31af7Sopenharmony_cinon-vendor-specific usage flags in addition to the recommended usage, it 3488e5c31af7Sopenharmony_cimust: support being used in the same ways as an Android hardware buffer 3489e5c31af7Sopenharmony_ciallocated with only the recommended usage, and also in ways indicated by the 3490e5c31af7Sopenharmony_ciadditional usage. 3491e5c31af7Sopenharmony_ci 3492e5c31af7Sopenharmony_ci[[memory-external-android-hardware-buffer-external-formats]] 3493e5c31af7Sopenharmony_ci===== Android Hardware Buffer External Formats ===== 3494e5c31af7Sopenharmony_ci 3495e5c31af7Sopenharmony_ciAndroid hardware buffers may: represent images using implementation-specific 3496e5c31af7Sopenharmony_ciformats, layouts, color models, etc., which do not have Vulkan equivalents. 3497e5c31af7Sopenharmony_ciSuch _external formats_ are commonly used by external image sources such as 3498e5c31af7Sopenharmony_civideo decoders or cameras. 3499e5c31af7Sopenharmony_ciVulkan can: import Android hardware buffers that have external formats, but 3500e5c31af7Sopenharmony_cisince the image contents are in an undiscoverable and possibly proprietary 3501e5c31af7Sopenharmony_cirepresentation, images with external formats must: only be used as sampled 3502e5c31af7Sopenharmony_ciimages, must: only be sampled with a sampler that has {YCbCr} conversion 3503e5c31af7Sopenharmony_cienabled, and must: have optimal tiling. 3504e5c31af7Sopenharmony_ci 3505e5c31af7Sopenharmony_ciImages that will be backed by an Android hardware buffer can: use an 3506e5c31af7Sopenharmony_ciexternal format by setting slink:VkImageCreateInfo::pname:format to 3507e5c31af7Sopenharmony_ciename:VK_FORMAT_UNDEFINED and including a slink:VkExternalFormatANDROID 3508e5c31af7Sopenharmony_cistructure in the pname:pNext chain. 3509e5c31af7Sopenharmony_ciImages can: be created with an external format even if the Android hardware 3510e5c31af7Sopenharmony_cibuffer has a format which has an 3511e5c31af7Sopenharmony_ci<<memory-external-android-hardware-buffer-formats,equivalent Vulkan format>> 3512e5c31af7Sopenharmony_cito enable consistent handling of images from sources that might use either 3513e5c31af7Sopenharmony_cicategory of format. 3514e5c31af7Sopenharmony_ciHowever, all images created with an external format are subject to the valid 3515e5c31af7Sopenharmony_ciusage requirements associated with external formats, even if the Android 3516e5c31af7Sopenharmony_cihardware buffer's format has a Vulkan equivalent. 3517e5c31af7Sopenharmony_ciThe external format of an Android hardware buffer can: be obtained by 3518e5c31af7Sopenharmony_cipassing a slink:VkAndroidHardwareBufferFormatPropertiesANDROID structure to 3519e5c31af7Sopenharmony_ciflink:vkGetAndroidHardwareBufferPropertiesANDROID. 3520e5c31af7Sopenharmony_ci 3521e5c31af7Sopenharmony_ci[[memory-external-android-hardware-buffer-image-resources]] 3522e5c31af7Sopenharmony_ci===== Android Hardware Buffer Image Resources 3523e5c31af7Sopenharmony_ci 3524e5c31af7Sopenharmony_ciAndroid hardware buffers have intrinsic width, height, format, and usage 3525e5c31af7Sopenharmony_ciproperties, so Vulkan images bound to memory imported from an Android 3526e5c31af7Sopenharmony_cihardware buffer must: use dedicated allocations: 3527e5c31af7Sopenharmony_cisname:VkMemoryDedicatedRequirements::pname:requiresDedicatedAllocation must: 3528e5c31af7Sopenharmony_cibe ename:VK_TRUE for images created with 3529e5c31af7Sopenharmony_cislink:VkExternalMemoryImageCreateInfo::pname:handleTypes that includes 3530e5c31af7Sopenharmony_ciename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID. 3531e5c31af7Sopenharmony_ciWhen creating an image that will be bound to an imported Android hardware 3532e5c31af7Sopenharmony_cibuffer, the image creation parameters must: be equivalent to the 3533e5c31af7Sopenharmony_cibasetype:AHardwareBuffer properties as described by the valid usage of 3534e5c31af7Sopenharmony_cislink:VkMemoryAllocateInfo. 3535e5c31af7Sopenharmony_ciSimilarly, device memory allocated for a dedicated image must: not be 3536e5c31af7Sopenharmony_ciexported to an Android hardware buffer until it has been bound to that 3537e5c31af7Sopenharmony_ciimage, and the implementation must: return an Android hardware buffer with 3538e5c31af7Sopenharmony_ciproperties derived from the image: 3539e5c31af7Sopenharmony_ci 3540e5c31af7Sopenharmony_ci * The code:width and code:height members of code:AHardwareBuffer_Desc 3541e5c31af7Sopenharmony_ci must: be the same as the pname:width and pname:height members of 3542e5c31af7Sopenharmony_ci slink:VkImageCreateInfo::pname:extent, respectively. 3543e5c31af7Sopenharmony_ci * The code:layers member of code:AHardwareBuffer_Desc must: be the same as 3544e5c31af7Sopenharmony_ci the pname:arrayLayers member of slink:VkImageCreateInfo. 3545e5c31af7Sopenharmony_ci * The code:format member of code:AHardwareBuffer_Desc must: be equivalent 3546e5c31af7Sopenharmony_ci to slink:VkImageCreateInfo::pname:format as defined by 3547e5c31af7Sopenharmony_ci <<memory-external-android-hardware-buffer-formats,AHardwareBuffer Format 3548e5c31af7Sopenharmony_ci Equivalence>>. 3549e5c31af7Sopenharmony_ci * The code:usage member of code:AHardwareBuffer_Desc must: include bits 3550e5c31af7Sopenharmony_ci corresponding to bits included in slink:VkImageCreateInfo::pname:usage 3551e5c31af7Sopenharmony_ci and slink:VkImageCreateInfo::pname:flags where such a correspondence 3552e5c31af7Sopenharmony_ci exists according to 3553e5c31af7Sopenharmony_ci <<memory-external-android-hardware-buffer-usage,AHardwareBuffer Usage 3554e5c31af7Sopenharmony_ci Equivalence>>. 3555e5c31af7Sopenharmony_ci It may: also include additional usage bits, including vendor-specific 3556e5c31af7Sopenharmony_ci usages. 3557e5c31af7Sopenharmony_ci Presence of vendor usage bits may: make the Android hardware buffer only 3558e5c31af7Sopenharmony_ci usable in ways indicated by the image creation parameters, even when 3559e5c31af7Sopenharmony_ci used outside Vulkan, in a similar way that allocating the Android 3560e5c31af7Sopenharmony_ci hardware buffer with usage returned in 3561e5c31af7Sopenharmony_ci slink:VkAndroidHardwareBufferUsageANDROID does. 3562e5c31af7Sopenharmony_ci 3563e5c31af7Sopenharmony_ciImplementations may: support fewer combinations of image creation parameters 3564e5c31af7Sopenharmony_cifor images with Android hardware buffer external handle type than for 3565e5c31af7Sopenharmony_cinon-external images. 3566e5c31af7Sopenharmony_ciSupport for a given set of parameters can: be determined by passing 3567e5c31af7Sopenharmony_cislink:VkExternalImageFormatProperties to 3568e5c31af7Sopenharmony_ciflink:vkGetPhysicalDeviceImageFormatProperties2 with pname:handleType set to 3569e5c31af7Sopenharmony_ciename:VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID. 3570e5c31af7Sopenharmony_ciAny Android hardware buffer successfully allocated outside Vulkan with usage 3571e5c31af7Sopenharmony_cithat includes code:AHARDWAREBUFFER_USAGE_GPU_* must: be supported when using 3572e5c31af7Sopenharmony_ciequivalent Vulkan image parameters. 3573e5c31af7Sopenharmony_ciIf a given choice of image parameters are supported for import, they can: 3574e5c31af7Sopenharmony_cialso be used to create an image and memory that will be exported to an 3575e5c31af7Sopenharmony_ciAndroid hardware buffer. 3576e5c31af7Sopenharmony_ci 3577e5c31af7Sopenharmony_ci[[memory-external-android-hardware-buffer-formats]] 3578e5c31af7Sopenharmony_ci.AHardwareBuffer Format Equivalence 3579e5c31af7Sopenharmony_ci[width="100%",options="header"] 3580e5c31af7Sopenharmony_ci|==== 3581e5c31af7Sopenharmony_ci| AHardwareBuffer Format | Vulkan Format 3582e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM | ename:VK_FORMAT_R8G8B8A8_UNORM 3583e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM ^1^ | ename:VK_FORMAT_R8G8B8A8_UNORM 3584e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM | ename:VK_FORMAT_R8G8B8_UNORM 3585e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM | ename:VK_FORMAT_R5G6B5_UNORM_PACK16 3586e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT | ename:VK_FORMAT_R16G16B16A16_SFLOAT 3587e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM | ename:VK_FORMAT_A2B10G10R10_UNORM_PACK32 3588e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_FORMAT_D16_UNORM | ename:VK_FORMAT_D16_UNORM 3589e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_FORMAT_D24_UNORM | ename:VK_FORMAT_X8_D24_UNORM_PACK32 3590e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_FORMAT_D24_UNORM_S8_UINT | ename:VK_FORMAT_D24_UNORM_S8_UINT 3591e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_FORMAT_D32_FLOAT | ename:VK_FORMAT_D32_SFLOAT 3592e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_FORMAT_D32_FLOAT_S8_UINT | ename:VK_FORMAT_D32_SFLOAT_S8_UINT 3593e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_FORMAT_S8_UINT | ename:VK_FORMAT_S8_UINT 3594e5c31af7Sopenharmony_ci|==== 3595e5c31af7Sopenharmony_ci 3596e5c31af7Sopenharmony_ci[[memory-external-android-hardware-buffer-usage]] 3597e5c31af7Sopenharmony_ci.AHardwareBuffer Usage Equivalence 3598e5c31af7Sopenharmony_ci[width="100%",options="header"] 3599e5c31af7Sopenharmony_ci|==== 3600e5c31af7Sopenharmony_ci| AHardwareBuffer Usage | Vulkan Usage or Creation Flag 3601e5c31af7Sopenharmony_ci| None | ename:VK_IMAGE_USAGE_TRANSFER_SRC_BIT 3602e5c31af7Sopenharmony_ci| None | ename:VK_IMAGE_USAGE_TRANSFER_DST_BIT 3603e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE | ename:VK_IMAGE_USAGE_SAMPLED_BIT 3604e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE | ename:VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT 3605e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER ^3^ | ename:VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT 3606e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER ^3^ | ename:VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT 3607e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_USAGE_GPU_CUBE_MAP | ename:VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT 3608e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_USAGE_GPU_MIPMAP_COMPLETE | None ^2^ 3609e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[] 3610e5c31af7Sopenharmony_ci| code:AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT | ename:VK_IMAGE_CREATE_PROTECTED_BIT 3611e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[] 3612e5c31af7Sopenharmony_ci| None | ename:VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT 3613e5c31af7Sopenharmony_ci| None | ename:VK_IMAGE_CREATE_EXTENDED_USAGE_BIT 3614e5c31af7Sopenharmony_ci|==== 3615e5c31af7Sopenharmony_ci 3616e5c31af7Sopenharmony_ci1:: 3617e5c31af7Sopenharmony_ci Vulkan does not differentiate between 3618e5c31af7Sopenharmony_ci code:AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM and 3619e5c31af7Sopenharmony_ci code:AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM: they both behave as 3620e5c31af7Sopenharmony_ci ename:VK_FORMAT_R8G8B8A8_UNORM. 3621e5c31af7Sopenharmony_ci After an external entity writes to a 3622e5c31af7Sopenharmony_ci code:AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM Android hardware buffer, the 3623e5c31af7Sopenharmony_ci values read by Vulkan from the X/A component are undefined:. 3624e5c31af7Sopenharmony_ci To emulate the traditional behavior of the X component during sampling 3625e5c31af7Sopenharmony_ci or blending, applications should: use ename:VK_COMPONENT_SWIZZLE_ONE in 3626e5c31af7Sopenharmony_ci image view component mappings and ename:VK_BLEND_FACTOR_ONE in color 3627e5c31af7Sopenharmony_ci blend factors. 3628e5c31af7Sopenharmony_ci There is no way to avoid copying these undefined: values when copying 3629e5c31af7Sopenharmony_ci from such an image to another image or buffer. 3630e5c31af7Sopenharmony_ci 3631e5c31af7Sopenharmony_ci2:: 3632e5c31af7Sopenharmony_ci The code:AHARDWAREBUFFER_USAGE_GPU_MIPMAP_COMPLETE flag does not 3633e5c31af7Sopenharmony_ci correspond to a Vulkan image usage or creation flag. 3634e5c31af7Sopenharmony_ci Instead, its presence indicates that the Android hardware buffer 3635e5c31af7Sopenharmony_ci contains a complete mipmap chain, and its absence indicates that the 3636e5c31af7Sopenharmony_ci Android hardware buffer contains only a single mip level. 3637e5c31af7Sopenharmony_ci 3638e5c31af7Sopenharmony_ci3:: 3639e5c31af7Sopenharmony_ci Only image usages valid for the format are valid. 3640e5c31af7Sopenharmony_ci It would be invalid to take a Android Hardware Buffer with a format of 3641e5c31af7Sopenharmony_ci code:AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM that has a 3642e5c31af7Sopenharmony_ci code:AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER usage and try to create an 3643e5c31af7Sopenharmony_ci image with ename:VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT. 3644e5c31af7Sopenharmony_ci 3645e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_KHR_image_format_list[] 3646e5c31af7Sopenharmony_ci[NOTE] 3647e5c31af7Sopenharmony_ci.Note 3648e5c31af7Sopenharmony_ci==== 3649e5c31af7Sopenharmony_ciWhen using ename:VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT with Android hardware 3650e5c31af7Sopenharmony_cibuffer images, applications should: use slink:VkImageFormatListCreateInfo to 3651e5c31af7Sopenharmony_ciinform the implementation which view formats will be used with the image. 3652e5c31af7Sopenharmony_ciFor some common sets of format, this allows some implementations to provide 3653e5c31af7Sopenharmony_cisignificantly better performance when accessing the image via Vulkan. 3654e5c31af7Sopenharmony_ci==== 3655e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_KHR_image_format_list[] 3656e5c31af7Sopenharmony_ci 3657e5c31af7Sopenharmony_ci[[memory-external-android-hardware-buffer-buffer-resources]] 3658e5c31af7Sopenharmony_ci===== Android Hardware Buffer Buffer Resources 3659e5c31af7Sopenharmony_ci 3660e5c31af7Sopenharmony_ciAndroid hardware buffers with a format of code:AHARDWAREBUFFER_FORMAT_BLOB 3661e5c31af7Sopenharmony_ciand usage that includes code:AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER can: be 3662e5c31af7Sopenharmony_ciused as the backing store for slink:VkBuffer objects. 3663e5c31af7Sopenharmony_ciSuch Android hardware buffers have a size in bytes specified by their 3664e5c31af7Sopenharmony_cicode:width; code:height and code:layers are both `1`. 3665e5c31af7Sopenharmony_ci 3666e5c31af7Sopenharmony_ciUnlike images, buffer resources backed by Android hardware buffers do not 3667e5c31af7Sopenharmony_cirequire dedicated allocations. 3668e5c31af7Sopenharmony_ci 3669e5c31af7Sopenharmony_ciExported basetype:AHardwareBuffer objects that do not have dedicated images 3670e5c31af7Sopenharmony_cimust: have a format of code:AHARDWAREBUFFER_FORMAT_BLOB, usage must: include 3671e5c31af7Sopenharmony_cicode:AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER, code:width must: equal the 3672e5c31af7Sopenharmony_cidevice memory allocation size, and code:height and code:layers must: be `1`. 3673e5c31af7Sopenharmony_ciendif::VK_KHR_external_memory_capabilities+VK_ANDROID_external_memory_android_hardware_buffer[] 3674e5c31af7Sopenharmony_ci 3675e5c31af7Sopenharmony_ci 3676e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_device_group[] 3677e5c31af7Sopenharmony_ci[[memory-peer-memory-features]] 3678e5c31af7Sopenharmony_ci=== Peer Memory Features 3679e5c31af7Sopenharmony_ci 3680e5c31af7Sopenharmony_ci[open,refpage='vkGetDeviceGroupPeerMemoryFeatures',desc='Query supported peer memory features of a device',type='protos'] 3681e5c31af7Sopenharmony_ci-- 3682e5c31af7Sopenharmony_ci_Peer memory_ is memory that is allocated for a given physical device and 3683e5c31af7Sopenharmony_cithen bound to a resource and accessed by a different physical device, in a 3684e5c31af7Sopenharmony_cilogical device that represents multiple physical devices. 3685e5c31af7Sopenharmony_ciSome ways of reading and writing peer memory may: not be supported by a 3686e5c31af7Sopenharmony_cidevice. 3687e5c31af7Sopenharmony_ci 3688e5c31af7Sopenharmony_ciTo determine how peer memory can: be accessed, call: 3689e5c31af7Sopenharmony_ci 3690e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[] 3691e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetDeviceGroupPeerMemoryFeatures.txt[] 3692e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[] 3693e5c31af7Sopenharmony_ci 3694e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1+VK_KHR_device_group[or the equivalent command] 3695e5c31af7Sopenharmony_ci 3696e5c31af7Sopenharmony_ciifdef::VK_KHR_device_group[] 3697e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetDeviceGroupPeerMemoryFeaturesKHR.txt[] 3698e5c31af7Sopenharmony_ciendif::VK_KHR_device_group[] 3699e5c31af7Sopenharmony_ci 3700e5c31af7Sopenharmony_ci * pname:device is the logical device that owns the memory. 3701e5c31af7Sopenharmony_ci * pname:heapIndex is the index of the memory heap from which the memory is 3702e5c31af7Sopenharmony_ci allocated. 3703e5c31af7Sopenharmony_ci * pname:localDeviceIndex is the device index of the physical device that 3704e5c31af7Sopenharmony_ci performs the memory access. 3705e5c31af7Sopenharmony_ci * pname:remoteDeviceIndex is the device index of the physical device that 3706e5c31af7Sopenharmony_ci the memory is allocated for. 3707e5c31af7Sopenharmony_ci * pname:pPeerMemoryFeatures is a pointer to a 3708e5c31af7Sopenharmony_ci tlink:VkPeerMemoryFeatureFlags bitmask indicating which types of memory 3709e5c31af7Sopenharmony_ci accesses are supported for the combination of heap, local, and remote 3710e5c31af7Sopenharmony_ci devices. 3711e5c31af7Sopenharmony_ci 3712e5c31af7Sopenharmony_ci.Valid Usage 3713e5c31af7Sopenharmony_ci**** 3714e5c31af7Sopenharmony_ci * [[VUID-vkGetDeviceGroupPeerMemoryFeatures-heapIndex-00691]] 3715e5c31af7Sopenharmony_ci pname:heapIndex must: be less than pname:memoryHeapCount 3716e5c31af7Sopenharmony_ci * [[VUID-vkGetDeviceGroupPeerMemoryFeatures-localDeviceIndex-00692]] 3717e5c31af7Sopenharmony_ci pname:localDeviceIndex must: be a valid device index 3718e5c31af7Sopenharmony_ci * [[VUID-vkGetDeviceGroupPeerMemoryFeatures-remoteDeviceIndex-00693]] 3719e5c31af7Sopenharmony_ci pname:remoteDeviceIndex must: be a valid device index 3720e5c31af7Sopenharmony_ci * [[VUID-vkGetDeviceGroupPeerMemoryFeatures-localDeviceIndex-00694]] 3721e5c31af7Sopenharmony_ci pname:localDeviceIndex must: not equal pname:remoteDeviceIndex 3722e5c31af7Sopenharmony_ci**** 3723e5c31af7Sopenharmony_ci 3724e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetDeviceGroupPeerMemoryFeatures.txt[] 3725e5c31af7Sopenharmony_ci-- 3726e5c31af7Sopenharmony_ci 3727e5c31af7Sopenharmony_ci[open,refpage='VkPeerMemoryFeatureFlagBits',desc='Bitmask specifying supported peer memory features',type='enums'] 3728e5c31af7Sopenharmony_ci-- 3729e5c31af7Sopenharmony_ciBits which may: be set in the value returned for 3730e5c31af7Sopenharmony_ciflink:vkGetDeviceGroupPeerMemoryFeatures::pname:pPeerMemoryFeatures, 3731e5c31af7Sopenharmony_ciindicating the supported peer memory features, are: 3732e5c31af7Sopenharmony_ci 3733e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkPeerMemoryFeatureFlagBits.txt[] 3734e5c31af7Sopenharmony_ci 3735e5c31af7Sopenharmony_ciifdef::VK_KHR_device_group[] 3736e5c31af7Sopenharmony_cior the equivalent 3737e5c31af7Sopenharmony_ci 3738e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkPeerMemoryFeatureFlagBitsKHR.txt[] 3739e5c31af7Sopenharmony_ciendif::VK_KHR_device_group[] 3740e5c31af7Sopenharmony_ci 3741e5c31af7Sopenharmony_ci * ename:VK_PEER_MEMORY_FEATURE_COPY_SRC_BIT specifies that the memory can: 3742e5c31af7Sopenharmony_ci be accessed as the source of any ftext:vkCmdCopy* command. 3743e5c31af7Sopenharmony_ci * ename:VK_PEER_MEMORY_FEATURE_COPY_DST_BIT specifies that the memory can: 3744e5c31af7Sopenharmony_ci be accessed as the destination of any ftext:vkCmdCopy* command. 3745e5c31af7Sopenharmony_ci * ename:VK_PEER_MEMORY_FEATURE_GENERIC_SRC_BIT specifies that the memory 3746e5c31af7Sopenharmony_ci can: be read as any memory access type. 3747e5c31af7Sopenharmony_ci * ename:VK_PEER_MEMORY_FEATURE_GENERIC_DST_BIT specifies that the memory 3748e5c31af7Sopenharmony_ci can: be written as any memory access type. 3749e5c31af7Sopenharmony_ci Shader atomics are considered to be writes. 3750e5c31af7Sopenharmony_ci 3751e5c31af7Sopenharmony_ci[NOTE] 3752e5c31af7Sopenharmony_ci.Note 3753e5c31af7Sopenharmony_ci==== 3754e5c31af7Sopenharmony_ciThe peer memory features of a memory heap also apply to any accesses that 3755e5c31af7Sopenharmony_cimay: be performed during <<synchronization-image-layout-transitions, image 3756e5c31af7Sopenharmony_cilayout transitions>>. 3757e5c31af7Sopenharmony_ci==== 3758e5c31af7Sopenharmony_ci 3759e5c31af7Sopenharmony_ciename:VK_PEER_MEMORY_FEATURE_COPY_DST_BIT must: be supported for all host 3760e5c31af7Sopenharmony_cilocal heaps and for at least one device-local memory heap. 3761e5c31af7Sopenharmony_ci 3762e5c31af7Sopenharmony_ciIf a device does not support a peer memory feature, it is still valid to use 3763e5c31af7Sopenharmony_cia resource that includes both local and peer memory bindings with the 3764e5c31af7Sopenharmony_cicorresponding access type as long as only the local bindings are actually 3765e5c31af7Sopenharmony_ciaccessed. 3766e5c31af7Sopenharmony_ciFor example, an application doing split-frame rendering would use 3767e5c31af7Sopenharmony_ciframebuffer attachments that include both local and peer memory bindings, 3768e5c31af7Sopenharmony_cibut would scissor the rendering to only update local memory. 3769e5c31af7Sopenharmony_ci-- 3770e5c31af7Sopenharmony_ci 3771e5c31af7Sopenharmony_ci[open,refpage='VkPeerMemoryFeatureFlags',desc='Bitmask of VkPeerMemoryFeatureFlagBits',type='flags'] 3772e5c31af7Sopenharmony_ci-- 3773e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkPeerMemoryFeatureFlags.txt[] 3774e5c31af7Sopenharmony_ci 3775e5c31af7Sopenharmony_ciifdef::VK_KHR_device_group[] 3776e5c31af7Sopenharmony_cior the equivalent 3777e5c31af7Sopenharmony_ci 3778e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkPeerMemoryFeatureFlagsKHR.txt[] 3779e5c31af7Sopenharmony_ciendif::VK_KHR_device_group[] 3780e5c31af7Sopenharmony_ci 3781e5c31af7Sopenharmony_citname:VkPeerMemoryFeatureFlags is a bitmask type for setting a mask of zero 3782e5c31af7Sopenharmony_cior more elink:VkPeerMemoryFeatureFlagBits. 3783e5c31af7Sopenharmony_ci-- 3784e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_device_group[] 3785e5c31af7Sopenharmony_ci 3786e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_KHR_buffer_device_address[] 3787e5c31af7Sopenharmony_ci=== Opaque Capture Address Query 3788e5c31af7Sopenharmony_ci 3789e5c31af7Sopenharmony_ci[open,refpage='vkGetDeviceMemoryOpaqueCaptureAddress',desc='Query an opaque capture address of a memory object',type='protos',alias='vkGetDeviceMemoryOpaqueCaptureAddressKHR'] 3790e5c31af7Sopenharmony_ci-- 3791e5c31af7Sopenharmony_ciTo query a 64-bit opaque capture address value from a memory object, call: 3792e5c31af7Sopenharmony_ci 3793e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2[] 3794e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetDeviceMemoryOpaqueCaptureAddress.txt[] 3795e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2[] 3796e5c31af7Sopenharmony_ci 3797e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2+VK_KHR_buffer_device_address[or the equivalent command] 3798e5c31af7Sopenharmony_ci 3799e5c31af7Sopenharmony_ciifdef::VK_KHR_buffer_device_address[] 3800e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetDeviceMemoryOpaqueCaptureAddressKHR.txt[] 3801e5c31af7Sopenharmony_ciendif::VK_KHR_buffer_device_address[] 3802e5c31af7Sopenharmony_ci 3803e5c31af7Sopenharmony_ci * pname:device is the logical device that the memory object was allocated 3804e5c31af7Sopenharmony_ci on. 3805e5c31af7Sopenharmony_ci * pname:pInfo is a pointer to a 3806e5c31af7Sopenharmony_ci slink:VkDeviceMemoryOpaqueCaptureAddressInfo structure specifying the 3807e5c31af7Sopenharmony_ci memory object to retrieve an address for. 3808e5c31af7Sopenharmony_ci 3809e5c31af7Sopenharmony_ciThe 64-bit return value is an opaque address representing the start of 3810e5c31af7Sopenharmony_cipname:pInfo->memory. 3811e5c31af7Sopenharmony_ci 3812e5c31af7Sopenharmony_ciIf the memory object was allocated with a non-zero value of 3813e5c31af7Sopenharmony_cislink:VkMemoryOpaqueCaptureAddressAllocateInfo::pname:opaqueCaptureAddress, 3814e5c31af7Sopenharmony_cithe return value must: be the same address. 3815e5c31af7Sopenharmony_ci 3816e5c31af7Sopenharmony_ci[NOTE] 3817e5c31af7Sopenharmony_ci.Note 3818e5c31af7Sopenharmony_ci==== 3819e5c31af7Sopenharmony_ciThe expected usage for these opaque addresses is only for trace 3820e5c31af7Sopenharmony_cicapture/replay tools to store these addresses in a trace and subsequently 3821e5c31af7Sopenharmony_cispecify them during replay. 3822e5c31af7Sopenharmony_ci==== 3823e5c31af7Sopenharmony_ci 3824e5c31af7Sopenharmony_ci.Valid Usage 3825e5c31af7Sopenharmony_ci**** 3826e5c31af7Sopenharmony_ci * [[VUID-vkGetDeviceMemoryOpaqueCaptureAddress-None-03334]] 3827e5c31af7Sopenharmony_ci The <<features-bufferDeviceAddress,bufferDeviceAddress>> feature must: 3828e5c31af7Sopenharmony_ci be enabled 3829e5c31af7Sopenharmony_ci * [[VUID-vkGetDeviceMemoryOpaqueCaptureAddress-device-03335]] 3830e5c31af7Sopenharmony_ci If pname:device was created with multiple physical devices, then the 3831e5c31af7Sopenharmony_ci <<features-bufferDeviceAddressMultiDevice,bufferDeviceAddressMultiDevice>> 3832e5c31af7Sopenharmony_ci feature must: be enabled 3833e5c31af7Sopenharmony_ci**** 3834e5c31af7Sopenharmony_ci 3835e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetDeviceMemoryOpaqueCaptureAddress.txt[] 3836e5c31af7Sopenharmony_ci-- 3837e5c31af7Sopenharmony_ci 3838e5c31af7Sopenharmony_ci[open,refpage='VkDeviceMemoryOpaqueCaptureAddressInfo',desc='Structure specifying the memory object to query an address for',type='structs',alias='VkDeviceMemoryOpaqueCaptureAddressInfoKHR'] 3839e5c31af7Sopenharmony_ci-- 3840e5c31af7Sopenharmony_ciThe sname:VkDeviceMemoryOpaqueCaptureAddressInfo structure is defined as: 3841e5c31af7Sopenharmony_ci 3842e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkDeviceMemoryOpaqueCaptureAddressInfo.txt[] 3843e5c31af7Sopenharmony_ci 3844e5c31af7Sopenharmony_ciifdef::VK_KHR_buffer_device_address[] 3845e5c31af7Sopenharmony_cior the equivalent 3846e5c31af7Sopenharmony_ci 3847e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkDeviceMemoryOpaqueCaptureAddressInfoKHR.txt[] 3848e5c31af7Sopenharmony_ciendif::VK_KHR_buffer_device_address[] 3849e5c31af7Sopenharmony_ci 3850e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 3851e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 3852e5c31af7Sopenharmony_ci structure. 3853e5c31af7Sopenharmony_ci * pname:memory specifies the memory whose address is being queried. 3854e5c31af7Sopenharmony_ci 3855e5c31af7Sopenharmony_ci.Valid Usage 3856e5c31af7Sopenharmony_ci**** 3857e5c31af7Sopenharmony_ci * [[VUID-VkDeviceMemoryOpaqueCaptureAddressInfo-memory-03336]] 3858e5c31af7Sopenharmony_ci pname:memory must: have been allocated with 3859e5c31af7Sopenharmony_ci ename:VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT 3860e5c31af7Sopenharmony_ci**** 3861e5c31af7Sopenharmony_ci 3862e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkDeviceMemoryOpaqueCaptureAddressInfo.txt[] 3863e5c31af7Sopenharmony_ci-- 3864e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_KHR_buffer_device_address[] 3865