• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2014-2023 The Khronos Group Inc.
2//
3// SPDX-License-Identifier: CC-BY-4.0
4
5== WSI Swapchain
6
7[open,refpage='VkSwapchainKHR',desc='Opaque handle to a swapchain object',type='handles',xrefs='vkQueuePresentKHR']
8--
9A swapchain object (a.k.a.
10swapchain) provides the ability to present rendering results to a surface.
11Swapchain objects are represented by sname:VkSwapchainKHR handles:
12
13include::{generated}/api/handles/VkSwapchainKHR.adoc[]
14
15A swapchain is an abstraction for an array of presentable images that are
16associated with a surface.
17The presentable images are represented by sname:VkImage objects created by
18the platform.
19One image (which can: be an array image for multiview/stereoscopic-3D
20surfaces) is displayed at a time, but multiple images can: be queued for
21presentation.
22An application renders to the image, and then queues the image for
23presentation to the surface.
24
25A native window cannot: be associated with more than one non-retired
26swapchain at a time.
27Further, swapchains cannot: be created for native windows that have a
28non-Vulkan graphics API surface associated with them.
29
30[NOTE]
31.Note
32====
33The presentation engine is an abstraction for the platform's compositor or
34display engine.
35
36The presentation engine may: be synchronous or asynchronous with respect to
37the application and/or logical device.
38
39Some implementations may: use the device's graphics queue or dedicated
40presentation hardware to perform presentation.
41====
42
43The presentable images of a swapchain are owned by the presentation engine.
44An application can: acquire use of a presentable image from the presentation
45engine.
46Use of a presentable image must: occur only after the image is returned by
47flink:vkAcquireNextImageKHR, and before it is released by
48flink:vkQueuePresentKHR.
49This includes transitioning the image layout and rendering commands.
50
51An application can: acquire use of a presentable image with
52flink:vkAcquireNextImageKHR.
53After acquiring a presentable image and before modifying it, the application
54must: use a synchronization primitive to ensure that the presentation engine
55has finished reading from the image.
56The application can: then transition the image's layout, queue rendering
57commands to it, etc.
58Finally, the application presents the image with flink:vkQueuePresentKHR,
59which releases the acquisition of the image.
60ifdef::VK_EXT_swapchain_maintenance1[]
61The application can: also release the acquisition of the image through
62flink:vkReleaseSwapchainImagesEXT, if the image is not in use by the device,
63and skip the present operation.
64endif::VK_EXT_swapchain_maintenance1[]
65
66The presentation engine controls the order in which presentable images are
67acquired for use by the application.
68
69[NOTE]
70.Note
71====
72This allows the platform to handle situations which require out-of-order
73return of images after presentation.
74At the same time, it allows the application to generate command buffers
75referencing all of the images in the swapchain at initialization time,
76rather than in its main loop.
77====
78--
79
80How this all works is described below.
81
82ifdef::VK_KHR_shared_presentable_image[]
83include::{chapters}/VK_KHR_shared_presentable_image/wsi.adoc[]
84endif::VK_KHR_shared_presentable_image[]
85
86[open,refpage='vkCreateSwapchainKHR',desc='Create a swapchain',type='protos']
87--
88:refpage: vkCreateSwapchainKHR
89:objectnameplural: swapchains
90:objectnamecamelcase: swapchain
91:objectcount: 1
92
93To create a swapchain, call:
94
95include::{generated}/api/protos/vkCreateSwapchainKHR.adoc[]
96
97  * pname:device is the device to create the swapchain for.
98  * pname:pCreateInfo is a pointer to a slink:VkSwapchainCreateInfoKHR
99    structure specifying the parameters of the created swapchain.
100  * pname:pAllocator is the allocator used for host memory allocated for the
101    swapchain object when there is no more specific allocator available (see
102    <<memory-allocation,Memory Allocation>>).
103  * pname:pSwapchain is a pointer to a slink:VkSwapchainKHR handle in which
104    the created swapchain object will be returned.
105
106As mentioned above, if fname:vkCreateSwapchainKHR succeeds, it will return a
107handle to a swapchain containing an array of at least
108pname:pCreateInfo->minImageCount presentable images.
109
110While acquired by the application, presentable images can: be used in any
111way that equivalent non-presentable images can: be used.
112A presentable image is equivalent to a non-presentable image created with
113the following slink:VkImageCreateInfo parameters:
114
115[[swapchain-wsi-image-create-info]]
116[options="header"]
117|====
118| sname:VkImageCreateInfo Field | Value
119ifndef::VK_VERSION_1_1,VK_KHR_device_group,VK_KHR_swapchain_mutable_format[]
120| pname:flags                   | 0
121endif::VK_VERSION_1_1,VK_KHR_device_group,VK_KHR_swapchain_mutable_format[]
122ifdef::VK_VERSION_1_1,VK_KHR_device_group,VK_KHR_swapchain_mutable_format[]
123| pname:flags                   |
124ifdef::VK_VERSION_1_1,VK_KHR_device_group[]
125ename:VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT is set if
126ename:VK_SWAPCHAIN_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR is set
127
128endif::VK_VERSION_1_1,VK_KHR_device_group[]
129ifdef::VK_VERSION_1_1[]
130ename:VK_IMAGE_CREATE_PROTECTED_BIT is set if
131ename:VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR is set
132
133endif::VK_VERSION_1_1[]
134ifdef::VK_KHR_swapchain_mutable_format[]
135ename:VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT and
136ename:VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR are both set if
137ename:VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR is set
138
139endif::VK_KHR_swapchain_mutable_format[]
140all other bits are unset
141endif::VK_VERSION_1_1,VK_KHR_device_group,VK_KHR_swapchain_mutable_format[]
142| pname:imageType               | ename:VK_IMAGE_TYPE_2D
143| pname:format                  | pname:pCreateInfo->imageFormat
144| pname:extent                  | {pname:pCreateInfo->imageExtent.width, pname:pCreateInfo->imageExtent.height, `1`}
145| pname:mipLevels               | 1
146| pname:arrayLayers             | pname:pCreateInfo->imageArrayLayers
147| pname:samples                 | ename:VK_SAMPLE_COUNT_1_BIT
148| pname:tiling                  | ename:VK_IMAGE_TILING_OPTIMAL
149| pname:usage                   | pname:pCreateInfo->imageUsage
150| pname:sharingMode             | pname:pCreateInfo->imageSharingMode
151| pname:queueFamilyIndexCount   | pname:pCreateInfo->queueFamilyIndexCount
152| pname:pQueueFamilyIndices     | pname:pCreateInfo->pQueueFamilyIndices
153| pname:initialLayout           | ename:VK_IMAGE_LAYOUT_UNDEFINED
154|====
155
156The pname:pCreateInfo->surface must: not be destroyed until after the
157swapchain is destroyed.
158
159ifdef::VKSC_VERSION_1_0[If]
160ifndef::VKSC_VERSION_1_0[If pname:oldSwapchain is dlink:VK_NULL_HANDLE, and]
161the native window referred to by pname:pCreateInfo->surface is already
162associated with a Vulkan swapchain, ename:VK_ERROR_NATIVE_WINDOW_IN_USE_KHR
163must: be returned.
164
165If the native window referred to by pname:pCreateInfo->surface is already
166associated with a non-Vulkan graphics API surface,
167ename:VK_ERROR_NATIVE_WINDOW_IN_USE_KHR must: be returned.
168
169The native window referred to by pname:pCreateInfo->surface must: not become
170associated with a non-Vulkan graphics API surface before all associated
171Vulkan swapchains have been destroyed.
172
173fname:vkCreateSwapchainKHR will return ename:VK_ERROR_DEVICE_LOST if the
174logical device was lost.
175ifndef::VKSC_VERSION_1_0[]
176The sname:VkSwapchainKHR is a child of the pname:device, and must: be
177destroyed before the pname:device.
178endif::VKSC_VERSION_1_0[]
179However, sname:VkSurfaceKHR is not a child of any sname:VkDevice and is not
180affected by the lost device.
181After successfully recreating a sname:VkDevice, the same sname:VkSurfaceKHR
182can: be used to create a new sname:VkSwapchainKHR, provided the previous one
183was destroyed.
184
185ifdef::VK_EXT_full_screen_exclusive[]
186If the pname:oldSwapchain parameter of pname:pCreateInfo is a valid
187swapchain, which has exclusive full-screen access, that access is released
188from pname:pCreateInfo->oldSwapchain.
189If the command succeeds in this case, the newly created swapchain will
190automatically acquire exclusive full-screen access from
191pname:pCreateInfo->oldSwapchain.
192
193[NOTE]
194.Note
195====
196This implicit transfer is intended to avoid exiting and entering full-screen
197exclusive mode, which may otherwise cause unwanted visual updates to the
198display.
199====
200
201In some cases, swapchain creation may: fail if exclusive full-screen mode is
202requested for application control, but for some implementation-specific
203reason exclusive full-screen access is unavailable for the particular
204combination of parameters provided.
205If this occurs, ename:VK_ERROR_INITIALIZATION_FAILED will be returned.
206
207[NOTE]
208.Note
209====
210In particular, it will fail if the pname:imageExtent member of
211pname:pCreateInfo does not match the extents of the monitor.
212ifdef::VK_KHR_win32_surface[]
213Other reasons for failure may include the app not being set as high-dpi
214aware, or if the physical device and monitor are not compatible in this
215mode.
216endif::VK_KHR_win32_surface[]
217====
218
219endif::VK_EXT_full_screen_exclusive[]
220
221ifdef::VK_NV_present_barrier[]
222If the pname:pNext chain of slink:VkSwapchainCreateInfoKHR includes a
223slink:VkSwapchainPresentBarrierCreateInfoNV structure, then that structure
224includes additional swapchain creation parameters specific to the present
225barrier.
226Swapchain creation may: fail if the state of the current system restricts
227the usage of the present barrier feature
228slink:VkSurfaceCapabilitiesPresentBarrierNV, or a swapchain itself does not
229satisfy all the required conditions.
230In this scenario ename:VK_ERROR_INITIALIZATION_FAILED is returned.
231endif::VK_NV_present_barrier[]
232
233ifdef::VK_NV_acquire_winrt_display[]
234When the slink:VkSurfaceKHR in slink:VkSwapchainCreateInfoKHR is a display
235surface, then the slink:VkDisplayModeKHR in display surface's
236slink:VkDisplaySurfaceCreateInfoKHR is associated with a particular
237slink:VkDisplayKHR.
238Swapchain creation may: fail if that slink:VkDisplayKHR is not acquired by
239the application.
240In this scenario ename:VK_ERROR_INITIALIZATION_FAILED is returned.
241endif::VK_NV_acquire_winrt_display[]
242
243include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[]
244
245ifdef::VKSC_VERSION_1_0[]
246.Valid Usage
247****
248include::{chapters}/commonvalidity/memory_reservation_request_count_common.adoc[]
249****
250endif::VKSC_VERSION_1_0[]
251
252include::{generated}/validity/protos/vkCreateSwapchainKHR.adoc[]
253--
254
255[open,refpage='VkSwapchainCreateInfoKHR',desc='Structure specifying parameters of a newly created swapchain object',type='structs']
256--
257The sname:VkSwapchainCreateInfoKHR structure is defined as:
258
259include::{generated}/api/structs/VkSwapchainCreateInfoKHR.adoc[]
260
261  * pname:sType is a elink:VkStructureType value identifying this structure.
262  * pname:pNext is `NULL` or a pointer to a structure extending this
263    structure.
264  * pname:flags is a bitmask of elink:VkSwapchainCreateFlagBitsKHR
265    indicating parameters of the swapchain creation.
266  * pname:surface is the surface onto which the swapchain will present
267    images.
268    If the creation succeeds, the swapchain becomes associated with
269    pname:surface.
270  * pname:minImageCount is the minimum number of presentable images that the
271    application needs.
272    The implementation will either create the swapchain with at least that
273    many images, or it will fail to create the swapchain.
274  * pname:imageFormat is a elink:VkFormat value specifying the format the
275    swapchain image(s) will be created with.
276  * pname:imageColorSpace is a elink:VkColorSpaceKHR value specifying the
277    way the swapchain interprets image data.
278  * pname:imageExtent is the size (in pixels) of the swapchain image(s).
279    The behavior is platform-dependent if the image extent does not match
280    the surface's pname:currentExtent as returned by
281    fname:vkGetPhysicalDeviceSurfaceCapabilitiesKHR.
282+
283[NOTE]
284.Note
285====
286On some platforms, it is normal that pname:maxImageExtent may: become `(0,
2870)`, for example when the window is minimized.
288In such a case, it is not possible to create a swapchain due to the Valid
289Usage requirements
290ifdef::VK_EXT_swapchain_maintenance1[]
291, unless scaling is selected through
292slink:VkSwapchainPresentScalingCreateInfoEXT, if supported
293endif::VK_EXT_swapchain_maintenance1[]
294.
295====
296  * pname:imageArrayLayers is the number of views in a multiview/stereo
297    surface.
298    For non-stereoscopic-3D applications, this value is 1.
299  * pname:imageUsage is a bitmask of elink:VkImageUsageFlagBits describing
300    the intended usage of the (acquired) swapchain images.
301  * pname:imageSharingMode is the sharing mode used for the image(s) of the
302    swapchain.
303  * pname:queueFamilyIndexCount is the number of queue families having
304    access to the image(s) of the swapchain when pname:imageSharingMode is
305    ename:VK_SHARING_MODE_CONCURRENT.
306  * pname:pQueueFamilyIndices is a pointer to an array of queue family
307    indices having access to the images(s) of the swapchain when
308    pname:imageSharingMode is ename:VK_SHARING_MODE_CONCURRENT.
309  * pname:preTransform is a elink:VkSurfaceTransformFlagBitsKHR value
310    describing the transform, relative to the presentation engine's natural
311    orientation, applied to the image content prior to presentation.
312    If it does not match the pname:currentTransform value returned by
313    fname:vkGetPhysicalDeviceSurfaceCapabilitiesKHR, the presentation engine
314    will transform the image content as part of the presentation operation.
315  * pname:compositeAlpha is a elink:VkCompositeAlphaFlagBitsKHR value
316    indicating the alpha compositing mode to use when this surface is
317    composited together with other surfaces on certain window systems.
318  * pname:presentMode is the presentation mode the swapchain will use.
319    A swapchain's present mode determines how incoming present requests will
320    be processed and queued internally.
321  * pname:clipped specifies whether the Vulkan implementation is allowed to
322    discard rendering operations that affect regions of the surface that are
323    not visible.
324  ** If set to ename:VK_TRUE, the presentable images associated with the
325     swapchain may: not own all of their pixels.
326     Pixels in the presentable images that correspond to regions of the
327     target surface obscured by another window on the desktop, or subject to
328     some other clipping mechanism will have undefined: content when read
329     back.
330     Fragment shaders may: not execute for these pixels, and thus any side
331     effects they would have had will not occur.
332     Setting ename:VK_TRUE does not guarantee any clipping will occur, but
333     allows more efficient presentation methods to be used on some
334     platforms.
335  ** If set to ename:VK_FALSE, presentable images associated with the
336     swapchain will own all of the pixels they contain.
337+
338[NOTE]
339.Note
340====
341Applications should: set this value to ename:VK_TRUE if they do not expect
342to read back the content of presentable images before presenting them or
343after reacquiring them, and if their fragment shaders do not have any side
344effects that require them to run for all pixels in the presentable image.
345====
346ifdef::VKSC_VERSION_1_0[]
347  * pname:oldSwapchain must: be dlink:VK_NULL_HANDLE in Vulkan SC
348    <<SCID-4>>.
349endif::VKSC_VERSION_1_0[]
350ifndef::VKSC_VERSION_1_0[]
351  * pname:oldSwapchain is dlink:VK_NULL_HANDLE, or the existing non-retired
352    swapchain currently associated with pname:surface.
353    Providing a valid pname:oldSwapchain may: aid in the resource reuse, and
354    also allows the application to still present any images that are already
355    acquired from it.
356endif::VKSC_VERSION_1_0[]
357
358ifndef::VKSC_VERSION_1_0[]
359Upon calling fname:vkCreateSwapchainKHR with an pname:oldSwapchain that is
360not dlink:VK_NULL_HANDLE, pname:oldSwapchain is retired -- even if creation
361of the new swapchain fails.
362The new swapchain is created in the non-retired state whether or not
363pname:oldSwapchain is dlink:VK_NULL_HANDLE.
364
365Upon calling fname:vkCreateSwapchainKHR with an pname:oldSwapchain that is
366not dlink:VK_NULL_HANDLE, any images from pname:oldSwapchain that are not
367acquired by the application may: be freed by the implementation, which may:
368occur even if creation of the new swapchain fails.
369The application can: destroy pname:oldSwapchain to free all memory
370associated with pname:oldSwapchain.
371
372[NOTE]
373.Note
374====
375Multiple retired swapchains can: be associated with the same
376sname:VkSurfaceKHR through multiple uses of pname:oldSwapchain that
377outnumber calls to flink:vkDestroySwapchainKHR.
378
379After pname:oldSwapchain is retired, the application can: pass to
380flink:vkQueuePresentKHR any images it had already acquired from
381pname:oldSwapchain.
382E.g., an application may present an image from the old swapchain before an
383image from the new swapchain is ready to be presented.
384As usual, flink:vkQueuePresentKHR may: fail if pname:oldSwapchain has
385entered a state that causes ename:VK_ERROR_OUT_OF_DATE_KHR to be returned.
386
387ifdef::VK_KHR_shared_presentable_image[]
388The application can: continue to use a shared presentable image obtained
389from pname:oldSwapchain until a presentable image is acquired from the new
390swapchain, as long as it has not entered a state that causes it to return
391ename:VK_ERROR_OUT_OF_DATE_KHR.
392endif::VK_KHR_shared_presentable_image[]
393====
394endif::VKSC_VERSION_1_0[]
395
396.Valid Usage
397****
398  * [[VUID-VkSwapchainCreateInfoKHR-surface-01270]]
399    pname:surface must: be a surface that is supported by the device as
400    determined using flink:vkGetPhysicalDeviceSurfaceSupportKHR
401ifndef::VK_KHR_shared_presentable_image[]
402  * [[VUID-VkSwapchainCreateInfoKHR-minImageCount-01271]]
403    pname:minImageCount must: be greater than or equal to the value returned
404    in the pname:minImageCount member of the sname:VkSurfaceCapabilitiesKHR
405    structure returned by flink:vkGetPhysicalDeviceSurfaceCapabilitiesKHR
406    for the surface
407endif::VK_KHR_shared_presentable_image[]
408  * [[VUID-VkSwapchainCreateInfoKHR-minImageCount-01272]]
409    pname:minImageCount must: be less than or equal to the value returned in
410    the pname:maxImageCount member of the sname:VkSurfaceCapabilitiesKHR
411    structure returned by fname:vkGetPhysicalDeviceSurfaceCapabilitiesKHR
412    for the surface if the returned pname:maxImageCount is not zero
413ifdef::VK_KHR_shared_presentable_image[]
414  * [[VUID-VkSwapchainCreateInfoKHR-presentMode-02839]]
415    If pname:presentMode is not
416    ename:VK_PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR nor
417    ename:VK_PRESENT_MODE_SHARED_CONTINUOUS_REFRESH_KHR, then
418    pname:minImageCount must: be greater than or equal to the value returned
419    in the pname:minImageCount member of the sname:VkSurfaceCapabilitiesKHR
420    structure returned by flink:vkGetPhysicalDeviceSurfaceCapabilitiesKHR
421    for the surface
422  * [[VUID-VkSwapchainCreateInfoKHR-minImageCount-01383]]
423    pname:minImageCount must: be `1` if pname:presentMode is either
424    ename:VK_PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR or
425    ename:VK_PRESENT_MODE_SHARED_CONTINUOUS_REFRESH_KHR
426endif::VK_KHR_shared_presentable_image[]
427  * [[VUID-VkSwapchainCreateInfoKHR-imageFormat-01273]]
428    pname:imageFormat and pname:imageColorSpace must: match the pname:format
429    and pname:colorSpace members, respectively, of one of the
430    sname:VkSurfaceFormatKHR structures returned by
431    fname:vkGetPhysicalDeviceSurfaceFormatsKHR for the surface
432ifndef::VK_EXT_swapchain_maintenance1[]
433  * [[VUID-VkSwapchainCreateInfoKHR-imageExtent-01274]]
434    pname:imageExtent must: be between pname:minImageExtent and
435    pname:maxImageExtent, inclusive, where pname:minImageExtent and
436    pname:maxImageExtent are members of the sname:VkSurfaceCapabilitiesKHR
437    structure returned by fname:vkGetPhysicalDeviceSurfaceCapabilitiesKHR
438    for the surface
439endif::VK_EXT_swapchain_maintenance1[]
440ifdef::VK_EXT_swapchain_maintenance1[]
441  * [[VUID-VkSwapchainCreateInfoKHR-pNext-07781]]
442    If a slink:VkSwapchainPresentScalingCreateInfoEXT structure was not
443    included in the pname:pNext chain, or it is included and
444    slink:VkSwapchainPresentScalingCreateInfoEXT::pname:scalingBehavior is
445    zero then pname:imageExtent must: be between pname:minImageExtent and
446    pname:maxImageExtent, inclusive, where pname:minImageExtent and
447    pname:maxImageExtent are members of the sname:VkSurfaceCapabilitiesKHR
448    structure returned by fname:vkGetPhysicalDeviceSurfaceCapabilitiesKHR
449    for the surface
450  * [[VUID-VkSwapchainCreateInfoKHR-pNext-07782]]
451    If a slink:VkSwapchainPresentScalingCreateInfoEXT structure was included
452    in the pname:pNext chain and
453    slink:VkSwapchainPresentScalingCreateInfoEXT::pname:scalingBehavior is
454    not zero then pname:imageExtent must: be between
455    pname:minScaledImageExtent and pname:maxScaledImageExtent, inclusive,
456    where pname:minScaledImageExtent and pname:maxScaledImageExtent are
457    members of the sname:VkSurfacePresentScalingCapabilitiesEXT structure
458    returned by fname:vkGetPhysicalDeviceSurfaceCapabilities2KHR for the
459    surface and pname:presentMode
460endif::VK_EXT_swapchain_maintenance1[]
461  * [[VUID-VkSwapchainCreateInfoKHR-imageExtent-01689]]
462    pname:imageExtent members pname:width and pname:height must: both be
463    non-zero
464  * [[VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275]]
465    pname:imageArrayLayers must: be greater than `0` and less than or equal
466    to the pname:maxImageArrayLayers member of the
467    sname:VkSurfaceCapabilitiesKHR structure returned by
468    fname:vkGetPhysicalDeviceSurfaceCapabilitiesKHR for the surface
469  * [[VUID-VkSwapchainCreateInfoKHR-presentMode-01427]]
470    If pname:presentMode is ename:VK_PRESENT_MODE_IMMEDIATE_KHR,
471    ename:VK_PRESENT_MODE_MAILBOX_KHR, ename:VK_PRESENT_MODE_FIFO_KHR or
472    ename:VK_PRESENT_MODE_FIFO_RELAXED_KHR, pname:imageUsage must: be a
473    subset of the supported usage flags present in the
474    pname:supportedUsageFlags member of the slink:VkSurfaceCapabilitiesKHR
475    structure returned by flink:vkGetPhysicalDeviceSurfaceCapabilitiesKHR
476    for pname:surface
477ifdef::VK_KHR_shared_presentable_image[]
478  * [[VUID-VkSwapchainCreateInfoKHR-imageUsage-01384]]
479    If pname:presentMode is ename:VK_PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR
480    or ename:VK_PRESENT_MODE_SHARED_CONTINUOUS_REFRESH_KHR, pname:imageUsage
481    must: be a subset of the supported usage flags present in the
482    pname:sharedPresentSupportedUsageFlags member of the
483    slink:VkSharedPresentSurfaceCapabilitiesKHR structure returned by
484    flink:vkGetPhysicalDeviceSurfaceCapabilities2KHR for pname:surface
485endif::VK_KHR_shared_presentable_image[]
486  * [[VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277]]
487    If pname:imageSharingMode is ename:VK_SHARING_MODE_CONCURRENT,
488    pname:pQueueFamilyIndices must: be a valid pointer to an array of
489    pname:queueFamilyIndexCount code:uint32_t values
490  * [[VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278]]
491    If pname:imageSharingMode is ename:VK_SHARING_MODE_CONCURRENT,
492    pname:queueFamilyIndexCount must: be greater than `1`
493ifndef::VK_VERSION_1_1,VK_KHR_get_physical_device_properties2[]
494  * [[VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01393]]
495    If pname:imageSharingMode is ename:VK_SHARING_MODE_CONCURRENT, each
496    element of pname:pQueueFamilyIndices must: be unique and must: be less
497    than pname:pQueueFamilyPropertyCount returned by
498    flink:vkGetPhysicalDeviceQueueFamilyProperties for the
499    pname:physicalDevice that was used to create pname:device
500endif::VK_VERSION_1_1,VK_KHR_get_physical_device_properties2[]
501ifdef::VK_VERSION_1_1,VK_KHR_get_physical_device_properties2[]
502  * [[VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01428]]
503    If pname:imageSharingMode is ename:VK_SHARING_MODE_CONCURRENT, each
504    element of pname:pQueueFamilyIndices must: be unique and must: be less
505    than pname:pQueueFamilyPropertyCount returned by either
506    flink:vkGetPhysicalDeviceQueueFamilyProperties or
507    flink:vkGetPhysicalDeviceQueueFamilyProperties2 for the
508    pname:physicalDevice that was used to create pname:device
509endif::VK_VERSION_1_1,VK_KHR_get_physical_device_properties2[]
510  * [[VUID-VkSwapchainCreateInfoKHR-preTransform-01279]]
511    pname:preTransform must: be one of the bits present in the
512    pname:supportedTransforms member of the sname:VkSurfaceCapabilitiesKHR
513    structure returned by fname:vkGetPhysicalDeviceSurfaceCapabilitiesKHR
514    for the surface
515  * [[VUID-VkSwapchainCreateInfoKHR-compositeAlpha-01280]]
516    pname:compositeAlpha must: be one of the bits present in the
517    pname:supportedCompositeAlpha member of the
518    sname:VkSurfaceCapabilitiesKHR structure returned by
519    fname:vkGetPhysicalDeviceSurfaceCapabilitiesKHR for the surface
520  * [[VUID-VkSwapchainCreateInfoKHR-presentMode-01281]]
521    pname:presentMode must: be one of the elink:VkPresentModeKHR values
522    returned by fname:vkGetPhysicalDeviceSurfacePresentModesKHR for the
523    surface
524ifdef::VK_VERSION_1_1,VK_KHR_device_group[]
525ifndef::VKSC_VERSION_1_0[]
526  * [[VUID-VkSwapchainCreateInfoKHR-physicalDeviceCount-01429]]
527    If the logical device was created with
528    slink:VkDeviceGroupDeviceCreateInfo::pname:physicalDeviceCount equal to
529    1, pname:flags must: not contain
530    ename:VK_SWAPCHAIN_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR
531endif::VKSC_VERSION_1_0[]
532ifdef::VKSC_VERSION_1_0[]
533  * [[VUID-VkSwapchainCreateInfoKHR-flags-05072]]
534    pname:flags must: not contain
535    ename:VK_SWAPCHAIN_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR
536endif::VKSC_VERSION_1_0[]
537endif::VK_VERSION_1_1,VK_KHR_device_group[]
538ifndef::VKSC_VERSION_1_0[]
539  * [[VUID-VkSwapchainCreateInfoKHR-oldSwapchain-01933]]
540    If pname:oldSwapchain is not dlink:VK_NULL_HANDLE, pname:oldSwapchain
541    must: be a non-retired swapchain associated with native window referred
542    to by pname:surface
543endif::VKSC_VERSION_1_0[]
544ifdef::VKSC_VERSION_1_0[]
545  * [[VUID-VkSwapchainCreateInfoKHR-oldSwapchain-05073]]
546    pname:oldSwapchain must: be dlink:VK_NULL_HANDLE
547endif::VKSC_VERSION_1_0[]
548  * [[VUID-VkSwapchainCreateInfoKHR-imageFormat-01778]]
549    The <<swapchain-wsi-image-create-info, implied image creation
550    parameters>> of the swapchain must: be supported as reported by
551    flink:vkGetPhysicalDeviceImageFormatProperties
552ifdef::VK_KHR_swapchain_mutable_format[]
553  * [[VUID-VkSwapchainCreateInfoKHR-flags-03168]]
554    If pname:flags contains ename:VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
555    then the pname:pNext chain must: include a
556    slink:VkImageFormatListCreateInfo structure with a pname:viewFormatCount
557    greater than zero and pname:pViewFormats must: have an element equal to
558    pname:imageFormat
559  * [[VUID-VkSwapchainCreateInfoKHR-pNext-04099]]
560    If a slink:VkImageFormatListCreateInfo structure was included in the
561    pname:pNext chain and
562    slink:VkImageFormatListCreateInfo::pname:viewFormatCount is not zero
563    then all of the formats in
564    slink:VkImageFormatListCreateInfo::pname:pViewFormats must: be
565    compatible with the pname:format as described in the
566    <<formats-compatibility,compatibility table>>
567  * [[VUID-VkSwapchainCreateInfoKHR-flags-04100]]
568    If pname:flags does not contain
569    ename:VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR and the pname:pNext
570    chain include a slink:VkImageFormatListCreateInfo structure then
571    slink:VkImageFormatListCreateInfo::pname:viewFormatCount must: be `0` or
572    `1`
573endif::VK_KHR_swapchain_mutable_format[]
574ifdef::VK_KHR_surface_protected_capabilities[]
575  * [[VUID-VkSwapchainCreateInfoKHR-flags-03187]]
576    If pname:flags contains ename:VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR,
577    then sname:VkSurfaceProtectedCapabilitiesKHR::pname:supportsProtected
578    must: be ename:VK_TRUE in the slink:VkSurfaceProtectedCapabilitiesKHR
579    structure returned by flink:vkGetPhysicalDeviceSurfaceCapabilities2KHR
580    for pname:surface
581endif::VK_KHR_surface_protected_capabilities[]
582ifdef::VK_EXT_full_screen_exclusive+VK_KHR_win32_surface[]
583  * [[VUID-VkSwapchainCreateInfoKHR-pNext-02679]]
584    If the pname:pNext chain includes a
585    slink:VkSurfaceFullScreenExclusiveInfoEXT structure with its
586    pname:fullScreenExclusive member set to
587    ename:VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT, and
588    pname:surface was created using flink:vkCreateWin32SurfaceKHR, a
589    slink:VkSurfaceFullScreenExclusiveWin32InfoEXT structure must: be
590    included in the pname:pNext chain
591endif::VK_EXT_full_screen_exclusive+VK_KHR_win32_surface[]
592ifdef::VK_EXT_image_compression_control[]
593ifndef::VK_EXT_image_compression_control_swapchain[]
594  * [[VUID-VkSwapchainCreateInfoKHR-pNext-06751]]
595    The pname:pNext chain must: not include an
596    slink:VkImageCompressionControlEXT structure
597endif::VK_EXT_image_compression_control_swapchain[]
598ifdef::VK_EXT_image_compression_control_swapchain[]
599  * [[VUID-VkSwapchainCreateInfoKHR-pNext-06752]]
600    If the <<features-imageCompressionControlSwapchain,
601    pname:imageCompressionControlSwapchain>> feature is not enabled, the
602    pname:pNext chain must: not include an
603    slink:VkImageCompressionControlEXT structure
604endif::VK_EXT_image_compression_control_swapchain[]
605endif::VK_EXT_image_compression_control[]
606****
607ifdef::VKSC_VERSION_1_0[]
608ifdef::hidden[]
609// tag::scdeviation[]
610  * slink:VkSwapchainCreateInfoKHR::pname:flags must: not contain
611    ename:VK_SWAPCHAIN_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR
612    <<SCID-8>>.
613  * slink:VkSwapchainCreateInfoKHR::pname:oldSwapchain must: be
614    dlink:VK_NULL_HANDLE <<SCID-4>>.
615// end::scdeviation[]
616endif::hidden[]
617endif::VKSC_VERSION_1_0[]
618
619include::{generated}/validity/structs/VkSwapchainCreateInfoKHR.adoc[]
620--
621
622[open,refpage='VkSwapchainCreateFlagBitsKHR',desc='Bitmask controlling swapchain creation',type='enums']
623--
624Bits which can: be set in slink:VkSwapchainCreateInfoKHR::pname:flags,
625specifying parameters of swapchain creation, are:
626
627include::{generated}/api/enums/VkSwapchainCreateFlagBitsKHR.adoc[]
628
629ifdef::VK_VERSION_1_1,VK_KHR_device_group[]
630  * ename:VK_SWAPCHAIN_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR specifies
631    that images created from the swapchain (i.e. with the pname:swapchain
632    member of slink:VkImageSwapchainCreateInfoKHR set to this swapchain's
633    handle) must: use ename:VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT.
634ifdef::VKSC_VERSION_1_0[]
635    This flag is not supported in Vulkan SC <<SCID-8>>.
636endif::VKSC_VERSION_1_0[]
637endif::VK_VERSION_1_1,VK_KHR_device_group[]
638ifdef::VK_VERSION_1_1[]
639  * ename:VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR specifies that images
640    created from the swapchain are protected images.
641endif::VK_VERSION_1_1[]
642ifdef::VK_KHR_swapchain_mutable_format[]
643  * ename:VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR specifies that the
644    images of the swapchain can: be used to create a sname:VkImageView with
645    a different format than what the swapchain was created with.
646    The list of allowed image view formats is specified by adding a
647    slink:VkImageFormatListCreateInfo structure to the pname:pNext chain of
648    slink:VkSwapchainCreateInfoKHR.
649    In addition, this flag also specifies that the swapchain can: be created
650    with usage flags that are not supported for the format the swapchain is
651    created with but are supported for at least one of the allowed image
652    view formats.
653endif::VK_KHR_swapchain_mutable_format[]
654ifdef::VK_EXT_swapchain_maintenance1[]
655  * ename:VK_SWAPCHAIN_CREATE_DEFERRED_MEMORY_ALLOCATION_BIT_EXT specifies
656    that the implementation may: defer allocation of memory associated with
657    each swapchain image until its index is to be returned from
658    flink:vkAcquireNextImageKHR
659ifdef::VK_VERSION_1_1,VK_KHR_device_group[or flink:vkAcquireNextImage2KHR]
660    for the first time.
661endif::VK_EXT_swapchain_maintenance1[]
662--
663
664[open,refpage='VkSwapchainCreateFlagsKHR',desc='Bitmask of VkSwapchainCreateFlagBitsKHR',type='flags']
665--
666include::{generated}/api/flags/VkSwapchainCreateFlagsKHR.adoc[]
667
668tname:VkSwapchainCreateFlagsKHR is a bitmask type for setting a mask of zero
669or more elink:VkSwapchainCreateFlagBitsKHR.
670--
671
672ifdef::VK_VERSION_1_1,VK_KHR_device_group[]
673[open,refpage='VkDeviceGroupSwapchainCreateInfoKHR',desc='Structure specifying parameters of a newly created swapchain object',type='structs']
674--
675If the pname:pNext chain of slink:VkSwapchainCreateInfoKHR includes a
676sname:VkDeviceGroupSwapchainCreateInfoKHR structure, then that structure
677includes a set of device group present modes that the swapchain can: be used
678with.
679
680The sname:VkDeviceGroupSwapchainCreateInfoKHR structure is defined as:
681
682include::{generated}/api/structs/VkDeviceGroupSwapchainCreateInfoKHR.adoc[]
683
684  * pname:sType is a elink:VkStructureType value identifying this structure.
685  * pname:pNext is `NULL` or a pointer to a structure extending this
686    structure.
687  * pname:modes is a bitfield of modes that the swapchain can: be used with.
688
689If this structure is not present, pname:modes is considered to be
690ename:VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR.
691
692include::{generated}/validity/structs/VkDeviceGroupSwapchainCreateInfoKHR.adoc[]
693--
694endif::VK_VERSION_1_1,VK_KHR_device_group[]
695
696ifdef::VK_AMD_display_native_hdr[]
697[open,refpage='VkSwapchainDisplayNativeHdrCreateInfoAMD',desc='Structure specifying display native HDR parameters of a newly created swapchain object',type='structs']
698--
699If the pname:pNext chain of slink:VkSwapchainCreateInfoKHR includes a
700sname:VkSwapchainDisplayNativeHdrCreateInfoAMD structure, then that
701structure includes additional swapchain creation parameters specific to
702display native HDR support.
703
704The sname:VkSwapchainDisplayNativeHdrCreateInfoAMD structure is defined as:
705
706include::{generated}/api/structs/VkSwapchainDisplayNativeHdrCreateInfoAMD.adoc[]
707
708  * pname:sType is a elink:VkStructureType value identifying this structure.
709  * pname:pNext is `NULL` or a pointer to a structure extending this
710    structure.
711  * pname:localDimmingEnable specifies whether local dimming is enabled for
712    the swapchain.
713
714If the pname:pNext chain of slink:VkSwapchainCreateInfoKHR does not include
715this structure, the default value for pname:localDimmingEnable is
716ename:VK_TRUE, meaning local dimming is initially enabled for the swapchain.
717
718include::{generated}/validity/structs/VkSwapchainDisplayNativeHdrCreateInfoAMD.adoc[]
719
720.Valid Usage
721****
722  * [[VUID-VkSwapchainDisplayNativeHdrCreateInfoAMD-localDimmingEnable-04449]]
723    It is only valid to set pname:localDimmingEnable to ename:VK_TRUE if
724    slink:VkDisplayNativeHdrSurfaceCapabilitiesAMD::pname:localDimmingSupport
725    is supported
726****
727--
728
729[open,refpage='vkSetLocalDimmingAMD',desc='Set Local Dimming',type='protos']
730--
731The local dimming HDR setting may also be changed over the life of a
732swapchain by calling:
733
734include::{generated}/api/protos/vkSetLocalDimmingAMD.adoc[]
735
736  * pname:device is the device associated with pname:swapChain.
737  * pname:swapChain handle to enable local dimming.
738  * pname:localDimmingEnable specifies whether local dimming is enabled for
739    the swapchain.
740
741include::{generated}/validity/protos/vkSetLocalDimmingAMD.adoc[]
742
743.Valid Usage
744****
745  * [[VUID-vkSetLocalDimmingAMD-localDimmingSupport-04618]]
746    slink:VkDisplayNativeHdrSurfaceCapabilitiesAMD::pname:localDimmingSupport
747    must: be supported
748****
749--
750endif::VK_AMD_display_native_hdr[]
751
752ifdef::VK_EXT_full_screen_exclusive[]
753If the pname:pNext chain of slink:VkSwapchainCreateInfoKHR includes a
754slink:VkSurfaceFullScreenExclusiveInfoEXT structure, then that structure
755specifies the application's preferred full-screen presentation behavior.
756If this structure is not present, pname:fullScreenExclusive is considered to
757be ename:VK_FULL_SCREEN_EXCLUSIVE_DEFAULT_EXT.
758endif::VK_EXT_full_screen_exclusive[]
759
760ifdef::VK_EXT_display_control[]
761include::{chapters}/VK_EXT_display_control/swapchain_counters.adoc[]
762endif::VK_EXT_display_control[]
763
764ifdef::VK_EXT_image_compression_control[]
765ifdef::VK_EXT_image_compression_control_swapchain[]
766To specify compression properties for the swapchain images in this
767swapchain, add a slink:VkImageCompressionControlEXT structure to the
768pname:pNext chain of the slink:VkSwapchainCreateInfoKHR structure.
769endif::VK_EXT_image_compression_control_swapchain[]
770endif::VK_EXT_image_compression_control[]
771
772ifdef::VK_EXT_swapchain_maintenance1[]
773include::{chapters}/VK_EXT_swapchain_maintenance1/SwapchainPresentModesCreateInfo.adoc[]
774include::{chapters}/VK_EXT_swapchain_maintenance1/SwapchainPresentScalingCreateInfo.adoc[]
775endif::VK_EXT_swapchain_maintenance1[]
776
777ifdef::VKSC_VERSION_1_0[]
778ifdef::hidden[]
779// tag::scremoved[]
780  * fname:vkDestroySwapchainKHR <<SCID-4>>
781// end::scremoved[]
782endif::hidden[]
783
784Swapchains cannot: be destroyed <<SCID-4>>.
785If
786slink:VkPhysicalDeviceVulkanSC10Properties::<<limits-deviceDestroyFreesMemory,pname:deviceDestroyFreesMemory>>
787is ename:VK_TRUE, the memory for swapchain images is returned to the system
788when the device is destroyed.
789
790endif::VKSC_VERSION_1_0[]
791ifndef::VKSC_VERSION_1_0[]
792[open,refpage='vkDestroySwapchainKHR',desc='Destroy a swapchain object',type='protos']
793--
794To destroy a swapchain object call:
795
796include::{generated}/api/protos/vkDestroySwapchainKHR.adoc[]
797
798  * pname:device is the slink:VkDevice associated with pname:swapchain.
799  * pname:swapchain is the swapchain to destroy.
800  * pname:pAllocator is the allocator used for host memory allocated for the
801    swapchain object when there is no more specific allocator available (see
802    <<memory-allocation,Memory Allocation>>).
803
804The application must: not destroy a swapchain until after completion of all
805outstanding operations on images that were acquired from the swapchain.
806pname:swapchain and all associated sname:VkImage handles are destroyed, and
807must: not be acquired or used any more by the application.
808The memory of each sname:VkImage will only be freed after that image is no
809longer used by the presentation engine.
810For example, if one image of the swapchain is being displayed in a window,
811the memory for that image may: not be freed until the window is destroyed,
812or another swapchain is created for the window.
813Destroying the swapchain does not invalidate the parent sname:VkSurfaceKHR,
814and a new swapchain can: be created with it.
815
816ifdef::VK_KHR_display_swapchain[]
817include::{chapters}/VK_KHR_display_swapchain/destroy_swapchain_interactions.adoc[]
818endif::VK_KHR_display_swapchain[]
819
820ifdef::VK_EXT_full_screen_exclusive[]
821If pname:swapchain has exclusive full-screen access, it is released before
822the swapchain is destroyed.
823endif::VK_EXT_full_screen_exclusive[]
824
825.Valid Usage
826****
827  * [[VUID-vkDestroySwapchainKHR-swapchain-01282]]
828    All uses of presentable images acquired from pname:swapchain must: have
829    completed execution
830ifndef::VKSC_VERSION_1_0[]
831  * [[VUID-vkDestroySwapchainKHR-swapchain-01283]]
832    If sname:VkAllocationCallbacks were provided when pname:swapchain was
833    created, a compatible set of callbacks must: be provided here
834  * [[VUID-vkDestroySwapchainKHR-swapchain-01284]]
835    If no sname:VkAllocationCallbacks were provided when pname:swapchain was
836    created, pname:pAllocator must: be `NULL`
837endif::VKSC_VERSION_1_0[]
838****
839
840include::{generated}/validity/protos/vkDestroySwapchainKHR.adoc[]
841--
842endif::VKSC_VERSION_1_0[]
843
844ifdef::VK_KHR_display_swapchain[]
845include::{chapters}/VK_KHR_display_swapchain/create_shared_swapchains.adoc[]
846endif::VK_KHR_display_swapchain[]
847
848[open,refpage='vkGetSwapchainImagesKHR',desc='Obtain the array of presentable images associated with a swapchain',type='protos']
849--
850:refpage: vkGetSwapchainImagesKHR
851
852To obtain the array of presentable images associated with a swapchain, call:
853
854include::{generated}/api/protos/vkGetSwapchainImagesKHR.adoc[]
855
856  * pname:device is the device associated with pname:swapchain.
857  * pname:swapchain is the swapchain to query.
858  * pname:pSwapchainImageCount is a pointer to an integer related to the
859    number of presentable images available or queried, as described below.
860  * pname:pSwapchainImages is either `NULL` or a pointer to an array of
861    sname:VkImage handles.
862
863If pname:pSwapchainImages is `NULL`, then the number of presentable images
864for pname:swapchain is returned in pname:pSwapchainImageCount.
865Otherwise, pname:pSwapchainImageCount must: point to a variable set by the
866user to the number of elements in the pname:pSwapchainImages array, and on
867return the variable is overwritten with the number of structures actually
868written to pname:pSwapchainImages.
869If the value of pname:pSwapchainImageCount is less than the number of
870presentable images for pname:swapchain, at most pname:pSwapchainImageCount
871structures will be written, and ename:VK_INCOMPLETE will be returned instead
872of ename:VK_SUCCESS, to indicate that not all the available presentable
873images were returned.
874
875include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[]
876
877include::{generated}/validity/protos/vkGetSwapchainImagesKHR.adoc[]
878--
879
880[NOTE]
881.Note
882====
883By knowing all presentable images used in the swapchain, the application can
884create command buffers that reference these images prior to entering its
885main rendering loop.
886ifdef::VK_EXT_swapchain_maintenance1[]
887However, command buffers are not allowed to reference presentable images
888created with ename:VK_SWAPCHAIN_CREATE_DEFERRED_MEMORY_ALLOCATION_BIT_EXT
889until their indices have been returned from flink:vkAcquireNextImageKHR at
890least once.
891endif::VK_EXT_swapchain_maintenance1[]
892====
893
894Images returned by flink:vkGetSwapchainImagesKHR are fully backed by memory
895before they are passed to the application, as if they are each bound
896completely and contiguously to a single sname:VkDeviceMemory object
897ifdef::VK_EXT_swapchain_maintenance1[]
898, unless the swapchain is created with the
899ename:VK_SWAPCHAIN_CREATE_DEFERRED_MEMORY_ALLOCATION_BIT_EXT flag
900endif::VK_EXT_swapchain_maintenance1[]
901.
902All presentable images are initially in the ename:VK_IMAGE_LAYOUT_UNDEFINED
903layout, thus before using presentable images, the application must:
904transition them to a valid layout for the intended use.
905
906ifndef::VKSC_VERSION_1_0[]
907
908Further, the lifetime of presentable images is controlled by the
909implementation, so applications must: not destroy a presentable image.
910See flink:vkDestroySwapchainKHR for further details on the lifetime of
911presentable images.
912
913endif::VKSC_VERSION_1_0[]
914
915ifdef::VK_VERSION_1_1,VK_KHR_device_group[]
916
917Images can: also be created by using flink:vkCreateImage with
918slink:VkImageSwapchainCreateInfoKHR and bound to swapchain memory using
919flink:vkBindImageMemory2 with slink:VkBindImageMemorySwapchainInfoKHR.
920These images can: be used anywhere swapchain images are used, and are useful
921in logical devices with multiple physical devices to create peer memory
922bindings of swapchain memory.
923These images and bindings have no effect on what memory is presented.
924Unlike images retrieved from fname:vkGetSwapchainImagesKHR, these images
925must: be destroyed with flink:vkDestroyImage.
926
927endif::VK_VERSION_1_1,VK_KHR_device_group[]
928
929[open,refpage='vkAcquireNextImageKHR',desc='Retrieve the index of the next available presentable image',type='protos']
930--
931:refpage: vkAcquireNextImageKHR
932
933To acquire an available presentable image to use, and retrieve the index of
934that image, call:
935
936include::{generated}/api/protos/vkAcquireNextImageKHR.adoc[]
937
938  * pname:device is the device associated with pname:swapchain.
939  * pname:swapchain is the non-retired swapchain from which an image is
940    being acquired.
941  * pname:timeout specifies how long the function waits, in nanoseconds, if
942    no image is available.
943  * pname:semaphore is dlink:VK_NULL_HANDLE or a semaphore to signal.
944  * pname:fence is dlink:VK_NULL_HANDLE or a fence to signal.
945  * pname:pImageIndex is a pointer to a code:uint32_t in which the index of
946    the next image to use (i.e. an index into the array of images returned
947    by fname:vkGetSwapchainImagesKHR) is returned.
948
949ifdef::VK_EXT_swapchain_maintenance1[]
950If the pname:swapchain has been created with the
951ename:VK_SWAPCHAIN_CREATE_DEFERRED_MEMORY_ALLOCATION_BIT_EXT flag, the image
952whose index is returned in pname:pImageIndex will be fully backed by memory
953before this call returns to the application, as if it is bound completely
954and contiguously to a single sname:VkDeviceMemory object.
955endif::VK_EXT_swapchain_maintenance1[]
956
957include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[]
958
959.Valid Usage
960****
961  * [[VUID-vkAcquireNextImageKHR-swapchain-01285]]
962    pname:swapchain must: not be in the retired state
963  * [[VUID-vkAcquireNextImageKHR-semaphore-01286]]
964    If pname:semaphore is not dlink:VK_NULL_HANDLE it must: be unsignaled
965  * [[VUID-vkAcquireNextImageKHR-semaphore-01779]]
966    If pname:semaphore is not dlink:VK_NULL_HANDLE it must: not have any
967    uncompleted signal or wait operations pending
968  * [[VUID-vkAcquireNextImageKHR-fence-01287]]
969    If pname:fence is not dlink:VK_NULL_HANDLE it must: be unsignaled and
970    must: not be associated with any other queue command that has not yet
971    completed execution on that queue
972  * [[VUID-vkAcquireNextImageKHR-semaphore-01780]]
973    pname:semaphore and pname:fence must: not both be equal to
974    dlink:VK_NULL_HANDLE
975  * [[VUID-vkAcquireNextImageKHR-surface-07783]]
976    If <<swapchain-acquire-forward-progress,forward progress>> cannot be
977    guaranteed for the pname:surface used to create the pname:swapchain
978    member of pname:pAcquireInfo, the pname:timeout member of
979    pname:pAcquireInfo must: not be code:UINT64_MAX
980ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[]
981  * [[VUID-vkAcquireNextImageKHR-semaphore-03265]]
982    pname:semaphore must: have a elink:VkSemaphoreType of
983    ename:VK_SEMAPHORE_TYPE_BINARY
984endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[]
985****
986
987include::{generated}/validity/protos/vkAcquireNextImageKHR.adoc[]
988--
989
990If an image is acquired successfully, fname:vkAcquireNextImageKHR must:
991either return ename:VK_SUCCESS or ename:VK_SUBOPTIMAL_KHR.
992The implementation may: return ename:VK_SUBOPTIMAL_KHR if the swapchain no
993longer matches the surface properties exactly, but can: still be used for
994presentation.
995
996When successful, fname:vkAcquireNextImageKHR acquires a presentable image
997from pname:swapchain that an application can: use, and sets
998pname:pImageIndex to the index of that image within the swapchain.
999The presentation engine may: not have finished reading from the image at the
1000time it is acquired, so the application must: use pname:semaphore and/or
1001pname:fence to ensure that the image layout and contents are not modified
1002until the presentation engine reads have completed.
1003Once fname:vkAcquireNextImageKHR successfully acquires an image, the
1004semaphore signal operation referenced by pname:semaphore, if not
1005dlink:VK_NULL_HANDLE, and the fence signal operation referenced by
1006pname:fence, if not dlink:VK_NULL_HANDLE, are submitted for execution.
1007If fname:vkAcquireNextImageKHR does not successfully acquire an image,
1008pname:semaphore and pname:fence are unaffected.
1009The order in which images are acquired is implementation-dependent, and may:
1010be different than the order the images were presented.
1011
1012If pname:timeout is zero, then fname:vkAcquireNextImageKHR does not wait,
1013and will either successfully acquire an image, or fail and return
1014ename:VK_NOT_READY if no image is available.
1015
1016If the specified timeout period expires before an image is acquired,
1017fname:vkAcquireNextImageKHR returns ename:VK_TIMEOUT.
1018If pname:timeout is code:UINT64_MAX, the timeout period is treated as
1019infinite, and fname:vkAcquireNextImageKHR will block until an image is
1020acquired or an error occurs.
1021
1022[[swapchain-acquire-forward-progress]]
1023Let [eq]#S# be the number of images in pname:swapchain.
1024ifndef::VK_EXT_swapchain_maintenance1[]
1025Let [eq]#M# be the value of
1026slink:VkSurfaceCapabilitiesKHR::pname:minImageCount.
1027endif::VK_EXT_swapchain_maintenance1[]
1028ifdef::VK_EXT_swapchain_maintenance1[]
1029If pname:swapchain is created with
1030slink:VkSwapchainPresentModesCreateInfoEXT, let [eq]#M# be the maximum of
1031the values in slink:VkSurfaceCapabilitiesKHR::pname:minImageCount when
1032queried with each present mode in
1033slink:VkSwapchainPresentModesCreateInfoEXT::pname:pPresentModes in
1034slink:VkSurfacePresentModeEXT.
1035Otherwise, let [eq]#M# be the value of
1036slink:VkSurfaceCapabilitiesKHR::pname:minImageCount without a
1037slink:VkSurfacePresentModeEXT as part of the query input.
1038endif::VK_EXT_swapchain_maintenance1[]
1039
1040fname:vkAcquireNextImageKHR should: not be called if the number of images
1041that the application has currently acquired is greater than [eq]#S-M#.
1042If fname:vkAcquireNextImageKHR is called when the number of images that the
1043application has currently acquired is less than or equal to [eq]#S-M#,
1044fname:vkAcquireNextImageKHR must: return in finite time with an allowed
1045ename:VkResult code.
1046
1047[NOTE]
1048.Note
1049====
1050Returning a result in finite time guarantees that the implementation cannot
1051deadlock an application, or suspend its execution indefinitely with correct
1052API usage.
1053Acquiring too many images at once may block indefinitely, which is covered
1054by valid usage when attempting to use code:UINT64_MAX.
1055For example, a scenario here is when a compositor holds on to images which
1056are currently being presented, and there are not any vacant images left to
1057be acquired.
1058====
1059
1060[NOTE]
1061.Note
1062====
1063ename:VK_SUBOPTIMAL_KHR may: happen, for example, if the platform surface
1064has been resized but the platform is able to scale the presented images to
1065the new size to produce valid surface updates.
1066It is up to the application to decide whether it prefers to continue using
1067the current swapchain in this state, or to re-create the swapchain to better
1068match the platform surface properties.
1069====
1070
1071If the swapchain images no longer match native surface properties, either
1072ename:VK_SUBOPTIMAL_KHR or ename:VK_ERROR_OUT_OF_DATE_KHR must: be returned.
1073If ename:VK_ERROR_OUT_OF_DATE_KHR is returned, no image is acquired and
1074attempts to present previously acquired images to the swapchain will also
1075fail with ename:VK_ERROR_OUT_OF_DATE_KHR.
1076Applications need to create a new swapchain for the surface to continue
1077presenting if ename:VK_ERROR_OUT_OF_DATE_KHR is returned.
1078
1079If device loss occurs (see <<devsandqueues-lost-device,Lost Device>>) before
1080the timeout has expired, fname:vkAcquireNextImageKHR must: return in finite
1081time with either one of the allowed success codes, or
1082ename:VK_ERROR_DEVICE_LOST.
1083
1084If pname:semaphore is not dlink:VK_NULL_HANDLE, the semaphore must: be
1085unsignaled, with no signal or wait operations pending.
1086It will become signaled when the application can: use the image.
1087
1088[NOTE]
1089.Note
1090====
1091Use of pname:semaphore allows rendering operations to be recorded and
1092submitted before the presentation engine has completed its use of the image.
1093====
1094
1095If pname:fence is not equal to dlink:VK_NULL_HANDLE, the fence must: be
1096unsignaled, with no signal operations pending.
1097It will become signaled when the application can: use the image.
1098
1099[NOTE]
1100.Note
1101====
1102Applications should: not rely on fname:vkAcquireNextImageKHR blocking in
1103order to meter their rendering speed.
1104The implementation may: return from this function immediately regardless of
1105how many presentation requests are queued, and regardless of when queued
1106presentation requests will complete relative to the call.
1107Instead, applications can: use pname:fence to meter their frame generation
1108work to match the presentation rate.
1109====
1110
1111An application must: wait until either the pname:semaphore or pname:fence is
1112signaled before accessing the image's data.
1113
1114[NOTE]
1115.Note
1116====
1117When the presentable image will be accessed by some stage [eq]#S#, the
1118recommended idiom for ensuring correct synchronization is:
1119
1120  * The slink:VkSubmitInfo used to submit the image layout transition for
1121    execution includes fname:vkAcquireNextImageKHR::pname:semaphore in its
1122    pname:pWaitSemaphores member, with the corresponding element of
1123    pname:pWaitDstStageMask including [eq]#S#.
1124  * The <<synchronization, synchronization command>> that performs any
1125    necessary image layout transition includes [eq]#S# in both the
1126    pname:srcStageMask and pname:dstStageMask.
1127====
1128
1129After a successful return, the image indicated by pname:pImageIndex and its
1130data will be unmodified compared to when it was presented.
1131
1132[NOTE]
1133.Note
1134====
1135Exclusive ownership of presentable images corresponding to a swapchain
1136created with ename:VK_SHARING_MODE_EXCLUSIVE as defined in
1137<<resources-sharing,Resource Sharing>> is not altered by a call to
1138fname:vkAcquireNextImageKHR.
1139That means upon the first acquisition from such a swapchain presentable
1140images are not owned by any queue family, while at subsequent acquisitions
1141the presentable images remain owned by the queue family the image was
1142previously presented on.
1143====
1144
1145The possible return values for fname:vkAcquireNextImageKHR depend on the
1146pname:timeout provided:
1147
1148  * ename:VK_SUCCESS is returned if an image became available.
1149  * ename:VK_ERROR_SURFACE_LOST_KHR is returned if the surface becomes no
1150    longer available.
1151  * ename:VK_NOT_READY is returned if pname:timeout is zero and no image was
1152    available.
1153  * ename:VK_TIMEOUT is returned if pname:timeout is greater than zero and
1154    less than code:UINT64_MAX, and no image became available within the time
1155    allowed.
1156  * ename:VK_SUBOPTIMAL_KHR is returned if an image became available, and
1157    the swapchain no longer matches the surface properties exactly, but can:
1158    still be used to present to the surface successfully.
1159
1160[NOTE]
1161.Note
1162====
1163This may: happen, for example, if the platform surface has been resized but
1164the platform is able to scale the presented images to the new size to
1165produce valid surface updates.
1166It is up to the application to decide whether it prefers to continue using
1167the current swapchain indefinitely or temporarily in this state, or to
1168re-create the swapchain to better match the platform surface properties.
1169====
1170
1171  * ename:VK_ERROR_OUT_OF_DATE_KHR is returned if the surface has changed in
1172    such a way that it is no longer compatible with the swapchain, and
1173    further presentation requests using the swapchain will fail.
1174    Applications must: query the new surface properties and recreate their
1175    swapchain if they wish to continue presenting to the surface.
1176
1177If the native surface and presented image sizes no longer match,
1178presentation may: fail
1179ifdef::VK_EXT_swapchain_maintenance1[]
1180unless the swapchain is created with a non-zero value in
1181slink:VkSwapchainPresentScalingCreateInfoEXT::pname:scalingBehavior
1182endif::VK_EXT_swapchain_maintenance1[]
1183.
1184If presentation does succeed, the mapping from the presented image to the
1185native surface is
1186ifdef::VK_EXT_swapchain_maintenance1[]
1187defined by the slink:VkSwapchainPresentScalingCreateInfoEXT structure if
1188provided.
1189Otherwise it is
1190endif::VK_EXT_swapchain_maintenance1[]
1191implementation-defined.
1192It is the application's responsibility to detect surface size changes and
1193react appropriately.
1194If presentation fails because of a mismatch in the surface and presented
1195image sizes, a ename:VK_ERROR_OUT_OF_DATE_KHR error will be returned.
1196
1197[NOTE]
1198.Note
1199====
1200For example, consider a 4x3 window/surface that gets resized to be 3x4
1201(taller than wider).
1202On some window systems, the portion of the window/surface that was
1203previously and still is visible (the 3x3 part) will contain the same
1204contents as before, while the remaining parts of the window will have
1205undefined: contents.
1206Other window systems may: squash/stretch the image to fill the new window
1207size without any undefined: contents, or apply some other mapping.
1208====
1209
1210ifdef::VK_VERSION_1_1,VK_KHR_device_group[]
1211[open,refpage='vkAcquireNextImage2KHR',desc='Retrieve the index of the next available presentable image',type='protos']
1212--
1213:refpage: vkAcquireNextImage2KHR
1214
1215To acquire an available presentable image to use, and retrieve the index of
1216that image, call:
1217
1218include::{generated}/api/protos/vkAcquireNextImage2KHR.adoc[]
1219
1220  * pname:device is the device associated with pname:swapchain.
1221  * pname:pAcquireInfo is a pointer to a slink:VkAcquireNextImageInfoKHR
1222    structure containing parameters of the acquire.
1223  * pname:pImageIndex is a pointer to a code:uint32_t that is set to the
1224    index of the next image to use.
1225
1226ifdef::VK_EXT_swapchain_maintenance1[]
1227If the pname:swapchain has been created with the
1228ename:VK_SWAPCHAIN_CREATE_DEFERRED_MEMORY_ALLOCATION_BIT_EXT flag, the image
1229whose index is returned in pname:pImageIndex will be fully backed by memory
1230before this call returns to the application.
1231endif::VK_EXT_swapchain_maintenance1[]
1232
1233include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[]
1234
1235.Valid Usage
1236****
1237  * [[VUID-vkAcquireNextImage2KHR-surface-07784]]
1238    If <<swapchain-acquire-forward-progress,forward progress>> cannot be
1239    guaranteed for the pname:surface used to create pname:swapchain, the
1240    pname:timeout member of pname:pAcquireInfo must: not be code:UINT64_MAX
1241****
1242
1243include::{generated}/validity/protos/vkAcquireNextImage2KHR.adoc[]
1244--
1245
1246[open,refpage='VkAcquireNextImageInfoKHR',desc='Structure specifying parameters of the acquire',type='structs']
1247--
1248The sname:VkAcquireNextImageInfoKHR structure is defined as:
1249
1250include::{generated}/api/structs/VkAcquireNextImageInfoKHR.adoc[]
1251
1252  * pname:sType is a elink:VkStructureType value identifying this structure.
1253  * pname:pNext is `NULL` or a pointer to a structure extending this
1254    structure.
1255  * pname:swapchain is a non-retired swapchain from which an image is
1256    acquired.
1257  * pname:timeout specifies how long the function waits, in nanoseconds, if
1258    no image is available.
1259  * pname:semaphore is dlink:VK_NULL_HANDLE or a semaphore to signal.
1260  * pname:fence is dlink:VK_NULL_HANDLE or a fence to signal.
1261  * pname:deviceMask is a mask of physical devices for which the swapchain
1262    image will be ready to use when the semaphore or fence is signaled.
1263
1264If flink:vkAcquireNextImageKHR is used, the device mask is considered to
1265include all physical devices in the logical device.
1266
1267[NOTE]
1268.Note
1269====
1270flink:vkAcquireNextImage2KHR signals at most one semaphore, even if the
1271application requests waiting for multiple physical devices to be ready via
1272the pname:deviceMask.
1273However, only a single physical device can: wait on that semaphore, since
1274the semaphore becomes unsignaled when the wait succeeds.
1275For other physical devices to wait for the image to be ready, it is
1276necessary for the application to submit semaphore signal operation(s) to
1277that first physical device to signal additional semaphore(s) after the wait
1278succeeds, which the other physical device(s) can: wait upon.
1279====
1280
1281.Valid Usage
1282****
1283  * [[VUID-VkAcquireNextImageInfoKHR-swapchain-01675]]
1284    pname:swapchain must: not be in the retired state
1285  * [[VUID-VkAcquireNextImageInfoKHR-semaphore-01288]]
1286    If pname:semaphore is not dlink:VK_NULL_HANDLE it must: be unsignaled
1287  * [[VUID-VkAcquireNextImageInfoKHR-semaphore-01781]]
1288    If pname:semaphore is not dlink:VK_NULL_HANDLE it must: not have any
1289    uncompleted signal or wait operations pending
1290  * [[VUID-VkAcquireNextImageInfoKHR-fence-01289]]
1291    If pname:fence is not dlink:VK_NULL_HANDLE it must: be unsignaled and
1292    must: not be associated with any other queue command that has not yet
1293    completed execution on that queue
1294  * [[VUID-VkAcquireNextImageInfoKHR-semaphore-01782]]
1295    pname:semaphore and pname:fence must: not both be equal to
1296    dlink:VK_NULL_HANDLE
1297  * [[VUID-VkAcquireNextImageInfoKHR-deviceMask-01290]]
1298    pname:deviceMask must: be a valid device mask
1299  * [[VUID-VkAcquireNextImageInfoKHR-deviceMask-01291]]
1300    pname:deviceMask must: not be zero
1301ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[]
1302  * [[VUID-VkAcquireNextImageInfoKHR-semaphore-03266]]
1303    pname:semaphore must: have a elink:VkSemaphoreType of
1304    ename:VK_SEMAPHORE_TYPE_BINARY
1305endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[]
1306****
1307
1308include::{generated}/validity/structs/VkAcquireNextImageInfoKHR.adoc[]
1309--
1310endif::VK_VERSION_1_1,VK_KHR_device_group[]
1311
1312[open,refpage='vkQueuePresentKHR',desc='Queue an image for presentation',type='protos']
1313--
1314:refpage: vkQueuePresentKHR
1315
1316After queueing all rendering commands and transitioning the image to the
1317correct layout, to queue an image for presentation, call:
1318
1319include::{generated}/api/protos/vkQueuePresentKHR.adoc[]
1320
1321  * pname:queue is a queue that is capable of presentation to the target
1322    surface's platform on the same device as the image's swapchain.
1323  * pname:pPresentInfo is a pointer to a slink:VkPresentInfoKHR structure
1324    specifying parameters of the presentation.
1325
1326.Note
1327[NOTE]
1328====
1329There is no requirement for an application to present images in the same
1330order that they were acquired - applications can arbitrarily present any
1331image that is currently acquired.
1332====
1333
1334include::{chapters}/commonvalidity/no_dynamic_allocations_common.adoc[]
1335
1336.Valid Usage
1337****
1338  * [[VUID-vkQueuePresentKHR-pSwapchains-01292]]
1339    Each element of pname:pSwapchains member of pname:pPresentInfo must: be
1340    a swapchain that is created for a surface for which presentation is
1341    supported from pname:queue as determined using a call to
1342    fname:vkGetPhysicalDeviceSurfaceSupportKHR
1343ifdef::VK_KHR_display_swapchain[]
1344  * [[VUID-vkQueuePresentKHR-pSwapchains-01293]]
1345    If more than one member of pname:pSwapchains was created from a display
1346    surface, all display surfaces referenced that refer to the same display
1347    must: use the same display mode
1348endif::VK_KHR_display_swapchain[]
1349  * [[VUID-vkQueuePresentKHR-pWaitSemaphores-01294]]
1350    When a semaphore wait operation referring to a binary semaphore defined
1351    by the elements of the pname:pWaitSemaphores member of
1352    pname:pPresentInfo executes on pname:queue, there must: be no other
1353    queues waiting on the same semaphore
1354ifndef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[]
1355  * [[VUID-vkQueuePresentKHR-pWaitSemaphores-01295]]
1356    All elements of the pname:pWaitSemaphores member of pname:pPresentInfo
1357    must: be semaphores that are signaled, or have
1358    <<synchronization-semaphores-signaling, semaphore signal operations>>
1359    previously submitted for execution
1360endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[]
1361ifdef::VK_VERSION_1_2,VK_KHR_timeline_semaphore[]
1362  * [[VUID-vkQueuePresentKHR-pWaitSemaphores-03267]]
1363    All elements of the pname:pWaitSemaphores member of pname:pPresentInfo
1364    must: be created with a elink:VkSemaphoreType of
1365    ename:VK_SEMAPHORE_TYPE_BINARY
1366  * [[VUID-vkQueuePresentKHR-pWaitSemaphores-03268]]
1367    All elements of the pname:pWaitSemaphores member of pname:pPresentInfo
1368    must: reference a semaphore signal operation that has been submitted for
1369    execution and any <<synchronization-semaphores-signaling, semaphore
1370    signal operations>> on which it depends (if any) must: have also been
1371    submitted for execution
1372endif::VK_VERSION_1_2,VK_KHR_timeline_semaphore[]
1373****
1374
1375Any writes to memory backing the images referenced by the
1376pname:pImageIndices and pname:pSwapchains members of pname:pPresentInfo,
1377that are available before flink:vkQueuePresentKHR is executed, are
1378automatically made visible to the read access performed by the presentation
1379engine.
1380This automatic visibility operation for an image happens-after the semaphore
1381signal operation, and happens-before the presentation engine accesses the
1382image.
1383
1384Queueing an image for presentation defines a set of _queue operations_,
1385including waiting on the semaphores and submitting a presentation request to
1386the presentation engine.
1387However, the scope of this set of queue operations does not include the
1388actual processing of the image by the presentation engine.
1389
1390.Note
1391[NOTE]
1392====
1393The origin of the native orientation of the surface coordinate system is not
1394specified in the Vulkan specification; it depends on the platform.
1395For most platforms the origin is by default upper-left, meaning the pixel of
1396the presented slink:VkImage at coordinates [eq]#(0,0)# would appear at the
1397upper left pixel of the platform surface (assuming
1398ename:VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR, and the display standing the
1399right way up).
1400====
1401
1402If fname:vkQueuePresentKHR fails to enqueue the corresponding set of queue
1403operations, it may: return ename:VK_ERROR_OUT_OF_HOST_MEMORY or
1404ename:VK_ERROR_OUT_OF_DEVICE_MEMORY.
1405If it does, the implementation must: ensure that the state and contents of
1406any resources or synchronization primitives referenced is unaffected by the
1407call or its failure.
1408
1409If fname:vkQueuePresentKHR fails in such a way that the implementation is
1410unable to make that guarantee, the implementation must: return
1411ename:VK_ERROR_DEVICE_LOST.
1412
1413However, if the presentation request is rejected by the presentation engine
1414with an error ename:VK_ERROR_OUT_OF_DATE_KHR,
1415ifdef::VK_EXT_full_screen_exclusive[]
1416ename:VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT,
1417endif::VK_EXT_full_screen_exclusive[]
1418or ename:VK_ERROR_SURFACE_LOST_KHR, the set of queue operations are still
1419considered to be enqueued and thus any semaphore wait operation specified in
1420slink:VkPresentInfoKHR will execute when the corresponding queue operation
1421is complete.
1422
1423Calls to fname:vkQueuePresentKHR may: block, but must: return in finite
1424time.
1425
1426ifdef::VK_EXT_full_screen_exclusive[]
1427If any pname:swapchain member of pname:pPresentInfo was created with
1428ename:VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT,
1429ename:VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT will be returned if that
1430swapchain does not have exclusive full-screen access, possibly for
1431implementation-specific reasons outside of the application's control.
1432endif::VK_EXT_full_screen_exclusive[]
1433
1434include::{generated}/validity/protos/vkQueuePresentKHR.adoc[]
1435--
1436
1437[open,refpage='VkPresentInfoKHR',desc='Structure describing parameters of a queue presentation',type='structs']
1438--
1439The sname:VkPresentInfoKHR structure is defined as:
1440
1441include::{generated}/api/structs/VkPresentInfoKHR.adoc[]
1442
1443  * pname:sType is a elink:VkStructureType value identifying this structure.
1444  * pname:pNext is `NULL` or a pointer to a structure extending this
1445    structure.
1446  * pname:waitSemaphoreCount is the number of semaphores to wait for before
1447    issuing the present request.
1448    The number may: be zero.
1449  * pname:pWaitSemaphores is `NULL` or a pointer to an array of
1450    slink:VkSemaphore objects with pname:waitSemaphoreCount entries, and
1451    specifies the semaphores to wait for before issuing the present request.
1452  * pname:swapchainCount is the number of swapchains being presented to by
1453    this command.
1454  * pname:pSwapchains is a pointer to an array of slink:VkSwapchainKHR
1455    objects with pname:swapchainCount entries.
1456  * pname:pImageIndices is a pointer to an array of indices into the array
1457    of each swapchain's presentable images, with pname:swapchainCount
1458    entries.
1459    Each entry in this array identifies the image to present on the
1460    corresponding entry in the pname:pSwapchains array.
1461  * pname:pResults is a pointer to an array of elink:VkResult typed elements
1462    with pname:swapchainCount entries.
1463    Applications that do not need per-swapchain results can: use `NULL` for
1464    pname:pResults.
1465    If non-`NULL`, each entry in pname:pResults will be set to the
1466    elink:VkResult for presenting the swapchain corresponding to the same
1467    index in pname:pSwapchains.
1468
1469Before an application can: present an image, the image's layout must: be
1470transitioned to the ename:VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
1471ifdef::VK_KHR_shared_presentable_image[]
1472layout, or for a shared presentable image the
1473ename:VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR
1474endif::VK_KHR_shared_presentable_image[]
1475layout.
1476
1477.Note
1478[NOTE]
1479====
1480When transitioning the image to
1481ifdef::VK_KHR_shared_presentable_image[]
1482ename:VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR or
1483endif::VK_KHR_shared_presentable_image[]
1484ename:VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, there is no need to delay subsequent
1485processing, or perform any visibility operations (as flink:vkQueuePresentKHR
1486performs automatic visibility operations).
1487To achieve this, the pname:dstAccessMask member of the
1488slink:VkImageMemoryBarrier should: be set to `0`, and the pname:dstStageMask
1489parameter should: be set to ename:VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT.
1490====
1491
1492.Valid Usage
1493****
1494  * [[VUID-VkPresentInfoKHR-pSwapchain-09231]]
1495    Elements of pname:pSwapchain must: be unique
1496ifndef::VK_KHR_shared_presentable_image[]
1497  * [[VUID-VkPresentInfoKHR-pImageIndices-01296]]
1498    Each element of pname:pImageIndices must: be the index of a presentable
1499    image acquired from the swapchain specified by the corresponding element
1500    of the pname:pSwapchains array, and the presented image subresource
1501    must: be in the ename:VK_IMAGE_LAYOUT_PRESENT_SRC_KHR layout at the time
1502    the operation is executed on a sname:VkDevice
1503endif::VK_KHR_shared_presentable_image[]
1504ifdef::VK_KHR_shared_presentable_image[]
1505  * [[VUID-VkPresentInfoKHR-pImageIndices-01430]]
1506    Each element of pname:pImageIndices must: be the index of a presentable
1507    image acquired from the swapchain specified by the corresponding element
1508    of the pname:pSwapchains array, and the presented image subresource
1509    must: be in the ename:VK_IMAGE_LAYOUT_PRESENT_SRC_KHR or
1510    ename:VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR layout at the time the
1511    operation is executed on a sname:VkDevice
1512endif::VK_KHR_shared_presentable_image[]
1513ifdef::VK_KHR_present_id[]
1514  * [[VUID-VkPresentInfoKHR-pNext-06235]]
1515    If a slink:VkPresentIdKHR structure is included in the pname:pNext
1516    chain, and the <<features-presentId, pname:presentId>> feature is not
1517    enabled, each pname:presentIds entry in that structure must: be NULL
1518endif::VK_KHR_present_id[]
1519ifdef::VK_EXT_swapchain_maintenance1[]
1520  * [[VUID-VkPresentInfoKHR-pSwapchains-09199]]
1521    If any element of the pname:pSwapchains array has been created with
1522    slink:VkSwapchainPresentModesCreateInfoEXT, all of the elements of this
1523    array must: be created with slink:VkSwapchainPresentModesCreateInfoEXT
1524endif::VK_EXT_swapchain_maintenance1[]
1525****
1526
1527include::{generated}/validity/structs/VkPresentInfoKHR.adoc[]
1528--
1529
1530ifdef::VK_KHR_incremental_present[]
1531include::{chapters}/VK_KHR_incremental_present/wsi.adoc[]
1532endif::VK_KHR_incremental_present[]
1533
1534ifdef::VK_KHR_display_swapchain[]
1535include::{chapters}/VK_KHR_display_swapchain/display_swapchain_present.adoc[]
1536endif::VK_KHR_display_swapchain[]
1537
1538ifdef::VK_VERSION_1_1,VK_KHR_device_group[]
1539[open,refpage='VkDeviceGroupPresentInfoKHR',desc='Mode and mask controlling which physical devices\' images are presented',type='structs']
1540--
1541If the pname:pNext chain of slink:VkPresentInfoKHR includes a
1542sname:VkDeviceGroupPresentInfoKHR structure, then that structure includes an
1543array of device masks and a device group present mode.
1544
1545The sname:VkDeviceGroupPresentInfoKHR structure is defined as:
1546
1547include::{generated}/api/structs/VkDeviceGroupPresentInfoKHR.adoc[]
1548
1549  * pname:sType is a elink:VkStructureType value identifying this structure.
1550  * pname:pNext is `NULL` or a pointer to a structure extending this
1551    structure.
1552  * pname:swapchainCount is zero or the number of elements in
1553    pname:pDeviceMasks.
1554  * pname:pDeviceMasks is a pointer to an array of device masks, one for
1555    each element of slink:VkPresentInfoKHR::pname:pSwapchains.
1556  * pname:mode is a elink:VkDeviceGroupPresentModeFlagBitsKHR value
1557    specifying the device group present mode that will be used for this
1558    present.
1559
1560If pname:mode is ename:VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR, then each
1561element of pname:pDeviceMasks selects which instance of the swapchain image
1562is presented.
1563Each element of pname:pDeviceMasks must: have exactly one bit set, and the
1564corresponding physical device must: have a presentation engine as reported
1565by slink:VkDeviceGroupPresentCapabilitiesKHR.
1566
1567If pname:mode is ename:VK_DEVICE_GROUP_PRESENT_MODE_REMOTE_BIT_KHR, then
1568each element of pname:pDeviceMasks selects which instance of the swapchain
1569image is presented.
1570Each element of pname:pDeviceMasks must: have exactly one bit set, and some
1571physical device in the logical device must: include that bit in its
1572slink:VkDeviceGroupPresentCapabilitiesKHR::pname:presentMask.
1573
1574If pname:mode is ename:VK_DEVICE_GROUP_PRESENT_MODE_SUM_BIT_KHR, then each
1575element of pname:pDeviceMasks selects which instances of the swapchain image
1576are component-wise summed and the sum of those images is presented.
1577If the sum in any component is outside the representable range, the value of
1578that component is undefined:.
1579Each element of pname:pDeviceMasks must: have a value for which all set bits
1580are set in one of the elements of
1581slink:VkDeviceGroupPresentCapabilitiesKHR::pname:presentMask.
1582
1583If pname:mode is
1584ename:VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_MULTI_DEVICE_BIT_KHR, then each
1585element of pname:pDeviceMasks selects which instance(s) of the swapchain
1586images are presented.
1587For each bit set in each element of pname:pDeviceMasks, the corresponding
1588physical device must: have a presentation engine as reported by
1589slink:VkDeviceGroupPresentCapabilitiesKHR.
1590
1591If sname:VkDeviceGroupPresentInfoKHR is not provided or pname:swapchainCount
1592is zero then the masks are considered to be `1`.
1593If sname:VkDeviceGroupPresentInfoKHR is not provided, pname:mode is
1594considered to be ename:VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR.
1595
1596.Valid Usage
1597****
1598  * [[VUID-VkDeviceGroupPresentInfoKHR-swapchainCount-01297]]
1599    pname:swapchainCount must: equal `0` or
1600    slink:VkPresentInfoKHR::pname:swapchainCount
1601  * [[VUID-VkDeviceGroupPresentInfoKHR-mode-01298]]
1602    If pname:mode is ename:VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR, then
1603    each element of pname:pDeviceMasks must: have exactly one bit set, and
1604    the corresponding element of
1605    slink:VkDeviceGroupPresentCapabilitiesKHR::pname:presentMask must: be
1606    non-zero
1607  * [[VUID-VkDeviceGroupPresentInfoKHR-mode-01299]]
1608    If pname:mode is ename:VK_DEVICE_GROUP_PRESENT_MODE_REMOTE_BIT_KHR, then
1609    each element of pname:pDeviceMasks must: have exactly one bit set, and
1610    some physical device in the logical device must: include that bit in its
1611    slink:VkDeviceGroupPresentCapabilitiesKHR::pname:presentMask
1612  * [[VUID-VkDeviceGroupPresentInfoKHR-mode-01300]]
1613    If pname:mode is ename:VK_DEVICE_GROUP_PRESENT_MODE_SUM_BIT_KHR, then
1614    each element of pname:pDeviceMasks must: have a value for which all set
1615    bits are set in one of the elements of
1616    slink:VkDeviceGroupPresentCapabilitiesKHR::pname:presentMask
1617  * [[VUID-VkDeviceGroupPresentInfoKHR-mode-01301]]
1618    If pname:mode is
1619    ename:VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_MULTI_DEVICE_BIT_KHR, then for
1620    each bit set in each element of pname:pDeviceMasks, the corresponding
1621    element of slink:VkDeviceGroupPresentCapabilitiesKHR::pname:presentMask
1622    must: be non-zero
1623  * [[VUID-VkDeviceGroupPresentInfoKHR-pDeviceMasks-01302]]
1624    The value of each element of pname:pDeviceMasks must: be equal to the
1625    device mask passed in slink:VkAcquireNextImageInfoKHR::pname:deviceMask
1626    when the image index was last acquired
1627  * [[VUID-VkDeviceGroupPresentInfoKHR-mode-01303]]
1628    pname:mode must: have exactly one bit set, and that bit must: have been
1629    included in slink:VkDeviceGroupSwapchainCreateInfoKHR::pname:modes
1630****
1631
1632include::{generated}/validity/structs/VkDeviceGroupPresentInfoKHR.adoc[]
1633--
1634endif::VK_VERSION_1_1,VK_KHR_device_group[]
1635
1636ifdef::VK_GOOGLE_display_timing[]
1637include::{chapters}/VK_GOOGLE_display_timing/PresentTimeInfo.adoc[]
1638endif::VK_GOOGLE_display_timing[]
1639
1640ifdef::VK_KHR_present_id[]
1641include::{chapters}/VK_KHR_swapchain/PresentId.adoc[]
1642endif::VK_KHR_present_id[]
1643
1644ifdef::VK_GGP_frame_token[]
1645include::{chapters}/VK_GGP_frame_token.adoc[]
1646endif::VK_GGP_frame_token[]
1647
1648ifdef::VK_EXT_swapchain_maintenance1[]
1649include::{chapters}/VK_EXT_swapchain_maintenance1/SwapchainPresentModeInfo.adoc[]
1650include::{chapters}/VK_EXT_swapchain_maintenance1/SwapchainPresentFenceInfo.adoc[]
1651endif::VK_EXT_swapchain_maintenance1[]
1652
1653fname:vkQueuePresentKHR releases the acquisition of the images referenced by
1654pname:imageIndices.
1655The queue family corresponding to the queue fname:vkQueuePresentKHR is
1656executed on must: have ownership of the presented images as defined in
1657<<resources-sharing,Resource Sharing>>.
1658fname:vkQueuePresentKHR does not alter the queue family ownership, but the
1659presented images must: not be used again before they have been reacquired
1660using fname:vkAcquireNextImageKHR.
1661
1662The processing of the presentation happens in issue order with other queue
1663operations, but semaphores have to be used to ensure that prior rendering
1664and other commands in the specified queue complete before the presentation
1665begins.
1666The presentation command itself does not delay processing of subsequent
1667commands on the queue, however, presentation requests sent to a particular
1668queue are always performed in order.
1669Exact presentation timing is controlled by the semantics of the presentation
1670engine and native platform in use.
1671
1672ifdef::VK_KHR_display_swapchain[]
1673include::{chapters}/VK_KHR_display_swapchain/queue_present_interactions.adoc[]
1674endif::VK_KHR_display_swapchain[]
1675
1676The result codes ename:VK_ERROR_OUT_OF_DATE_KHR and ename:VK_SUBOPTIMAL_KHR
1677have the same meaning when returned by fname:vkQueuePresentKHR as they do
1678when returned by fname:vkAcquireNextImageKHR.
1679If multiple swapchains are presented, the result code is determined applying
1680the following rules in order:
1681
1682  * If the device is lost, ename:VK_ERROR_DEVICE_LOST is returned.
1683  * If any of the target surfaces are no longer available the error
1684    ename:VK_ERROR_SURFACE_LOST_KHR is returned.
1685  * If any of the presents would have a result of
1686    ename:VK_ERROR_OUT_OF_DATE_KHR if issued separately then
1687    ename:VK_ERROR_OUT_OF_DATE_KHR is returned.
1688ifdef::VK_EXT_full_screen_exclusive[]
1689  * If any of the presents would have a result of
1690    ename:VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT if issued separately
1691    then ename:VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT is returned.
1692endif::VK_EXT_full_screen_exclusive[]
1693  * If any of the presents would have a result of ename:VK_SUBOPTIMAL_KHR if
1694    issued separately then ename:VK_SUBOPTIMAL_KHR is returned.
1695  * Otherwise ename:VK_SUCCESS is returned.
1696
1697Presentation is a read-only operation that will not affect the content of
1698the presentable images.
1699Upon reacquiring the image and transitioning it away from the
1700ename:VK_IMAGE_LAYOUT_PRESENT_SRC_KHR layout, the contents will be the same
1701as they were prior to transitioning the image to the present source layout
1702and presenting it.
1703However, if a mechanism other than Vulkan is used to modify the platform
1704window associated with the swapchain, the content of all presentable images
1705in the swapchain becomes undefined:.
1706
1707[NOTE]
1708.Note
1709====
1710The application can: continue to present any acquired images from a retired
1711swapchain as long as the swapchain has not entered a state that causes
1712flink:vkQueuePresentKHR to return ename:VK_ERROR_OUT_OF_DATE_KHR.
1713====
1714
1715ifdef::VK_EXT_swapchain_maintenance1[]
1716[open,refpage='vkReleaseSwapchainImagesEXT',desc='Release previously acquired but unused images',type='protos']
1717--
1718To release images previously acquired through
1719ifdef::VK_VERSION_1_1,VK_KHR_device_group[flink:vkAcquireNextImage2KHR or]
1720flink:vkAcquireNextImageKHR, call:
1721
1722include::{generated}/api/protos/vkReleaseSwapchainImagesEXT.adoc[]
1723
1724  * pname:device is the device associated with
1725    slink:VkReleaseSwapchainImagesInfoEXT::pname:swapchain.
1726  * pname:pReleaseInfo is a pointer to a
1727    slink:VkReleaseSwapchainImagesInfoEXT structure containing parameters of
1728    the release.
1729
1730Only images that are not in use by the device can: be released.
1731
1732Releasing images is a read-only operation that will not affect the content
1733of the released images.
1734Upon reacquiring the image, the image contents and its layout will be the
1735same as they were prior to releasing it.
1736However, if a mechanism other than Vulkan is used to modify the platform
1737window associated with the swapchain, the content of all presentable images
1738in the swapchain becomes undefined:.
1739
1740.Note
1741[NOTE]
1742====
1743This functionality is useful during swapchain recreation, where acquired
1744images from the old swapchain can be released instead of presented.
1745====
1746
1747include::{generated}/validity/protos/vkReleaseSwapchainImagesEXT.adoc[]
1748--
1749
1750[open,refpage='VkReleaseSwapchainImagesInfoEXT',desc='Structure describing a list of swapchain image indices to be released',type='structs']
1751--
1752The sname:VkReleaseSwapchainImagesInfoEXT structure is defined as:
1753
1754include::{generated}/api/structs/VkReleaseSwapchainImagesInfoEXT.adoc[]
1755
1756  * pname:sType is a elink:VkStructureType value identifying this structure.
1757  * pname:pNext is `NULL` or a pointer to a structure extending this
1758    structure.
1759  * pname:swapchain is a swapchain to which images are being released.
1760  * pname:imageIndexCount is the number of image indices to be released.
1761  * pname:pImageIndices is a pointer to an array of indices into the array
1762    of pname:swapchain's presentable images, with pname:imageIndexCount
1763    entries.
1764
1765.Valid Usage
1766****
1767  * [[VUID-VkReleaseSwapchainImagesInfoEXT-pImageIndices-07785]]
1768    Each element of pname:pImageIndices must: be the index of a presentable
1769    image acquired from the swapchain specified by pname:swapchain
1770  * [[VUID-VkReleaseSwapchainImagesInfoEXT-pImageIndices-07786]]
1771    All uses of presentable images identified by elements of
1772    pname:pImageIndices must: have completed execution
1773****
1774
1775include::{generated}/validity/structs/VkReleaseSwapchainImagesInfoEXT.adoc[]
1776--
1777endif::VK_EXT_swapchain_maintenance1[]
1778
1779ifdef::VK_EXT_hdr_metadata[]
1780include::{chapters}/VK_EXT_hdr_metadata.adoc[]
1781endif::VK_EXT_hdr_metadata[]
1782