xref: /third_party/vulkan-loader/loader/wsi.h (revision 5db71995)
1/*
2 * Copyright (c) 2015-2021 The Khronos Group Inc.
3 * Copyright (c) 2015-2021 Valve Corporation
4 * Copyright (c) 2015-2021 LunarG, Inc.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 *     http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * Author: Ian Elliott <ian@lunarg.com>
19 * Author: Charles Giessen <charles@lunarg.com>
20 *
21 */
22
23#pragma once
24
25#include "loader_common.h"
26
27typedef struct {
28    union {
29#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
30        VkIcdSurfaceWayland wayland_surf;
31#endif  // VK_USE_PLATFORM_WAYLAND_KHR
32#if defined(VK_USE_PLATFORM_WIN32_KHR)
33        VkIcdSurfaceWin32 win_surf;
34#endif  // VK_USE_PLATFORM_WIN32_KHR
35#if defined(VK_USE_PLATFORM_XCB_KHR)
36        VkIcdSurfaceXcb xcb_surf;
37#endif  // VK_USE_PLATFORM_XCB_KHR
38#if defined(VK_USE_PLATFORM_XLIB_KHR)
39        VkIcdSurfaceXlib xlib_surf;
40#endif  // VK_USE_PLATFORM_XLIB_KHR
41#if defined(VK_USE_PLATFORM_DIRECTFB_EXT)
42        VkIcdSurfaceDirectFB directfb_surf;
43#endif  // VK_USE_PLATFORM_DIRECTFB_EXT
44#if defined(VK_USE_PLATFORM_MACOS_MVK)
45        VkIcdSurfaceMacOS macos_surf;
46#endif  // VK_USE_PLATFORM_MACOS_MVK
47#if defined(VK_USE_PLATFORM_GGP)
48        VkIcdSurfaceGgp ggp_surf;
49#endif  // VK_USE_PLATFORM_GGP
50#if defined(VK_USE_PLATFORM_FUCHSIA)
51        VkIcdSurfaceImagePipe imagepipe_surf;
52#endif  // VK_USE_PLATFORM_FUCHSIA
53#if defined(VK_USE_PLATFORM_METAL_EXT)
54        VkIcdSurfaceMetal metal_surf;
55#endif  // VK_USE_PLATFORM_METAL_EXT
56#if defined(VK_USE_PLATFORM_SCREEN_QNX)
57        VkIcdSurfaceScreen screen_surf;
58#endif  // VK_USE_PLATFORM_SCREEN_QNX
59#if defined(VK_USE_PLATFORM_VI_NN)
60        VkIcdSurfaceVi vi_surf;
61#endif  // VK_USE_PLATFORM_VI_NN
62        VkIcdSurfaceDisplay display_surf;
63        VkIcdSurfaceHeadless headless_surf;
64    };
65    uint32_t base_size;            // Size of VkIcdSurfaceBase
66    uint32_t platform_size;        // Size of corresponding VkIcdSurfaceXXX
67    uint32_t non_platform_offset;  // Start offset to base_size
68    uint32_t entire_size;          // Size of entire VkIcdSurface
69    VkSurfaceKHR *real_icd_surfaces;
70} VkIcdSurface;
71
72bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char *name, void **addr);
73
74void wsi_create_instance(struct loader_instance *ptr_instance, const VkInstanceCreateInfo *pCreateInfo);
75bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop);
76
77VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateHeadlessSurfaceEXT(VkInstance instance,
78                                                                   const VkHeadlessSurfaceCreateInfoEXT *pCreateInfo,
79                                                                   const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
80
81VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
82                                                             const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain);
83
84VKAPI_ATTR void VKAPI_CALL terminator_DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
85                                                        const VkAllocationCallbacks *pAllocator);
86
87VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,
88                                                                             uint32_t queueFamilyIndex, VkSurfaceKHR surface,
89                                                                             VkBool32 *pSupported);
90
91VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice,
92                                                                                  VkSurfaceKHR surface,
93                                                                                  VkSurfaceCapabilitiesKHR *pSurfaceCapabilities);
94
95VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
96                                                                             uint32_t *pSurfaceFormatCount,
97                                                                             VkSurfaceFormatKHR *pSurfaceFormats);
98
99VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
100                                                                                  VkSurfaceKHR surface, uint32_t *pPresentModeCount,
101                                                                                  VkPresentModeKHR *pPresentModes);
102
103VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDeviceGroupSurfacePresentModesKHR(VkDevice device, VkSurfaceKHR surface,
104                                                                               VkDeviceGroupPresentModeFlagsKHR *pModes);
105
106#if defined(VK_USE_PLATFORM_WIN32_KHR)
107VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
108                                                                const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
109VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice,
110                                                                                       uint32_t queueFamilyIndex);
111#endif
112#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
113VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(VkInstance instance,
114                                                                  const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
115                                                                  const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
116VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceWaylandPresentationSupportKHR(VkPhysicalDevice physicalDevice,
117                                                                                         uint32_t queueFamilyIndex,
118                                                                                         struct wl_display *display);
119#endif
120#if defined(VK_USE_PLATFORM_XCB_KHR)
121VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXcbSurfaceKHR(VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
122                                                              const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
123
124VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice,
125                                                                                     uint32_t queueFamilyIndex,
126                                                                                     xcb_connection_t *connection,
127                                                                                     xcb_visualid_t visual_id);
128#endif
129#if defined(VK_USE_PLATFORM_XLIB_KHR)
130VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXlibSurfaceKHR(VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
131                                                               const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
132VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice,
133                                                                                      uint32_t queueFamilyIndex, Display *dpy,
134                                                                                      VisualID visualID);
135#endif
136#if defined(VK_USE_PLATFORM_DIRECTFB_EXT)
137VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDirectFBSurfaceEXT(VkInstance instance,
138                                                                   const VkDirectFBSurfaceCreateInfoEXT *pCreateInfo,
139                                                                   const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
140VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceDirectFBPresentationSupportEXT(VkPhysicalDevice physicalDevice,
141                                                                                          uint32_t queueFamilyIndex,
142                                                                                          IDirectFB *dfb);
143#endif
144#if defined(VK_USE_PLATFORM_MACOS_MVK)
145VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMacOSSurfaceMVK(VkInstance instance, const VkMacOSSurfaceCreateInfoMVK *pCreateInfo,
146                                                                const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
147#endif
148#if defined(VK_USE_PLATFORM_IOS_MVK)
149VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateIOSSurfaceMVK(VkInstance instance, const VkIOSSurfaceCreateInfoMVK *pCreateInfo,
150                                                              const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
151#endif
152#if defined(VK_USE_PLATFORM_GGP)
153VKAPI_ATTR VkResult VKAPI_CALL
154terminator_CreateStreamDescriptorSurfaceGGP(VkInstance instance, const VkStreamDescriptorSurfaceCreateInfoGGP *pCreateInfo,
155                                            const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
156#endif
157#if defined(VK_USE_PLATFORM_METAL_EXT)
158VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMetalSurfaceEXT(VkInstance instance, const VkMetalSurfaceCreateInfoEXT *pCreateInfo,
159                                                                const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
160#endif
161#if defined(VK_USE_PLATFORM_SCREEN_QNX)
162VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateScreenSurfaceQNX(VkInstance instance,
163                                                                 const VkScreenSurfaceCreateInfoQNX *pCreateInfo,
164                                                                 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
165VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceScreenPresentationSupportQNX(VkPhysicalDevice physicalDevice,
166                                                                                        uint32_t queueFamilyIndex,
167                                                                                        struct _screen_window *window);
168#endif  // VK_USE_PLATFORM_SCREEN_QNX
169#if defined(VK_USE_PLATFORM_VI_NN)
170VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateViSurfaceNN(VkInstance instance, const VkViSurfaceCreateInfoNN *pCreateInfo,
171                                                            const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
172#endif  // VK_USE_PLATFORM_VI_NN
173VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice,
174                                                                                uint32_t *pPropertyCount,
175                                                                                VkDisplayPropertiesKHR *pProperties);
176VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPlanePropertiesKHR(VkPhysicalDevice physicalDevice,
177                                                                                     uint32_t *pPropertyCount,
178                                                                                     VkDisplayPlanePropertiesKHR *pProperties);
179VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex,
180                                                                              uint32_t *pDisplayCount, VkDisplayKHR *pDisplays);
181VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
182                                                                      uint32_t *pPropertyCount,
183                                                                      VkDisplayModePropertiesKHR *pProperties);
184VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
185                                                               const VkDisplayModeCreateInfoKHR *pCreateInfo,
186                                                               const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode);
187VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode,
188                                                                         uint32_t planeIndex,
189                                                                         VkDisplayPlaneCapabilitiesKHR *pCapabilities);
190VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR(VkInstance instance,
191                                                                       const VkDisplaySurfaceCreateInfoKHR *pCreateInfo,
192                                                                       const VkAllocationCallbacks *pAllocator,
193                                                                       VkSurfaceKHR *pSurface);
194
195VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount,
196                                                                    const VkSwapchainCreateInfoKHR *pCreateInfos,
197                                                                    const VkAllocationCallbacks *pAllocator,
198                                                                    VkSwapchainKHR *pSwapchains);
199
200VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDevicePresentRectanglesKHR(VkPhysicalDevice physicalDevice,
201                                                                                VkSurfaceKHR surface, uint32_t *pRectCount,
202                                                                                VkRect2D *pRects);
203
204VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice,
205                                                                                 uint32_t *pPropertyCount,
206                                                                                 VkDisplayProperties2KHR *pProperties);
207
208VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPlaneProperties2KHR(VkPhysicalDevice physicalDevice,
209                                                                                      uint32_t *pPropertyCount,
210                                                                                      VkDisplayPlaneProperties2KHR *pProperties);
211
212VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
213                                                                       uint32_t *pPropertyCount,
214                                                                       VkDisplayModeProperties2KHR *pProperties);
215
216VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneCapabilities2KHR(VkPhysicalDevice physicalDevice,
217                                                                          const VkDisplayPlaneInfo2KHR *pDisplayPlaneInfo,
218                                                                          VkDisplayPlaneCapabilities2KHR *pCapabilities);
219#if defined(VK_USE_PLATFORM_FUCHSIA)
220VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateImagePipeSurfaceFUCHSIA(VkInstance instance,
221                                                                        const VkImagePipeSurfaceCreateInfoFUCHSIA *pCreateInfo,
222                                                                        const VkAllocationCallbacks *pAllocator,
223                                                                        VkSurfaceKHR *pSurface);
224#endif
225
226#if defined(VK_USE_PLATFORM_ANDROID_KHR)
227VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateAndroidSurfaceKHR(VkInstance instance,
228                                                                  const VkAndroidSurfaceCreateInfoKHR *pCreateInfo,
229                                                                  const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
230#endif
231
232#if defined(VK_USE_PLATFORM_OHOS)
233VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateSurfaceOHOS(VkInstance instance,
234                                                                       const VkSurfaceCreateInfoOHOS* pCreateInfo,
235                                                                       const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
236#endif
237
238VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2KHR(
239    VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
240    VkSurfaceCapabilities2KHR *pSurfaceCapabilities);
241
242VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice,
243                                                                              const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
244                                                                              uint32_t *pSurfaceFormatCount,
245                                                                              VkSurfaceFormat2KHR *pSurfaceFormats);
246