1e5c31af7Sopenharmony_ci// Copyright 2014-2024 The Khronos Group Inc.
2e5c31af7Sopenharmony_ci//
3e5c31af7Sopenharmony_ci// SPDX-License-Identifier: CC-BY-4.0
4e5c31af7Sopenharmony_ci
5e5c31af7Sopenharmony_ciinclude::{generated}/meta/{refprefix}VK_KHR_surface.adoc[]
6e5c31af7Sopenharmony_ci
7e5c31af7Sopenharmony_ci=== Other Extension Metadata
8e5c31af7Sopenharmony_ci
9e5c31af7Sopenharmony_ci*Last Modified Date*::
10e5c31af7Sopenharmony_ci    2016-08-25
11e5c31af7Sopenharmony_ci*IP Status*::
12e5c31af7Sopenharmony_ci    No known IP claims.
13e5c31af7Sopenharmony_ci*Contributors*::
14e5c31af7Sopenharmony_ci  - Patrick Doane, Blizzard
15e5c31af7Sopenharmony_ci  - Ian Elliott, LunarG
16e5c31af7Sopenharmony_ci  - Jesse Hall, Google
17e5c31af7Sopenharmony_ci  - James Jones, NVIDIA
18e5c31af7Sopenharmony_ci  - David Mao, AMD
19e5c31af7Sopenharmony_ci  - Norbert Nopper, Freescale
20e5c31af7Sopenharmony_ci  - Alon Or-bach, Samsung
21e5c31af7Sopenharmony_ci  - Daniel Rakos, AMD
22e5c31af7Sopenharmony_ci  - Graham Sellers, AMD
23e5c31af7Sopenharmony_ci  - Jeff Vigil, Qualcomm
24e5c31af7Sopenharmony_ci  - Chia-I Wu, LunarG
25e5c31af7Sopenharmony_ci  - Faith Ekstrand, Intel
26e5c31af7Sopenharmony_ci
27e5c31af7Sopenharmony_ci=== Description
28e5c31af7Sopenharmony_ci
29e5c31af7Sopenharmony_ciThe `VK_KHR_surface` extension is an instance extension.
30e5c31af7Sopenharmony_ciIt introduces slink:VkSurfaceKHR objects, which abstract native platform
31e5c31af7Sopenharmony_cisurface or window objects for use with Vulkan.
32e5c31af7Sopenharmony_ciIt also provides a way to determine whether a queue family in a physical
33e5c31af7Sopenharmony_cidevice supports presenting to particular surface.
34e5c31af7Sopenharmony_ci
35e5c31af7Sopenharmony_ciSeparate extensions for each platform provide the mechanisms for creating
36e5c31af7Sopenharmony_cislink:VkSurfaceKHR objects, but once created they may be used in this and
37e5c31af7Sopenharmony_ciother platform-independent extensions, in particular the
38e5c31af7Sopenharmony_ci`apiext:VK_KHR_swapchain` extension.
39e5c31af7Sopenharmony_ci
40e5c31af7Sopenharmony_ciinclude::{generated}/interfaces/VK_KHR_surface.adoc[]
41e5c31af7Sopenharmony_ci
42e5c31af7Sopenharmony_ciifndef::VKSC_VERSION_1_0[]
43e5c31af7Sopenharmony_ci=== Examples
44e5c31af7Sopenharmony_ci
45e5c31af7Sopenharmony_ci[NOTE]
46e5c31af7Sopenharmony_ci.Note
47e5c31af7Sopenharmony_ci====
48e5c31af7Sopenharmony_ciThe example code for the `VK_KHR_surface` and `apiext:VK_KHR_swapchain`
49e5c31af7Sopenharmony_ciextensions was removed from the appendix after revision 1.0.29.
50e5c31af7Sopenharmony_ciThis WSI example code was ported to the cube demo that is shipped with the
51e5c31af7Sopenharmony_ciofficial Khronos SDK, and is being kept up-to-date in that location (see:
52e5c31af7Sopenharmony_cihttps://github.com/KhronosGroup/Vulkan-Tools/blob/master/cube/cube.c).
53e5c31af7Sopenharmony_ci====
54e5c31af7Sopenharmony_ciendif::VKSC_VERSION_1_0[]
55e5c31af7Sopenharmony_ci
56e5c31af7Sopenharmony_ci=== Issues
57e5c31af7Sopenharmony_ci
58e5c31af7Sopenharmony_ci1) Should this extension include a method to query whether a physical device
59e5c31af7Sopenharmony_cisupports presenting to a specific window or native surface on a given
60e5c31af7Sopenharmony_ciplatform?
61e5c31af7Sopenharmony_ci
62e5c31af7Sopenharmony_ci*RESOLVED*: Yes.
63e5c31af7Sopenharmony_ciWithout this, applications would need to create a device instance to
64e5c31af7Sopenharmony_cidetermine whether a particular window can be presented to.
65e5c31af7Sopenharmony_ciKnowing that a device supports presentation to a platform in general is not
66e5c31af7Sopenharmony_cisufficient, as a single machine might support multiple seats, or instances
67e5c31af7Sopenharmony_ciof the platform that each use different underlying physical devices.
68e5c31af7Sopenharmony_ciAdditionally, on some platforms, such as the X Window System, different
69e5c31af7Sopenharmony_cidrivers and devices might be used for different windows depending on which
70e5c31af7Sopenharmony_cisection of the desktop they exist on.
71e5c31af7Sopenharmony_ci
72e5c31af7Sopenharmony_ci2) Should the flink:vkGetPhysicalDeviceSurfaceCapabilitiesKHR,
73e5c31af7Sopenharmony_ciflink:vkGetPhysicalDeviceSurfaceFormatsKHR, and
74e5c31af7Sopenharmony_ciflink:vkGetPhysicalDeviceSurfacePresentModesKHR functions be in this
75e5c31af7Sopenharmony_ciextension and operate on physical devices, rather than being in
76e5c31af7Sopenharmony_ci`apiext:VK_KHR_swapchain` (i.e. device extension) and being dependent on
77e5c31af7Sopenharmony_cislink:VkDevice?
78e5c31af7Sopenharmony_ci
79e5c31af7Sopenharmony_ci*RESOLVED*: Yes.
80e5c31af7Sopenharmony_ciWhile it might be useful to depend on sname:VkDevice (and therefore on
81e5c31af7Sopenharmony_cienabled extensions and features) for the queries, Vulkan was released only
82e5c31af7Sopenharmony_ciwith the slink:VkPhysicalDevice versions.
83e5c31af7Sopenharmony_ciMany cases can be resolved by a Valid Usage statement, and/or by a separate
84e5c31af7Sopenharmony_cipname:pNext chain version of the query struct specific to a given extension
85e5c31af7Sopenharmony_cior parameters, via extensible versions of the queries:
86e5c31af7Sopenharmony_ciifdef::VK_EXT_full_screen_exclusive[flink:vkGetPhysicalDeviceSurfacePresentModes2EXT,]
87e5c31af7Sopenharmony_ciflink:vkGetPhysicalDeviceSurfaceCapabilities2KHR, and
88e5c31af7Sopenharmony_ciflink:vkGetPhysicalDeviceSurfaceFormats2KHR.
89e5c31af7Sopenharmony_ci
90e5c31af7Sopenharmony_ci3) Should Vulkan support Xlib or XCB as the API for accessing the X Window
91e5c31af7Sopenharmony_ciSystem platform?
92e5c31af7Sopenharmony_ci
93e5c31af7Sopenharmony_ci*RESOLVED*: Both.
94e5c31af7Sopenharmony_ciXCB is a more modern and efficient API, but Xlib usage is deeply ingrained
95e5c31af7Sopenharmony_ciin many applications and likely will remain in use for the foreseeable
96e5c31af7Sopenharmony_cifuture.
97e5c31af7Sopenharmony_ciNot all drivers necessarily need to support both, but including both as
98e5c31af7Sopenharmony_cioptions in the core specification will probably encourage support, which
99e5c31af7Sopenharmony_cishould in turn ease adoption of the Vulkan API in older codebases.
100e5c31af7Sopenharmony_ciAdditionally, the performance improvements possible with XCB likely will not
101e5c31af7Sopenharmony_cihave a measurable impact on the performance of Vulkan presentation and other
102e5c31af7Sopenharmony_ciminimal window system interactions defined here.
103e5c31af7Sopenharmony_ci
104e5c31af7Sopenharmony_ci4) Should the GBM platform be included in the list of platform enums?
105e5c31af7Sopenharmony_ci
106e5c31af7Sopenharmony_ci*RESOLVED*: Deferred, and will be addressed with a platform-specific
107e5c31af7Sopenharmony_ciextension to be written in the future.
108e5c31af7Sopenharmony_ci
109e5c31af7Sopenharmony_ci=== Version History
110e5c31af7Sopenharmony_ci
111e5c31af7Sopenharmony_ci  * Revision 1, 2015-05-20 (James Jones)
112e5c31af7Sopenharmony_ci  ** Initial draft, based on LunarG KHR spec, other KHR specs, patches
113e5c31af7Sopenharmony_ci     attached to bugs.
114e5c31af7Sopenharmony_ci
115e5c31af7Sopenharmony_ci  * Revision 2, 2015-05-22 (Ian Elliott)
116e5c31af7Sopenharmony_ci  ** Created initial Description section.
117e5c31af7Sopenharmony_ci  ** Removed query for whether a platform requires the use of a queue for
118e5c31af7Sopenharmony_ci     presentation, since it was decided that presentation will always be
119e5c31af7Sopenharmony_ci     modeled as being part of the queue.
120e5c31af7Sopenharmony_ci  ** Fixed typos and other minor mistakes.
121e5c31af7Sopenharmony_ci
122e5c31af7Sopenharmony_ci  * Revision 3, 2015-05-26 (Ian Elliott)
123e5c31af7Sopenharmony_ci  ** Improved the Description section.
124e5c31af7Sopenharmony_ci
125e5c31af7Sopenharmony_ci  * Revision 4, 2015-05-27 (James Jones)
126e5c31af7Sopenharmony_ci  ** Fixed compilation errors in example code.
127e5c31af7Sopenharmony_ci
128e5c31af7Sopenharmony_ci  * Revision 5, 2015-06-01 (James Jones)
129e5c31af7Sopenharmony_ci  ** Added issues 1 and 2 and made related spec updates.
130e5c31af7Sopenharmony_ci
131e5c31af7Sopenharmony_ci  * Revision 6, 2015-06-01 (James Jones)
132e5c31af7Sopenharmony_ci  ** Merged the platform type mappings table previously removed from
133e5c31af7Sopenharmony_ci     VK_KHR_swapchain with the platform description table in this spec.
134e5c31af7Sopenharmony_ci  ** Added issues 3 and 4 documenting choices made when building the initial
135e5c31af7Sopenharmony_ci     list of native platforms supported.
136e5c31af7Sopenharmony_ci
137e5c31af7Sopenharmony_ci  * Revision 7, 2015-06-11 (Ian Elliott)
138e5c31af7Sopenharmony_ci  ** Updated table 1 per input from the KHR TSG.
139e5c31af7Sopenharmony_ci  ** Updated issue 4 (GBM) per discussion with Daniel Stone.
140e5c31af7Sopenharmony_ci     He will create a platform-specific extension sometime in the future.
141e5c31af7Sopenharmony_ci
142e5c31af7Sopenharmony_ci  * Revision 8, 2015-06-17 (James Jones)
143e5c31af7Sopenharmony_ci  ** Updated enum-extending values using new convention.
144e5c31af7Sopenharmony_ci  ** Fixed the value of VK_SURFACE_PLATFORM_INFO_TYPE_SUPPORTED_KHR.
145e5c31af7Sopenharmony_ci
146e5c31af7Sopenharmony_ci  * Revision 9, 2015-06-17 (James Jones)
147e5c31af7Sopenharmony_ci  ** Rebased on Vulkan API version 126.
148e5c31af7Sopenharmony_ci
149e5c31af7Sopenharmony_ci  * Revision 10, 2015-06-18 (James Jones)
150e5c31af7Sopenharmony_ci  ** Marked issues 2 and 3 resolved.
151e5c31af7Sopenharmony_ci
152e5c31af7Sopenharmony_ci  * Revision 11, 2015-06-23 (Ian Elliott)
153e5c31af7Sopenharmony_ci  ** Examples now show use of function pointers for extension functions.
154e5c31af7Sopenharmony_ci  ** Eliminated extraneous whitespace.
155e5c31af7Sopenharmony_ci
156e5c31af7Sopenharmony_ci  * Revision 12, 2015-07-07 (Daniel Rakos)
157e5c31af7Sopenharmony_ci  ** Added error section describing when each error is expected to be
158e5c31af7Sopenharmony_ci     reported.
159e5c31af7Sopenharmony_ci  ** Replaced the term "`queue node index`" with "`queue family index`" in
160e5c31af7Sopenharmony_ci     the spec as that is the agreed term to be used in the latest version of
161e5c31af7Sopenharmony_ci     the core header and spec.
162e5c31af7Sopenharmony_ci  ** Replaced bool32_t with VkBool32.
163e5c31af7Sopenharmony_ci
164e5c31af7Sopenharmony_ci  * Revision 13, 2015-08-06 (Daniel Rakos)
165e5c31af7Sopenharmony_ci  ** Updated spec against latest core API header version.
166e5c31af7Sopenharmony_ci
167e5c31af7Sopenharmony_ci  * Revision 14, 2015-08-20 (Ian Elliott)
168e5c31af7Sopenharmony_ci  ** Renamed this extension and all of its enumerations, types, functions,
169e5c31af7Sopenharmony_ci     etc.
170e5c31af7Sopenharmony_ci     This makes it compliant with the proposed standard for Vulkan
171e5c31af7Sopenharmony_ci     extensions.
172e5c31af7Sopenharmony_ci  ** Switched from "`revision`" to "`version`", including use of the
173e5c31af7Sopenharmony_ci     VK_MAKE_VERSION macro in the header file.
174e5c31af7Sopenharmony_ci  ** Did miscellaneous cleanup, etc.
175e5c31af7Sopenharmony_ci
176e5c31af7Sopenharmony_ci  * Revision 15, 2015-08-20 (Ian Elliott--porting a 2015-07-29 change from
177e5c31af7Sopenharmony_ci    James Jones)
178e5c31af7Sopenharmony_ci  ** Moved the surface transform enums here from VK_WSI_swapchain so they
179e5c31af7Sopenharmony_ci     could be reused by VK_WSI_display.
180e5c31af7Sopenharmony_ci
181e5c31af7Sopenharmony_ci  * Revision 16, 2015-09-01 (James Jones)
182e5c31af7Sopenharmony_ci  ** Restore single-field revision number.
183e5c31af7Sopenharmony_ci
184e5c31af7Sopenharmony_ci  * Revision 17, 2015-09-01 (James Jones)
185e5c31af7Sopenharmony_ci  ** Fix example code compilation errors.
186e5c31af7Sopenharmony_ci
187e5c31af7Sopenharmony_ci  * Revision 18, 2015-09-26 (Jesse Hall)
188e5c31af7Sopenharmony_ci  ** Replaced VkSurfaceDescriptionKHR with the VkSurfaceKHR object, which is
189e5c31af7Sopenharmony_ci     created via layered extensions.
190e5c31af7Sopenharmony_ci     Added VkDestroySurfaceKHR.
191e5c31af7Sopenharmony_ci
192e5c31af7Sopenharmony_ci  * Revision 19, 2015-09-28 (Jesse Hall)
193e5c31af7Sopenharmony_ci  ** Renamed from VK_EXT_KHR_swapchain to VK_EXT_KHR_surface.
194e5c31af7Sopenharmony_ci
195e5c31af7Sopenharmony_ci  * Revision 20, 2015-09-30 (Jeff Vigil)
196e5c31af7Sopenharmony_ci  ** Add error result VK_ERROR_SURFACE_LOST_KHR.
197e5c31af7Sopenharmony_ci
198e5c31af7Sopenharmony_ci  * Revision 21, 2015-10-15 (Daniel Rakos)
199e5c31af7Sopenharmony_ci  ** Updated the resolution of issue #2 and include the surface capability
200e5c31af7Sopenharmony_ci     queries in this extension.
201e5c31af7Sopenharmony_ci  ** Renamed SurfaceProperties to SurfaceCapabilities as it better reflects
202e5c31af7Sopenharmony_ci     that the values returned are the capabilities of the surface on a
203e5c31af7Sopenharmony_ci     particular device.
204e5c31af7Sopenharmony_ci  ** Other minor cleanup and consistency changes.
205e5c31af7Sopenharmony_ci
206e5c31af7Sopenharmony_ci  * Revision 22, 2015-10-26 (Ian Elliott)
207e5c31af7Sopenharmony_ci  ** Renamed from VK_EXT_KHR_surface to VK_KHR_surface.
208e5c31af7Sopenharmony_ci
209e5c31af7Sopenharmony_ci  * Revision 23, 2015-11-03 (Daniel Rakos)
210e5c31af7Sopenharmony_ci  ** Added allocation callbacks to vkDestroySurfaceKHR.
211e5c31af7Sopenharmony_ci
212e5c31af7Sopenharmony_ci  * Revision 24, 2015-11-10 (Jesse Hall)
213e5c31af7Sopenharmony_ci  ** Removed VkSurfaceTransformKHR.
214e5c31af7Sopenharmony_ci     Use VkSurfaceTransformFlagBitsKHR instead.
215e5c31af7Sopenharmony_ci  ** Rename VkSurfaceCapabilitiesKHR member maxImageArraySize to
216e5c31af7Sopenharmony_ci     maxImageArrayLayers.
217e5c31af7Sopenharmony_ci
218e5c31af7Sopenharmony_ci  * Revision 25, 2016-01-14 (James Jones)
219e5c31af7Sopenharmony_ci  ** Moved VK_ERROR_NATIVE_WINDOW_IN_USE_KHR from the VK_KHR_android_surface
220e5c31af7Sopenharmony_ci     to the VK_KHR_surface extension.
221e5c31af7Sopenharmony_ci
222e5c31af7Sopenharmony_ci  * 2016-08-23 (Ian Elliott)
223e5c31af7Sopenharmony_ci  ** Update the example code, to not have so many characters per line, and
224e5c31af7Sopenharmony_ci     to split out a new example to show how to obtain function pointers.
225e5c31af7Sopenharmony_ci
226e5c31af7Sopenharmony_ci  * 2016-08-25 (Ian Elliott)
227e5c31af7Sopenharmony_ci  ** A note was added at the beginning of the example code, stating that it
228e5c31af7Sopenharmony_ci     will be removed from future versions of the appendix.
229