1e5c31af7Sopenharmony_ci// Copyright 2015-2024 The Khronos Group Inc.
2e5c31af7Sopenharmony_ci//
3e5c31af7Sopenharmony_ci// SPDX-License-Identifier: CC-BY-4.0
4e5c31af7Sopenharmony_ci
5e5c31af7Sopenharmony_ci[[fundamentals]]
6e5c31af7Sopenharmony_ci= Fundamentals
7e5c31af7Sopenharmony_ci
8e5c31af7Sopenharmony_ciThis chapter introduces fundamental concepts including the Vulkan
9e5c31af7Sopenharmony_ciarchitecture and execution model, API syntax, queues, pipeline
10e5c31af7Sopenharmony_ciconfigurations, numeric representation, state and state queries, and the
11e5c31af7Sopenharmony_cidifferent types of objects and shaders.
12e5c31af7Sopenharmony_ciIt provides a framework for interpreting more specific descriptions of
13e5c31af7Sopenharmony_cicommands and behavior in the remainder of the Specification.
14e5c31af7Sopenharmony_ci
15e5c31af7Sopenharmony_ci
16e5c31af7Sopenharmony_ci[[fundamentals-host-environment]]
17e5c31af7Sopenharmony_ci== Host and Device Environment
18e5c31af7Sopenharmony_ci
19e5c31af7Sopenharmony_ciThe Vulkan Specification assumes and requires: the following properties of
20e5c31af7Sopenharmony_cithe host environment with respect to Vulkan implementations:
21e5c31af7Sopenharmony_ci
22e5c31af7Sopenharmony_ci  * The host must: have runtime support for 8, 16, 32 and 64-bit signed and
23e5c31af7Sopenharmony_ci    unsigned twos-complement integers, all addressable at the granularity of
24e5c31af7Sopenharmony_ci    their size in bytes.
25e5c31af7Sopenharmony_ci  * The host must: have runtime support for 32- and 64-bit floating-point
26e5c31af7Sopenharmony_ci    types satisfying the range and precision constraints in the
27e5c31af7Sopenharmony_ci    <<fundamentals-floatingpoint,Floating Point Computation>> section.
28e5c31af7Sopenharmony_ci  * The representation and endianness of these types on the host must: match
29e5c31af7Sopenharmony_ci    the representation and endianness of the same types on every physical
30e5c31af7Sopenharmony_ci    device supported.
31e5c31af7Sopenharmony_ci
32e5c31af7Sopenharmony_ci[NOTE]
33e5c31af7Sopenharmony_ci.Note
34e5c31af7Sopenharmony_ci====
35e5c31af7Sopenharmony_ciSince a variety of data types and structures in Vulkan may: be accessible by
36e5c31af7Sopenharmony_ciboth host and physical device operations, the implementation should: be able
37e5c31af7Sopenharmony_cito access such data efficiently in both paths in order to facilitate writing
38e5c31af7Sopenharmony_ciportable and performant applications.
39e5c31af7Sopenharmony_ci====
40e5c31af7Sopenharmony_ci
41e5c31af7Sopenharmony_ci
42e5c31af7Sopenharmony_ci[[fundamentals-execmodel]]
43e5c31af7Sopenharmony_ci== Execution Model
44e5c31af7Sopenharmony_ci
45e5c31af7Sopenharmony_ciThis section outlines the execution model of a Vulkan system.
46e5c31af7Sopenharmony_ci
47e5c31af7Sopenharmony_ciVulkan exposes one or more _devices_, each of which exposes one or more
48e5c31af7Sopenharmony_ci_queues_ which may: process work asynchronously to one another.
49e5c31af7Sopenharmony_ciThe set of queues supported by a device is partitioned into _families_.
50e5c31af7Sopenharmony_ciEach family supports one or more types of functionality and may: contain
51e5c31af7Sopenharmony_cimultiple queues with similar characteristics.
52e5c31af7Sopenharmony_ciQueues within a single family are considered _compatible_ with one another,
53e5c31af7Sopenharmony_ciand work produced for a family of queues can: be executed on any queue
54e5c31af7Sopenharmony_ciwithin that family.
55e5c31af7Sopenharmony_ciThis specification defines the following types of functionality that queues
56e5c31af7Sopenharmony_cimay: support: graphics, compute,
57e5c31af7Sopenharmony_ciifdef::VK_KHR_video_decode_queue[]
58e5c31af7Sopenharmony_civideo decode,
59e5c31af7Sopenharmony_ciendif::VK_KHR_video_decode_queue[]
60e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_queue[]
61e5c31af7Sopenharmony_civideo encode,
62e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_queue[]
63e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[protected memory management,]
64e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[sparse memory management,]
65e5c31af7Sopenharmony_ciand transfer.
66e5c31af7Sopenharmony_ci
67e5c31af7Sopenharmony_ci[NOTE]
68e5c31af7Sopenharmony_ci.Note
69e5c31af7Sopenharmony_ci====
70e5c31af7Sopenharmony_ciA single device may: report multiple similar queue families rather than, or
71e5c31af7Sopenharmony_cias well as, reporting multiple members of one or more of those families.
72e5c31af7Sopenharmony_ciThis indicates that while members of those families have similar
73e5c31af7Sopenharmony_cicapabilities, they are _not_ directly compatible with one another.
74e5c31af7Sopenharmony_ci====
75e5c31af7Sopenharmony_ci
76e5c31af7Sopenharmony_ciDevice memory is explicitly managed by the application.
77e5c31af7Sopenharmony_ciEach device may: advertise one or more heaps, representing different areas
78e5c31af7Sopenharmony_ciof memory.
79e5c31af7Sopenharmony_ciMemory heaps are either device-local or host-local, but are always visible
80e5c31af7Sopenharmony_cito the device.
81e5c31af7Sopenharmony_ciFurther detail about memory heaps is exposed via memory types available on
82e5c31af7Sopenharmony_cithat heap.
83e5c31af7Sopenharmony_ciExamples of memory areas that may: be available on an implementation
84e5c31af7Sopenharmony_ciinclude:
85e5c31af7Sopenharmony_ci
86e5c31af7Sopenharmony_ci  * _device-local_ is memory that is physically connected to the device.
87e5c31af7Sopenharmony_ci  * _device-local, host visible_ is device-local memory that is visible to
88e5c31af7Sopenharmony_ci    the host.
89e5c31af7Sopenharmony_ci  * _host-local, host visible_ is memory that is local to the host and
90e5c31af7Sopenharmony_ci    visible to the device and host.
91e5c31af7Sopenharmony_ci
92e5c31af7Sopenharmony_ciOn other architectures, there may: only be a single heap that can: be used
93e5c31af7Sopenharmony_cifor any purpose.
94e5c31af7Sopenharmony_ci
95e5c31af7Sopenharmony_ci
96e5c31af7Sopenharmony_ci[[fundamentals-queueoperation]]
97e5c31af7Sopenharmony_ci=== Queue Operation
98e5c31af7Sopenharmony_ci
99e5c31af7Sopenharmony_ciVulkan queues provide an interface to the execution engines of a device.
100e5c31af7Sopenharmony_ciCommands for these execution engines are recorded into command buffers ahead
101e5c31af7Sopenharmony_ciof execution time, and then submitted to a queue for execution.
102e5c31af7Sopenharmony_ciOnce submitted to a queue, command buffers will begin and complete execution
103e5c31af7Sopenharmony_ciwithout further application intervention, though the order of this execution
104e5c31af7Sopenharmony_ciis dependent on a number of <<synchronization, implicit and explicit
105e5c31af7Sopenharmony_ciordering constraints>>.
106e5c31af7Sopenharmony_ci
107e5c31af7Sopenharmony_ciWork is submitted to queues using _queue submission commands_ that typically
108e5c31af7Sopenharmony_citake the form ftext:vkQueue* (e.g. flink:vkQueueSubmit
109e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[, flink:vkQueueBindSparse]
110e5c31af7Sopenharmony_ci), and can: take a list of semaphores upon which to wait before work begins
111e5c31af7Sopenharmony_ciand a list of semaphores to signal once work has completed.
112e5c31af7Sopenharmony_ciThe work itself, as well as signaling and waiting on the semaphores are all
113e5c31af7Sopenharmony_ci_queue operations_.
114e5c31af7Sopenharmony_ciQueue submission commands return control to the application once queue
115e5c31af7Sopenharmony_cioperations have been submitted - they do not wait for completion.
116e5c31af7Sopenharmony_ci
117e5c31af7Sopenharmony_ciThere are no implicit ordering constraints between queue operations on
118e5c31af7Sopenharmony_cidifferent queues, or between queues and the host, so these may: operate in
119e5c31af7Sopenharmony_ciany order with respect to each other.
120e5c31af7Sopenharmony_ciExplicit ordering constraints between different queues or with the host can:
121e5c31af7Sopenharmony_cibe expressed with <<synchronization-semaphores,semaphores>> and
122e5c31af7Sopenharmony_ci<<synchronization-fences,fences>>.
123e5c31af7Sopenharmony_ci
124e5c31af7Sopenharmony_ciCommand buffer submissions to a single queue respect
125e5c31af7Sopenharmony_ci<<synchronization-submission-order, submission order>> and other
126e5c31af7Sopenharmony_ci<<synchronization-implicit, implicit ordering guarantees>>, but otherwise
127e5c31af7Sopenharmony_cimay: overlap or execute out of order.
128e5c31af7Sopenharmony_ciOther types of batches and queue submissions against a single queue
129e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[(e.g. <<sparsemem-memory-binding, sparse memory binding>>)]
130e5c31af7Sopenharmony_cihave no implicit ordering constraints with any other queue submission or
131e5c31af7Sopenharmony_cibatch.
132e5c31af7Sopenharmony_ciAdditional explicit ordering constraints between queue submissions and
133e5c31af7Sopenharmony_ciindividual batches can be expressed with
134e5c31af7Sopenharmony_ci<<synchronization-semaphores,semaphores>> and
135e5c31af7Sopenharmony_ci<<synchronization-fences,fences>>.
136e5c31af7Sopenharmony_ci
137e5c31af7Sopenharmony_ciBefore a fence or semaphore is signaled, it is guaranteed that any
138e5c31af7Sopenharmony_cipreviously submitted queue operations have completed execution, and that
139e5c31af7Sopenharmony_cimemory writes from those queue operations are
140e5c31af7Sopenharmony_ci<<synchronization-dependencies-available-and-visible,available>> to future
141e5c31af7Sopenharmony_ciqueue operations.
142e5c31af7Sopenharmony_ciWaiting on a signaled semaphore or fence guarantees that previous writes
143e5c31af7Sopenharmony_cithat are available are also
144e5c31af7Sopenharmony_ci<<synchronization-dependencies-available-and-visible,visible>> to subsequent
145e5c31af7Sopenharmony_cicommands.
146e5c31af7Sopenharmony_ci
147e5c31af7Sopenharmony_ciCommand buffer boundaries, both between primary command buffers of the same
148e5c31af7Sopenharmony_cior different batches or submissions as well as between primary and secondary
149e5c31af7Sopenharmony_cicommand buffers, do not introduce any additional ordering constraints.
150e5c31af7Sopenharmony_ciIn other words, submitting the set of command buffers (which can: include
151e5c31af7Sopenharmony_ciexecuting secondary command buffers) between any semaphore or fence
152e5c31af7Sopenharmony_cioperations execute the recorded commands as if they had all been recorded
153e5c31af7Sopenharmony_ciinto a single primary command buffer, except that the current state is
154e5c31af7Sopenharmony_ci<<commandbuffers-statereset,reset>> on each boundary.
155e5c31af7Sopenharmony_ciExplicit ordering constraints can: be expressed with <<synchronization,
156e5c31af7Sopenharmony_ciexplicit synchronization primitives>>.
157e5c31af7Sopenharmony_ci
158e5c31af7Sopenharmony_ciThere are a few <<synchronization-implicit, implicit ordering guarantees>>
159e5c31af7Sopenharmony_cibetween commands within a command buffer, but only covering a subset of
160e5c31af7Sopenharmony_ciexecution.
161e5c31af7Sopenharmony_ciAdditional explicit ordering constraints can be expressed with the various
162e5c31af7Sopenharmony_ci<<synchronization, explicit synchronization primitives>>.
163e5c31af7Sopenharmony_ci
164e5c31af7Sopenharmony_ci[NOTE]
165e5c31af7Sopenharmony_ci.Note
166e5c31af7Sopenharmony_ci====
167e5c31af7Sopenharmony_ciImplementations have significant freedom to overlap execution of work
168e5c31af7Sopenharmony_cisubmitted to a queue, and this is common due to deep pipelining and
169e5c31af7Sopenharmony_ciparallelism in Vulkan devices.
170e5c31af7Sopenharmony_ci====
171e5c31af7Sopenharmony_ci
172e5c31af7Sopenharmony_ci[[fundamentals-queueoperation-command-types]]
173e5c31af7Sopenharmony_ciCommands recorded in command buffers can perform actions, set state that
174e5c31af7Sopenharmony_cipersists across commands, synchronize other commands, or indirectly launch
175e5c31af7Sopenharmony_ciother commands, with some commands fulfilling several of these roles.
176e5c31af7Sopenharmony_ciThe "`Command Properties`" section for each such command lists which of
177e5c31af7Sopenharmony_cithese roles the command takes.
178e5c31af7Sopenharmony_ciState setting commands update the _current state_ of the command buffer.
179e5c31af7Sopenharmony_ciSome commands that perform actions (e.g. draw/dispatch) do so based on the
180e5c31af7Sopenharmony_cicurrent state set cumulatively since the start of the command buffer.
181e5c31af7Sopenharmony_ciThe work involved in performing action commands is often allowed to overlap
182e5c31af7Sopenharmony_cior to be reordered, but doing so must: not alter the state to be used by
183e5c31af7Sopenharmony_cieach action command.
184e5c31af7Sopenharmony_ciIn general, action commands are those commands that alter framebuffer
185e5c31af7Sopenharmony_ciattachments, read/write buffer or image memory, or write to query pools.
186e5c31af7Sopenharmony_ci
187e5c31af7Sopenharmony_ciSynchronization commands introduce explicit
188e5c31af7Sopenharmony_ci<<synchronization-dependencies,execution and memory dependencies>> between
189e5c31af7Sopenharmony_citwo sets of action commands, where the second set of commands depends on the
190e5c31af7Sopenharmony_cifirst set of commands.
191e5c31af7Sopenharmony_ciThese dependencies enforce both that the execution of certain
192e5c31af7Sopenharmony_ci<<synchronization-pipeline-stages, pipeline stages>> in the later set occurs
193e5c31af7Sopenharmony_ciafter the execution of certain stages in the source set, and that the
194e5c31af7Sopenharmony_cieffects of <<synchronization-global-memory-barriers,memory accesses>>
195e5c31af7Sopenharmony_ciperformed by certain pipeline stages occur in order and are visible to each
196e5c31af7Sopenharmony_ciother.
197e5c31af7Sopenharmony_ciWhen not enforced by an explicit dependency or <<synchronization-implicit,
198e5c31af7Sopenharmony_ciimplicit ordering guarantees>>, action commands may: overlap execution or
199e5c31af7Sopenharmony_ciexecute out of order, and may: not see the side effects of each other's
200e5c31af7Sopenharmony_cimemory accesses.
201e5c31af7Sopenharmony_ci
202e5c31af7Sopenharmony_ci
203e5c31af7Sopenharmony_ci[[fundamentals-objectmodel-overview]]
204e5c31af7Sopenharmony_ci== Object Model
205e5c31af7Sopenharmony_ci
206e5c31af7Sopenharmony_ciThe devices, queues, and other entities in Vulkan are represented by Vulkan
207e5c31af7Sopenharmony_ciobjects.
208e5c31af7Sopenharmony_ciAt the API level, all objects are referred to by handles.
209e5c31af7Sopenharmony_ciThere are two classes of handles, dispatchable and non-dispatchable.
210e5c31af7Sopenharmony_ci_Dispatchable_ handle types are a pointer to an opaque type.
211e5c31af7Sopenharmony_ciThis pointer may: be used by layers as part of intercepting API commands,
212e5c31af7Sopenharmony_ciand thus each API command takes a dispatchable type as its first parameter.
213e5c31af7Sopenharmony_ciEach object of a dispatchable type must: have a unique handle value during
214e5c31af7Sopenharmony_ciits lifetime.
215e5c31af7Sopenharmony_ci
216e5c31af7Sopenharmony_ci_Non-dispatchable_ handle types are a 64-bit integer type whose meaning is
217e5c31af7Sopenharmony_ciimplementation-dependent.
218e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_private_data[]
219e5c31af7Sopenharmony_ciIf the <<features-privateData, pname:privateData>> feature is enabled for a
220e5c31af7Sopenharmony_cislink:VkDevice, each object of a non-dispatchable type created on that
221e5c31af7Sopenharmony_cidevice must: have a handle value that is unique among objects created on
222e5c31af7Sopenharmony_cithat device, for the duration of the object's lifetime.
223e5c31af7Sopenharmony_ciOtherwise, non-dispatchable
224e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_EXT_private_data[]
225e5c31af7Sopenharmony_ciifndef::VK_VERSION_1_3,VK_EXT_private_data[Non-dispatchable]
226e5c31af7Sopenharmony_cihandles may: encode object information directly in the handle rather than
227e5c31af7Sopenharmony_ciacting as a reference to an underlying object, and thus may: not have unique
228e5c31af7Sopenharmony_cihandle values.
229e5c31af7Sopenharmony_ciIf handle values are not unique, then destroying one such handle must: not
230e5c31af7Sopenharmony_cicause identical handles of other types to become invalid, and must: not
231e5c31af7Sopenharmony_cicause identical handles of the same type to become invalid if that handle
232e5c31af7Sopenharmony_civalue has been created more times than it has been destroyed.
233e5c31af7Sopenharmony_ci
234e5c31af7Sopenharmony_ciAll objects created or allocated from a sname:VkDevice (i.e. with a
235e5c31af7Sopenharmony_cisname:VkDevice as the first parameter) are private to that device, and must:
236e5c31af7Sopenharmony_cinot be used on other devices.
237e5c31af7Sopenharmony_ci
238e5c31af7Sopenharmony_ci
239e5c31af7Sopenharmony_ci[[fundamentals-objectmodel-lifetime]]
240e5c31af7Sopenharmony_ci=== Object Lifetime
241e5c31af7Sopenharmony_ci
242e5c31af7Sopenharmony_ciObjects are created or allocated by ftext:vkCreate* and ftext:vkAllocate*
243e5c31af7Sopenharmony_cicommands, respectively.
244e5c31af7Sopenharmony_ciOnce an object is created or allocated, its "`structure`" is considered to
245e5c31af7Sopenharmony_cibe immutable, though the contents of certain object types is still free to
246e5c31af7Sopenharmony_cichange.
247e5c31af7Sopenharmony_ciObjects are destroyed or freed by ftext:vkDestroy* and ftext:vkFree*
248e5c31af7Sopenharmony_cicommands, respectively.
249e5c31af7Sopenharmony_ci
250e5c31af7Sopenharmony_ciObjects that are allocated (rather than created) take resources from an
251e5c31af7Sopenharmony_ciexisting pool object or memory heap, and when freed return resources to that
252e5c31af7Sopenharmony_cipool or heap.
253e5c31af7Sopenharmony_ciWhile object creation and destruction are generally expected to be
254e5c31af7Sopenharmony_cilow-frequency occurrences during runtime, allocating and freeing objects
255e5c31af7Sopenharmony_cican: occur at high frequency.
256e5c31af7Sopenharmony_ciPool objects help accommodate improved performance of the allocations and
257e5c31af7Sopenharmony_cifrees.
258e5c31af7Sopenharmony_ci
259e5c31af7Sopenharmony_ciifdef::VKSC_VERSION_1_0[]
260e5c31af7Sopenharmony_ciIn Vulkan SC, data structures for objects are reserved by the implementation
261e5c31af7Sopenharmony_ciat device creation time in order to enable implementations to rely solely on
262e5c31af7Sopenharmony_cistatic memory management at run-time.
263e5c31af7Sopenharmony_ciThe slink:VkDeviceObjectReservationCreateInfo structure provides upper
264e5c31af7Sopenharmony_cibounds on the simultaneous number of objects of each type that can: be
265e5c31af7Sopenharmony_ciallocated during the lifetime of the slink:VkDevice.
266e5c31af7Sopenharmony_ciMost objects can be created and destroyed as needed, provided that no more
267e5c31af7Sopenharmony_cithan the requested number are in existence at any point in time.
268e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
269e5c31af7Sopenharmony_ci
270e5c31af7Sopenharmony_ciIt is an application's responsibility to track the lifetime of Vulkan
271e5c31af7Sopenharmony_ciobjects, and not to destroy them while they are still in use.
272e5c31af7Sopenharmony_ci
273e5c31af7Sopenharmony_ci[[fundamentals-objectmodel-lifetime-acquire]]
274e5c31af7Sopenharmony_ciThe ownership of application-owned memory is immediately acquired by any
275e5c31af7Sopenharmony_ciVulkan command it is passed
276e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[into.]
277e5c31af7Sopenharmony_ciifdef::VKSC_VERSION_1_0[into, unless otherwise noted below.]
278e5c31af7Sopenharmony_ciOwnership of such memory must: be released back to the application at the
279e5c31af7Sopenharmony_ciend of the duration of the command,
280e5c31af7Sopenharmony_ciifdef::VK_KHR_deferred_host_operations[]
281e5c31af7Sopenharmony_ciunless that command was deferred,
282e5c31af7Sopenharmony_ciendif::VK_KHR_deferred_host_operations[]
283e5c31af7Sopenharmony_ciso that the application can: alter or free this memory as soon as all the
284e5c31af7Sopenharmony_cicommands that acquired it have returned.
285e5c31af7Sopenharmony_ciifdef::VK_KHR_deferred_host_operations[]
286e5c31af7Sopenharmony_ciIf the command was <<deferred-host-operations-requesting, deferred>>,
287e5c31af7Sopenharmony_ciownership of such memory is released back to the application when the
288e5c31af7Sopenharmony_cideferred operation is complete.
289e5c31af7Sopenharmony_ciendif::VK_KHR_deferred_host_operations[]
290e5c31af7Sopenharmony_ci
291e5c31af7Sopenharmony_ciThe following object types are consumed when they are passed into a Vulkan
292e5c31af7Sopenharmony_cicommand and not further accessed by the objects they are used to create.
293e5c31af7Sopenharmony_ciThey must: not be destroyed in the duration of any API command they are
294e5c31af7Sopenharmony_cipassed into:
295e5c31af7Sopenharmony_ci
296e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[]
297e5c31af7Sopenharmony_ci  * sname:VkShaderModule
298e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
299e5c31af7Sopenharmony_ci  * sname:VkPipelineCache
300e5c31af7Sopenharmony_ciifdef::VK_EXT_validation_cache[]
301e5c31af7Sopenharmony_ci  * sname:VkValidationCacheEXT
302e5c31af7Sopenharmony_ciendif::VK_EXT_validation_cache[]
303e5c31af7Sopenharmony_ci
304e5c31af7Sopenharmony_ciifdef::VKSC_VERSION_1_0[]
305e5c31af7Sopenharmony_ciA sname:VkPipelineCache object created with
306e5c31af7Sopenharmony_ciename:VK_PIPELINE_CACHE_CREATE_USE_APPLICATION_STORAGE_BIT requires the
307e5c31af7Sopenharmony_ciapplication to maintain the memory contents pointed to by
308e5c31af7Sopenharmony_cisname:VkPipelineCacheCreateInfo::pname:pInitialData for the lifetime of the
309e5c31af7Sopenharmony_cipipeline cache object.
310e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
311e5c31af7Sopenharmony_ci
312e5c31af7Sopenharmony_ciA sname:VkRenderPass
313e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_KHR_maintenance4[]
314e5c31af7Sopenharmony_cior sname:VkPipelineLayout
315e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_KHR_maintenance4[]
316e5c31af7Sopenharmony_ciobject passed as a parameter to create another object is not further
317e5c31af7Sopenharmony_ciaccessed by that object after the duration of the command it is passed into.
318e5c31af7Sopenharmony_ciA sname:VkRenderPass used in a command buffer follows the rules described
319e5c31af7Sopenharmony_cibelow.
320e5c31af7Sopenharmony_ci
321e5c31af7Sopenharmony_ciifndef::VK_VERSION_1_3,VK_KHR_maintenance4[]
322e5c31af7Sopenharmony_ciA sname:VkPipelineLayout object must: not be destroyed while any command
323e5c31af7Sopenharmony_cibuffer that uses it is in the recording state.
324e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_KHR_maintenance4[]
325e5c31af7Sopenharmony_ci
326e5c31af7Sopenharmony_cisname:VkDescriptorSetLayout objects may: be accessed by commands that
327e5c31af7Sopenharmony_cioperate on descriptor sets allocated using that layout, and those descriptor
328e5c31af7Sopenharmony_cisets must: not be updated with flink:vkUpdateDescriptorSets after the
329e5c31af7Sopenharmony_cidescriptor set layout has been destroyed.
330e5c31af7Sopenharmony_ciOtherwise, a sname:VkDescriptorSetLayout object passed as a parameter to
331e5c31af7Sopenharmony_cicreate another object is not further accessed by that object after the
332e5c31af7Sopenharmony_ciduration of the command it is passed into.
333e5c31af7Sopenharmony_ci
334e5c31af7Sopenharmony_ciThe application must: not destroy any other type of Vulkan object until all
335e5c31af7Sopenharmony_ciuses of that object by the device (such as via command buffer execution)
336e5c31af7Sopenharmony_cihave completed.
337e5c31af7Sopenharmony_ci
338e5c31af7Sopenharmony_ci[[fundamentals-objectmodel-lifetime-cmdbuffers]]
339e5c31af7Sopenharmony_ciThe following Vulkan objects must: not be destroyed while any command
340e5c31af7Sopenharmony_cibuffers using the object are in the <<commandbuffers-lifecycle, pending
341e5c31af7Sopenharmony_cistate>>:
342e5c31af7Sopenharmony_ci
343e5c31af7Sopenharmony_ci  * sname:VkEvent
344e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[]
345e5c31af7Sopenharmony_ci  * sname:VkQueryPool
346e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
347e5c31af7Sopenharmony_ci  * sname:VkBuffer
348e5c31af7Sopenharmony_ci  * sname:VkBufferView
349e5c31af7Sopenharmony_ci  * sname:VkImage
350e5c31af7Sopenharmony_ci  * sname:VkImageView
351e5c31af7Sopenharmony_ci  * sname:VkPipeline
352e5c31af7Sopenharmony_ci  * sname:VkSampler
353e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[]
354e5c31af7Sopenharmony_ci  * sname:VkSamplerYcbcrConversion
355e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[]
356e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[]
357e5c31af7Sopenharmony_ci  * sname:VkDescriptorPool
358e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
359e5c31af7Sopenharmony_ci  * sname:VkFramebuffer
360e5c31af7Sopenharmony_ci  * sname:VkRenderPass
361e5c31af7Sopenharmony_ci  * sname:VkCommandBuffer
362e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[]
363e5c31af7Sopenharmony_ci  * sname:VkCommandPool
364e5c31af7Sopenharmony_ci  * sname:VkDeviceMemory
365e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
366e5c31af7Sopenharmony_ci  * sname:VkDescriptorSet
367e5c31af7Sopenharmony_ciifdef::VK_NV_device_generated_commands[]
368e5c31af7Sopenharmony_ci  * sname:VkIndirectCommandsLayoutNV
369e5c31af7Sopenharmony_ciendif::VK_NV_device_generated_commands[]
370e5c31af7Sopenharmony_ciifdef::VK_NV_ray_tracing[]
371e5c31af7Sopenharmony_ci  * sname:VkAccelerationStructureNV
372e5c31af7Sopenharmony_ciendif::VK_NV_ray_tracing[]
373e5c31af7Sopenharmony_ciifdef::VK_KHR_acceleration_structure[]
374e5c31af7Sopenharmony_ci  * sname:VkAccelerationStructureKHR
375e5c31af7Sopenharmony_ciendif::VK_KHR_acceleration_structure[]
376e5c31af7Sopenharmony_ciifdef::VK_KHR_video_queue[]
377e5c31af7Sopenharmony_ci  * sname:VkVideoSessionKHR
378e5c31af7Sopenharmony_ci  * sname:VkVideoSessionParametersKHR
379e5c31af7Sopenharmony_ciendif::VK_KHR_video_queue[]
380e5c31af7Sopenharmony_ci
381e5c31af7Sopenharmony_ciDestroying these objects will move any command buffers that are in the
382e5c31af7Sopenharmony_ci<<commandbuffers-lifecycle, recording or executable state>>, and are using
383e5c31af7Sopenharmony_cithose objects, to the <<commandbuffers-lifecycle, invalid state>>.
384e5c31af7Sopenharmony_ci
385e5c31af7Sopenharmony_ciThe following Vulkan objects must: not be destroyed while any queue is
386e5c31af7Sopenharmony_ciexecuting commands that use the object:
387e5c31af7Sopenharmony_ci
388e5c31af7Sopenharmony_ci  * sname:VkFence
389e5c31af7Sopenharmony_ci  * sname:VkSemaphore
390e5c31af7Sopenharmony_ci  * sname:VkCommandBuffer
391e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[]
392e5c31af7Sopenharmony_ci  * sname:VkCommandPool
393e5c31af7Sopenharmony_ciifdef::VK_NV_external_sci_sync2[]
394e5c31af7Sopenharmony_ci  * sname:VkSemaphoreSciSyncPoolNV
395e5c31af7Sopenharmony_ciendif::VK_NV_external_sci_sync2[]
396e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
397e5c31af7Sopenharmony_ci
398e5c31af7Sopenharmony_ciIn general, objects can: be destroyed or freed in any order, even if the
399e5c31af7Sopenharmony_ciobject being freed is involved in the use of another object (e.g. use of a
400e5c31af7Sopenharmony_ciresource in a view, use of a view in a descriptor set,
401e5c31af7Sopenharmony_ciifdef::VK_KHR_pipeline_library[]
402e5c31af7Sopenharmony_ciuse of a <<pipelines-library,pipeline library>> in another pipeline,
403e5c31af7Sopenharmony_ciendif::VK_KHR_pipeline_library[]
404e5c31af7Sopenharmony_ciifdef::VK_NV_device_generated_commands[]
405e5c31af7Sopenharmony_ciuse of a <<graphics-shadergroups,referenced pipeline>> for additional
406e5c31af7Sopenharmony_cigraphics shader groups in another pipeline,
407e5c31af7Sopenharmony_ciendif::VK_NV_device_generated_commands[]
408e5c31af7Sopenharmony_ciifdef::VK_KHR_acceleration_structure[]
409e5c31af7Sopenharmony_ciuse of a <<acceleration-structure-bottom-level, bottom level acceleration
410e5c31af7Sopenharmony_cistructure>> in an instance referenced by a
411e5c31af7Sopenharmony_ci<<acceleration-structure-top-level, top level acceleration structure>>,
412e5c31af7Sopenharmony_ciendif::VK_KHR_acceleration_structure[]
413e5c31af7Sopenharmony_ciuse of an object in a command buffer, binding of a memory allocation to a
414e5c31af7Sopenharmony_ciresource), as long as any object that uses the freed object is not further
415e5c31af7Sopenharmony_ciused in any way except to be destroyed or to be reset in such a way that it
416e5c31af7Sopenharmony_cino longer uses the other object (such as resetting a command buffer).
417e5c31af7Sopenharmony_ciIf the object has been reset, then it can: be used as if it never used the
418e5c31af7Sopenharmony_cifreed object.
419e5c31af7Sopenharmony_ciAn exception to this is when there is a parent/child relationship between
420e5c31af7Sopenharmony_ciobjects.
421e5c31af7Sopenharmony_ciIn this case, the application must: not destroy a parent object before its
422e5c31af7Sopenharmony_cichildren, except when the parent is explicitly defined to free its children
423e5c31af7Sopenharmony_ciwhen it is destroyed (e.g. for pool objects, as defined below).
424e5c31af7Sopenharmony_ci
425e5c31af7Sopenharmony_cisname:VkCommandPool objects are parents of sname:VkCommandBuffer objects.
426e5c31af7Sopenharmony_cisname:VkDescriptorPool objects are parents of sname:VkDescriptorSet objects.
427e5c31af7Sopenharmony_cisname:VkDevice objects are parents of many object types (all that take a
428e5c31af7Sopenharmony_cisname:VkDevice as a parameter to their creation).
429e5c31af7Sopenharmony_ci
430e5c31af7Sopenharmony_ciThe following Vulkan objects have specific restrictions for when they can:
431e5c31af7Sopenharmony_cibe destroyed:
432e5c31af7Sopenharmony_ci
433e5c31af7Sopenharmony_ci  * sname:VkQueue objects cannot: be explicitly destroyed.
434e5c31af7Sopenharmony_ci    Instead, they are implicitly destroyed when the sname:VkDevice object
435e5c31af7Sopenharmony_ci    they are retrieved from is destroyed.
436e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[]
437e5c31af7Sopenharmony_ci  * Destroying a pool object implicitly frees all objects allocated from
438e5c31af7Sopenharmony_ci    that pool.
439e5c31af7Sopenharmony_ci    Specifically, destroying sname:VkCommandPool frees all
440e5c31af7Sopenharmony_ci    sname:VkCommandBuffer objects that were allocated from it, and
441e5c31af7Sopenharmony_ci    destroying sname:VkDescriptorPool frees all sname:VkDescriptorSet
442e5c31af7Sopenharmony_ci    objects that were allocated from it.
443e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
444e5c31af7Sopenharmony_ciifdef::VKSC_VERSION_1_0[]
445e5c31af7Sopenharmony_ci  * [[fundamentals-objectmodel-no-destroy]] Device memory
446e5c31af7Sopenharmony_ci    (slink:VkDeviceMemory) allocations,
447e5c31af7Sopenharmony_ciifdef::VK_KHR_swapchain[swapchains (slink:VkSwapchainKHR),]
448e5c31af7Sopenharmony_ci    and pool objects (slink:VkCommandPool, slink:VkDescriptorPool,
449e5c31af7Sopenharmony_ciifdef::VK_NV_external_sci_sync2[slink:VkSemaphoreSciSyncPoolNV,]
450e5c31af7Sopenharmony_ci    slink:VkQueryPool) cannot: be explicitly freed or destroyed.
451e5c31af7Sopenharmony_ci    Instead, they are implicitly freed or destroyed when the sname:VkDevice
452e5c31af7Sopenharmony_ci    object they are created from is destroyed.
453e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
454e5c31af7Sopenharmony_ci  * sname:VkDevice objects can: be destroyed when all sname:VkQueue objects
455e5c31af7Sopenharmony_ci    retrieved from them are idle, and all objects created from them have
456e5c31af7Sopenharmony_ci    been destroyed.
457e5c31af7Sopenharmony_ci  ** This includes the following objects:
458e5c31af7Sopenharmony_ci+
459e5c31af7Sopenharmony_ci--
460e5c31af7Sopenharmony_ci  ** sname:VkFence
461e5c31af7Sopenharmony_ci  ** sname:VkSemaphore
462e5c31af7Sopenharmony_ci  ** sname:VkEvent
463e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[]
464e5c31af7Sopenharmony_ci  ** sname:VkQueryPool
465e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
466e5c31af7Sopenharmony_ci  ** sname:VkBuffer
467e5c31af7Sopenharmony_ci  ** sname:VkBufferView
468e5c31af7Sopenharmony_ci  ** sname:VkImage
469e5c31af7Sopenharmony_ci  ** sname:VkImageView
470e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[]
471e5c31af7Sopenharmony_ci  ** sname:VkShaderModule
472e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
473e5c31af7Sopenharmony_ci  ** sname:VkPipelineCache
474e5c31af7Sopenharmony_ci  ** sname:VkPipeline
475e5c31af7Sopenharmony_ci  ** sname:VkPipelineLayout
476e5c31af7Sopenharmony_ci  ** sname:VkSampler
477e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[]
478e5c31af7Sopenharmony_ci  ** sname:VkSamplerYcbcrConversion
479e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion[]
480e5c31af7Sopenharmony_ci  ** sname:VkDescriptorSetLayout
481e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[]
482e5c31af7Sopenharmony_ci  ** sname:VkDescriptorPool
483e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
484e5c31af7Sopenharmony_ci  ** sname:VkFramebuffer
485e5c31af7Sopenharmony_ci  ** sname:VkRenderPass
486e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[]
487e5c31af7Sopenharmony_ci  ** sname:VkCommandPool
488e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
489e5c31af7Sopenharmony_ci  ** sname:VkCommandBuffer
490e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[]
491e5c31af7Sopenharmony_ci  ** sname:VkDeviceMemory
492e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
493e5c31af7Sopenharmony_ciifdef::VK_EXT_validation_cache[]
494e5c31af7Sopenharmony_ci  ** sname:VkValidationCacheEXT
495e5c31af7Sopenharmony_ciendif::VK_EXT_validation_cache[]
496e5c31af7Sopenharmony_ciifdef::VK_NV_ray_tracing[]
497e5c31af7Sopenharmony_ci  ** sname:VkAccelerationStructureNV
498e5c31af7Sopenharmony_ciendif::VK_NV_ray_tracing[]
499e5c31af7Sopenharmony_ciifdef::VK_KHR_acceleration_structure[]
500e5c31af7Sopenharmony_ci  ** sname:VkAccelerationStructureKHR
501e5c31af7Sopenharmony_ciendif::VK_KHR_acceleration_structure[]
502e5c31af7Sopenharmony_ciifdef::VK_KHR_video_queue[]
503e5c31af7Sopenharmony_ci  ** sname:VkVideoSessionKHR
504e5c31af7Sopenharmony_ci  ** sname:VkVideoSessionParametersKHR
505e5c31af7Sopenharmony_ciendif::VK_KHR_video_queue[]
506e5c31af7Sopenharmony_ci--
507e5c31af7Sopenharmony_ciifdef::VKSC_VERSION_1_0[]
508e5c31af7Sopenharmony_ci  ** This does not include objects that do not have corresponding free or
509e5c31af7Sopenharmony_ci     destroy commands.
510e5c31af7Sopenharmony_ci     If
511e5c31af7Sopenharmony_ci     slink:VkPhysicalDeviceVulkanSC10Properties::<<limits-deviceDestroyFreesMemory,
512e5c31af7Sopenharmony_ci     pname:deviceDestroyFreesMemory>> is ename:VK_TRUE, the memory from
513e5c31af7Sopenharmony_ci     these objects is returned to the system when the device is destroyed,
514e5c31af7Sopenharmony_ci     otherwise it may: not be returned to the system until the process is
515e5c31af7Sopenharmony_ci     terminated.
516e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
517e5c31af7Sopenharmony_ci  * sname:VkPhysicalDevice objects cannot: be explicitly destroyed.
518e5c31af7Sopenharmony_ci    Instead, they are implicitly destroyed when the sname:VkInstance object
519e5c31af7Sopenharmony_ci    they are retrieved from is destroyed.
520e5c31af7Sopenharmony_ci  * sname:VkInstance objects can: be destroyed once all sname:VkDevice
521e5c31af7Sopenharmony_ci    objects created from any of its sname:VkPhysicalDevice objects have been
522e5c31af7Sopenharmony_ci    destroyed.
523e5c31af7Sopenharmony_ci
524e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_external_memory_capabilities,VK_KHR_external_semaphore_capabilities,VK_KHR_external_fence_capabilities[]
525e5c31af7Sopenharmony_ci[[fundamentals-objectmodel-external]]
526e5c31af7Sopenharmony_ci=== External Object Handles
527e5c31af7Sopenharmony_ci
528e5c31af7Sopenharmony_ciAs defined above, the scope of object handles created or allocated from a
529e5c31af7Sopenharmony_cisname:VkDevice is limited to that logical device.
530e5c31af7Sopenharmony_ciObjects which are not in scope are said to be external.
531e5c31af7Sopenharmony_ciTo bring an external object into scope, an external handle must: be exported
532e5c31af7Sopenharmony_cifrom the object in the source scope and imported into the destination scope.
533e5c31af7Sopenharmony_ci
534e5c31af7Sopenharmony_ci[NOTE]
535e5c31af7Sopenharmony_ci.Note
536e5c31af7Sopenharmony_ci====
537e5c31af7Sopenharmony_ciThe scope of external handles and their associated resources may: vary
538e5c31af7Sopenharmony_ciaccording to their type, but they can: generally be shared across process
539e5c31af7Sopenharmony_ciand API boundaries.
540e5c31af7Sopenharmony_ci====
541e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_external_memory_capabilities,VK_KHR_external_semaphore_capabilities,VK_KHR_external_fence_capabilities[]
542e5c31af7Sopenharmony_ci
543e5c31af7Sopenharmony_ci
544e5c31af7Sopenharmony_ci[[fundamentals-abi]]
545e5c31af7Sopenharmony_ci== Application Binary Interface
546e5c31af7Sopenharmony_ci
547e5c31af7Sopenharmony_ciThe mechanism by which Vulkan is made available to applications is platform-
548e5c31af7Sopenharmony_cior implementation- defined.
549e5c31af7Sopenharmony_ciOn many platforms the C interface described in this Specification is
550e5c31af7Sopenharmony_ciprovided by a shared library.
551e5c31af7Sopenharmony_ciSince shared libraries can be changed independently of the applications that
552e5c31af7Sopenharmony_ciuse them, they present particular compatibility challenges, and this
553e5c31af7Sopenharmony_ciSpecification places some requirements on them.
554e5c31af7Sopenharmony_ci
555e5c31af7Sopenharmony_ciShared library implementations must: use the default Application Binary
556e5c31af7Sopenharmony_ciInterface (ABI) of the standard C compiler for the platform, or provide
557e5c31af7Sopenharmony_cicustomized API headers that cause application code to use the
558e5c31af7Sopenharmony_ciimplementation's non-default ABI.
559e5c31af7Sopenharmony_ciAn ABI in this context means the size, alignment, and layout of C data
560e5c31af7Sopenharmony_citypes; the procedure calling convention; and the naming convention for
561e5c31af7Sopenharmony_cishared library symbols corresponding to C functions.
562e5c31af7Sopenharmony_ciCustomizing the calling convention for a platform is usually accomplished by
563e5c31af7Sopenharmony_cidefining <<boilerplate-platform-specific-calling-conventions,calling
564e5c31af7Sopenharmony_ciconvention macros>> appropriately in `vk_platform.h`.
565e5c31af7Sopenharmony_ci
566e5c31af7Sopenharmony_ciOn platforms where Vulkan is provided as a shared library, library symbols
567e5c31af7Sopenharmony_cibeginning with "`vk`" and followed by a digit or uppercase letter are
568e5c31af7Sopenharmony_cireserved for use by the implementation.
569e5c31af7Sopenharmony_ciApplications which use Vulkan must: not provide definitions of these
570e5c31af7Sopenharmony_cisymbols.
571e5c31af7Sopenharmony_ciThis allows the Vulkan shared library to be updated with additional symbols
572e5c31af7Sopenharmony_cifor new API versions or extensions without causing symbol conflicts with
573e5c31af7Sopenharmony_ciexisting applications.
574e5c31af7Sopenharmony_ci
575e5c31af7Sopenharmony_ciShared library implementations should: provide library symbols for commands
576e5c31af7Sopenharmony_ciin the highest version of this Specification they support, and for
577e5c31af7Sopenharmony_ciifdef::VK_KHR_surface[]
578e5c31af7Sopenharmony_ci<<wsi,Window System Integration>>
579e5c31af7Sopenharmony_ciendif::VK_KHR_surface[]
580e5c31af7Sopenharmony_ciifndef::VK_KHR_surface[]
581e5c31af7Sopenharmony_ciWindow System Integration
582e5c31af7Sopenharmony_ciendif::VK_KHR_surface[]
583e5c31af7Sopenharmony_ciextensions relevant to the platform.
584e5c31af7Sopenharmony_ciThey may: also provide library symbols for commands defined by additional
585e5c31af7Sopenharmony_ciextensions.
586e5c31af7Sopenharmony_ci
587e5c31af7Sopenharmony_ci[NOTE]
588e5c31af7Sopenharmony_ci.Note
589e5c31af7Sopenharmony_ci====
590e5c31af7Sopenharmony_ciThese requirements and recommendations are intended to allow implementors to
591e5c31af7Sopenharmony_citake advantage of platform-specific conventions for SDKs, ABIs, library
592e5c31af7Sopenharmony_civersioning mechanisms, etc.
593e5c31af7Sopenharmony_ciwhile still minimizing the code changes necessary to port applications or
594e5c31af7Sopenharmony_cilibraries between platforms.
595e5c31af7Sopenharmony_ciPlatform vendors, or providers of the _de facto_ standard Vulkan shared
596e5c31af7Sopenharmony_cilibrary for a platform, are encouraged to document what symbols the shared
597e5c31af7Sopenharmony_cilibrary provides and how it will be versioned when new symbols are added.
598e5c31af7Sopenharmony_ci
599e5c31af7Sopenharmony_ciApplications should: only rely on shared library symbols for commands in the
600e5c31af7Sopenharmony_ciminimum core version required by the application.
601e5c31af7Sopenharmony_ciflink:vkGetInstanceProcAddr and flink:vkGetDeviceProcAddr should: be used to
602e5c31af7Sopenharmony_ciobtain function pointers for commands in core versions beyond the
603e5c31af7Sopenharmony_ciapplication's minimum required version.
604e5c31af7Sopenharmony_ci====
605e5c31af7Sopenharmony_ci
606e5c31af7Sopenharmony_ci
607e5c31af7Sopenharmony_ci[[fundamentals-commandsyntax]]
608e5c31af7Sopenharmony_ci== Command Syntax and Duration
609e5c31af7Sopenharmony_ci
610e5c31af7Sopenharmony_ciThe Specification describes Vulkan commands as functions or procedures using
611e5c31af7Sopenharmony_ciC99 syntax.
612e5c31af7Sopenharmony_ciLanguage bindings for other languages such as C++ and JavaScript may: allow
613e5c31af7Sopenharmony_cifor stricter parameter passing, or object-oriented interfaces.
614e5c31af7Sopenharmony_ci
615e5c31af7Sopenharmony_ciVulkan uses the standard C types for the base type of scalar parameters
616e5c31af7Sopenharmony_ci(e.g. types from `<stdint.h>`), with exceptions described below, or
617e5c31af7Sopenharmony_cielsewhere in the text when appropriate:
618e5c31af7Sopenharmony_ci
619e5c31af7Sopenharmony_ci[open,refpage='VkBool32',desc='Vulkan boolean type',type='basetypes',xrefs='VK_TRUE VK_FALSE']
620e5c31af7Sopenharmony_ci--
621e5c31af7Sopenharmony_cibasetype:VkBool32 represents boolean `True` and `False` values, since C does
622e5c31af7Sopenharmony_cinot have a sufficiently portable built-in boolean type:
623e5c31af7Sopenharmony_ci
624e5c31af7Sopenharmony_ciinclude::{generated}/api/basetypes/VkBool32.adoc[]
625e5c31af7Sopenharmony_ci
626e5c31af7Sopenharmony_ciename:VK_TRUE represents a boolean *True* (unsigned integer 1) value, and
627e5c31af7Sopenharmony_ciename:VK_FALSE a boolean *False* (unsigned integer 0) value.
628e5c31af7Sopenharmony_ci
629e5c31af7Sopenharmony_ciAll values returned from a Vulkan implementation in a basetype:VkBool32 will
630e5c31af7Sopenharmony_cibe either ename:VK_TRUE or ename:VK_FALSE.
631e5c31af7Sopenharmony_ci
632e5c31af7Sopenharmony_ciApplications must: not pass any other values than ename:VK_TRUE or
633e5c31af7Sopenharmony_ciename:VK_FALSE into a Vulkan implementation where a basetype:VkBool32 is
634e5c31af7Sopenharmony_ciexpected.
635e5c31af7Sopenharmony_ci--
636e5c31af7Sopenharmony_ci
637e5c31af7Sopenharmony_ci[open,refpage='VK_TRUE',desc='Boolean true value',type='consts',xrefs='VkBool32 VK_FALSE']
638e5c31af7Sopenharmony_ci--
639e5c31af7Sopenharmony_ciename:VK_TRUE is a constant representing a basetype:VkBool32 *True* value.
640e5c31af7Sopenharmony_ci
641e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VK_TRUE.adoc[]
642e5c31af7Sopenharmony_ci--
643e5c31af7Sopenharmony_ci
644e5c31af7Sopenharmony_ci[open,refpage='VK_FALSE',desc='Boolean false value',type='consts',xrefs='VkBool32 VK_TRUE']
645e5c31af7Sopenharmony_ci--
646e5c31af7Sopenharmony_ciename:VK_FALSE is a constant representing a basetype:VkBool32 *False* value.
647e5c31af7Sopenharmony_ci
648e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VK_FALSE.adoc[]
649e5c31af7Sopenharmony_ci--
650e5c31af7Sopenharmony_ci
651e5c31af7Sopenharmony_ci
652e5c31af7Sopenharmony_ci[open,refpage='VkDeviceSize',desc='Vulkan device memory size and offsets',type='basetypes']
653e5c31af7Sopenharmony_ci--
654e5c31af7Sopenharmony_cibasetype:VkDeviceSize represents device memory size and offset values:
655e5c31af7Sopenharmony_ci
656e5c31af7Sopenharmony_ciinclude::{generated}/api/basetypes/VkDeviceSize.adoc[]
657e5c31af7Sopenharmony_ci--
658e5c31af7Sopenharmony_ci
659e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_0,VK_EXT_buffer_device_address,VK_KHR_buffer_device_address[]
660e5c31af7Sopenharmony_ci[open,refpage='VkDeviceAddress',desc='Vulkan device address type',type='basetypes']
661e5c31af7Sopenharmony_ci--
662e5c31af7Sopenharmony_cibasetype:VkDeviceAddress represents device buffer address values:
663e5c31af7Sopenharmony_ci
664e5c31af7Sopenharmony_ciinclude::{generated}/api/basetypes/VkDeviceAddress.adoc[]
665e5c31af7Sopenharmony_ci--
666e5c31af7Sopenharmony_ciendif::VK_VERSION_1_0,VK_EXT_buffer_device_address,VK_KHR_buffer_device_address[]
667e5c31af7Sopenharmony_ci
668e5c31af7Sopenharmony_ciCommands that create Vulkan objects are of the form ftext:vkCreate* and take
669e5c31af7Sopenharmony_cistext:Vk*CreateInfo structures with the parameters needed to create the
670e5c31af7Sopenharmony_ciobject.
671e5c31af7Sopenharmony_ciThese Vulkan objects are destroyed with commands of the form
672e5c31af7Sopenharmony_ciftext:vkDestroy*.
673e5c31af7Sopenharmony_ci
674e5c31af7Sopenharmony_ciThe last in-parameter to each command that creates or destroys a Vulkan
675e5c31af7Sopenharmony_ciobject is pname:pAllocator.
676e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[]
677e5c31af7Sopenharmony_ciThe pname:pAllocator parameter can: be set to a non-`NULL` value such that
678e5c31af7Sopenharmony_ciallocations for the given object are delegated to an application provided
679e5c31af7Sopenharmony_cicallback; refer to the <<memory-allocation,Memory Allocation>> chapter for
680e5c31af7Sopenharmony_cifurther details.
681e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
682e5c31af7Sopenharmony_ciifdef::VKSC_VERSION_1_0[]
683e5c31af7Sopenharmony_ciThe pname:pAllocator parameter must: be set to `NULL`.
684e5c31af7Sopenharmony_ciRefer to the <<memory-allocation,Memory Allocation>> chapter for further
685e5c31af7Sopenharmony_cidetails.
686e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
687e5c31af7Sopenharmony_ci
688e5c31af7Sopenharmony_ciCommands that allocate Vulkan objects owned by pool objects are of the form
689e5c31af7Sopenharmony_ciftext:vkAllocate*, and take stext:Vk*AllocateInfo structures.
690e5c31af7Sopenharmony_ciThese Vulkan objects are freed with commands of the form ftext:vkFree*.
691e5c31af7Sopenharmony_ciThese objects do not take allocators; if host memory is needed, they will
692e5c31af7Sopenharmony_ciuse the allocator that was specified when their parent pool was created.
693e5c31af7Sopenharmony_ci
694e5c31af7Sopenharmony_ciCommands are recorded into a command buffer by calling API commands of the
695e5c31af7Sopenharmony_ciform ftext:vkCmd*.
696e5c31af7Sopenharmony_ciEach such command may: have different restrictions on where it can: be used:
697e5c31af7Sopenharmony_ciin a primary and/or secondary command buffer, inside and/or outside a render
698e5c31af7Sopenharmony_cipass, and in one or more of the supported queue types.
699e5c31af7Sopenharmony_ciThese restrictions are documented together with the definition of each such
700e5c31af7Sopenharmony_cicommand.
701e5c31af7Sopenharmony_ci
702e5c31af7Sopenharmony_ciThe _duration_ of a Vulkan command refers to the interval between calling
703e5c31af7Sopenharmony_cithe command and its return to the caller.
704e5c31af7Sopenharmony_ci
705e5c31af7Sopenharmony_ci
706e5c31af7Sopenharmony_ci[[fundamentals-commandsyntax-results-lifetime]]
707e5c31af7Sopenharmony_ci=== Lifetime of Retrieved Results
708e5c31af7Sopenharmony_ci
709e5c31af7Sopenharmony_ciInformation is retrieved from the implementation with commands of the form
710e5c31af7Sopenharmony_ciftext:vkGet* and ftext:vkEnumerate*.
711e5c31af7Sopenharmony_ci
712e5c31af7Sopenharmony_ciUnless otherwise specified for an individual command, the results are
713e5c31af7Sopenharmony_ci_invariant_; that is, they will remain unchanged when retrieved again by
714e5c31af7Sopenharmony_cicalling the same command with the same parameters, so long as those
715e5c31af7Sopenharmony_ciparameters themselves all remain valid.
716e5c31af7Sopenharmony_ci
717e5c31af7Sopenharmony_ci
718e5c31af7Sopenharmony_ci[[fundamentals-threadingbehavior]]
719e5c31af7Sopenharmony_ci== Threading Behavior
720e5c31af7Sopenharmony_ci
721e5c31af7Sopenharmony_ciVulkan is intended to provide scalable performance when used on multiple
722e5c31af7Sopenharmony_cihost threads.
723e5c31af7Sopenharmony_ciAll commands support being called concurrently from multiple threads, but
724e5c31af7Sopenharmony_cicertain parameters, or components of parameters are defined to be
725e5c31af7Sopenharmony_ci_externally synchronized_.
726e5c31af7Sopenharmony_ciThis means that the caller must: guarantee that no more than one thread is
727e5c31af7Sopenharmony_ciusing such a parameter at a given time.
728e5c31af7Sopenharmony_ci
729e5c31af7Sopenharmony_ciMore precisely, Vulkan commands use simple stores to update the state of
730e5c31af7Sopenharmony_ciVulkan objects.
731e5c31af7Sopenharmony_ciA parameter declared as externally synchronized may: have its contents
732e5c31af7Sopenharmony_ciupdated at any time during the host execution of the command.
733e5c31af7Sopenharmony_ciIf two commands operate on the same object and at least one of the commands
734e5c31af7Sopenharmony_cideclares the object to be externally synchronized, then the caller must:
735e5c31af7Sopenharmony_ciguarantee not only that the commands do not execute simultaneously, but also
736e5c31af7Sopenharmony_cithat the two commands are separated by an appropriate memory barrier (if
737e5c31af7Sopenharmony_cineeded).
738e5c31af7Sopenharmony_ci
739e5c31af7Sopenharmony_ci[NOTE]
740e5c31af7Sopenharmony_ci.Note
741e5c31af7Sopenharmony_ci====
742e5c31af7Sopenharmony_ciMemory barriers are particularly relevant for hosts based on the ARM CPU
743e5c31af7Sopenharmony_ciarchitecture, which is more weakly ordered than many developers are
744e5c31af7Sopenharmony_ciaccustomed to from x86/x64 programming.
745e5c31af7Sopenharmony_ciFortunately, most higher-level synchronization primitives (like the pthread
746e5c31af7Sopenharmony_cilibrary) perform memory barriers as a part of mutual exclusion, so mutexing
747e5c31af7Sopenharmony_ciVulkan objects via these primitives will have the desired effect.
748e5c31af7Sopenharmony_ci====
749e5c31af7Sopenharmony_ci
750e5c31af7Sopenharmony_ciSimilarly the application must: avoid any potential data hazard of
751e5c31af7Sopenharmony_ciapplication-owned memory that has its
752e5c31af7Sopenharmony_ci<<fundamentals-objectmodel-lifetime-acquire,ownership temporarily acquired>>
753e5c31af7Sopenharmony_ciby a Vulkan command.
754e5c31af7Sopenharmony_ciWhile the ownership of application-owned memory remains acquired by a
755e5c31af7Sopenharmony_cicommand the implementation may: read the memory at any point, and it may:
756e5c31af7Sopenharmony_ciwrite non-code:const qualified memory at any point.
757e5c31af7Sopenharmony_ciParameters referring to non-code:const qualified application-owned memory
758e5c31af7Sopenharmony_ciare not marked explicitly as _externally synchronized_ in the Specification.
759e5c31af7Sopenharmony_ci
760e5c31af7Sopenharmony_ciifdef::VK_KHR_deferred_host_operations[]
761e5c31af7Sopenharmony_ciIf an application is using <<deferred-host-operations, deferred host
762e5c31af7Sopenharmony_cioperations>> in a command, and that operation is successfully deferred,
763e5c31af7Sopenharmony_ciobject parameters and application-owned memory passed to that command may:
764e5c31af7Sopenharmony_cibe accessed at any time until the deferred operation is complete.
765e5c31af7Sopenharmony_ciendif::VK_KHR_deferred_host_operations[]
766e5c31af7Sopenharmony_ci
767e5c31af7Sopenharmony_ciMany object types are _immutable_, meaning the objects cannot: change once
768e5c31af7Sopenharmony_cithey have been created.
769e5c31af7Sopenharmony_ciThese types of objects never need external synchronization, except that they
770e5c31af7Sopenharmony_cimust: not be destroyed while they are in use on another thread.
771e5c31af7Sopenharmony_ciIn certain special cases mutable object parameters are internally
772e5c31af7Sopenharmony_cisynchronized, making external synchronization unnecessary.
773e5c31af7Sopenharmony_ciAny command parameters that are not labeled as externally synchronized are
774e5c31af7Sopenharmony_cieither not mutated by the command or are internally synchronized.
775e5c31af7Sopenharmony_ciAdditionally, certain objects related to a command's parameters (e.g.
776e5c31af7Sopenharmony_cicommand pools and descriptor pools) may: be affected by a command, and must:
777e5c31af7Sopenharmony_cialso be externally synchronized.
778e5c31af7Sopenharmony_ciThese implicit parameters are documented as described below.
779e5c31af7Sopenharmony_ci
780e5c31af7Sopenharmony_ciParameters of commands that are externally synchronized are listed below.
781e5c31af7Sopenharmony_ci
782e5c31af7Sopenharmony_ciinclude::{generated}/hostsynctable/parameters.adoc[]
783e5c31af7Sopenharmony_ci
784e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_pipeline_creation_cache_control[]
785e5c31af7Sopenharmony_ciFor slink:VkPipelineCache objects created with pname:flags containing
786e5c31af7Sopenharmony_ciename:VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT, the above table
787e5c31af7Sopenharmony_ciis extended with the pname:pipelineCache parameter to
788e5c31af7Sopenharmony_ciftext:vkCreate*Pipelines being externally synchronized.
789e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_EXT_pipeline_creation_cache_control[]
790e5c31af7Sopenharmony_ci
791e5c31af7Sopenharmony_ciThere are also a few instances where a command can: take in a user allocated
792e5c31af7Sopenharmony_cilist whose contents are externally synchronized parameters.
793e5c31af7Sopenharmony_ciIn these cases, the caller must: guarantee that at most one thread is using
794e5c31af7Sopenharmony_cia given element within the list at a given time.
795e5c31af7Sopenharmony_ciThese parameters are listed below.
796e5c31af7Sopenharmony_ci
797e5c31af7Sopenharmony_ciinclude::{generated}/hostsynctable/parameterlists.adoc[]
798e5c31af7Sopenharmony_ci
799e5c31af7Sopenharmony_ciIn addition, there are some implicit parameters that need to be externally
800e5c31af7Sopenharmony_cisynchronized.
801e5c31af7Sopenharmony_ciFor example, when a pname:commandBuffer parameter needs to be externally
802e5c31af7Sopenharmony_cisynchronized, it implies that the pname:commandPool from which that command
803e5c31af7Sopenharmony_cibuffer was allocated also needs to be externally synchronized.
804e5c31af7Sopenharmony_ciThe implicit parameters and their associated object are listed below.
805e5c31af7Sopenharmony_ci
806e5c31af7Sopenharmony_ciinclude::{generated}/hostsynctable/implicit.adoc[]
807e5c31af7Sopenharmony_ci
808e5c31af7Sopenharmony_ci
809e5c31af7Sopenharmony_ci[[fundamentals-validusage]]
810e5c31af7Sopenharmony_ci== Valid Usage
811e5c31af7Sopenharmony_ci
812e5c31af7Sopenharmony_ci// preserving old id for permalinking
813e5c31af7Sopenharmony_ci[[fundamentals-errors]]
814e5c31af7Sopenharmony_ciValid usage defines a set of conditions which must: be met in order to
815e5c31af7Sopenharmony_ciachieve well-defined runtime behavior in an application.
816e5c31af7Sopenharmony_ciThese conditions depend only on Vulkan state, and the parameters or objects
817e5c31af7Sopenharmony_ciwhose usage is constrained by the condition.
818e5c31af7Sopenharmony_ci
819e5c31af7Sopenharmony_ciThe core layer assumes applications are using the API correctly.
820e5c31af7Sopenharmony_ciExcept as documented elsewhere in the Specification, the behavior of the
821e5c31af7Sopenharmony_cicore layer to an application using the API incorrectly is undefined:, and
822e5c31af7Sopenharmony_cimay: include program termination.
823e5c31af7Sopenharmony_ciHowever, implementations must: ensure that incorrect usage by an application
824e5c31af7Sopenharmony_cidoes not affect the integrity of the operating system, the Vulkan
825e5c31af7Sopenharmony_ciimplementation, or other Vulkan client applications in the system.
826e5c31af7Sopenharmony_ciIn particular, any guarantees made by an operating system about whether
827e5c31af7Sopenharmony_cimemory from one process can: be visible to another process or not must: not
828e5c31af7Sopenharmony_cibe violated by a Vulkan implementation for *any memory allocation*.
829e5c31af7Sopenharmony_ciVulkan implementations are not required: to make additional security or
830e5c31af7Sopenharmony_ciintegrity guarantees beyond those provided by the OS unless explicitly
831e5c31af7Sopenharmony_cidirected by the application's use of a particular feature or extension.
832e5c31af7Sopenharmony_ci
833e5c31af7Sopenharmony_ci[NOTE]
834e5c31af7Sopenharmony_ci.Note
835e5c31af7Sopenharmony_ci====
836e5c31af7Sopenharmony_ciFor instance, if an operating system guarantees that data in all its memory
837e5c31af7Sopenharmony_ciallocations are set to zero when newly allocated, the Vulkan implementation
838e5c31af7Sopenharmony_cimust: make the same guarantees for any allocations it controls (e.g.
839e5c31af7Sopenharmony_cislink:VkDeviceMemory).
840e5c31af7Sopenharmony_ci
841e5c31af7Sopenharmony_ciSimilarly, if an operating system guarantees that use-after-free of host
842e5c31af7Sopenharmony_ciallocations will not result in values written by another process becoming
843e5c31af7Sopenharmony_civisible, the same guarantees must: be made by the Vulkan implementation for
844e5c31af7Sopenharmony_cidevice memory.
845e5c31af7Sopenharmony_ci====
846e5c31af7Sopenharmony_ci
847e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[]
848e5c31af7Sopenharmony_ciIf the <<features-protectedMemory, pname:protectedMemory>> feature is
849e5c31af7Sopenharmony_cisupported, the implementation provides additional guarantees when invalid
850e5c31af7Sopenharmony_ciusage occurs to prevent values in protected memory from being accessed or
851e5c31af7Sopenharmony_ciinferred outside of protected operations, as described in
852e5c31af7Sopenharmony_ci<<memory-protected-access-rules>>.
853e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[]
854e5c31af7Sopenharmony_ci
855e5c31af7Sopenharmony_ciSome valid usage conditions have dependencies on runtime limits or feature
856e5c31af7Sopenharmony_ciavailability.
857e5c31af7Sopenharmony_ciIt is possible to validate these conditions against Vulkan's minimum
858e5c31af7Sopenharmony_cisupported values for these limits and features, or some subset of other
859e5c31af7Sopenharmony_ciknown values.
860e5c31af7Sopenharmony_ci
861e5c31af7Sopenharmony_ciValid usage conditions do not cover conditions where well-defined behavior
862e5c31af7Sopenharmony_ci(including returning an error code) exists.
863e5c31af7Sopenharmony_ci
864e5c31af7Sopenharmony_ciValid usage conditions should: apply to the command or structure where
865e5c31af7Sopenharmony_cicomplete information about the condition would be known during execution of
866e5c31af7Sopenharmony_cian application.
867e5c31af7Sopenharmony_ciThis is such that a validation layer or linter can: be written directly
868e5c31af7Sopenharmony_ciagainst these statements at the point they are specified.
869e5c31af7Sopenharmony_ci
870e5c31af7Sopenharmony_ci[NOTE]
871e5c31af7Sopenharmony_ci.Note
872e5c31af7Sopenharmony_ci====
873e5c31af7Sopenharmony_ciThis does lead to some non-obvious places for valid usage statements.
874e5c31af7Sopenharmony_ciFor instance, the valid values for a structure might depend on a separate
875e5c31af7Sopenharmony_civalue in the calling command.
876e5c31af7Sopenharmony_ciIn this case, the structure itself will not reference this valid usage as it
877e5c31af7Sopenharmony_ciis impossible to determine validity from the structure that it is invalid -
878e5c31af7Sopenharmony_ciinstead this valid usage would be attached to the calling command.
879e5c31af7Sopenharmony_ci
880e5c31af7Sopenharmony_ciAnother example is draw state - the state setters are independent, and can
881e5c31af7Sopenharmony_cicause a legitimately invalid state configuration between draw calls; so the
882e5c31af7Sopenharmony_civalid usage statements are attached to the place where all state needs to be
883e5c31af7Sopenharmony_civalid - at the drawing command.
884e5c31af7Sopenharmony_ci====
885e5c31af7Sopenharmony_ci
886e5c31af7Sopenharmony_ciValid usage conditions are described in a block labelled "`Valid Usage`"
887e5c31af7Sopenharmony_cifollowing each command or structure they apply to.
888e5c31af7Sopenharmony_ci
889e5c31af7Sopenharmony_ci
890e5c31af7Sopenharmony_ci[[fundamentals-validation]]
891e5c31af7Sopenharmony_ci=== Usage Validation
892e5c31af7Sopenharmony_ci
893e5c31af7Sopenharmony_ciVulkan is a layered API.
894e5c31af7Sopenharmony_ciThe lowest layer is the core Vulkan layer, as defined by this Specification.
895e5c31af7Sopenharmony_ciThe application can: use additional layers above the core for debugging,
896e5c31af7Sopenharmony_civalidation, and other purposes.
897e5c31af7Sopenharmony_ci
898e5c31af7Sopenharmony_ciOne of the core principles of Vulkan is that building and submitting command
899e5c31af7Sopenharmony_cibuffers should: be highly efficient.
900e5c31af7Sopenharmony_ciThus error checking and validation of state in the core layer is minimal,
901e5c31af7Sopenharmony_cialthough more rigorous validation can: be enabled through the use of layers.
902e5c31af7Sopenharmony_ci
903e5c31af7Sopenharmony_ciValidation of correct API usage is left to validation layers.
904e5c31af7Sopenharmony_ciApplications should: be developed with validation layers enabled, to help
905e5c31af7Sopenharmony_cicatch and eliminate errors.
906e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[]
907e5c31af7Sopenharmony_ciOnce validated, released applications should: not enable validation layers
908e5c31af7Sopenharmony_ciby default.
909e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
910e5c31af7Sopenharmony_ci
911e5c31af7Sopenharmony_ci
912e5c31af7Sopenharmony_ci[[fundamentals-implicit-validity]]
913e5c31af7Sopenharmony_ci=== Implicit Valid Usage
914e5c31af7Sopenharmony_ci
915e5c31af7Sopenharmony_ciSome valid usage conditions apply to all commands and structures in the API,
916e5c31af7Sopenharmony_ciunless explicitly denoted otherwise for a specific command or structure.
917e5c31af7Sopenharmony_ciThese conditions are considered _implicit_, and are described in a block
918e5c31af7Sopenharmony_cilabelled "`Valid Usage (Implicit)`" following each command or structure they
919e5c31af7Sopenharmony_ciapply to.
920e5c31af7Sopenharmony_ciImplicit valid usage conditions are described in detail below.
921e5c31af7Sopenharmony_ci
922e5c31af7Sopenharmony_ci
923e5c31af7Sopenharmony_ci[[fundamentals-validusage-handles]]
924e5c31af7Sopenharmony_ci==== Valid Usage for Object Handles
925e5c31af7Sopenharmony_ci
926e5c31af7Sopenharmony_ciAny input parameter to a command that is an object handle must: be a valid
927e5c31af7Sopenharmony_ciobject handle, unless otherwise specified.
928e5c31af7Sopenharmony_ciAn object handle is valid if:
929e5c31af7Sopenharmony_ci
930e5c31af7Sopenharmony_ci  * It has been created or allocated by a previous, successful call to the
931e5c31af7Sopenharmony_ci    API.
932e5c31af7Sopenharmony_ci    Such calls are noted in the Specification.
933e5c31af7Sopenharmony_ci  * It has not been deleted or freed by a previous call to the API.
934e5c31af7Sopenharmony_ci    Such calls are noted in the Specification.
935e5c31af7Sopenharmony_ci  * Any objects used by that object, either as part of creation or
936e5c31af7Sopenharmony_ci    execution, must: also be valid.
937e5c31af7Sopenharmony_ci
938e5c31af7Sopenharmony_ciThe reserved values dlink:VK_NULL_HANDLE and `NULL` can: be used in place of
939e5c31af7Sopenharmony_civalid non-dispatchable handles and dispatchable handles, respectively, when
940e5c31af7Sopenharmony_ci_explicitly called out in the Specification_.
941e5c31af7Sopenharmony_ciAny command that creates an object successfully must: not return these
942e5c31af7Sopenharmony_civalues.
943e5c31af7Sopenharmony_ciIt is valid to pass these values to ftext:vkDestroy* or ftext:vkFree*
944e5c31af7Sopenharmony_cicommands, which will silently ignore these values.
945e5c31af7Sopenharmony_ci
946e5c31af7Sopenharmony_ci
947e5c31af7Sopenharmony_ci[[fundamentals-validusage-pointers]]
948e5c31af7Sopenharmony_ci==== Valid Usage for Pointers
949e5c31af7Sopenharmony_ci
950e5c31af7Sopenharmony_ciAny parameter that is a pointer must: be a _valid pointer_ only if it is
951e5c31af7Sopenharmony_ciexplicitly called out by a Valid Usage statement.
952e5c31af7Sopenharmony_ci
953e5c31af7Sopenharmony_ciA pointer is "`valid`" if it points at memory containing values of the
954e5c31af7Sopenharmony_cinumber and type(s) expected by the command, and all fundamental types
955e5c31af7Sopenharmony_ciaccessed through the pointer (e.g. as elements of an array or as members of
956e5c31af7Sopenharmony_cia structure) satisfy the alignment requirements of the host processor.
957e5c31af7Sopenharmony_ci
958e5c31af7Sopenharmony_ci
959e5c31af7Sopenharmony_ci[[fundamentals-validusage-strings]]
960e5c31af7Sopenharmony_ci==== Valid Usage for Strings
961e5c31af7Sopenharmony_ci
962e5c31af7Sopenharmony_ciAny parameter that is a pointer to `char` must: be a finite sequence of
963e5c31af7Sopenharmony_civalues terminated by a null character, or if _explicitly called out in the
964e5c31af7Sopenharmony_ciSpecification_, can: be `NULL`.
965e5c31af7Sopenharmony_ci
966e5c31af7Sopenharmony_ci
967e5c31af7Sopenharmony_ci[[fundamentals-validusage-enums]]
968e5c31af7Sopenharmony_ci==== Valid Usage for Enumerated Types
969e5c31af7Sopenharmony_ci
970e5c31af7Sopenharmony_ciAny parameter of an enumerated type must: be a valid enumerant for that
971e5c31af7Sopenharmony_citype.
972e5c31af7Sopenharmony_ciUse of an enumerant is valid if the following conditions are true:
973e5c31af7Sopenharmony_ci
974e5c31af7Sopenharmony_ci  * The enumerant is defined as part of the enumerated type.
975e5c31af7Sopenharmony_ci  * The enumerant is not a value suffixed with etext:_MAX_ENUM.
976e5c31af7Sopenharmony_ci  ** This value exists only to ensure that C `enum` types are 32 bits in
977e5c31af7Sopenharmony_ci     size and must: not be used by applications.
978e5c31af7Sopenharmony_ci  * If the enumerant is used in a function that has a slink:VkInstance as
979e5c31af7Sopenharmony_ci    its first parameter and either:
980e5c31af7Sopenharmony_ci  ** it was added by a core version that is supported
981e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[]
982e5c31af7Sopenharmony_ci     (as reported by flink:vkEnumerateInstanceVersion)
983e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[]
984e5c31af7Sopenharmony_ci     and the value of slink:VkApplicationInfo::pname:apiVersion is greater
985e5c31af7Sopenharmony_ci     than or equal to the version that added it; or
986e5c31af7Sopenharmony_ci  ** it was added by an <<extensions, instance extension>> that was enabled
987e5c31af7Sopenharmony_ci     for the instance.
988e5c31af7Sopenharmony_ci  * If the enumerant is used in a function that has a slink:VkPhysicalDevice
989e5c31af7Sopenharmony_ci    object as its first parameter and either:
990e5c31af7Sopenharmony_ci  ** it was added by a core version that is supported by that device (as
991e5c31af7Sopenharmony_ci     reported by slink:VkPhysicalDeviceProperties::pname:apiVersion);
992e5c31af7Sopenharmony_ci  ** it was added by an <<extensions, instance extension>> that was enabled
993e5c31af7Sopenharmony_ci     for the instance; or
994e5c31af7Sopenharmony_ci  ** it was added by a <<extensions, device extension>> that is supported by
995e5c31af7Sopenharmony_ci     that device.
996e5c31af7Sopenharmony_ci  * If the enumerant is used in a function that has any other dispatchable
997e5c31af7Sopenharmony_ci    object as its first parameter and either:
998e5c31af7Sopenharmony_ci  ** it was added by a core version that is supported for the device (as
999e5c31af7Sopenharmony_ci     reported by slink:VkPhysicalDeviceProperties::pname:apiVersion); or
1000e5c31af7Sopenharmony_ci  ** it was added by a <<extensions, device extension>> that was enabled for
1001e5c31af7Sopenharmony_ci     the device.
1002e5c31af7Sopenharmony_ci
1003e5c31af7Sopenharmony_ciifdef::VK_KHR_maintenance5[]
1004e5c31af7Sopenharmony_ciAdditionally, if <<features-maintenance5,pname:maintenance5>> is supported,
1005e5c31af7Sopenharmony_ciany integer value representable in the range valid for the defined type is
1006e5c31af7Sopenharmony_civalid when used in a function that has a slink:VkPhysicalDevice object as
1007e5c31af7Sopenharmony_ciits first parameter.
1008e5c31af7Sopenharmony_ciPhysical device queries will either return results indicating lack of
1009e5c31af7Sopenharmony_cisupport, or ignore unsupported values when used as a bit flag in a
1010e5c31af7Sopenharmony_cietext:Vk*Flags* parameter.
1011e5c31af7Sopenharmony_ciendif::VK_KHR_maintenance5[]
1012e5c31af7Sopenharmony_ci
1013e5c31af7Sopenharmony_ciAny enumerated type returned from a query command or otherwise output from
1014e5c31af7Sopenharmony_ciVulkan to the application must: not have a reserved value.
1015e5c31af7Sopenharmony_ciReserved values are values not defined by any extension for that enumerated
1016e5c31af7Sopenharmony_citype.
1017e5c31af7Sopenharmony_ci
1018e5c31af7Sopenharmony_ci[NOTE]
1019e5c31af7Sopenharmony_ci.Note
1020e5c31af7Sopenharmony_ci====
1021e5c31af7Sopenharmony_ciIn some special cases, an enumerant is only meaningful if a feature defined
1022e5c31af7Sopenharmony_ciby an extension is also enabled, as well as the extension itself.
1023e5c31af7Sopenharmony_ciThe global "`valid enumerant`" rule described here does not address such
1024e5c31af7Sopenharmony_cicases.
1025e5c31af7Sopenharmony_ci====
1026e5c31af7Sopenharmony_ci
1027e5c31af7Sopenharmony_ci[NOTE]
1028e5c31af7Sopenharmony_ci.Note
1029e5c31af7Sopenharmony_ci====
1030e5c31af7Sopenharmony_ciThis language is intended to accommodate cases such as "`hidden`" extensions
1031e5c31af7Sopenharmony_ciknown only to driver internals, or layers enabling extensions without
1032e5c31af7Sopenharmony_ciknowledge of the application, without allowing return of values not defined
1033e5c31af7Sopenharmony_ciby any extension.
1034e5c31af7Sopenharmony_ci====
1035e5c31af7Sopenharmony_ci
1036e5c31af7Sopenharmony_ci[NOTE]
1037e5c31af7Sopenharmony_ci.Note
1038e5c31af7Sopenharmony_ci====
1039e5c31af7Sopenharmony_ciApplication developers are encouraged to be careful when using `switch`
1040e5c31af7Sopenharmony_cistatements with Vulkan API enums.
1041e5c31af7Sopenharmony_ciThis is because new extensions can add new values to existing enums.
1042e5c31af7Sopenharmony_ciUsing a `default:` statement within a `switch` may avoid future compilation
1043e5c31af7Sopenharmony_ciissues.
1044e5c31af7Sopenharmony_ci
1045e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2[]
1046e5c31af7Sopenharmony_ciThis is particularly true for enums such as elink:VkDriverId, which may have
1047e5c31af7Sopenharmony_civalues added that do not belong to a corresponding new extension.
1048e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2[]
1049e5c31af7Sopenharmony_ci====
1050e5c31af7Sopenharmony_ci
1051e5c31af7Sopenharmony_ci
1052e5c31af7Sopenharmony_ci[[fundamentals-validusage-flags]]
1053e5c31af7Sopenharmony_ci==== Valid Usage for Flags
1054e5c31af7Sopenharmony_ci
1055e5c31af7Sopenharmony_ci[open,refpage='VkFlags',desc='Vulkan bitmasks',type='basetypes',xrefs='VkColorComponentFlags VkFlags64']
1056e5c31af7Sopenharmony_ci--
1057e5c31af7Sopenharmony_ciA collection of flags is represented by a bitmask using the type
1058e5c31af7Sopenharmony_cibasetype:VkFlags:
1059e5c31af7Sopenharmony_ci
1060e5c31af7Sopenharmony_ciinclude::{generated}/api/basetypes/VkFlags.adoc[]
1061e5c31af7Sopenharmony_ci
1062e5c31af7Sopenharmony_ciBitmasks are passed to many commands and structures to compactly represent
1063e5c31af7Sopenharmony_cioptions, but basetype:VkFlags is not used directly in the API.
1064e5c31af7Sopenharmony_ciInstead, a etext:Vk*Flags type which is an alias of basetype:VkFlags, and
1065e5c31af7Sopenharmony_ciwhose name matches the corresponding etext:Vk*FlagBits that are valid for
1066e5c31af7Sopenharmony_cithat type, is used.
1067e5c31af7Sopenharmony_ci
1068e5c31af7Sopenharmony_ciAny etext:Vk*Flags member or parameter used in the API as an input must: be
1069e5c31af7Sopenharmony_cia valid combination of bit flags.
1070e5c31af7Sopenharmony_ciA valid combination is either zero or the bitwise OR of valid bit flags.
1071e5c31af7Sopenharmony_ci
1072e5c31af7Sopenharmony_ciAn individual bit flag is valid for a etext:Vk*Flags type if it would be a
1073e5c31af7Sopenharmony_ci<<fundamentals-validusage-enums,valid enumerant>> when used with the
1074e5c31af7Sopenharmony_ciequivalent etext:Vk*FlagBits type, where the bits type is obtained by taking
1075e5c31af7Sopenharmony_cithe flag type and replacing the trailing etext:Flags with etext:FlagBits.
1076e5c31af7Sopenharmony_ciFor example, a flag value of type tlink:VkColorComponentFlags must: contain
1077e5c31af7Sopenharmony_cionly bit flags defined by elink:VkColorComponentFlagBits.
1078e5c31af7Sopenharmony_ci
1079e5c31af7Sopenharmony_ciAny etext:Vk*Flags member or parameter returned from a query command or
1080e5c31af7Sopenharmony_ciotherwise output from Vulkan to the application may: contain bit flags
1081e5c31af7Sopenharmony_ciundefined: in its corresponding etext:Vk*FlagBits type.
1082e5c31af7Sopenharmony_ciAn application cannot: rely on the state of these unspecified bits.
1083e5c31af7Sopenharmony_ci
1084e5c31af7Sopenharmony_ciOnly the low-order 31 bits (bit positions zero through 30) are available for
1085e5c31af7Sopenharmony_ciuse as flag bits.
1086e5c31af7Sopenharmony_ci
1087e5c31af7Sopenharmony_ci[NOTE]
1088e5c31af7Sopenharmony_ci.Note
1089e5c31af7Sopenharmony_ci====
1090e5c31af7Sopenharmony_ciThis restriction is due to poorly defined behavior by C compilers given a C
1091e5c31af7Sopenharmony_cienumerant value of `0x80000000`.
1092e5c31af7Sopenharmony_ciIn some cases adding this enumerant value may increase the size of the
1093e5c31af7Sopenharmony_ciunderlying etext:Vk*FlagBits type, breaking the ABI.
1094e5c31af7Sopenharmony_ci====
1095e5c31af7Sopenharmony_ci--
1096e5c31af7Sopenharmony_ci
1097e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_KHR_format_feature_flags2,VK_KHR_synchronization2[]
1098e5c31af7Sopenharmony_ci[open,refpage='VkFlags64',desc='Vulkan 64-bit bitmasks',type='basetypes',xrefs='VkFlags']
1099e5c31af7Sopenharmony_ci--
1100e5c31af7Sopenharmony_ciA collection of 64-bit flags is represented by a bitmask using the type
1101e5c31af7Sopenharmony_cibasetype:VkFlags64:
1102e5c31af7Sopenharmony_ci
1103e5c31af7Sopenharmony_ciinclude::{generated}/api/basetypes/VkFlags64.adoc[]
1104e5c31af7Sopenharmony_ci
1105e5c31af7Sopenharmony_ciWhen the 31 bits available in basetype:VkFlags are insufficient, the
1106e5c31af7Sopenharmony_cibasetype:VkFlags64 type can be passed to commands and structures to
1107e5c31af7Sopenharmony_cirepresent up to 64 options.
1108e5c31af7Sopenharmony_cibasetype:VkFlags64 is not used directly in the API.
1109e5c31af7Sopenharmony_ciInstead, a etext:Vk*Flags2 type which is an alias of basetype:VkFlags64, and
1110e5c31af7Sopenharmony_ciwhose name matches the corresponding etext:Vk*FlagBits2 that are valid for
1111e5c31af7Sopenharmony_cithat type, is used.
1112e5c31af7Sopenharmony_ci
1113e5c31af7Sopenharmony_ciAny etext:Vk*Flags2 member or parameter used in the API as an input must: be
1114e5c31af7Sopenharmony_cia valid combination of bit flags.
1115e5c31af7Sopenharmony_ciA valid combination is either zero or the bitwise OR of valid bit flags.
1116e5c31af7Sopenharmony_ci
1117e5c31af7Sopenharmony_ciAn individual bit flag is valid for a etext:Vk*Flags2 type if it would be a
1118e5c31af7Sopenharmony_ci<<fundamentals-validusage-enums,valid enumerant>> when used with the
1119e5c31af7Sopenharmony_ciequivalent etext:Vk*FlagBits2 type, where the bits type is obtained by
1120e5c31af7Sopenharmony_citaking the flag type and replacing the trailing etext:Flags2 with
1121e5c31af7Sopenharmony_cietext:FlagBits2.
1122e5c31af7Sopenharmony_ciFor example, a flag value of type tlink:VkAccessFlags2KHR must: contain only
1123e5c31af7Sopenharmony_cibit flags defined by elink:VkAccessFlagBits2KHR.
1124e5c31af7Sopenharmony_ci
1125e5c31af7Sopenharmony_ciAny etext:Vk*Flags2 member or parameter returned from a query command or
1126e5c31af7Sopenharmony_ciotherwise output from Vulkan to the application may: contain bit flags
1127e5c31af7Sopenharmony_ciundefined: in its corresponding etext:Vk*FlagBits2 type.
1128e5c31af7Sopenharmony_ciAn application cannot: rely on the state of these unspecified bits.
1129e5c31af7Sopenharmony_ci
1130e5c31af7Sopenharmony_ci[NOTE]
1131e5c31af7Sopenharmony_ci.Note
1132e5c31af7Sopenharmony_ci====
1133e5c31af7Sopenharmony_ciBoth the etext:Vk*FlagBits2 type, and the individual bits defined for that
1134e5c31af7Sopenharmony_citype, are defined as `uint64_t` integers in the C API.
1135e5c31af7Sopenharmony_ciThis is in contrast to the 32-bit types, where the etext:Vk*FlagBits type is
1136e5c31af7Sopenharmony_cidefined as a C `enum` and the individual bits as enumerants belonging to
1137e5c31af7Sopenharmony_cithat `enum`.
1138e5c31af7Sopenharmony_ciAs a result, there is less compile time type checking possible for the
1139e5c31af7Sopenharmony_ci64-bit types.
1140e5c31af7Sopenharmony_ciThis is unavoidable since there is no sufficiently portable way to define a
1141e5c31af7Sopenharmony_ci64-bit `enum` type in C99.
1142e5c31af7Sopenharmony_ci====
1143e5c31af7Sopenharmony_ci--
1144e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_KHR_format_feature_flags2,VK_KHR_synchronization2[]
1145e5c31af7Sopenharmony_ci
1146e5c31af7Sopenharmony_ci
1147e5c31af7Sopenharmony_ci[[fundamentals-validusage-sType]]
1148e5c31af7Sopenharmony_ci==== Valid Usage for Structure Types
1149e5c31af7Sopenharmony_ci
1150e5c31af7Sopenharmony_ciAny parameter that is a structure containing a pname:sType member must: have
1151e5c31af7Sopenharmony_cia value of ptext:sType which is a valid elink:VkStructureType value matching
1152e5c31af7Sopenharmony_cithe type of the structure.
1153e5c31af7Sopenharmony_ci
1154e5c31af7Sopenharmony_ci
1155e5c31af7Sopenharmony_ci[[fundamentals-validusage-pNext]]
1156e5c31af7Sopenharmony_ci==== Valid Usage for Structure Pointer Chains
1157e5c31af7Sopenharmony_ci
1158e5c31af7Sopenharmony_ciAny parameter that is a structure containing a code:void* ptext:pNext member
1159e5c31af7Sopenharmony_cimust: have a value of pname:pNext that is either `NULL`, or is a pointer to
1160e5c31af7Sopenharmony_cia valid _extending structure_, containing ptext:sType and ptext:pNext
1161e5c31af7Sopenharmony_cimembers as described in the <<vulkan-styleguide,Vulkan Documentation and
1162e5c31af7Sopenharmony_ciExtensions>> document in the section "`Extending Structures`".
1163e5c31af7Sopenharmony_ciThe set of structures connected by ptext:pNext pointers is referred to as a
1164e5c31af7Sopenharmony_ci_pname:pNext chain_.
1165e5c31af7Sopenharmony_ci
1166e5c31af7Sopenharmony_ciEach structure included in the pname:pNext chain must: be defined at runtime
1167e5c31af7Sopenharmony_ciby either:
1168e5c31af7Sopenharmony_ci
1169e5c31af7Sopenharmony_ci  * a core version which is supported
1170e5c31af7Sopenharmony_ci  * an extension which is enabled
1171e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_get_physical_device_properties2[]
1172e5c31af7Sopenharmony_ci  * a supported device extension in the case of physical-device-level
1173e5c31af7Sopenharmony_cifunctionality added by the device extension
1174e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_get_physical_device_properties2[]
1175e5c31af7Sopenharmony_ci
1176e5c31af7Sopenharmony_ciEach type of extending structure must: not appear more than once in a
1177e5c31af7Sopenharmony_ciptext:pNext chain, including any
1178e5c31af7Sopenharmony_ci<<extendingvulkan-compatibility-aliases,aliases>>.
1179e5c31af7Sopenharmony_ciThis general rule may be explicitly overridden for specific structures.
1180e5c31af7Sopenharmony_ci
1181e5c31af7Sopenharmony_ciAny component of the implementation (the loader, any enabled layers, and
1182e5c31af7Sopenharmony_cidrivers) must: skip over, without processing (other than reading the
1183e5c31af7Sopenharmony_cipname:sType and pname:pNext members) any extending structures in the chain
1184e5c31af7Sopenharmony_cinot defined by core versions or extensions supported by that component.
1185e5c31af7Sopenharmony_ci
1186e5c31af7Sopenharmony_ciAs a convenience to implementations and layers needing to iterate through a
1187e5c31af7Sopenharmony_cistructure pointer chain, the Vulkan API provides two _base structures_.
1188e5c31af7Sopenharmony_ciThese structures allow for some type safety, and can be used by Vulkan API
1189e5c31af7Sopenharmony_cifunctions that operate on generic inputs and outputs.
1190e5c31af7Sopenharmony_ci
1191e5c31af7Sopenharmony_ci[open,refpage='VkBaseInStructure',desc='Base structure for a read-only pointer chain',type='structs']
1192e5c31af7Sopenharmony_ci--
1193e5c31af7Sopenharmony_ciThe sname:VkBaseInStructure structure is defined as:
1194e5c31af7Sopenharmony_ci
1195e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkBaseInStructure.adoc[]
1196e5c31af7Sopenharmony_ci
1197e5c31af7Sopenharmony_ci  * pname:sType is the structure type of the structure being iterated
1198e5c31af7Sopenharmony_ci    through.
1199e5c31af7Sopenharmony_ci  * pname:pNext is `NULL` or a pointer to the next structure in a structure
1200e5c31af7Sopenharmony_ci    chain.
1201e5c31af7Sopenharmony_ci
1202e5c31af7Sopenharmony_cisname:VkBaseInStructure can be used to facilitate iterating through a
1203e5c31af7Sopenharmony_ciread-only structure pointer chain.
1204e5c31af7Sopenharmony_ci--
1205e5c31af7Sopenharmony_ci
1206e5c31af7Sopenharmony_ci[open,refpage='VkBaseOutStructure',desc='Base structure for a read-only pointer chain',type='structs']
1207e5c31af7Sopenharmony_ci--
1208e5c31af7Sopenharmony_ciThe sname:VkBaseOutStructure structure is defined as:
1209e5c31af7Sopenharmony_ci
1210e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkBaseOutStructure.adoc[]
1211e5c31af7Sopenharmony_ci
1212e5c31af7Sopenharmony_ci  * pname:sType is the structure type of the structure being iterated
1213e5c31af7Sopenharmony_ci    through.
1214e5c31af7Sopenharmony_ci  * pname:pNext is `NULL` or a pointer to the next structure in a structure
1215e5c31af7Sopenharmony_ci    chain.
1216e5c31af7Sopenharmony_ci
1217e5c31af7Sopenharmony_cisname:VkBaseOutStructure can be used to facilitate iterating through a
1218e5c31af7Sopenharmony_cistructure pointer chain that returns data back to the application.
1219e5c31af7Sopenharmony_ci--
1220e5c31af7Sopenharmony_ci
1221e5c31af7Sopenharmony_ci
1222e5c31af7Sopenharmony_ci[[fundamentals-validusage-nested-structs]]
1223e5c31af7Sopenharmony_ci==== Valid Usage for Nested Structures
1224e5c31af7Sopenharmony_ci
1225e5c31af7Sopenharmony_ciThe above conditions also apply recursively to members of structures
1226e5c31af7Sopenharmony_ciprovided as input to a command, either as a direct argument to the command,
1227e5c31af7Sopenharmony_cior themselves a member of another structure.
1228e5c31af7Sopenharmony_ci
1229e5c31af7Sopenharmony_ciSpecifics on valid usage of each command are covered in their individual
1230e5c31af7Sopenharmony_cisections.
1231e5c31af7Sopenharmony_ci
1232e5c31af7Sopenharmony_ci
1233e5c31af7Sopenharmony_ci[[fundamentals-validusage-extensions]]
1234e5c31af7Sopenharmony_ci==== Valid Usage for Extensions
1235e5c31af7Sopenharmony_ci
1236e5c31af7Sopenharmony_ciInstance-level functionality or behavior added by an <<extensions, instance
1237e5c31af7Sopenharmony_ciextension>> to the API must: not be used unless that extension is supported
1238e5c31af7Sopenharmony_ciby the instance as determined by
1239e5c31af7Sopenharmony_ciflink:vkEnumerateInstanceExtensionProperties, and that extension is enabled
1240e5c31af7Sopenharmony_ciin slink:VkInstanceCreateInfo.
1241e5c31af7Sopenharmony_ci
1242e5c31af7Sopenharmony_ciPhysical-device-level functionality or behavior added by an <<extensions,
1243e5c31af7Sopenharmony_ciinstance extension>> to the API must: not be used unless that extension is
1244e5c31af7Sopenharmony_cisupported by the instance as determined by
1245e5c31af7Sopenharmony_ciflink:vkEnumerateInstanceExtensionProperties, and that extension is enabled
1246e5c31af7Sopenharmony_ciin slink:VkInstanceCreateInfo.
1247e5c31af7Sopenharmony_ci
1248e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_get_physical_device_properties2[]
1249e5c31af7Sopenharmony_ciPhysical-device-level functionality or behavior added by a <<extensions,
1250e5c31af7Sopenharmony_cidevice extension>> to the API must: not be used unless the conditions
1251e5c31af7Sopenharmony_cidescribed in <<initialization-phys-dev-extensions, Extending Physical Device
1252e5c31af7Sopenharmony_ciCore Functionality>> are met.
1253e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_get_physical_device_properties2[]
1254e5c31af7Sopenharmony_ci
1255e5c31af7Sopenharmony_ciDevice-level functionality added by a <<extensions, device extension>> that
1256e5c31af7Sopenharmony_ciis dispatched from a slink:VkDevice, or from a child object of a
1257e5c31af7Sopenharmony_cislink:VkDevice must: not be used unless that extension is supported by the
1258e5c31af7Sopenharmony_cidevice as determined by flink:vkEnumerateDeviceExtensionProperties, and that
1259e5c31af7Sopenharmony_ciextension is enabled in slink:VkDeviceCreateInfo.
1260e5c31af7Sopenharmony_ci
1261e5c31af7Sopenharmony_ci[[fundamentals-validusage-versions]]
1262e5c31af7Sopenharmony_ci==== Valid Usage for Newer Core Versions
1263e5c31af7Sopenharmony_ci
1264e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[]
1265e5c31af7Sopenharmony_ci
1266e5c31af7Sopenharmony_ciInstance-level functionality or behavior added by a <<versions, new core
1267e5c31af7Sopenharmony_civersion>> of the API must: not be used unless it is supported by the
1268e5c31af7Sopenharmony_ciinstance as determined by flink:vkEnumerateInstanceVersion and the specified
1269e5c31af7Sopenharmony_civersion of slink:VkApplicationInfo::pname:apiVersion.
1270e5c31af7Sopenharmony_ci
1271e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[]
1272e5c31af7Sopenharmony_ci
1273e5c31af7Sopenharmony_ciPhysical-device-level functionality or behavior added by a <<versions, new
1274e5c31af7Sopenharmony_cicore version>> of the API must: not be used unless it is supported by the
1275e5c31af7Sopenharmony_ciphysical device as determined by
1276e5c31af7Sopenharmony_cislink:VkPhysicalDeviceProperties::pname:apiVersion and the specified version
1277e5c31af7Sopenharmony_ciof slink:VkApplicationInfo::pname:apiVersion.
1278e5c31af7Sopenharmony_ci
1279e5c31af7Sopenharmony_ciDevice-level functionality or behavior added by a <<versions, new core
1280e5c31af7Sopenharmony_civersion>> of the API must: not be used unless it is supported by the device
1281e5c31af7Sopenharmony_cias determined by slink:VkPhysicalDeviceProperties::pname:apiVersion and the
1282e5c31af7Sopenharmony_cispecified version of slink:VkApplicationInfo::pname:apiVersion.
1283e5c31af7Sopenharmony_ci
1284e5c31af7Sopenharmony_ci
1285e5c31af7Sopenharmony_ci[[fundamentals-returncodes]]
1286e5c31af7Sopenharmony_ci== `VkResult` Return Codes
1287e5c31af7Sopenharmony_ci
1288e5c31af7Sopenharmony_ci[open,refpage='VkResult',desc='Vulkan command return codes',type='enums']
1289e5c31af7Sopenharmony_ci--
1290e5c31af7Sopenharmony_ciWhile the core Vulkan API is not designed to capture incorrect usage, some
1291e5c31af7Sopenharmony_cicircumstances still require return codes.
1292e5c31af7Sopenharmony_ciCommands in Vulkan return their status via return codes that are in one of
1293e5c31af7Sopenharmony_citwo categories:
1294e5c31af7Sopenharmony_ci
1295e5c31af7Sopenharmony_ci  * Successful completion codes are returned when a command needs to
1296e5c31af7Sopenharmony_ci    communicate success or status information.
1297e5c31af7Sopenharmony_ci    All successful completion codes are non-negative values.
1298e5c31af7Sopenharmony_ci  * Run time error codes are returned when a command needs to communicate a
1299e5c31af7Sopenharmony_ci    failure that could only be detected at runtime.
1300e5c31af7Sopenharmony_ci    All runtime error codes are negative values.
1301e5c31af7Sopenharmony_ci
1302e5c31af7Sopenharmony_ciAll return codes in Vulkan are reported via elink:VkResult return values.
1303e5c31af7Sopenharmony_ciThe possible codes are:
1304e5c31af7Sopenharmony_ci
1305e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkResult.adoc[]
1306e5c31af7Sopenharmony_ci
1307e5c31af7Sopenharmony_ci[[fundamentals-successcodes]]
1308e5c31af7Sopenharmony_ci.Success Codes
1309e5c31af7Sopenharmony_ci  * ename:VK_SUCCESS Command successfully completed
1310e5c31af7Sopenharmony_ci  * ename:VK_NOT_READY A fence or query has not yet completed
1311e5c31af7Sopenharmony_ci  * ename:VK_TIMEOUT A wait operation has not completed in the specified
1312e5c31af7Sopenharmony_ci    time
1313e5c31af7Sopenharmony_ci  * ename:VK_EVENT_SET An event is signaled
1314e5c31af7Sopenharmony_ci  * ename:VK_EVENT_RESET An event is unsignaled
1315e5c31af7Sopenharmony_ci  * ename:VK_INCOMPLETE A return array was too small for the result
1316e5c31af7Sopenharmony_ciifdef::VK_KHR_swapchain[]
1317e5c31af7Sopenharmony_ci  * ename:VK_SUBOPTIMAL_KHR A swapchain no longer matches the surface
1318e5c31af7Sopenharmony_ci    properties exactly, but can: still be used to present to the surface
1319e5c31af7Sopenharmony_ci    successfully.
1320e5c31af7Sopenharmony_ciendif::VK_KHR_swapchain[]
1321e5c31af7Sopenharmony_ciifdef::VK_KHR_deferred_host_operations[]
1322e5c31af7Sopenharmony_ci  * ename:VK_THREAD_IDLE_KHR A deferred operation is not complete but there
1323e5c31af7Sopenharmony_ci    is currently no work for this thread to do at the time of this call.
1324e5c31af7Sopenharmony_ci  * ename:VK_THREAD_DONE_KHR A deferred operation is not complete but there
1325e5c31af7Sopenharmony_ci    is no work remaining to assign to additional threads.
1326e5c31af7Sopenharmony_ci  * ename:VK_OPERATION_DEFERRED_KHR A deferred operation was requested and
1327e5c31af7Sopenharmony_ci    at least some of the work was deferred.
1328e5c31af7Sopenharmony_ci  * ename:VK_OPERATION_NOT_DEFERRED_KHR A deferred operation was requested
1329e5c31af7Sopenharmony_ci    and no operations were deferred.
1330e5c31af7Sopenharmony_ciendif::VK_KHR_deferred_host_operations[]
1331e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_3,VK_EXT_pipeline_creation_cache_control[]
1332e5c31af7Sopenharmony_ci  * ename:VK_PIPELINE_COMPILE_REQUIRED A requested pipeline creation would
1333e5c31af7Sopenharmony_ci    have required compilation, but the application requested compilation to
1334e5c31af7Sopenharmony_ci    not be performed.
1335e5c31af7Sopenharmony_ciendif::VK_VERSION_1_3,VK_EXT_pipeline_creation_cache_control[]
1336e5c31af7Sopenharmony_ci
1337e5c31af7Sopenharmony_ci[[fundamentals-errorcodes]]
1338e5c31af7Sopenharmony_ci.Error codes
1339e5c31af7Sopenharmony_ci  * ename:VK_ERROR_OUT_OF_HOST_MEMORY A host memory allocation has failed.
1340e5c31af7Sopenharmony_ci  * ename:VK_ERROR_OUT_OF_DEVICE_MEMORY A device memory allocation has
1341e5c31af7Sopenharmony_ci    failed.
1342e5c31af7Sopenharmony_ci  * ename:VK_ERROR_INITIALIZATION_FAILED Initialization of an object could
1343e5c31af7Sopenharmony_ci    not be completed for implementation-specific reasons.
1344e5c31af7Sopenharmony_ci  * ename:VK_ERROR_DEVICE_LOST The logical or physical device has been lost.
1345e5c31af7Sopenharmony_ci    See <<devsandqueues-lost-device,Lost Device>>
1346e5c31af7Sopenharmony_ci  * ename:VK_ERROR_MEMORY_MAP_FAILED Mapping of a memory object has failed.
1347e5c31af7Sopenharmony_ci  * ename:VK_ERROR_LAYER_NOT_PRESENT A requested layer is not present or
1348e5c31af7Sopenharmony_ci    could not be loaded.
1349e5c31af7Sopenharmony_ci  * ename:VK_ERROR_EXTENSION_NOT_PRESENT A requested extension is not
1350e5c31af7Sopenharmony_ci    supported.
1351e5c31af7Sopenharmony_ci  * ename:VK_ERROR_FEATURE_NOT_PRESENT A requested feature is not supported.
1352e5c31af7Sopenharmony_ci  * ename:VK_ERROR_INCOMPATIBLE_DRIVER The requested version of Vulkan is
1353e5c31af7Sopenharmony_ci    not supported by the driver or is otherwise incompatible for
1354e5c31af7Sopenharmony_ci    implementation-specific reasons.
1355e5c31af7Sopenharmony_ci  * ename:VK_ERROR_TOO_MANY_OBJECTS Too many objects of the type have
1356e5c31af7Sopenharmony_ci    already been created.
1357e5c31af7Sopenharmony_ci  * ename:VK_ERROR_FORMAT_NOT_SUPPORTED A requested format is not supported
1358e5c31af7Sopenharmony_ci    on this device.
1359e5c31af7Sopenharmony_ci  * ename:VK_ERROR_FRAGMENTED_POOL A pool allocation has failed due to
1360e5c31af7Sopenharmony_ci    fragmentation of the pool's memory.
1361e5c31af7Sopenharmony_ci    This must: only be returned if no attempt to allocate host or device
1362e5c31af7Sopenharmony_ci    memory was made to accommodate the new allocation.
1363e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_maintenance1[]
1364e5c31af7Sopenharmony_ci    This should: be returned in preference to
1365e5c31af7Sopenharmony_ci    ename:VK_ERROR_OUT_OF_POOL_MEMORY, but only if the implementation is
1366e5c31af7Sopenharmony_ci    certain that the pool allocation failure was due to fragmentation.
1367e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_maintenance1[]
1368e5c31af7Sopenharmony_ciifdef::VK_KHR_surface[]
1369e5c31af7Sopenharmony_ci  * ename:VK_ERROR_SURFACE_LOST_KHR A surface is no longer available.
1370e5c31af7Sopenharmony_ci  * ename:VK_ERROR_NATIVE_WINDOW_IN_USE_KHR The requested window is already
1371e5c31af7Sopenharmony_ci    in use by Vulkan or another API in a manner which prevents it from being
1372e5c31af7Sopenharmony_ci    used again.
1373e5c31af7Sopenharmony_ciendif::VK_KHR_surface[]
1374e5c31af7Sopenharmony_ciifdef::VK_KHR_swapchain[]
1375e5c31af7Sopenharmony_ci  * ename:VK_ERROR_OUT_OF_DATE_KHR A surface has changed in such a way that
1376e5c31af7Sopenharmony_ci    it is no longer compatible with the swapchain, and further presentation
1377e5c31af7Sopenharmony_ci    requests using the swapchain will fail.
1378e5c31af7Sopenharmony_ci    Applications must: query the new surface properties and recreate their
1379e5c31af7Sopenharmony_ci    swapchain if they wish to continue presenting to the surface.
1380e5c31af7Sopenharmony_ciendif::VK_KHR_swapchain[]
1381e5c31af7Sopenharmony_ciifdef::VK_KHR_display_swapchain[]
1382e5c31af7Sopenharmony_ci  * ename:VK_ERROR_INCOMPATIBLE_DISPLAY_KHR The display used by a swapchain
1383e5c31af7Sopenharmony_ci    does not use the same presentable image layout, or is incompatible in a
1384e5c31af7Sopenharmony_ci    way that prevents sharing an image.
1385e5c31af7Sopenharmony_ciendif::VK_KHR_display_swapchain[]
1386e5c31af7Sopenharmony_ciifdef::VK_NV_glsl_shader[]
1387e5c31af7Sopenharmony_ci  * ename:VK_ERROR_INVALID_SHADER_NV One or more shaders failed to compile
1388e5c31af7Sopenharmony_ci    or link.
1389e5c31af7Sopenharmony_ci    More details are reported back to the application via
1390e5c31af7Sopenharmony_ci    `apiext:VK_EXT_debug_report` if enabled.
1391e5c31af7Sopenharmony_ciendif::VK_NV_glsl_shader[]
1392e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_maintenance1[]
1393e5c31af7Sopenharmony_ci  * ename:VK_ERROR_OUT_OF_POOL_MEMORY A pool memory allocation has failed.
1394e5c31af7Sopenharmony_ci    This must: only be returned if no attempt to allocate host or device
1395e5c31af7Sopenharmony_ci    memory was made to accommodate the new allocation.
1396e5c31af7Sopenharmony_ci    If the failure was definitely due to fragmentation of the pool,
1397e5c31af7Sopenharmony_ci    ename:VK_ERROR_FRAGMENTED_POOL should: be returned instead.
1398e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_maintenance1[]
1399e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_external_memory,VK_KHR_external_semaphore,VK_KHR_external_fence[]
1400e5c31af7Sopenharmony_ci  * ename:VK_ERROR_INVALID_EXTERNAL_HANDLE An external handle is not a valid
1401e5c31af7Sopenharmony_ci    handle of the specified type.
1402e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_external_memory,VK_KHR_external_semaphore,VK_KHR_external_fence[]
1403e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_EXT_descriptor_indexing[]
1404e5c31af7Sopenharmony_ci  * ename:VK_ERROR_FRAGMENTATION A descriptor pool creation has failed due
1405e5c31af7Sopenharmony_ci    to fragmentation.
1406e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_EXT_descriptor_indexing[]
1407e5c31af7Sopenharmony_ciifdef::VK_EXT_buffer_device_address[]
1408e5c31af7Sopenharmony_ci  * ename:VK_ERROR_INVALID_DEVICE_ADDRESS_EXT A buffer creation failed
1409e5c31af7Sopenharmony_ci    because the requested address is not available.
1410e5c31af7Sopenharmony_ciendif::VK_EXT_buffer_device_address[]
1411e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_KHR_buffer_device_address[]
1412e5c31af7Sopenharmony_ci  * ename:VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS A buffer creation
1413e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_KHR_buffer_device_address[]
1414e5c31af7Sopenharmony_ci    or memory allocation
1415e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_KHR_buffer_device_address[]
1416e5c31af7Sopenharmony_ci    failed because the requested address is not available.
1417e5c31af7Sopenharmony_ciifdef::VK_KHR_ray_tracing_pipeline[]
1418e5c31af7Sopenharmony_ci    A shader group handle assignment failed because the requested shader
1419e5c31af7Sopenharmony_ci    group handle information is no longer valid.
1420e5c31af7Sopenharmony_ciendif::VK_KHR_ray_tracing_pipeline[]
1421e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_EXT_buffer_device_address,VK_KHR_buffer_device_address[]
1422e5c31af7Sopenharmony_ciifdef::VK_EXT_full_screen_exclusive[]
1423e5c31af7Sopenharmony_ci  * ename:VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT An operation on a
1424e5c31af7Sopenharmony_ci    swapchain created with
1425e5c31af7Sopenharmony_ci    ename:VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT failed as it
1426e5c31af7Sopenharmony_ci    did not have exclusive full-screen access.
1427e5c31af7Sopenharmony_ci    This may: occur due to implementation-dependent reasons, outside of the
1428e5c31af7Sopenharmony_ci    application's control.
1429e5c31af7Sopenharmony_ciendif::VK_EXT_full_screen_exclusive[]
1430e5c31af7Sopenharmony_ciifdef::VKSC_VERSION_1_0,VK_EXT_debug_report[]
1431e5c31af7Sopenharmony_ciifdef::VKSC_VERSION_1_0[]
1432e5c31af7Sopenharmony_ci  * ename:VK_ERROR_VALIDATION_FAILED
1433e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
1434e5c31af7Sopenharmony_ciifdef::VK_EXT_debug_report[]
1435e5c31af7Sopenharmony_ci  * ename:VK_ERROR_VALIDATION_FAILED_EXT
1436e5c31af7Sopenharmony_ciendif::VK_EXT_debug_report[]
1437e5c31af7Sopenharmony_ci    A command failed because invalid usage was detected by the
1438e5c31af7Sopenharmony_ci    implementation or a validation-layer.
1439e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0,VK_EXT_debug_report[]
1440e5c31af7Sopenharmony_ciifdef::VKSC_VERSION_1_0[]
1441e5c31af7Sopenharmony_ci  * ename:VK_ERROR_INVALID_PIPELINE_CACHE_DATA The supplied pipeline cache
1442e5c31af7Sopenharmony_ci    data was not valid for the current implementation.
1443e5c31af7Sopenharmony_ci  * ename:VK_ERROR_NO_PIPELINE_MATCH The implementation did not find a match
1444e5c31af7Sopenharmony_ci    in the pipeline cache for the specified pipeline, or
1445e5c31af7Sopenharmony_ci    slink:VkPipelineOfflineCreateInfo was not provided to the
1446e5c31af7Sopenharmony_ci    ftext:vkCreate*Pipelines function.
1447e5c31af7Sopenharmony_ciifdef::hidden[]
1448e5c31af7Sopenharmony_ci// tag::scaddition[]
1449e5c31af7Sopenharmony_ci  * extending elink:VkResult
1450e5c31af7Sopenharmony_ci  ** ename:VK_ERROR_VALIDATION_FAILED <<SCID-1>>
1451e5c31af7Sopenharmony_ci  ** ename:VK_ERROR_INVALID_PIPELINE_CACHE_DATA <<SCID-1>>
1452e5c31af7Sopenharmony_ci  ** ename:VK_ERROR_NO_PIPELINE_MATCH <<SCID-1>>
1453e5c31af7Sopenharmony_ci// end::scaddition[]
1454e5c31af7Sopenharmony_ciendif::hidden[]
1455e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
1456e5c31af7Sopenharmony_ciifdef::VK_EXT_image_compression_control[]
1457e5c31af7Sopenharmony_ci  * ename:VK_ERROR_COMPRESSION_EXHAUSTED_EXT An image creation failed
1458e5c31af7Sopenharmony_ci    because internal resources required for compression are exhausted.
1459e5c31af7Sopenharmony_ci    This must: only be returned when fixed-rate compression is requested.
1460e5c31af7Sopenharmony_ciendif::VK_EXT_image_compression_control[]
1461e5c31af7Sopenharmony_ciifdef::VK_KHR_video_queue[]
1462e5c31af7Sopenharmony_ci  * ename:VK_ERROR_IMAGE_USAGE_NOT_SUPPORTED_KHR The requested
1463e5c31af7Sopenharmony_ci    tlink:VkImageUsageFlags are not supported.
1464e5c31af7Sopenharmony_ci  * ename:VK_ERROR_VIDEO_PICTURE_LAYOUT_NOT_SUPPORTED_KHR The requested
1465e5c31af7Sopenharmony_ci    video picture layout is not supported.
1466e5c31af7Sopenharmony_ci  * ename:VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR A video profile
1467e5c31af7Sopenharmony_ci    operation specified via
1468e5c31af7Sopenharmony_ci    slink:VkVideoProfileInfoKHR::pname:videoCodecOperation is not supported.
1469e5c31af7Sopenharmony_ci  * ename:VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR Format parameters
1470e5c31af7Sopenharmony_ci    in a requested slink:VkVideoProfileInfoKHR chain are not supported.
1471e5c31af7Sopenharmony_ci  * ename:VK_ERROR_VIDEO_PROFILE_CODEC_NOT_SUPPORTED_KHR Codec-specific
1472e5c31af7Sopenharmony_ci    parameters in a requested slink:VkVideoProfileInfoKHR chain are not
1473e5c31af7Sopenharmony_ci    supported.
1474e5c31af7Sopenharmony_ci  * ename:VK_ERROR_VIDEO_STD_VERSION_NOT_SUPPORTED_KHR The specified video
1475e5c31af7Sopenharmony_ci    Std header version is not supported.
1476e5c31af7Sopenharmony_ciendif::VK_KHR_video_queue[]
1477e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_queue[]
1478e5c31af7Sopenharmony_ci  * ename:VK_ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR The specified Video Std
1479e5c31af7Sopenharmony_ci    parameters do not adhere to the syntactic or semantic requirements of
1480e5c31af7Sopenharmony_ci    the used video compression standard, or values derived from parameters
1481e5c31af7Sopenharmony_ci    according to the rules defined by the used video compression standard do
1482e5c31af7Sopenharmony_ci    not adhere to the capabilities of the video compression standard or the
1483e5c31af7Sopenharmony_ci    implementation.
1484e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_queue[]
1485e5c31af7Sopenharmony_ciifdef::VK_EXT_shader_object[]
1486e5c31af7Sopenharmony_ci  * ename:VK_ERROR_INCOMPATIBLE_SHADER_BINARY_EXT The provided binary shader
1487e5c31af7Sopenharmony_ci    code is not compatible with this device.
1488e5c31af7Sopenharmony_ciendif::VK_EXT_shader_object[]
1489e5c31af7Sopenharmony_ci  * ename:VK_ERROR_UNKNOWN An unknown error has occurred; either the
1490e5c31af7Sopenharmony_ci    application has provided invalid input, or an implementation failure has
1491e5c31af7Sopenharmony_ci    occurred.
1492e5c31af7Sopenharmony_ci
1493e5c31af7Sopenharmony_ciIf a command returns a runtime error, unless otherwise specified any output
1494e5c31af7Sopenharmony_ciparameters will have undefined: contents, except that if the output
1495e5c31af7Sopenharmony_ciparameter is a structure with pname:sType and pname:pNext fields, those
1496e5c31af7Sopenharmony_cifields will be unmodified.
1497e5c31af7Sopenharmony_ciAny structures chained from pname:pNext will also have undefined: contents,
1498e5c31af7Sopenharmony_ciexcept that pname:sType and pname:pNext will be unmodified.
1499e5c31af7Sopenharmony_ci
1500e5c31af7Sopenharmony_cietext:VK_ERROR_OUT_OF_*_MEMORY errors do not modify any currently existing
1501e5c31af7Sopenharmony_ciVulkan objects.
1502e5c31af7Sopenharmony_ciObjects that have already been successfully created can: still be used by
1503e5c31af7Sopenharmony_cithe application.
1504e5c31af7Sopenharmony_ciifdef::VKSC_VERSION_1_0[]
1505e5c31af7Sopenharmony_ciIf
1506e5c31af7Sopenharmony_cislink:VkPhysicalDeviceVulkanSC10Properties::pname:deviceNoDynamicHostAllocations
1507e5c31af7Sopenharmony_ciis ename:VK_TRUE, ename:VK_ERROR_OUT_OF_HOST_MEMORY must: not be returned
1508e5c31af7Sopenharmony_cifrom any physical or logical device command which explicitly disallows it.
1509e5c31af7Sopenharmony_ciifdef::hidden[]
1510e5c31af7Sopenharmony_ci// tag::scdeviation[]
1511e5c31af7Sopenharmony_ci  * If
1512e5c31af7Sopenharmony_ci    slink:VkPhysicalDeviceVulkanSC10Properties::pname:deviceNoDynamicHostAllocations
1513e5c31af7Sopenharmony_ci    is ename:VK_TRUE, ename:VK_ERROR_OUT_OF_HOST_MEMORY must: not be
1514e5c31af7Sopenharmony_ci    returned by physical or logical device commands which explicitly
1515e5c31af7Sopenharmony_ci    disallow it <<SCID-4>>.
1516e5c31af7Sopenharmony_ci// end::scdeviation[]
1517e5c31af7Sopenharmony_ciendif::hidden[]
1518e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
1519e5c31af7Sopenharmony_ci
1520e5c31af7Sopenharmony_ci[NOTE]
1521e5c31af7Sopenharmony_ci.Note
1522e5c31af7Sopenharmony_ci====
1523e5c31af7Sopenharmony_ciAs a general rule, ftext:Free, ftext:Release, and ftext:Reset commands do
1524e5c31af7Sopenharmony_cinot return ename:VK_ERROR_OUT_OF_HOST_MEMORY, while any other command with a
1525e5c31af7Sopenharmony_cireturn code may: return it.
1526e5c31af7Sopenharmony_ciAny exceptions from this rule are described for those commands.
1527e5c31af7Sopenharmony_ci====
1528e5c31af7Sopenharmony_ci
1529e5c31af7Sopenharmony_ciename:VK_ERROR_UNKNOWN will be returned by an implementation when an
1530e5c31af7Sopenharmony_ciunexpected error occurs that cannot be attributed to valid behavior of the
1531e5c31af7Sopenharmony_ciapplication and implementation.
1532e5c31af7Sopenharmony_ciUnder these conditions, it may: be returned from any command returning a
1533e5c31af7Sopenharmony_cielink:VkResult.
1534e5c31af7Sopenharmony_ci
1535e5c31af7Sopenharmony_ci[NOTE]
1536e5c31af7Sopenharmony_ci.Note
1537e5c31af7Sopenharmony_ci====
1538e5c31af7Sopenharmony_ciename:VK_ERROR_UNKNOWN is not expected to ever be returned if the
1539e5c31af7Sopenharmony_ciapplication behavior is valid, and if the implementation is bug-free.
1540e5c31af7Sopenharmony_ciIf ename:VK_ERROR_UNKNOWN is received, the application should be checked
1541e5c31af7Sopenharmony_ciagainst the latest validation layers to verify correct behavior as much as
1542e5c31af7Sopenharmony_cipossible.
1543e5c31af7Sopenharmony_ciIf no issues are identified it could be an implementation issue, and the
1544e5c31af7Sopenharmony_ciimplementor should be contacted for support.
1545e5c31af7Sopenharmony_ci====
1546e5c31af7Sopenharmony_ci
1547e5c31af7Sopenharmony_ciifdef::VKSC_VERSION_1_0,VK_EXT_debug_report[]
1548e5c31af7Sopenharmony_ciAny command returning a elink:VkResult may: return
1549e5c31af7Sopenharmony_ciifdef::VKSC_VERSION_1_0[ename:VK_ERROR_VALIDATION_FAILED]
1550e5c31af7Sopenharmony_ciifdef::VK_EXT_debug_report[ename:VK_ERROR_VALIDATION_FAILED_EXT]
1551e5c31af7Sopenharmony_ciif a violation of valid usage is detected, even though commands do not
1552e5c31af7Sopenharmony_ciexplicitly list this as a possible return code.
1553e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0,VK_EXT_debug_report[]
1554e5c31af7Sopenharmony_ci
1555e5c31af7Sopenharmony_ciPerformance-critical commands generally do not have return codes.
1556e5c31af7Sopenharmony_ciIf a runtime error occurs in such commands, the implementation will defer
1557e5c31af7Sopenharmony_cireporting the error until a specified point.
1558e5c31af7Sopenharmony_ciFor commands that record into command buffers (ftext:vkCmd*) runtime errors
1559e5c31af7Sopenharmony_ciare reported by fname:vkEndCommandBuffer.
1560e5c31af7Sopenharmony_ci
1561e5c31af7Sopenharmony_ciifdef::VKSC_VERSION_1_0[]
1562e5c31af7Sopenharmony_ci[NOTE]
1563e5c31af7Sopenharmony_ci.Note
1564e5c31af7Sopenharmony_ci====
1565e5c31af7Sopenharmony_ciImplementations can also use <<fault-handling>> to report runtime errors
1566e5c31af7Sopenharmony_ciwhere suitable return values are not available or to provide more prompt
1567e5c31af7Sopenharmony_cinotification of an error.
1568e5c31af7Sopenharmony_ci====
1569e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
1570e5c31af7Sopenharmony_ci--
1571e5c31af7Sopenharmony_ci
1572e5c31af7Sopenharmony_ci
1573e5c31af7Sopenharmony_ci[[fundamentals-numerics]]
1574e5c31af7Sopenharmony_ci== Numeric Representation and Computation
1575e5c31af7Sopenharmony_ci
1576e5c31af7Sopenharmony_ciImplementations normally perform computations in floating-point, and must:
1577e5c31af7Sopenharmony_cimeet the range and precision requirements defined under "`Floating-Point
1578e5c31af7Sopenharmony_ciComputation`" below.
1579e5c31af7Sopenharmony_ci
1580e5c31af7Sopenharmony_ciThese requirements only apply to computations performed in Vulkan operations
1581e5c31af7Sopenharmony_cioutside of shader execution, such as texture image specification and
1582e5c31af7Sopenharmony_cisampling, and per-fragment operations.
1583e5c31af7Sopenharmony_ciRange and precision requirements during shader execution differ and are
1584e5c31af7Sopenharmony_cispecified by the <<spirvenv-precision-operation, Precision and Operation of
1585e5c31af7Sopenharmony_ciSPIR-V Instructions>> section.
1586e5c31af7Sopenharmony_ci
1587e5c31af7Sopenharmony_ciIn some cases, the representation and/or precision of operations is
1588e5c31af7Sopenharmony_ciimplicitly limited by the specified format of vertex or texel data consumed
1589e5c31af7Sopenharmony_ciby Vulkan.
1590e5c31af7Sopenharmony_ciSpecific floating-point formats are described later in this section.
1591e5c31af7Sopenharmony_ci
1592e5c31af7Sopenharmony_ci
1593e5c31af7Sopenharmony_ci[[fundamentals-floatingpoint]]
1594e5c31af7Sopenharmony_ci=== Floating-Point Computation
1595e5c31af7Sopenharmony_ci
1596e5c31af7Sopenharmony_ciMost floating-point computation is performed in SPIR-V shader modules.
1597e5c31af7Sopenharmony_ciThe properties of computation within shaders are constrained as defined by
1598e5c31af7Sopenharmony_cithe <<spirvenv-precision-operation, Precision and Operation of SPIR-V
1599e5c31af7Sopenharmony_ciInstructions>> section.
1600e5c31af7Sopenharmony_ci
1601e5c31af7Sopenharmony_ciSome floating-point computation is performed outside of shaders, such as
1602e5c31af7Sopenharmony_civiewport and depth range calculations.
1603e5c31af7Sopenharmony_ciFor these computations, we do not specify how floating-point numbers are to
1604e5c31af7Sopenharmony_cibe represented, or the details of how operations on them are performed, but
1605e5c31af7Sopenharmony_cionly place minimal requirements on representation and precision as described
1606e5c31af7Sopenharmony_ciin the remainder of this section.
1607e5c31af7Sopenharmony_ci
1608e5c31af7Sopenharmony_ciifdef::editing-notes[]
1609e5c31af7Sopenharmony_ci[NOTE]
1610e5c31af7Sopenharmony_ci.editing-note
1611e5c31af7Sopenharmony_ci====
1612e5c31af7Sopenharmony_ci(Jon, Bug 14966) This is a rat's nest of complexity, both in terms of
1613e5c31af7Sopenharmony_cidescribing/enumerating places such computation may: take place (other than
1614e5c31af7Sopenharmony_ci"`not shader code`") and in how implementations may: do it.
1615e5c31af7Sopenharmony_ciWe have consciously deferred the resolution of this issue to post-1.0, and
1616e5c31af7Sopenharmony_ciin the meantime, the following language inherited from the OpenGL
1617e5c31af7Sopenharmony_ciSpecification is inserted as a placeholder.
1618e5c31af7Sopenharmony_ciHopefully it can: be tightened up considerably.
1619e5c31af7Sopenharmony_ci====
1620e5c31af7Sopenharmony_ciendif::editing-notes[]
1621e5c31af7Sopenharmony_ci
1622e5c31af7Sopenharmony_ciWe require simply that numbers`' floating-point parts contain enough bits
1623e5c31af7Sopenharmony_ciand that their exponent fields are large enough so that individual results
1624e5c31af7Sopenharmony_ciof floating-point operations are accurate to about 1 part in 10^5^.
1625e5c31af7Sopenharmony_ciThe maximum representable magnitude for all floating-point values must: be
1626e5c31af7Sopenharmony_ciat least 2^32^.
1627e5c31af7Sopenharmony_ci
1628e5c31af7Sopenharmony_ci  {empty}:: [eq]#x {times} 0 = 0 {times} x = 0# for any non-infinite and
1629e5c31af7Sopenharmony_ci            non-[eq]#NaN# [eq]#x#.
1630e5c31af7Sopenharmony_ci  {empty}:: [eq]#1 {times} x = x {times} 1 = x#.
1631e5c31af7Sopenharmony_ci  {empty}:: [eq]#x {plus} 0 = 0 {plus} x = x#.
1632e5c31af7Sopenharmony_ci  {empty}:: [eq]#0^0^ = 1#.
1633e5c31af7Sopenharmony_ci
1634e5c31af7Sopenharmony_ciOccasionally, further requirements will be specified.
1635e5c31af7Sopenharmony_ciMost single-precision floating-point formats meet these requirements.
1636e5c31af7Sopenharmony_ci
1637e5c31af7Sopenharmony_ciThe special values [eq]#Inf# and [eq]#-Inf# encode values with magnitudes
1638e5c31af7Sopenharmony_citoo large to be represented; the special value [eq]#NaN# encodes "`Not A
1639e5c31af7Sopenharmony_ciNumber`" values resulting from undefined: arithmetic operations such as
1640e5c31af7Sopenharmony_ci[eq]#0 / 0#.
1641e5c31af7Sopenharmony_ciImplementations may: support [eq]#Inf# and [eq]#NaN# in their floating-point
1642e5c31af7Sopenharmony_cicomputations.
1643e5c31af7Sopenharmony_ciAny computation which does not support either [eq]#Inf# or [eq]#NaN#, for
1644e5c31af7Sopenharmony_ciwhich that value is an input or output will yield an undefined: value.
1645e5c31af7Sopenharmony_ci
1646e5c31af7Sopenharmony_ci
1647e5c31af7Sopenharmony_ci[[fundamentals-fp-conversion]]
1648e5c31af7Sopenharmony_ci=== Floating-Point Format Conversions
1649e5c31af7Sopenharmony_ci
1650e5c31af7Sopenharmony_ciWhen a value is converted to a defined floating-point representation, finite
1651e5c31af7Sopenharmony_civalues falling between two representable finite values are rounded to one or
1652e5c31af7Sopenharmony_cithe other.
1653e5c31af7Sopenharmony_ciThe rounding mode is not defined.
1654e5c31af7Sopenharmony_ciFinite values whose magnitude is larger than that of any representable
1655e5c31af7Sopenharmony_cifinite value may be rounded either to the closest representable finite value
1656e5c31af7Sopenharmony_cior to the appropriately signed infinity.
1657e5c31af7Sopenharmony_ciFor unsigned destination formats any negative values are converted to zero.
1658e5c31af7Sopenharmony_ciPositive infinity is converted to positive infinity; negative infinity is
1659e5c31af7Sopenharmony_ciconverted to negative infinity in signed formats and to zero in unsigned
1660e5c31af7Sopenharmony_ciformats; and any [eq]#NaN# is converted to a [eq]#NaN#.
1661e5c31af7Sopenharmony_ci
1662e5c31af7Sopenharmony_ci
1663e5c31af7Sopenharmony_ci[[fundamentals-fp16]]
1664e5c31af7Sopenharmony_ci=== 16-Bit Floating-Point Numbers
1665e5c31af7Sopenharmony_ci
1666e5c31af7Sopenharmony_ci16-bit floating point numbers are defined in the "`16-bit floating point
1667e5c31af7Sopenharmony_cinumbers`" section of the <<data-format,Khronos Data Format Specification>>.
1668e5c31af7Sopenharmony_ci
1669e5c31af7Sopenharmony_ci
1670e5c31af7Sopenharmony_ci[[fundamentals-fp11]]
1671e5c31af7Sopenharmony_ci=== Unsigned 11-Bit Floating-Point Numbers
1672e5c31af7Sopenharmony_ci
1673e5c31af7Sopenharmony_ciUnsigned 11-bit floating point numbers are defined in the "`Unsigned 11-bit
1674e5c31af7Sopenharmony_cifloating point numbers`" section of the <<data-format,Khronos Data Format
1675e5c31af7Sopenharmony_ciSpecification>>.
1676e5c31af7Sopenharmony_ci
1677e5c31af7Sopenharmony_ci
1678e5c31af7Sopenharmony_ci[[fundamentals-fp10]]
1679e5c31af7Sopenharmony_ci=== Unsigned 10-Bit Floating-Point Numbers
1680e5c31af7Sopenharmony_ci
1681e5c31af7Sopenharmony_ciUnsigned 10-bit floating point numbers are defined in the "`Unsigned 10-bit
1682e5c31af7Sopenharmony_cifloating point numbers`" section of the <<data-format,Khronos Data Format
1683e5c31af7Sopenharmony_ciSpecification>>.
1684e5c31af7Sopenharmony_ci
1685e5c31af7Sopenharmony_ci
1686e5c31af7Sopenharmony_ci[[fundamentals-general]]
1687e5c31af7Sopenharmony_ci=== General Requirements
1688e5c31af7Sopenharmony_ci
1689e5c31af7Sopenharmony_ciAny representable floating-point value in the appropriate format is legal as
1690e5c31af7Sopenharmony_ciinput to a Vulkan command that requires floating-point data.
1691e5c31af7Sopenharmony_ciThe result of providing a value that is not a floating-point number to such
1692e5c31af7Sopenharmony_cia command is unspecified, but must: not lead to Vulkan interruption or
1693e5c31af7Sopenharmony_citermination.
1694e5c31af7Sopenharmony_ciFor example, providing a negative zero (where applicable) or a denormalized
1695e5c31af7Sopenharmony_cinumber to a Vulkan command must: yield deterministic results, while
1696e5c31af7Sopenharmony_ciproviding a [eq]#NaN# or [eq]#Inf# yields unspecified results.
1697e5c31af7Sopenharmony_ci
1698e5c31af7Sopenharmony_ciSome calculations require division.
1699e5c31af7Sopenharmony_ciIn such cases (including implied divisions performed by vector
1700e5c31af7Sopenharmony_cinormalization), division by zero produces an unspecified result but must:
1701e5c31af7Sopenharmony_cinot lead to Vulkan interruption or termination.
1702e5c31af7Sopenharmony_ci
1703e5c31af7Sopenharmony_ci
1704e5c31af7Sopenharmony_ci[[fundamentals-fixedconv]]
1705e5c31af7Sopenharmony_ci== Fixed-Point Data Conversions
1706e5c31af7Sopenharmony_ci
1707e5c31af7Sopenharmony_ciWhen generic vertex attributes and pixel color or depth _components_ are
1708e5c31af7Sopenharmony_cirepresented as integers, they are often (but not always) considered to be
1709e5c31af7Sopenharmony_ci_normalized_.
1710e5c31af7Sopenharmony_ciNormalized integer values are treated specially when being converted to and
1711e5c31af7Sopenharmony_cifrom floating-point values, and are usually referred to as _normalized
1712e5c31af7Sopenharmony_cifixed-point_.
1713e5c31af7Sopenharmony_ci
1714e5c31af7Sopenharmony_ciIn the remainder of this section, [eq]#b# denotes the bit width of the
1715e5c31af7Sopenharmony_cifixed-point integer representation.
1716e5c31af7Sopenharmony_ciWhen the integer is one of the types defined by the API, [eq]#b# is the bit
1717e5c31af7Sopenharmony_ciwidth of that type.
1718e5c31af7Sopenharmony_ciWhen the integer comes from an <<resources-images,image>> containing color
1719e5c31af7Sopenharmony_cior depth component texels, [eq]#b# is the number of bits allocated to that
1720e5c31af7Sopenharmony_cicomponent in its <<formats,specified image format>>.
1721e5c31af7Sopenharmony_ci
1722e5c31af7Sopenharmony_ciThe signed and unsigned fixed-point representations are assumed to be
1723e5c31af7Sopenharmony_ci[eq]#b#-bit binary two's-complement integers and binary unsigned integers,
1724e5c31af7Sopenharmony_cirespectively.
1725e5c31af7Sopenharmony_ci
1726e5c31af7Sopenharmony_ci
1727e5c31af7Sopenharmony_ci[[fundamentals-fixedfpconv]]
1728e5c31af7Sopenharmony_ci=== Conversion From Normalized Fixed-Point to Floating-Point
1729e5c31af7Sopenharmony_ci
1730e5c31af7Sopenharmony_ciUnsigned normalized fixed-point integers represent numbers in the range
1731e5c31af7Sopenharmony_ci[eq]#[0,1]#.
1732e5c31af7Sopenharmony_ciThe conversion from an unsigned normalized fixed-point value [eq]#c# to the
1733e5c31af7Sopenharmony_cicorresponding floating-point value [eq]#f# is defined as
1734e5c31af7Sopenharmony_ci
1735e5c31af7Sopenharmony_ci[latexmath]
1736e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1737e5c31af7Sopenharmony_cif = { c \over { 2^b - 1 } }
1738e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1739e5c31af7Sopenharmony_ci
1740e5c31af7Sopenharmony_ciSigned normalized fixed-point integers represent numbers in the range
1741e5c31af7Sopenharmony_ci[eq]#[-1,1]#.
1742e5c31af7Sopenharmony_ciThe conversion from a signed normalized fixed-point value [eq]#c# to the
1743e5c31af7Sopenharmony_cicorresponding floating-point value [eq]#f# is performed using
1744e5c31af7Sopenharmony_ci
1745e5c31af7Sopenharmony_ci[latexmath]
1746e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1747e5c31af7Sopenharmony_cif = \max\left( {c \over {2^{b-1} - 1}}, -1.0 \right)
1748e5c31af7Sopenharmony_ci++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1749e5c31af7Sopenharmony_ci
1750e5c31af7Sopenharmony_ciOnly the range [eq]#[-2^b-1^ {plus} 1, 2^b-1^ - 1]# is used to represent
1751e5c31af7Sopenharmony_cisigned fixed-point values in the range [eq]#[-1,1]#.
1752e5c31af7Sopenharmony_ciFor example, if [eq]#b = 8#, then the integer value [eq]#-127# corresponds
1753e5c31af7Sopenharmony_cito [eq]#-1.0# and the value 127 corresponds to [eq]#1.0#.
1754e5c31af7Sopenharmony_ciThis equation is used everywhere that signed normalized fixed-point values
1755e5c31af7Sopenharmony_ciare converted to floating-point.
1756e5c31af7Sopenharmony_ci
1757e5c31af7Sopenharmony_ciNote that while zero is exactly expressible in this representation, one
1758e5c31af7Sopenharmony_civalue ([eq]#-128# in the example) is outside the representable range, and
1759e5c31af7Sopenharmony_ciimplementations must: clamp it to [eq]#-1.0#.
1760e5c31af7Sopenharmony_ciWhere the value is subject to further processing by the implementation, e.g.
1761e5c31af7Sopenharmony_ciduring texture filtering, values less than [eq]#-1.0# may: be used but the
1762e5c31af7Sopenharmony_ciresult must: be clamped before the value is returned to shaders.
1763e5c31af7Sopenharmony_ci
1764e5c31af7Sopenharmony_ci
1765e5c31af7Sopenharmony_ci[[fundamentals-fpfixedconv]]
1766e5c31af7Sopenharmony_ci=== Conversion From Floating-Point to Normalized Fixed-Point
1767e5c31af7Sopenharmony_ci
1768e5c31af7Sopenharmony_ciThe conversion from a floating-point value [eq]#f# to the corresponding
1769e5c31af7Sopenharmony_ciunsigned normalized fixed-point value [eq]#c# is defined by first clamping
1770e5c31af7Sopenharmony_ci[eq]#f# to the range [eq]#[0,1]#, then computing
1771e5c31af7Sopenharmony_ci
1772e5c31af7Sopenharmony_ci  {empty}:: [eq]#c = convertFloatToUint(f {times} (2^b^ - 1), b)#
1773e5c31af7Sopenharmony_ci
1774e5c31af7Sopenharmony_ciwhere [eq]#convertFloatToUint(r,b)# returns one of the two unsigned binary
1775e5c31af7Sopenharmony_ciinteger values with exactly [eq]#b# bits which are closest to the
1776e5c31af7Sopenharmony_cifloating-point value [eq]#r#.
1777e5c31af7Sopenharmony_ciImplementations should: round to nearest.
1778e5c31af7Sopenharmony_ciIf [eq]#r# is equal to an integer, then that integer value must: be
1779e5c31af7Sopenharmony_cireturned.
1780e5c31af7Sopenharmony_ciIn particular, if [eq]#f# is equal to 0.0 or 1.0, then [eq]#c# must: be
1781e5c31af7Sopenharmony_ciassigned 0 or [eq]#2^b^ - 1#, respectively.
1782e5c31af7Sopenharmony_ci
1783e5c31af7Sopenharmony_ciThe conversion from a floating-point value [eq]#f# to the corresponding
1784e5c31af7Sopenharmony_cisigned normalized fixed-point value [eq]#c# is performed by clamping [eq]#f#
1785e5c31af7Sopenharmony_cito the range [eq]#[-1,1]#, then computing
1786e5c31af7Sopenharmony_ci
1787e5c31af7Sopenharmony_ci  {empty}:: [eq]#c = convertFloatToInt(f {times} (2^b-1^ - 1), b)#
1788e5c31af7Sopenharmony_ci
1789e5c31af7Sopenharmony_ciwhere [eq]#convertFloatToInt(r,b)# returns one of the two signed
1790e5c31af7Sopenharmony_citwo's-complement binary integer values with exactly [eq]#b# bits which are
1791e5c31af7Sopenharmony_ciclosest to the floating-point value [eq]#r#.
1792e5c31af7Sopenharmony_ciImplementations should: round to nearest.
1793e5c31af7Sopenharmony_ciIf [eq]#r# is equal to an integer, then that integer value must: be
1794e5c31af7Sopenharmony_cireturned.
1795e5c31af7Sopenharmony_ciIn particular, if [eq]#f# is equal to -1.0, 0.0, or 1.0, then [eq]#c# must:
1796e5c31af7Sopenharmony_cibe assigned [eq]#-(2^b-1^ - 1)#, 0, or [eq]#2^b-1^ - 1#, respectively.
1797e5c31af7Sopenharmony_ci
1798e5c31af7Sopenharmony_ciThis equation is used everywhere that floating-point values are converted to
1799e5c31af7Sopenharmony_cisigned normalized fixed-point.
1800e5c31af7Sopenharmony_ci
1801e5c31af7Sopenharmony_ci
1802e5c31af7Sopenharmony_ci[[fundamentals-common-objects]]
1803e5c31af7Sopenharmony_ci== Common Object Types
1804e5c31af7Sopenharmony_ci
1805e5c31af7Sopenharmony_ciSome types of Vulkan objects are used in many different structures and
1806e5c31af7Sopenharmony_cicommand parameters, and are described here.
1807e5c31af7Sopenharmony_ciThese types include _offsets_, _extents_, and _rectangles_.
1808e5c31af7Sopenharmony_ci
1809e5c31af7Sopenharmony_ci
1810e5c31af7Sopenharmony_ci=== Offsets
1811e5c31af7Sopenharmony_ci
1812e5c31af7Sopenharmony_ciOffsets are used to describe a pixel location within an image or
1813e5c31af7Sopenharmony_ciframebuffer, as an (x,y) location for two-dimensional images, or an (x,y,z)
1814e5c31af7Sopenharmony_cilocation for three-dimensional images.
1815e5c31af7Sopenharmony_ci
1816e5c31af7Sopenharmony_ci[open,refpage='VkOffset2D',desc='Structure specifying a two-dimensional offset',type='structs']
1817e5c31af7Sopenharmony_ci--
1818e5c31af7Sopenharmony_ciA two-dimensional offset is defined by the structure:
1819e5c31af7Sopenharmony_ci
1820e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkOffset2D.adoc[]
1821e5c31af7Sopenharmony_ci
1822e5c31af7Sopenharmony_ci  * pname:x is the x offset.
1823e5c31af7Sopenharmony_ci  * pname:y is the y offset.
1824e5c31af7Sopenharmony_ci
1825e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkOffset2D.adoc[]
1826e5c31af7Sopenharmony_ci--
1827e5c31af7Sopenharmony_ci
1828e5c31af7Sopenharmony_ci[open,refpage='VkOffset3D',desc='Structure specifying a three-dimensional offset',type='structs']
1829e5c31af7Sopenharmony_ci--
1830e5c31af7Sopenharmony_ciA three-dimensional offset is defined by the structure:
1831e5c31af7Sopenharmony_ci
1832e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkOffset3D.adoc[]
1833e5c31af7Sopenharmony_ci
1834e5c31af7Sopenharmony_ci  * pname:x is the x offset.
1835e5c31af7Sopenharmony_ci  * pname:y is the y offset.
1836e5c31af7Sopenharmony_ci  * pname:z is the z offset.
1837e5c31af7Sopenharmony_ci
1838e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkOffset3D.adoc[]
1839e5c31af7Sopenharmony_ci--
1840e5c31af7Sopenharmony_ci
1841e5c31af7Sopenharmony_ci
1842e5c31af7Sopenharmony_ci=== Extents
1843e5c31af7Sopenharmony_ci
1844e5c31af7Sopenharmony_ciExtents are used to describe the size of a rectangular region of pixels
1845e5c31af7Sopenharmony_ciwithin an image or framebuffer, as (width,height) for two-dimensional
1846e5c31af7Sopenharmony_ciimages, or as (width,height,depth) for three-dimensional images.
1847e5c31af7Sopenharmony_ci
1848e5c31af7Sopenharmony_ci[open,refpage='VkExtent2D',desc='Structure specifying a two-dimensional extent',type='structs']
1849e5c31af7Sopenharmony_ci--
1850e5c31af7Sopenharmony_ciA two-dimensional extent is defined by the structure:
1851e5c31af7Sopenharmony_ci
1852e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkExtent2D.adoc[]
1853e5c31af7Sopenharmony_ci
1854e5c31af7Sopenharmony_ci  * pname:width is the width of the extent.
1855e5c31af7Sopenharmony_ci  * pname:height is the height of the extent.
1856e5c31af7Sopenharmony_ci
1857e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkExtent2D.adoc[]
1858e5c31af7Sopenharmony_ci--
1859e5c31af7Sopenharmony_ci
1860e5c31af7Sopenharmony_ci[open,refpage='VkExtent3D',desc='Structure specifying a three-dimensional extent',type='structs']
1861e5c31af7Sopenharmony_ci--
1862e5c31af7Sopenharmony_ciA three-dimensional extent is defined by the structure:
1863e5c31af7Sopenharmony_ci
1864e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkExtent3D.adoc[]
1865e5c31af7Sopenharmony_ci
1866e5c31af7Sopenharmony_ci  * pname:width is the width of the extent.
1867e5c31af7Sopenharmony_ci  * pname:height is the height of the extent.
1868e5c31af7Sopenharmony_ci  * pname:depth is the depth of the extent.
1869e5c31af7Sopenharmony_ci
1870e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkExtent3D.adoc[]
1871e5c31af7Sopenharmony_ci--
1872e5c31af7Sopenharmony_ci
1873e5c31af7Sopenharmony_ci
1874e5c31af7Sopenharmony_ci=== Rectangles
1875e5c31af7Sopenharmony_ci
1876e5c31af7Sopenharmony_ci[open,refpage='VkRect2D',desc='Structure specifying a two-dimensional subregion',type='structs']
1877e5c31af7Sopenharmony_ci--
1878e5c31af7Sopenharmony_ciRectangles are used to describe a specified rectangular region of pixels
1879e5c31af7Sopenharmony_ciwithin an image or framebuffer.
1880e5c31af7Sopenharmony_ciRectangles include both an offset and an extent of the same dimensionality,
1881e5c31af7Sopenharmony_cias described above.
1882e5c31af7Sopenharmony_ciTwo-dimensional rectangles are defined by the structure
1883e5c31af7Sopenharmony_ci
1884e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkRect2D.adoc[]
1885e5c31af7Sopenharmony_ci
1886e5c31af7Sopenharmony_ci  * pname:offset is a slink:VkOffset2D specifying the rectangle offset.
1887e5c31af7Sopenharmony_ci  * pname:extent is a slink:VkExtent2D specifying the rectangle extent.
1888e5c31af7Sopenharmony_ci
1889e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkRect2D.adoc[]
1890e5c31af7Sopenharmony_ci--
1891e5c31af7Sopenharmony_ci
1892e5c31af7Sopenharmony_ci
1893e5c31af7Sopenharmony_ci// VkStructureType is pretty long,
1894e5c31af7Sopenharmony_ci// so keep it as a last chapter section for readability.
1895e5c31af7Sopenharmony_ci=== Structure Types
1896e5c31af7Sopenharmony_ci
1897e5c31af7Sopenharmony_ci[open,refpage='VkStructureType',desc='Vulkan structure types (pname:sType)',type='enums']
1898e5c31af7Sopenharmony_ci--
1899e5c31af7Sopenharmony_ciEach value corresponds to a particular structure with a pname:sType member
1900e5c31af7Sopenharmony_ciwith a matching name.
1901e5c31af7Sopenharmony_ciAs a general rule, the name of each elink:VkStructureType value is obtained
1902e5c31af7Sopenharmony_ciby taking the name of the structure, stripping the leading etext:Vk,
1903e5c31af7Sopenharmony_ciprefixing each capital letter with etext:_, converting the entire resulting
1904e5c31af7Sopenharmony_cistring to upper case, and prefixing it with etext:VK_STRUCTURE_TYPE_.
1905e5c31af7Sopenharmony_ciFor example, structures of type slink:VkImageCreateInfo correspond to a
1906e5c31af7Sopenharmony_cielink:VkStructureType value of ename:VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
1907e5c31af7Sopenharmony_ciand thus a structure of this type must: have its pname:sType member set to
1908e5c31af7Sopenharmony_cithis value before it is passed to the API.
1909e5c31af7Sopenharmony_ci
1910e5c31af7Sopenharmony_ciThe values ename:VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO and
1911e5c31af7Sopenharmony_ciename:VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO are reserved for internal
1912e5c31af7Sopenharmony_ciuse by the loader, and do not have corresponding Vulkan structures in this
1913e5c31af7Sopenharmony_ciSpecification.
1914e5c31af7Sopenharmony_ci
1915e5c31af7Sopenharmony_ciStructure types supported by the Vulkan API include:
1916e5c31af7Sopenharmony_ci
1917e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkStructureType.adoc[]
1918e5c31af7Sopenharmony_ci
1919e5c31af7Sopenharmony_ciifdef::VKSC_VERSION_1_0[]
1920e5c31af7Sopenharmony_ciifdef::hidden[]
1921e5c31af7Sopenharmony_ci// tag::scremoved[]
1922e5c31af7Sopenharmony_ci  * elink:VkStructureType (deprecated aliases)
1923e5c31af7Sopenharmony_ci  ** etext:VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES
1924e5c31af7Sopenharmony_ci     <<SCID-8>>
1925e5c31af7Sopenharmony_ci  ** etext:VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETER_FEATURES
1926e5c31af7Sopenharmony_ci     <<SCID-8>>
1927e5c31af7Sopenharmony_ci  ** etext:VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES2_EXT <<SCID-8>>
1928e5c31af7Sopenharmony_ci// end::scremoved[]
1929e5c31af7Sopenharmony_ciendif::hidden[]
1930e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
1931e5c31af7Sopenharmony_ci--
1932e5c31af7Sopenharmony_ci
1933e5c31af7Sopenharmony_ci
1934e5c31af7Sopenharmony_ci[[fundamentals-api-name-aliases]]
1935e5c31af7Sopenharmony_ci== API Name Aliases
1936e5c31af7Sopenharmony_ci
1937e5c31af7Sopenharmony_ciA small number of APIs did not follow the <<vulkan-styleguide, naming
1938e5c31af7Sopenharmony_ciconventions>> when initially defined.
1939e5c31af7Sopenharmony_ciFor consistency, when we discover an API name that violates the naming
1940e5c31af7Sopenharmony_ciconventions, we rename it in the Specification, XML, and header files.
1941e5c31af7Sopenharmony_ciFor backwards compatibility, the original (incorrect) name is retained as a
1942e5c31af7Sopenharmony_ci"`typo alias`".
1943e5c31af7Sopenharmony_ciThe alias is deprecated and should not be used, but will be retained
1944e5c31af7Sopenharmony_ciindefinitely.
1945e5c31af7Sopenharmony_ci
1946e5c31af7Sopenharmony_ci[NOTE]
1947e5c31af7Sopenharmony_ci.Note
1948e5c31af7Sopenharmony_ci====
1949e5c31af7Sopenharmony_cietext:VK_STENCIL_FRONT_AND_BACK is an example of a _typo alias_.
1950e5c31af7Sopenharmony_ciIt was initially defined as part of elink:VkStencilFaceFlagBits.
1951e5c31af7Sopenharmony_ciOnce the naming inconsistency was noticed, it was renamed to
1952e5c31af7Sopenharmony_ciename:VK_STENCIL_FACE_FRONT_AND_BACK, and the old name was aliased to the
1953e5c31af7Sopenharmony_cicorrect name.
1954e5c31af7Sopenharmony_ci====
1955