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