blob: 4d63f41af83474a195debee357f26e400060580a [file] [log] [blame]
Ian Elliotta81e8ac2015-10-30 15:28:23 -06001/*
Jon Ashburn44aed662016-02-02 17:47:28 -07002 * Copyright (c) 2015-2016 The Khronos Group Inc.
3 * Copyright (c) 2015-2016 Valve Corporation
4 * Copyright (c) 2015-2016 LunarG, Inc.
Ian Elliotta81e8ac2015-10-30 15:28:23 -06005 *
Jon Ashburn44aed662016-02-02 17:47:28 -07006 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and/or associated documentation files (the "Materials"), to
8 * deal in the Materials without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Materials, and to permit persons to whom the Materials are
11 * furnished to do so, subject to the following conditions:
Ian Elliotta81e8ac2015-10-30 15:28:23 -060012 *
Jon Ashburn44aed662016-02-02 17:47:28 -070013 * The above copyright notice(s) and this permission notice shall be included in
14 * all copies or substantial portions of the Materials.
Ian Elliotta81e8ac2015-10-30 15:28:23 -060015 *
Jon Ashburn44aed662016-02-02 17:47:28 -070016 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060017 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Jon Ashburn44aed662016-02-02 17:47:28 -070018 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 *
20 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE
23 * USE OR OTHER DEALINGS IN THE MATERIALS.
Ian Elliotta81e8ac2015-10-30 15:28:23 -060024 *
25 * Author: Ian Elliott <ian@lunarg.com>
Jon Ashburn44aed662016-02-02 17:47:28 -070026 * Author: Jon Ashburn <jon@lunarg.com>
Ian Elliott3ce23f92015-11-19 11:58:08 -070027 * Author: Ian Elliott <ianelliott@google.com>
Jon Ashburn44aed662016-02-02 17:47:28 -070028 * Author: Mark Lobodzinski <mark@lunarg.com>
Ian Elliotta81e8ac2015-10-30 15:28:23 -060029 */
30
31//#define _ISOC11_SOURCE /* for aligned_alloc() */
32#define _GNU_SOURCE
33#include <stdlib.h>
34#include <string.h>
35#include "vk_loader_platform.h"
36#include "loader.h"
37#include "wsi.h"
Ian Elliottb2484122015-11-19 13:14:05 -070038#include <vulkan/vk_icd.h>
Ian Elliotta81e8ac2015-10-30 15:28:23 -060039
40static const VkExtensionProperties wsi_surface_extension_info = {
Jon Ashburn44aed662016-02-02 17:47:28 -070041 .extensionName = VK_KHR_SURFACE_EXTENSION_NAME,
42 .specVersion = VK_KHR_SURFACE_SPEC_VERSION,
Ian Elliotta81e8ac2015-10-30 15:28:23 -060043};
44
Ian Elliott3ce23f92015-11-19 11:58:08 -070045#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060046static const VkExtensionProperties wsi_win32_surface_extension_info = {
Jon Ashburn44aed662016-02-02 17:47:28 -070047 .extensionName = VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
48 .specVersion = VK_KHR_WIN32_SURFACE_SPEC_VERSION,
Ian Elliotta81e8ac2015-10-30 15:28:23 -060049};
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -070050#endif // VK_USE_PLATFORM_WIN32_KHR
51
Ian Elliott9c068c92015-10-30 17:45:05 -060052#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060053static const VkExtensionProperties wsi_mir_surface_extension_info = {
Jon Ashburn44aed662016-02-02 17:47:28 -070054 .extensionName = VK_KHR_MIR_SURFACE_EXTENSION_NAME,
55 .specVersion = VK_KHR_MIR_SURFACE_SPEC_VERSION,
Ian Elliotta81e8ac2015-10-30 15:28:23 -060056};
Ian Elliott9c068c92015-10-30 17:45:05 -060057#endif // VK_USE_PLATFORM_MIR_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060058
Ian Elliott9c068c92015-10-30 17:45:05 -060059#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060060static const VkExtensionProperties wsi_wayland_surface_extension_info = {
Jon Ashburn44aed662016-02-02 17:47:28 -070061 .extensionName = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME,
62 .specVersion = VK_KHR_WAYLAND_SURFACE_SPEC_VERSION,
Ian Elliotta81e8ac2015-10-30 15:28:23 -060063};
Ian Elliott9c068c92015-10-30 17:45:05 -060064#endif // VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060065
Ian Elliott9c068c92015-10-30 17:45:05 -060066#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060067static const VkExtensionProperties wsi_xcb_surface_extension_info = {
Jon Ashburn44aed662016-02-02 17:47:28 -070068 .extensionName = VK_KHR_XCB_SURFACE_EXTENSION_NAME,
69 .specVersion = VK_KHR_XCB_SURFACE_SPEC_VERSION,
Ian Elliotta81e8ac2015-10-30 15:28:23 -060070};
Ian Elliott9c068c92015-10-30 17:45:05 -060071#endif // VK_USE_PLATFORM_XCB_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060072
Ian Elliott9c068c92015-10-30 17:45:05 -060073#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060074static const VkExtensionProperties wsi_xlib_surface_extension_info = {
Jon Ashburn44aed662016-02-02 17:47:28 -070075 .extensionName = VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
76 .specVersion = VK_KHR_XLIB_SURFACE_SPEC_VERSION,
Ian Elliotta81e8ac2015-10-30 15:28:23 -060077};
Ian Elliott9c068c92015-10-30 17:45:05 -060078#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -070079
80#ifdef VK_USE_PLATFORM_ANDROID_KHR
81static const VkExtensionProperties wsi_android_surface_extension_info = {
Jon Ashburn44aed662016-02-02 17:47:28 -070082 .extensionName = VK_KHR_ANDROID_SURFACE_EXTENSION_NAME,
83 .specVersion = VK_KHR_ANDROID_SURFACE_REVISION,
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -070084};
85#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060086
Jon Ashburn44aed662016-02-02 17:47:28 -070087void wsi_add_instance_extensions(const struct loader_instance *inst,
88 struct loader_extension_list *ext_list) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -060089 loader_add_to_ext_list(inst, ext_list, 1, &wsi_surface_extension_info);
Ian Elliott3ce23f92015-11-19 11:58:08 -070090#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -070091 loader_add_to_ext_list(inst, ext_list, 1,
92 &wsi_win32_surface_extension_info);
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -070093#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott9c068c92015-10-30 17:45:05 -060094#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060095 loader_add_to_ext_list(inst, ext_list, 1, &wsi_mir_surface_extension_info);
Ian Elliott9c068c92015-10-30 17:45:05 -060096#endif // VK_USE_PLATFORM_MIR_KHR
97#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -070098 loader_add_to_ext_list(inst, ext_list, 1,
99 &wsi_wayland_surface_extension_info);
Ian Elliott9c068c92015-10-30 17:45:05 -0600100#endif // VK_USE_PLATFORM_WAYLAND_KHR
101#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600102 loader_add_to_ext_list(inst, ext_list, 1, &wsi_xcb_surface_extension_info);
Ian Elliott9c068c92015-10-30 17:45:05 -0600103#endif // VK_USE_PLATFORM_XCB_KHR
104#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600105 loader_add_to_ext_list(inst, ext_list, 1, &wsi_xlib_surface_extension_info);
Ian Elliott9c068c92015-10-30 17:45:05 -0600106#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700107#ifdef VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700108 loader_add_to_ext_list(inst, ext_list, 1,
109 &wsi_android_surface_extension_info);
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700110#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600111}
112
Jon Ashburn44aed662016-02-02 17:47:28 -0700113void wsi_create_instance(struct loader_instance *ptr_instance,
114 const VkInstanceCreateInfo *pCreateInfo) {
Ian Elliott9c068c92015-10-30 17:45:05 -0600115 ptr_instance->wsi_surface_enabled = false;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700116
117#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700118 ptr_instance->wsi_win32_surface_enabled = true;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700119#endif // VK_USE_PLATFORM_WIN32_KHR
120#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600121 ptr_instance->wsi_mir_surface_enabled = false;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700122#endif // VK_USE_PLATFORM_MIR_KHR
123#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600124 ptr_instance->wsi_wayland_surface_enabled = false;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700125#endif // VK_USE_PLATFORM_WAYLAND_KHR
126#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600127 ptr_instance->wsi_xcb_surface_enabled = false;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700128#endif // VK_USE_PLATFORM_XCB_KHR
129#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600130 ptr_instance->wsi_xlib_surface_enabled = false;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700131#endif // VK_USE_PLATFORM_XLIB_KHR
132#ifdef VK_USE_PLATFORM_ANDROID_KHR
133 ptr_instance->wsi_android_surface_enabled = false;
134#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600135
Jon Ashburna4ae48b2016-01-11 13:12:43 -0700136 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Jon Ashburn44aed662016-02-02 17:47:28 -0700137 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
138 VK_KHR_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600139 ptr_instance->wsi_surface_enabled = true;
Ian Elliott3ce23f92015-11-19 11:58:08 -0700140 continue;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600141 }
Ian Elliott3ce23f92015-11-19 11:58:08 -0700142#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700143 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
144 VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700145 ptr_instance->wsi_win32_surface_enabled = true;
Ian Elliott3ce23f92015-11-19 11:58:08 -0700146 continue;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600147 }
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700148#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott9c068c92015-10-30 17:45:05 -0600149#ifdef VK_USE_PLATFORM_MIR_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700150 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
151 VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600152 ptr_instance->wsi_mir_surface_enabled = true;
Ian Elliott3ce23f92015-11-19 11:58:08 -0700153 continue;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600154 }
Ian Elliott9c068c92015-10-30 17:45:05 -0600155#endif // VK_USE_PLATFORM_MIR_KHR
156#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700157 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
158 VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600159 ptr_instance->wsi_wayland_surface_enabled = true;
Ian Elliott3ce23f92015-11-19 11:58:08 -0700160 continue;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600161 }
Ian Elliott9c068c92015-10-30 17:45:05 -0600162#endif // VK_USE_PLATFORM_WAYLAND_KHR
163#ifdef VK_USE_PLATFORM_XCB_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700164 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
165 VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600166 ptr_instance->wsi_xcb_surface_enabled = true;
Ian Elliott3ce23f92015-11-19 11:58:08 -0700167 continue;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600168 }
Ian Elliott9c068c92015-10-30 17:45:05 -0600169#endif // VK_USE_PLATFORM_XCB_KHR
170#ifdef VK_USE_PLATFORM_XLIB_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700171 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
172 VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600173 ptr_instance->wsi_xlib_surface_enabled = true;
Ian Elliott3ce23f92015-11-19 11:58:08 -0700174 continue;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600175 }
Ian Elliott9c068c92015-10-30 17:45:05 -0600176#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700177#ifdef VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700178 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
179 VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0) {
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700180 ptr_instance->wsi_android_surface_enabled = true;
181 continue;
182 }
183#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600184 }
185}
186
187/*
Ian Elliottb2484122015-11-19 13:14:05 -0700188 * Functions for the VK_KHR_surface extension:
189 */
190
191/*
192 * This is the trampoline entrypoint
193 * for DestroySurfaceKHR
Ian Elliottb2484122015-11-19 13:14:05 -0700194 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700195LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
196vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
197 const VkAllocationCallbacks *pAllocator) {
Ian Elliott7b9f7822015-11-25 14:43:02 -0700198 const VkLayerInstanceDispatchTable *disp;
199 disp = loader_get_instance_dispatch(instance);
200 disp->DestroySurfaceKHR(instance, surface, pAllocator);
201}
202
203/*
204 * This is the instance chain terminator function
205 * for DestroySurfaceKHR
206 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700207VKAPI_ATTR void VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700208terminator_DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
209 const VkAllocationCallbacks *pAllocator) {
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700210 struct loader_instance *ptr_instance = loader_get_instance(instance);
211
Mark Young2acdd152016-01-13 13:47:16 -0700212 loader_heap_free(ptr_instance, (void *)surface);
Ian Elliottb2484122015-11-19 13:14:05 -0700213}
214
215/*
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600216 * This is the trampoline entrypoint
217 * for GetPhysicalDeviceSurfaceSupportKHR
218 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700219LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
220vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,
221 uint32_t queueFamilyIndex,
222 VkSurfaceKHR surface,
223 VkBool32 *pSupported) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600224 const VkLayerInstanceDispatchTable *disp;
Jon Ashburn87660432016-03-01 19:51:07 -0700225 VkPhysicalDevice unwrapped_phys_dev =
226 loader_unwrap_physical_device(physicalDevice);
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600227 disp = loader_get_instance_dispatch(physicalDevice);
228 VkResult res = disp->GetPhysicalDeviceSurfaceSupportKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700229 unwrapped_phys_dev, queueFamilyIndex, surface, pSupported);
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600230 return res;
231}
232
233/*
234 * This is the instance chain terminator function
235 * for GetPhysicalDeviceSurfaceSupportKHR
236 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700237VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700238terminator_GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,
239 uint32_t queueFamilyIndex,
240 VkSurfaceKHR surface,
241 VkBool32 *pSupported) {
Jon Ashburn44aed662016-02-02 17:47:28 -0700242 struct loader_physical_device *phys_dev =
243 (struct loader_physical_device *)physicalDevice;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600244 struct loader_icd *icd = phys_dev->this_icd;
245
Jon Ashburn44aed662016-02-02 17:47:28 -0700246 assert(pSupported &&
247 "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported");
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600248 *pSupported = false;
249
Jon Ashburn44aed662016-02-02 17:47:28 -0700250 assert(icd->GetPhysicalDeviceSurfaceSupportKHR &&
251 "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer");
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600252
Jon Ashburn44aed662016-02-02 17:47:28 -0700253 return icd->GetPhysicalDeviceSurfaceSupportKHR(
254 phys_dev->phys_dev, queueFamilyIndex, surface, pSupported);
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600255}
256
Ian Elliott8cda1802015-11-19 16:05:09 -0700257/*
258 * This is the trampoline entrypoint
259 * for GetPhysicalDeviceSurfaceCapabilitiesKHR
260 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700261LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
262vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
263 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
264 VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) {
Jon Ashburn87660432016-03-01 19:51:07 -0700265
Ian Elliott8cda1802015-11-19 16:05:09 -0700266 const VkLayerInstanceDispatchTable *disp;
Jon Ashburn87660432016-03-01 19:51:07 -0700267 VkPhysicalDevice unwrapped_phys_dev =
268 loader_unwrap_physical_device(physicalDevice);
Ian Elliott8cda1802015-11-19 16:05:09 -0700269 disp = loader_get_instance_dispatch(physicalDevice);
270 VkResult res = disp->GetPhysicalDeviceSurfaceCapabilitiesKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700271 unwrapped_phys_dev, surface, pSurfaceCapabilities);
Ian Elliott8cda1802015-11-19 16:05:09 -0700272 return res;
273}
274
275/*
276 * This is the instance chain terminator function
277 * for GetPhysicalDeviceSurfaceCapabilitiesKHR
278 */
Jon Ashburna9c4a572016-02-26 13:14:27 -0700279VKAPI_ATTR VkResult VKAPI_CALL
280terminator_GetPhysicalDeviceSurfaceCapabilitiesKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700281 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
282 VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) {
283 struct loader_physical_device *phys_dev =
284 (struct loader_physical_device *)physicalDevice;
Ian Elliott8cda1802015-11-19 16:05:09 -0700285 struct loader_icd *icd = phys_dev->this_icd;
286
Jon Ashburn44aed662016-02-02 17:47:28 -0700287 assert(pSurfaceCapabilities && "GetPhysicalDeviceSurfaceCapabilitiesKHR: "
288 "Error, null pSurfaceCapabilities");
Ian Elliott8cda1802015-11-19 16:05:09 -0700289
Jon Ashburn44aed662016-02-02 17:47:28 -0700290 assert(icd->GetPhysicalDeviceSurfaceCapabilitiesKHR &&
291 "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer");
Ian Elliott8cda1802015-11-19 16:05:09 -0700292
Jon Ashburn44aed662016-02-02 17:47:28 -0700293 return icd->GetPhysicalDeviceSurfaceCapabilitiesKHR(
294 phys_dev->phys_dev, surface, pSurfaceCapabilities);
Ian Elliott8cda1802015-11-19 16:05:09 -0700295}
296
297/*
298 * This is the trampoline entrypoint
299 * for GetPhysicalDeviceSurfaceFormatsKHR
300 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700301LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
302vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
303 VkSurfaceKHR surface,
304 uint32_t *pSurfaceFormatCount,
305 VkSurfaceFormatKHR *pSurfaceFormats) {
Jon Ashburn87660432016-03-01 19:51:07 -0700306 VkPhysicalDevice unwrapped_phys_dev =
307 loader_unwrap_physical_device(physicalDevice);
Ian Elliott8cda1802015-11-19 16:05:09 -0700308 const VkLayerInstanceDispatchTable *disp;
309 disp = loader_get_instance_dispatch(physicalDevice);
310 VkResult res = disp->GetPhysicalDeviceSurfaceFormatsKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700311 unwrapped_phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats);
Ian Elliott8cda1802015-11-19 16:05:09 -0700312 return res;
313}
314
315/*
316 * This is the instance chain terminator function
317 * for GetPhysicalDeviceSurfaceFormatsKHR
318 */
Jon Ashburna9c4a572016-02-26 13:14:27 -0700319VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormatsKHR(
320 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
321 uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats) {
Jon Ashburn44aed662016-02-02 17:47:28 -0700322 struct loader_physical_device *phys_dev =
323 (struct loader_physical_device *)physicalDevice;
Ian Elliott8cda1802015-11-19 16:05:09 -0700324 struct loader_icd *icd = phys_dev->this_icd;
325
Jon Ashburn44aed662016-02-02 17:47:28 -0700326 assert(
327 pSurfaceFormatCount &&
328 "GetPhysicalDeviceSurfaceFormatsKHR: Error, null pSurfaceFormatCount");
Ian Elliott8cda1802015-11-19 16:05:09 -0700329
Jon Ashburn44aed662016-02-02 17:47:28 -0700330 assert(icd->GetPhysicalDeviceSurfaceFormatsKHR &&
331 "loader: null GetPhysicalDeviceSurfaceFormatsKHR ICD pointer");
Ian Elliott8cda1802015-11-19 16:05:09 -0700332
Jon Ashburn44aed662016-02-02 17:47:28 -0700333 return icd->GetPhysicalDeviceSurfaceFormatsKHR(
334 phys_dev->phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats);
Ian Elliott8cda1802015-11-19 16:05:09 -0700335}
336
337/*
338 * This is the trampoline entrypoint
339 * for GetPhysicalDeviceSurfacePresentModesKHR
340 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700341LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
342vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
343 VkSurfaceKHR surface,
344 uint32_t *pPresentModeCount,
345 VkPresentModeKHR *pPresentModes) {
Jon Ashburn87660432016-03-01 19:51:07 -0700346 VkPhysicalDevice unwrapped_phys_dev =
347 loader_unwrap_physical_device(physicalDevice);
Ian Elliott8cda1802015-11-19 16:05:09 -0700348 const VkLayerInstanceDispatchTable *disp;
349 disp = loader_get_instance_dispatch(physicalDevice);
350 VkResult res = disp->GetPhysicalDeviceSurfacePresentModesKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700351 unwrapped_phys_dev, surface, pPresentModeCount, pPresentModes);
Ian Elliott8cda1802015-11-19 16:05:09 -0700352 return res;
353}
354
355/*
356 * This is the instance chain terminator function
357 * for GetPhysicalDeviceSurfacePresentModesKHR
358 */
Jon Ashburna9c4a572016-02-26 13:14:27 -0700359VKAPI_ATTR VkResult VKAPI_CALL
360terminator_GetPhysicalDeviceSurfacePresentModesKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700361 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
362 uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes) {
363 struct loader_physical_device *phys_dev =
364 (struct loader_physical_device *)physicalDevice;
Ian Elliott8cda1802015-11-19 16:05:09 -0700365 struct loader_icd *icd = phys_dev->this_icd;
366
Jon Ashburn44aed662016-02-02 17:47:28 -0700367 assert(pPresentModeCount && "GetPhysicalDeviceSurfacePresentModesKHR: "
368 "Error, null pPresentModeCount");
Ian Elliott8cda1802015-11-19 16:05:09 -0700369
Jon Ashburn44aed662016-02-02 17:47:28 -0700370 assert(icd->GetPhysicalDeviceSurfacePresentModesKHR &&
371 "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer");
Ian Elliott8cda1802015-11-19 16:05:09 -0700372
Jon Ashburn44aed662016-02-02 17:47:28 -0700373 return icd->GetPhysicalDeviceSurfacePresentModesKHR(
374 phys_dev->phys_dev, surface, pPresentModeCount, pPresentModes);
Ian Elliott8cda1802015-11-19 16:05:09 -0700375}
376
Ian Elliottb2484122015-11-19 13:14:05 -0700377/*
378 * Functions for the VK_KHR_swapchain extension:
379 */
380
Ian Elliott5bf16c32015-11-19 16:39:21 -0700381/*
382 * This is the trampoline entrypoint
383 * for CreateSwapchainKHR
384 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700385LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
386vkCreateSwapchainKHR(VkDevice device,
387 const VkSwapchainCreateInfoKHR *pCreateInfo,
388 const VkAllocationCallbacks *pAllocator,
389 VkSwapchainKHR *pSwapchain) {
Ian Elliott5bf16c32015-11-19 16:39:21 -0700390 const VkLayerDispatchTable *disp;
391 disp = loader_get_dispatch(device);
Jon Ashburn44aed662016-02-02 17:47:28 -0700392 VkResult res =
393 disp->CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain);
Ian Elliott5bf16c32015-11-19 16:39:21 -0700394 return res;
395}
Ian Elliottb2484122015-11-19 13:14:05 -0700396
Ian Elliott5bf16c32015-11-19 16:39:21 -0700397/*
398 * This is the trampoline entrypoint
399 * for DestroySwapchainKHR
400 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700401LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
402vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain,
403 const VkAllocationCallbacks *pAllocator) {
Ian Elliott5bf16c32015-11-19 16:39:21 -0700404 const VkLayerDispatchTable *disp;
405 disp = loader_get_dispatch(device);
406 disp->DestroySwapchainKHR(device, swapchain, pAllocator);
407}
Ian Elliottb2484122015-11-19 13:14:05 -0700408
Ian Elliott5bf16c32015-11-19 16:39:21 -0700409/*
410 * This is the trampoline entrypoint
411 * for GetSwapchainImagesKHR
412 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700413LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
414vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain,
415 uint32_t *pSwapchainImageCount,
416 VkImage *pSwapchainImages) {
Ian Elliott5bf16c32015-11-19 16:39:21 -0700417 const VkLayerDispatchTable *disp;
418 disp = loader_get_dispatch(device);
419 VkResult res = disp->GetSwapchainImagesKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700420 device, swapchain, pSwapchainImageCount, pSwapchainImages);
Ian Elliott5bf16c32015-11-19 16:39:21 -0700421 return res;
422}
423
424/*
425 * This is the trampoline entrypoint
426 * for AcquireNextImageKHR
427 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700428LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
429vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain,
430 uint64_t timeout, VkSemaphore semaphore, VkFence fence,
431 uint32_t *pImageIndex) {
Ian Elliott5bf16c32015-11-19 16:39:21 -0700432 const VkLayerDispatchTable *disp;
433 disp = loader_get_dispatch(device);
Jon Ashburn44aed662016-02-02 17:47:28 -0700434 VkResult res = disp->AcquireNextImageKHR(device, swapchain, timeout,
435 semaphore, fence, pImageIndex);
Ian Elliott5bf16c32015-11-19 16:39:21 -0700436 return res;
437}
438
439/*
440 * This is the trampoline entrypoint
441 * for QueuePresentKHR
442 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700443LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
444vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) {
Ian Elliott5bf16c32015-11-19 16:39:21 -0700445 const VkLayerDispatchTable *disp;
446 disp = loader_get_dispatch(queue);
447 VkResult res = disp->QueuePresentKHR(queue, pPresentInfo);
448 return res;
449}
Ian Elliottb2484122015-11-19 13:14:05 -0700450
Ian Elliottb2484122015-11-19 13:14:05 -0700451#ifdef VK_USE_PLATFORM_WIN32_KHR
452
453/*
454 * Functions for the VK_KHR_win32_surface extension:
455 */
456
457/*
458 * This is the trampoline entrypoint
459 * for CreateWin32SurfaceKHR
460 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700461LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
462vkCreateWin32SurfaceKHR(VkInstance instance,
463 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
464 const VkAllocationCallbacks *pAllocator,
465 VkSurfaceKHR *pSurface) {
Jon Ashburn25a158f2015-11-25 17:55:49 -0700466 const VkLayerInstanceDispatchTable *disp;
467 disp = loader_get_instance_dispatch(instance);
468 VkResult res;
469
Jon Ashburn44aed662016-02-02 17:47:28 -0700470 res = disp->CreateWin32SurfaceKHR(instance, pCreateInfo, pAllocator,
471 pSurface);
Jon Ashburn25a158f2015-11-25 17:55:49 -0700472 return res;
473}
474
475/*
476 * This is the instance chain terminator function
477 * for CreateWin32SurfaceKHR
478 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700479VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700480terminator_CreateWin32SurfaceKHR(VkInstance instance,
481 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
482 const VkAllocationCallbacks *pAllocator,
483 VkSurfaceKHR *pSurface) {
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700484 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliottb2484122015-11-19 13:14:05 -0700485 VkIcdSurfaceWin32 *pIcdSurface = NULL;
486
Jon Ashburn44aed662016-02-02 17:47:28 -0700487 pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceWin32),
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700488 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliottb2484122015-11-19 13:14:05 -0700489 if (pIcdSurface == NULL) {
490 return VK_ERROR_OUT_OF_HOST_MEMORY;
491 }
492
493 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WIN32;
Ian Elliottdcb176f2015-12-10 17:28:50 -0700494 pIcdSurface->hinstance = pCreateInfo->hinstance;
495 pIcdSurface->hwnd = pCreateInfo->hwnd;
Ian Elliottb2484122015-11-19 13:14:05 -0700496
Jon Ashburn44aed662016-02-02 17:47:28 -0700497 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliottb2484122015-11-19 13:14:05 -0700498
499 return VK_SUCCESS;
500}
Ian Elliott4e309e92015-11-24 15:39:10 -0700501
502/*
503 * This is the trampoline entrypoint
504 * for GetPhysicalDeviceWin32PresentationSupportKHR
505 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700506LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
507vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice,
508 uint32_t queueFamilyIndex) {
Jon Ashburn87660432016-03-01 19:51:07 -0700509 VkPhysicalDevice unwrapped_phys_dev =
510 loader_unwrap_physical_device(physicalDevice);
Ian Elliott4e309e92015-11-24 15:39:10 -0700511 const VkLayerInstanceDispatchTable *disp;
512 disp = loader_get_instance_dispatch(physicalDevice);
513 VkBool32 res = disp->GetPhysicalDeviceWin32PresentationSupportKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700514 unwrapped_phys_dev, queueFamilyIndex);
Ian Elliott4e309e92015-11-24 15:39:10 -0700515 return res;
516}
517
Ian Elliott4e309e92015-11-24 15:39:10 -0700518/*
519 * This is the instance chain terminator function
520 * for GetPhysicalDeviceWin32PresentationSupportKHR
521 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700522VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700523terminator_GetPhysicalDeviceWin32PresentationSupportKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700524 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex) {
525 struct loader_physical_device *phys_dev =
526 (struct loader_physical_device *)physicalDevice;
Ian Elliott4e309e92015-11-24 15:39:10 -0700527 struct loader_icd *icd = phys_dev->this_icd;
528
Jon Ashburn44aed662016-02-02 17:47:28 -0700529 assert(icd->GetPhysicalDeviceWin32PresentationSupportKHR &&
530 "loader: null GetPhysicalDeviceWin32PresentationSupportKHR ICD "
531 "pointer");
Ian Elliott4e309e92015-11-24 15:39:10 -0700532
533 return icd->GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev->phys_dev,
Jon Ashburn44aed662016-02-02 17:47:28 -0700534 queueFamilyIndex);
Ian Elliott4e309e92015-11-24 15:39:10 -0700535}
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700536#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliottb2484122015-11-19 13:14:05 -0700537
538#ifdef VK_USE_PLATFORM_MIR_KHR
539
540/*
541 * Functions for the VK_KHR_mir_surface extension:
542 */
543
544/*
545 * This is the trampoline entrypoint
546 * for CreateMirSurfaceKHR
547 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700548LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
549vkCreateMirSurfaceKHR(VkInstance instance,
550 const VkMirSurfaceCreateInfoKHR *pCreateInfo,
551 const VkAllocationCallbacks *pAllocator,
552 VkSurfaceKHR *pSurface) {
Jon Ashburn25a158f2015-11-25 17:55:49 -0700553 const VkLayerInstanceDispatchTable *disp;
554 disp = loader_get_instance_dispatch(instance);
555 VkResult res;
556
Jon Ashburn44aed662016-02-02 17:47:28 -0700557 res =
558 disp->CreateMirSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburn25a158f2015-11-25 17:55:49 -0700559 return res;
560}
561
562/*
563 * This is the instance chain terminator function
564 * for CreateMirSurfaceKHR
565 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700566VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700567terminator_CreateMirSurfaceKHR(VkInstance instance,
568 const VkMirSurfaceCreateInfoKHR *pCreateInfo,
569 const VkAllocationCallbacks *pAllocator,
570 VkSurfaceKHR *pSurface) {
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700571 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliottb2484122015-11-19 13:14:05 -0700572 VkIcdSurfaceMir *pIcdSurface = NULL;
573
Jon Ashburn44aed662016-02-02 17:47:28 -0700574 pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceMir),
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700575 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliottb2484122015-11-19 13:14:05 -0700576 if (pIcdSurface == NULL) {
577 return VK_ERROR_OUT_OF_HOST_MEMORY;
578 }
579
580 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_MIR;
Ian Elliottdcb176f2015-12-10 17:28:50 -0700581 pIcdSurface->connection = pCreateInfo->connection;
582 pIcdSurface->mirSurface = pCreateInfo->mirSurface;
Ian Elliottb2484122015-11-19 13:14:05 -0700583
Jon Ashburn44aed662016-02-02 17:47:28 -0700584 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliottb2484122015-11-19 13:14:05 -0700585
586 return VK_SUCCESS;
587}
Ian Elliott4e309e92015-11-24 15:39:10 -0700588
589/*
590 * This is the trampoline entrypoint
591 * for GetPhysicalDeviceMirPresentationSupportKHR
592 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700593LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
594vkGetPhysicalDeviceMirPresentationSupportKHR(VkPhysicalDevice physicalDevice,
595 uint32_t queueFamilyIndex,
596 MirConnection *connection) {
Jon Ashburn87660432016-03-01 19:51:07 -0700597 VkPhysicalDevice unwrapped_phys_dev =
598 loader_unwrap_physical_device(physicalDevice);
Ian Elliott4e309e92015-11-24 15:39:10 -0700599 const VkLayerInstanceDispatchTable *disp;
600 disp = loader_get_instance_dispatch(physicalDevice);
601 VkBool32 res = disp->GetPhysicalDeviceMirPresentationSupportKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700602 unwrapped_phys_dev, queueFamilyIndex, connection);
Ian Elliott4e309e92015-11-24 15:39:10 -0700603 return res;
604}
605
Ian Elliott4e309e92015-11-24 15:39:10 -0700606/*
607 * This is the instance chain terminator function
608 * for GetPhysicalDeviceMirPresentationSupportKHR
609 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700610VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700611terminator_GetPhysicalDeviceMirPresentationSupportKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700612 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
613 MirConnection *connection) {
614 struct loader_physical_device *phys_dev =
615 (struct loader_physical_device *)physicalDevice;
Ian Elliott4e309e92015-11-24 15:39:10 -0700616 struct loader_icd *icd = phys_dev->this_icd;
617
Jon Ashburn44aed662016-02-02 17:47:28 -0700618 assert(
619 icd->GetPhysicalDeviceMirPresentationSupportKHR &&
620 "loader: null GetPhysicalDeviceMirPresentationSupportKHR ICD pointer");
Ian Elliott4e309e92015-11-24 15:39:10 -0700621
Jon Ashburn44aed662016-02-02 17:47:28 -0700622 return icd->GetPhysicalDeviceMirPresentationSupportKHR(
623 phys_dev->phys_dev, queueFamilyIndex, connection);
Ian Elliott4e309e92015-11-24 15:39:10 -0700624}
Ian Elliottb2484122015-11-19 13:14:05 -0700625#endif // VK_USE_PLATFORM_MIR_KHR
626
627#ifdef VK_USE_PLATFORM_WAYLAND_KHR
628
629/*
630 * Functions for the VK_KHR_wayland_surface extension:
631 */
632
633/*
634 * This is the trampoline entrypoint
635 * for CreateWaylandSurfaceKHR
636 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700637LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
638vkCreateWaylandSurfaceKHR(VkInstance instance,
Jason Ekstrandcd0672c2016-02-12 17:25:03 -0800639 const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
Jon Ashburn44aed662016-02-02 17:47:28 -0700640 const VkAllocationCallbacks *pAllocator,
641 VkSurfaceKHR *pSurface) {
Jon Ashburn25a158f2015-11-25 17:55:49 -0700642 const VkLayerInstanceDispatchTable *disp;
643 disp = loader_get_instance_dispatch(instance);
644 VkResult res;
645
Jon Ashburn44aed662016-02-02 17:47:28 -0700646 res = disp->CreateWaylandSurfaceKHR(instance, pCreateInfo, pAllocator,
647 pSurface);
Jon Ashburn25a158f2015-11-25 17:55:49 -0700648 return res;
649}
650
651/*
652 * This is the instance chain terminator function
Mun, Gwan-gyeong3932b9e2016-02-22 09:33:58 +0900653 * for CreateWaylandSurfaceKHR
Jon Ashburn25a158f2015-11-25 17:55:49 -0700654 */
Jon Ashburna9c4a572016-02-26 13:14:27 -0700655VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(
656 VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
657 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700658 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliottb2484122015-11-19 13:14:05 -0700659 VkIcdSurfaceWayland *pIcdSurface = NULL;
660
Jon Ashburn44aed662016-02-02 17:47:28 -0700661 pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceWayland),
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700662 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliottb2484122015-11-19 13:14:05 -0700663 if (pIcdSurface == NULL) {
664 return VK_ERROR_OUT_OF_HOST_MEMORY;
665 }
666
667 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WAYLAND;
Ian Elliottdcb176f2015-12-10 17:28:50 -0700668 pIcdSurface->display = pCreateInfo->display;
669 pIcdSurface->surface = pCreateInfo->surface;
Ian Elliottb2484122015-11-19 13:14:05 -0700670
Jon Ashburn44aed662016-02-02 17:47:28 -0700671 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliottb2484122015-11-19 13:14:05 -0700672
673 return VK_SUCCESS;
674}
Ian Elliott4e309e92015-11-24 15:39:10 -0700675
676/*
677 * This is the trampoline entrypoint
678 * for GetPhysicalDeviceWaylandPresentationSupportKHR
679 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700680LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
681vkGetPhysicalDeviceWaylandPresentationSupportKHR(
682 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
683 struct wl_display *display) {
Jon Ashburn87660432016-03-01 19:51:07 -0700684 VkPhysicalDevice unwrapped_phys_dev =
685 loader_unwrap_physical_device(physicalDevice);
Ian Elliott4e309e92015-11-24 15:39:10 -0700686 const VkLayerInstanceDispatchTable *disp;
687 disp = loader_get_instance_dispatch(physicalDevice);
688 VkBool32 res = disp->GetPhysicalDeviceWaylandPresentationSupportKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700689 unwrapped_phys_dev, queueFamilyIndex, display);
Ian Elliott4e309e92015-11-24 15:39:10 -0700690 return res;
691}
692
Ian Elliott4e309e92015-11-24 15:39:10 -0700693/*
694 * This is the instance chain terminator function
695 * for GetPhysicalDeviceWaylandPresentationSupportKHR
696 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700697VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700698terminator_GetPhysicalDeviceWaylandPresentationSupportKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700699 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
700 struct wl_display *display) {
701 struct loader_physical_device *phys_dev =
702 (struct loader_physical_device *)physicalDevice;
Ian Elliott4e309e92015-11-24 15:39:10 -0700703 struct loader_icd *icd = phys_dev->this_icd;
704
Jon Ashburn44aed662016-02-02 17:47:28 -0700705 assert(icd->GetPhysicalDeviceWaylandPresentationSupportKHR &&
706 "loader: null GetPhysicalDeviceWaylandPresentationSupportKHR ICD "
707 "pointer");
Ian Elliott4e309e92015-11-24 15:39:10 -0700708
Jon Ashburn44aed662016-02-02 17:47:28 -0700709 return icd->GetPhysicalDeviceWaylandPresentationSupportKHR(
710 phys_dev->phys_dev, queueFamilyIndex, display);
Ian Elliott4e309e92015-11-24 15:39:10 -0700711}
Ian Elliottb2484122015-11-19 13:14:05 -0700712#endif // VK_USE_PLATFORM_WAYLAND_KHR
713
714#ifdef VK_USE_PLATFORM_XCB_KHR
715
716/*
717 * Functions for the VK_KHR_xcb_surface extension:
718 */
719
720/*
721 * This is the trampoline entrypoint
722 * for CreateXcbSurfaceKHR
723 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700724LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
725vkCreateXcbSurfaceKHR(VkInstance instance,
726 const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
727 const VkAllocationCallbacks *pAllocator,
728 VkSurfaceKHR *pSurface) {
Jon Ashburn25a158f2015-11-25 17:55:49 -0700729 const VkLayerInstanceDispatchTable *disp;
730 disp = loader_get_instance_dispatch(instance);
731 VkResult res;
732
Jon Ashburn44aed662016-02-02 17:47:28 -0700733 res =
734 disp->CreateXcbSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburn25a158f2015-11-25 17:55:49 -0700735 return res;
736}
737
738/*
739 * This is the instance chain terminator function
740 * for CreateXcbSurfaceKHR
741 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700742VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700743terminator_CreateXcbSurfaceKHR(VkInstance instance,
744 const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
745 const VkAllocationCallbacks *pAllocator,
746 VkSurfaceKHR *pSurface) {
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700747 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliottb2484122015-11-19 13:14:05 -0700748 VkIcdSurfaceXcb *pIcdSurface = NULL;
749
Jon Ashburn44aed662016-02-02 17:47:28 -0700750 pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceXcb),
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700751 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliottb2484122015-11-19 13:14:05 -0700752 if (pIcdSurface == NULL) {
753 return VK_ERROR_OUT_OF_HOST_MEMORY;
754 }
755
756 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XCB;
Ian Elliottdcb176f2015-12-10 17:28:50 -0700757 pIcdSurface->connection = pCreateInfo->connection;
758 pIcdSurface->window = pCreateInfo->window;
Ian Elliottb2484122015-11-19 13:14:05 -0700759
Jon Ashburn44aed662016-02-02 17:47:28 -0700760 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliottb2484122015-11-19 13:14:05 -0700761
762 return VK_SUCCESS;
763}
Ian Elliott4e309e92015-11-24 15:39:10 -0700764
765/*
766 * This is the trampoline entrypoint
767 * for GetPhysicalDeviceXcbPresentationSupportKHR
768 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700769LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
770vkGetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice,
771 uint32_t queueFamilyIndex,
772 xcb_connection_t *connection,
773 xcb_visualid_t visual_id) {
Jon Ashburn87660432016-03-01 19:51:07 -0700774 VkPhysicalDevice unwrapped_phys_dev =
775 loader_unwrap_physical_device(physicalDevice);
Ian Elliott4e309e92015-11-24 15:39:10 -0700776 const VkLayerInstanceDispatchTable *disp;
777 disp = loader_get_instance_dispatch(physicalDevice);
778 VkBool32 res = disp->GetPhysicalDeviceXcbPresentationSupportKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700779 unwrapped_phys_dev, queueFamilyIndex, connection, visual_id);
Ian Elliott4e309e92015-11-24 15:39:10 -0700780 return res;
781}
782
Ian Elliott4e309e92015-11-24 15:39:10 -0700783/*
784 * This is the instance chain terminator function
785 * for GetPhysicalDeviceXcbPresentationSupportKHR
786 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700787VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700788terminator_GetPhysicalDeviceXcbPresentationSupportKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700789 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
790 xcb_connection_t *connection, xcb_visualid_t visual_id) {
791 struct loader_physical_device *phys_dev =
792 (struct loader_physical_device *)physicalDevice;
Ian Elliott4e309e92015-11-24 15:39:10 -0700793 struct loader_icd *icd = phys_dev->this_icd;
794
Jon Ashburn44aed662016-02-02 17:47:28 -0700795 assert(
796 icd->GetPhysicalDeviceXcbPresentationSupportKHR &&
797 "loader: null GetPhysicalDeviceXcbPresentationSupportKHR ICD pointer");
Ian Elliott4e309e92015-11-24 15:39:10 -0700798
Jon Ashburn44aed662016-02-02 17:47:28 -0700799 return icd->GetPhysicalDeviceXcbPresentationSupportKHR(
800 phys_dev->phys_dev, queueFamilyIndex, connection, visual_id);
Ian Elliott4e309e92015-11-24 15:39:10 -0700801}
Ian Elliottb2484122015-11-19 13:14:05 -0700802#endif // VK_USE_PLATFORM_XCB_KHR
803
804#ifdef VK_USE_PLATFORM_XLIB_KHR
805
806/*
807 * Functions for the VK_KHR_xlib_surface extension:
808 */
809
810/*
811 * This is the trampoline entrypoint
812 * for CreateXlibSurfaceKHR
813 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700814LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
815vkCreateXlibSurfaceKHR(VkInstance instance,
816 const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
817 const VkAllocationCallbacks *pAllocator,
818 VkSurfaceKHR *pSurface) {
Jon Ashburn25a158f2015-11-25 17:55:49 -0700819 const VkLayerInstanceDispatchTable *disp;
820 disp = loader_get_instance_dispatch(instance);
821 VkResult res;
822
Jon Ashburn44aed662016-02-02 17:47:28 -0700823 res =
824 disp->CreateXlibSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburn25a158f2015-11-25 17:55:49 -0700825 return res;
826}
827
828/*
829 * This is the instance chain terminator function
830 * for CreateXlibSurfaceKHR
831 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700832VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700833terminator_CreateXlibSurfaceKHR(VkInstance instance,
834 const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
835 const VkAllocationCallbacks *pAllocator,
836 VkSurfaceKHR *pSurface) {
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700837 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliottb2484122015-11-19 13:14:05 -0700838 VkIcdSurfaceXlib *pIcdSurface = NULL;
839
Jon Ashburn44aed662016-02-02 17:47:28 -0700840 pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceXlib),
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700841 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliottb2484122015-11-19 13:14:05 -0700842 if (pIcdSurface == NULL) {
843 return VK_ERROR_OUT_OF_HOST_MEMORY;
844 }
845
846 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XLIB;
Ian Elliottdcb176f2015-12-10 17:28:50 -0700847 pIcdSurface->dpy = pCreateInfo->dpy;
848 pIcdSurface->window = pCreateInfo->window;
Ian Elliottb2484122015-11-19 13:14:05 -0700849
Jon Ashburn44aed662016-02-02 17:47:28 -0700850 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliottb2484122015-11-19 13:14:05 -0700851
852 return VK_SUCCESS;
853}
Ian Elliott4e309e92015-11-24 15:39:10 -0700854
855/*
856 * This is the trampoline entrypoint
857 * for GetPhysicalDeviceXlibPresentationSupportKHR
858 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700859LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
860vkGetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice,
861 uint32_t queueFamilyIndex,
862 Display *dpy, VisualID visualID) {
Jon Ashburn87660432016-03-01 19:51:07 -0700863 VkPhysicalDevice unwrapped_phys_dev =
864 loader_unwrap_physical_device(physicalDevice);
Ian Elliott4e309e92015-11-24 15:39:10 -0700865 const VkLayerInstanceDispatchTable *disp;
866 disp = loader_get_instance_dispatch(physicalDevice);
867 VkBool32 res = disp->GetPhysicalDeviceXlibPresentationSupportKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700868 unwrapped_phys_dev, queueFamilyIndex, dpy, visualID);
Ian Elliott4e309e92015-11-24 15:39:10 -0700869 return res;
870}
871
Ian Elliott4e309e92015-11-24 15:39:10 -0700872/*
873 * This is the instance chain terminator function
874 * for GetPhysicalDeviceXlibPresentationSupportKHR
875 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700876VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700877terminator_GetPhysicalDeviceXlibPresentationSupportKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700878 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display *dpy,
879 VisualID visualID) {
880 struct loader_physical_device *phys_dev =
881 (struct loader_physical_device *)physicalDevice;
Ian Elliott4e309e92015-11-24 15:39:10 -0700882 struct loader_icd *icd = phys_dev->this_icd;
883
Jon Ashburn44aed662016-02-02 17:47:28 -0700884 assert(
885 icd->GetPhysicalDeviceXlibPresentationSupportKHR &&
886 "loader: null GetPhysicalDeviceXlibPresentationSupportKHR ICD pointer");
Ian Elliott4e309e92015-11-24 15:39:10 -0700887
Jon Ashburn44aed662016-02-02 17:47:28 -0700888 return icd->GetPhysicalDeviceXlibPresentationSupportKHR(
889 phys_dev->phys_dev, queueFamilyIndex, dpy, visualID);
Ian Elliott4e309e92015-11-24 15:39:10 -0700890}
Ian Elliottb2484122015-11-19 13:14:05 -0700891#endif // VK_USE_PLATFORM_XLIB_KHR
892
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700893#ifdef VK_USE_PLATFORM_ANDROID_KHR
Ian Elliottb2484122015-11-19 13:14:05 -0700894
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700895/*
896 * Functions for the VK_KHR_android_surface extension:
897 */
898
899/*
900 * This is the trampoline entrypoint
901 * for CreateAndroidSurfaceKHR
902 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700903LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
904vkCreateAndroidSurfaceKHR(VkInstance instance, ANativeWindow *window,
905 const VkAllocationCallbacks *pAllocator,
906 VkSurfaceKHR *pSurface) {
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700907 const VkLayerInstanceDispatchTable *disp;
908 disp = loader_get_instance_dispatch(instance);
909 VkResult res;
910
911 res = disp->CreateAndroidSurfaceKHR(instance, window, pAllocator, pSurface);
912 return res;
913}
914
915/*
916 * This is the instance chain terminator function
917 * for CreateAndroidSurfaceKHR
918 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700919VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700920terminator_CreateAndroidSurfaceKHR(VkInstance instance, Window window,
921 const VkAllocationCallbacks *pAllocator,
922 VkSurfaceKHR *pSurface) {
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700923 struct loader_instance *ptr_instance = loader_get_instance(instance);
924 VkIcdSurfaceAndroid *pIcdSurface = NULL;
925
Jon Ashburn44aed662016-02-02 17:47:28 -0700926 pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceAndroid),
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700927 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
928 if (pIcdSurface == NULL) {
929 return VK_ERROR_OUT_OF_HOST_MEMORY;
930 }
931
932 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_ANDROID;
933 pIcdSurface->dpy = dpy;
934 pIcdSurface->window = window;
935
Jon Ashburn44aed662016-02-02 17:47:28 -0700936 *pSurface = (VkSurfaceKHR)pIcdSurface;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700937
938 return VK_SUCCESS;
939}
940
941#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliottb2484122015-11-19 13:14:05 -0700942
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600943bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance,
Jon Ashburn44aed662016-02-02 17:47:28 -0700944 const char *name, void **addr) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600945 *addr = NULL;
946
Ian Elliott5bf16c32015-11-19 16:39:21 -0700947 /*
948 * Functions for the VK_KHR_surface extension:
949 */
Ian Elliottb2484122015-11-19 13:14:05 -0700950 if (!strcmp("vkDestroySurfaceKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -0700951 *addr = ptr_instance->wsi_surface_enabled ? (void *)vkDestroySurfaceKHR
952 : NULL;
Ian Elliottb2484122015-11-19 13:14:05 -0700953 return true;
954 }
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600955 if (!strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -0700956 *addr = ptr_instance->wsi_surface_enabled
957 ? (void *)vkGetPhysicalDeviceSurfaceSupportKHR
958 : NULL;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600959 return true;
960 }
Ian Elliott8cda1802015-11-19 16:05:09 -0700961 if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -0700962 *addr = ptr_instance->wsi_surface_enabled
963 ? (void *)vkGetPhysicalDeviceSurfaceCapabilitiesKHR
964 : NULL;
Ian Elliott8cda1802015-11-19 16:05:09 -0700965 return true;
966 }
967 if (!strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -0700968 *addr = ptr_instance->wsi_surface_enabled
969 ? (void *)vkGetPhysicalDeviceSurfaceFormatsKHR
970 : NULL;
Ian Elliott8cda1802015-11-19 16:05:09 -0700971 return true;
972 }
973 if (!strcmp("vkGetPhysicalDeviceSurfacePresentModesKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -0700974 *addr = ptr_instance->wsi_surface_enabled
975 ? (void *)vkGetPhysicalDeviceSurfacePresentModesKHR
976 : NULL;
Ian Elliott8cda1802015-11-19 16:05:09 -0700977 return true;
978 }
Ian Elliott5bf16c32015-11-19 16:39:21 -0700979
980 /*
981 * Functions for the VK_KHR_swapchain extension:
982 *
983 * Note: This is a device extension, and its functions are statically
984 * exported from the loader. Per Khronos decisions, the the loader's GIPA
985 * function will return the trampoline function for such device-extension
986 * functions, regardless of whether the extension has been enabled.
987 */
988 if (!strcmp("vkCreateSwapchainKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -0700989 *addr = (void *)vkCreateSwapchainKHR;
Ian Elliott5bf16c32015-11-19 16:39:21 -0700990 return true;
991 }
992 if (!strcmp("vkDestroySwapchainKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -0700993 *addr = (void *)vkDestroySwapchainKHR;
Ian Elliott5bf16c32015-11-19 16:39:21 -0700994 return true;
995 }
996 if (!strcmp("vkGetSwapchainImagesKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -0700997 *addr = (void *)vkGetSwapchainImagesKHR;
Ian Elliott5bf16c32015-11-19 16:39:21 -0700998 return true;
999 }
1000 if (!strcmp("vkAcquireNextImageKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001001 *addr = (void *)vkAcquireNextImageKHR;
Ian Elliott5bf16c32015-11-19 16:39:21 -07001002 return true;
1003 }
1004 if (!strcmp("vkQueuePresentKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001005 *addr = (void *)vkQueuePresentKHR;
Ian Elliott5bf16c32015-11-19 16:39:21 -07001006 return true;
1007 }
1008
Ian Elliottb2484122015-11-19 13:14:05 -07001009#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott5bf16c32015-11-19 16:39:21 -07001010 /*
1011 * Functions for the VK_KHR_win32_surface extension:
1012 */
Ian Elliottb2484122015-11-19 13:14:05 -07001013 if (!strcmp("vkCreateWin32SurfaceKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001014 *addr = ptr_instance->wsi_win32_surface_enabled
1015 ? (void *)vkCreateWin32SurfaceKHR
1016 : NULL;
Ian Elliottb2484122015-11-19 13:14:05 -07001017 return true;
1018 }
Ian Elliott4e309e92015-11-24 15:39:10 -07001019 if (!strcmp("vkGetPhysicalDeviceWin32PresentationSupportKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001020 *addr = ptr_instance->wsi_win32_surface_enabled
1021 ? (void *)vkGetPhysicalDeviceWin32PresentationSupportKHR
1022 : NULL;
Ian Elliott4e309e92015-11-24 15:39:10 -07001023 return true;
1024 }
Ian Elliottb2484122015-11-19 13:14:05 -07001025#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliottb2484122015-11-19 13:14:05 -07001026#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott5bf16c32015-11-19 16:39:21 -07001027 /*
1028 * Functions for the VK_KHR_mir_surface extension:
1029 */
Ian Elliottb2484122015-11-19 13:14:05 -07001030 if (!strcmp("vkCreateMirSurfaceKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001031 *addr = ptr_instance->wsi_mir_surface_enabled
1032 ? (void *)vkCreateMirSurfaceKHR
1033 : NULL;
Ian Elliottb2484122015-11-19 13:14:05 -07001034 return true;
1035 }
Ian Elliott4e309e92015-11-24 15:39:10 -07001036 if (!strcmp("vkGetPhysicalDeviceMirPresentationSupportKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001037 *addr = ptr_instance->wsi_mir_surface_enabled
1038 ? (void *)vkGetPhysicalDeviceMirPresentationSupportKHR
1039 : NULL;
Ian Elliott4e309e92015-11-24 15:39:10 -07001040 return true;
Jason Ekstrandcd0672c2016-02-12 17:25:03 -08001041 }
Ian Elliottb2484122015-11-19 13:14:05 -07001042#endif // VK_USE_PLATFORM_MIR_KHR
1043#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Jon Ashburna9c4a572016-02-26 13:14:27 -07001044 /*
1045 * Functions for the VK_KHR_wayland_surface extension:
1046 */
1047 if (!strcmp("vkCreateWaylandSurfaceKHR", name)) {
1048 *addr = ptr_instance->wsi_wayland_surface_enabled
1049 ? (void *)vkCreateWaylandSurfaceKHR
1050 : NULL;
1051 return true;
1052 }
1053 if (!strcmp("vkGetPhysicalDeviceWaylandPresentationSupportKHR", name)) {
1054 *addr = ptr_instance->wsi_wayland_surface_enabled
Jon Ashburn44aed662016-02-02 17:47:28 -07001055 ? (void *)vkGetPhysicalDeviceWaylandPresentationSupportKHR
1056 : NULL;
Jon Ashburna9c4a572016-02-26 13:14:27 -07001057 return true;
1058 }
Ian Elliottb2484122015-11-19 13:14:05 -07001059#endif // VK_USE_PLATFORM_WAYLAND_KHR
1060#ifdef VK_USE_PLATFORM_XCB_KHR
Jon Ashburna9c4a572016-02-26 13:14:27 -07001061 /*
1062 * Functions for the VK_KHR_xcb_surface extension:
1063 */
1064 if (!strcmp("vkCreateXcbSurfaceKHR", name)) {
1065 *addr = ptr_instance->wsi_xcb_surface_enabled
1066 ? (void *)vkCreateXcbSurfaceKHR
1067 : NULL;
1068 return true;
1069 }
1070 if (!strcmp("vkGetPhysicalDeviceXcbPresentationSupportKHR", name)) {
1071 *addr = ptr_instance->wsi_xcb_surface_enabled
1072 ? (void *)vkGetPhysicalDeviceXcbPresentationSupportKHR
1073 : NULL;
1074 return true;
1075 }
Ian Elliottb2484122015-11-19 13:14:05 -07001076#endif // VK_USE_PLATFORM_XCB_KHR
1077#ifdef VK_USE_PLATFORM_XLIB_KHR
Jon Ashburna9c4a572016-02-26 13:14:27 -07001078 /*
1079 * Functions for the VK_KHR_xlib_surface extension:
1080 */
1081 if (!strcmp("vkCreateXlibSurfaceKHR", name)) {
1082 *addr = ptr_instance->wsi_xlib_surface_enabled
1083 ? (void *)vkCreateXlibSurfaceKHR
1084 : NULL;
1085 return true;
1086 }
1087 if (!strcmp("vkGetPhysicalDeviceXlibPresentationSupportKHR", name)) {
1088 *addr = ptr_instance->wsi_xlib_surface_enabled
1089 ? (void *)vkGetPhysicalDeviceXlibPresentationSupportKHR
1090 : NULL;
1091 return true;
1092 }
Ian Elliottb2484122015-11-19 13:14:05 -07001093#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -07001094#ifdef VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburna9c4a572016-02-26 13:14:27 -07001095 /*
1096 * Functions for the VK_KHR_android_surface extension:
1097 */
1098 if (!strcmp("vkCreateAndroidSurfaceKHR", name)) {
1099 *addr = ptr_instance->wsi_xlib_surface_enabled
1100 ? (void *)vkCreateAndroidSurfaceKHR
1101 : NULL;
1102 return true;
1103 }
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -07001104#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliottb2484122015-11-19 13:14:05 -07001105
Jon Ashburna9c4a572016-02-26 13:14:27 -07001106 return false;
1107}