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