blob: d53ce4a9fe6b72284e30439256656892bbe297f1 [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 Ashburn00df0452016-03-08 09:30:30 -070087// Note for VK_DISPLAY_KHR don't advertise support since we really need support
88// to come from ICD, although the loader supplements the support from ICD
89
Jon Ashburn44aed662016-02-02 17:47:28 -070090void wsi_add_instance_extensions(const struct loader_instance *inst,
91 struct loader_extension_list *ext_list) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -060092 loader_add_to_ext_list(inst, ext_list, 1, &wsi_surface_extension_info);
Ian Elliott3ce23f92015-11-19 11:58:08 -070093#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -070094 loader_add_to_ext_list(inst, ext_list, 1,
95 &wsi_win32_surface_extension_info);
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -070096#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott9c068c92015-10-30 17:45:05 -060097#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060098 loader_add_to_ext_list(inst, ext_list, 1, &wsi_mir_surface_extension_info);
Ian Elliott9c068c92015-10-30 17:45:05 -060099#endif // VK_USE_PLATFORM_MIR_KHR
100#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700101 loader_add_to_ext_list(inst, ext_list, 1,
102 &wsi_wayland_surface_extension_info);
Ian Elliott9c068c92015-10-30 17:45:05 -0600103#endif // VK_USE_PLATFORM_WAYLAND_KHR
104#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600105 loader_add_to_ext_list(inst, ext_list, 1, &wsi_xcb_surface_extension_info);
Ian Elliott9c068c92015-10-30 17:45:05 -0600106#endif // VK_USE_PLATFORM_XCB_KHR
107#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600108 loader_add_to_ext_list(inst, ext_list, 1, &wsi_xlib_surface_extension_info);
Ian Elliott9c068c92015-10-30 17:45:05 -0600109#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700110#ifdef VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700111 loader_add_to_ext_list(inst, ext_list, 1,
112 &wsi_android_surface_extension_info);
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700113#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600114}
115
Jon Ashburn44aed662016-02-02 17:47:28 -0700116void wsi_create_instance(struct loader_instance *ptr_instance,
117 const VkInstanceCreateInfo *pCreateInfo) {
Ian Elliott9c068c92015-10-30 17:45:05 -0600118 ptr_instance->wsi_surface_enabled = false;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700119
120#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburn00df0452016-03-08 09:30:30 -0700121 ptr_instance->wsi_win32_surface_enabled = false;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700122#endif // VK_USE_PLATFORM_WIN32_KHR
123#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600124 ptr_instance->wsi_mir_surface_enabled = false;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700125#endif // VK_USE_PLATFORM_MIR_KHR
126#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600127 ptr_instance->wsi_wayland_surface_enabled = false;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700128#endif // VK_USE_PLATFORM_WAYLAND_KHR
129#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600130 ptr_instance->wsi_xcb_surface_enabled = false;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700131#endif // VK_USE_PLATFORM_XCB_KHR
132#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600133 ptr_instance->wsi_xlib_surface_enabled = false;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700134#endif // VK_USE_PLATFORM_XLIB_KHR
135#ifdef VK_USE_PLATFORM_ANDROID_KHR
136 ptr_instance->wsi_android_surface_enabled = false;
137#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600138
Jon Ashburn00df0452016-03-08 09:30:30 -0700139 ptr_instance->wsi_display_enabled = false;
140
Jon Ashburna4ae48b2016-01-11 13:12:43 -0700141 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Jon Ashburn44aed662016-02-02 17:47:28 -0700142 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
143 VK_KHR_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600144 ptr_instance->wsi_surface_enabled = true;
Ian Elliott3ce23f92015-11-19 11:58:08 -0700145 continue;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600146 }
Ian Elliott3ce23f92015-11-19 11:58:08 -0700147#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700148 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
149 VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700150 ptr_instance->wsi_win32_surface_enabled = true;
Ian Elliott3ce23f92015-11-19 11:58:08 -0700151 continue;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600152 }
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700153#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott9c068c92015-10-30 17:45:05 -0600154#ifdef VK_USE_PLATFORM_MIR_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700155 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
156 VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600157 ptr_instance->wsi_mir_surface_enabled = true;
Ian Elliott3ce23f92015-11-19 11:58:08 -0700158 continue;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600159 }
Ian Elliott9c068c92015-10-30 17:45:05 -0600160#endif // VK_USE_PLATFORM_MIR_KHR
161#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700162 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
163 VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600164 ptr_instance->wsi_wayland_surface_enabled = true;
Ian Elliott3ce23f92015-11-19 11:58:08 -0700165 continue;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600166 }
Ian Elliott9c068c92015-10-30 17:45:05 -0600167#endif // VK_USE_PLATFORM_WAYLAND_KHR
168#ifdef VK_USE_PLATFORM_XCB_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700169 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
170 VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600171 ptr_instance->wsi_xcb_surface_enabled = true;
Ian Elliott3ce23f92015-11-19 11:58:08 -0700172 continue;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600173 }
Ian Elliott9c068c92015-10-30 17:45:05 -0600174#endif // VK_USE_PLATFORM_XCB_KHR
175#ifdef VK_USE_PLATFORM_XLIB_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700176 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
177 VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600178 ptr_instance->wsi_xlib_surface_enabled = true;
Ian Elliott3ce23f92015-11-19 11:58:08 -0700179 continue;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600180 }
Ian Elliott9c068c92015-10-30 17:45:05 -0600181#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700182#ifdef VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700183 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
184 VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0) {
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700185 ptr_instance->wsi_android_surface_enabled = true;
186 continue;
187 }
188#endif // VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburn00df0452016-03-08 09:30:30 -0700189 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
190 VK_KHR_DISPLAY_EXTENSION_NAME) == 0) {
191 ptr_instance->wsi_display_enabled = true;
192 continue;
193 }
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600194 }
195}
196
197/*
Ian Elliottb2484122015-11-19 13:14:05 -0700198 * Functions for the VK_KHR_surface extension:
199 */
200
201/*
202 * This is the trampoline entrypoint
203 * for DestroySurfaceKHR
Ian Elliottb2484122015-11-19 13:14:05 -0700204 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700205LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
206vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
207 const VkAllocationCallbacks *pAllocator) {
Ian Elliott7b9f7822015-11-25 14:43:02 -0700208 const VkLayerInstanceDispatchTable *disp;
209 disp = loader_get_instance_dispatch(instance);
210 disp->DestroySurfaceKHR(instance, surface, pAllocator);
211}
212
Jon Ashburn00df0452016-03-08 09:30:30 -0700213// TODO probably need to lock around all the loader_get_instance() calls.
Ian Elliott7b9f7822015-11-25 14:43:02 -0700214/*
215 * This is the instance chain terminator function
216 * for DestroySurfaceKHR
217 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700218VKAPI_ATTR void VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700219terminator_DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
220 const VkAllocationCallbacks *pAllocator) {
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700221 struct loader_instance *ptr_instance = loader_get_instance(instance);
222
Mark Young2acdd152016-01-13 13:47:16 -0700223 loader_heap_free(ptr_instance, (void *)surface);
Ian Elliottb2484122015-11-19 13:14:05 -0700224}
225
226/*
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600227 * This is the trampoline entrypoint
228 * for GetPhysicalDeviceSurfaceSupportKHR
229 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700230LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
231vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,
232 uint32_t queueFamilyIndex,
233 VkSurfaceKHR surface,
234 VkBool32 *pSupported) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600235 const VkLayerInstanceDispatchTable *disp;
Jon Ashburn87660432016-03-01 19:51:07 -0700236 VkPhysicalDevice unwrapped_phys_dev =
237 loader_unwrap_physical_device(physicalDevice);
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600238 disp = loader_get_instance_dispatch(physicalDevice);
239 VkResult res = disp->GetPhysicalDeviceSurfaceSupportKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700240 unwrapped_phys_dev, queueFamilyIndex, surface, pSupported);
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600241 return res;
242}
243
244/*
245 * This is the instance chain terminator function
246 * for GetPhysicalDeviceSurfaceSupportKHR
247 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700248VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700249terminator_GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,
250 uint32_t queueFamilyIndex,
251 VkSurfaceKHR surface,
252 VkBool32 *pSupported) {
Jon Ashburn44aed662016-02-02 17:47:28 -0700253 struct loader_physical_device *phys_dev =
254 (struct loader_physical_device *)physicalDevice;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600255 struct loader_icd *icd = phys_dev->this_icd;
256
Jon Ashburn44aed662016-02-02 17:47:28 -0700257 assert(pSupported &&
258 "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported");
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600259 *pSupported = false;
260
Jon Ashburn44aed662016-02-02 17:47:28 -0700261 assert(icd->GetPhysicalDeviceSurfaceSupportKHR &&
262 "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer");
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600263
Jon Ashburn44aed662016-02-02 17:47:28 -0700264 return icd->GetPhysicalDeviceSurfaceSupportKHR(
265 phys_dev->phys_dev, queueFamilyIndex, surface, pSupported);
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600266}
267
Ian Elliott8cda1802015-11-19 16:05:09 -0700268/*
269 * This is the trampoline entrypoint
270 * for GetPhysicalDeviceSurfaceCapabilitiesKHR
271 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700272LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
273vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
274 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
275 VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) {
Jon Ashburn87660432016-03-01 19:51:07 -0700276
Ian Elliott8cda1802015-11-19 16:05:09 -0700277 const VkLayerInstanceDispatchTable *disp;
Jon Ashburn87660432016-03-01 19:51:07 -0700278 VkPhysicalDevice unwrapped_phys_dev =
279 loader_unwrap_physical_device(physicalDevice);
Ian Elliott8cda1802015-11-19 16:05:09 -0700280 disp = loader_get_instance_dispatch(physicalDevice);
281 VkResult res = disp->GetPhysicalDeviceSurfaceCapabilitiesKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700282 unwrapped_phys_dev, surface, pSurfaceCapabilities);
Ian Elliott8cda1802015-11-19 16:05:09 -0700283 return res;
284}
285
286/*
287 * This is the instance chain terminator function
288 * for GetPhysicalDeviceSurfaceCapabilitiesKHR
289 */
Jon Ashburna9c4a572016-02-26 13:14:27 -0700290VKAPI_ATTR VkResult VKAPI_CALL
291terminator_GetPhysicalDeviceSurfaceCapabilitiesKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700292 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
293 VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) {
294 struct loader_physical_device *phys_dev =
295 (struct loader_physical_device *)physicalDevice;
Ian Elliott8cda1802015-11-19 16:05:09 -0700296 struct loader_icd *icd = phys_dev->this_icd;
297
Jon Ashburn44aed662016-02-02 17:47:28 -0700298 assert(pSurfaceCapabilities && "GetPhysicalDeviceSurfaceCapabilitiesKHR: "
299 "Error, null pSurfaceCapabilities");
Ian Elliott8cda1802015-11-19 16:05:09 -0700300
Jon Ashburn44aed662016-02-02 17:47:28 -0700301 assert(icd->GetPhysicalDeviceSurfaceCapabilitiesKHR &&
302 "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer");
Ian Elliott8cda1802015-11-19 16:05:09 -0700303
Jon Ashburn44aed662016-02-02 17:47:28 -0700304 return icd->GetPhysicalDeviceSurfaceCapabilitiesKHR(
305 phys_dev->phys_dev, surface, pSurfaceCapabilities);
Ian Elliott8cda1802015-11-19 16:05:09 -0700306}
307
308/*
309 * This is the trampoline entrypoint
310 * for GetPhysicalDeviceSurfaceFormatsKHR
311 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700312LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
313vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
314 VkSurfaceKHR surface,
315 uint32_t *pSurfaceFormatCount,
316 VkSurfaceFormatKHR *pSurfaceFormats) {
Jon Ashburn87660432016-03-01 19:51:07 -0700317 VkPhysicalDevice unwrapped_phys_dev =
318 loader_unwrap_physical_device(physicalDevice);
Ian Elliott8cda1802015-11-19 16:05:09 -0700319 const VkLayerInstanceDispatchTable *disp;
320 disp = loader_get_instance_dispatch(physicalDevice);
321 VkResult res = disp->GetPhysicalDeviceSurfaceFormatsKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700322 unwrapped_phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats);
Ian Elliott8cda1802015-11-19 16:05:09 -0700323 return res;
324}
325
326/*
327 * This is the instance chain terminator function
328 * for GetPhysicalDeviceSurfaceFormatsKHR
329 */
Jon Ashburna9c4a572016-02-26 13:14:27 -0700330VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormatsKHR(
331 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
332 uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats) {
Jon Ashburn44aed662016-02-02 17:47:28 -0700333 struct loader_physical_device *phys_dev =
334 (struct loader_physical_device *)physicalDevice;
Ian Elliott8cda1802015-11-19 16:05:09 -0700335 struct loader_icd *icd = phys_dev->this_icd;
336
Jon Ashburn44aed662016-02-02 17:47:28 -0700337 assert(
338 pSurfaceFormatCount &&
339 "GetPhysicalDeviceSurfaceFormatsKHR: Error, null pSurfaceFormatCount");
Ian Elliott8cda1802015-11-19 16:05:09 -0700340
Jon Ashburn44aed662016-02-02 17:47:28 -0700341 assert(icd->GetPhysicalDeviceSurfaceFormatsKHR &&
342 "loader: null GetPhysicalDeviceSurfaceFormatsKHR ICD pointer");
Ian Elliott8cda1802015-11-19 16:05:09 -0700343
Jon Ashburn44aed662016-02-02 17:47:28 -0700344 return icd->GetPhysicalDeviceSurfaceFormatsKHR(
345 phys_dev->phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats);
Ian Elliott8cda1802015-11-19 16:05:09 -0700346}
347
348/*
349 * This is the trampoline entrypoint
350 * for GetPhysicalDeviceSurfacePresentModesKHR
351 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700352LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
353vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
354 VkSurfaceKHR surface,
355 uint32_t *pPresentModeCount,
356 VkPresentModeKHR *pPresentModes) {
Jon Ashburn87660432016-03-01 19:51:07 -0700357 VkPhysicalDevice unwrapped_phys_dev =
358 loader_unwrap_physical_device(physicalDevice);
Ian Elliott8cda1802015-11-19 16:05:09 -0700359 const VkLayerInstanceDispatchTable *disp;
360 disp = loader_get_instance_dispatch(physicalDevice);
361 VkResult res = disp->GetPhysicalDeviceSurfacePresentModesKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700362 unwrapped_phys_dev, surface, pPresentModeCount, pPresentModes);
Ian Elliott8cda1802015-11-19 16:05:09 -0700363 return res;
364}
365
366/*
367 * This is the instance chain terminator function
368 * for GetPhysicalDeviceSurfacePresentModesKHR
369 */
Jon Ashburna9c4a572016-02-26 13:14:27 -0700370VKAPI_ATTR VkResult VKAPI_CALL
371terminator_GetPhysicalDeviceSurfacePresentModesKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700372 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
373 uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes) {
374 struct loader_physical_device *phys_dev =
375 (struct loader_physical_device *)physicalDevice;
Ian Elliott8cda1802015-11-19 16:05:09 -0700376 struct loader_icd *icd = phys_dev->this_icd;
377
Jon Ashburn44aed662016-02-02 17:47:28 -0700378 assert(pPresentModeCount && "GetPhysicalDeviceSurfacePresentModesKHR: "
379 "Error, null pPresentModeCount");
Ian Elliott8cda1802015-11-19 16:05:09 -0700380
Jon Ashburn44aed662016-02-02 17:47:28 -0700381 assert(icd->GetPhysicalDeviceSurfacePresentModesKHR &&
382 "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer");
Ian Elliott8cda1802015-11-19 16:05:09 -0700383
Jon Ashburn44aed662016-02-02 17:47:28 -0700384 return icd->GetPhysicalDeviceSurfacePresentModesKHR(
385 phys_dev->phys_dev, surface, pPresentModeCount, pPresentModes);
Ian Elliott8cda1802015-11-19 16:05:09 -0700386}
387
Ian Elliottb2484122015-11-19 13:14:05 -0700388/*
389 * Functions for the VK_KHR_swapchain extension:
390 */
391
Ian Elliott5bf16c32015-11-19 16:39:21 -0700392/*
393 * This is the trampoline entrypoint
394 * for CreateSwapchainKHR
395 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700396LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
397vkCreateSwapchainKHR(VkDevice device,
398 const VkSwapchainCreateInfoKHR *pCreateInfo,
399 const VkAllocationCallbacks *pAllocator,
400 VkSwapchainKHR *pSwapchain) {
Ian Elliott5bf16c32015-11-19 16:39:21 -0700401 const VkLayerDispatchTable *disp;
402 disp = loader_get_dispatch(device);
Jon Ashburn44aed662016-02-02 17:47:28 -0700403 VkResult res =
404 disp->CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain);
Ian Elliott5bf16c32015-11-19 16:39:21 -0700405 return res;
406}
Ian Elliottb2484122015-11-19 13:14:05 -0700407
Ian Elliott5bf16c32015-11-19 16:39:21 -0700408/*
409 * This is the trampoline entrypoint
410 * for DestroySwapchainKHR
411 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700412LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
413vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain,
414 const VkAllocationCallbacks *pAllocator) {
Ian Elliott5bf16c32015-11-19 16:39:21 -0700415 const VkLayerDispatchTable *disp;
416 disp = loader_get_dispatch(device);
417 disp->DestroySwapchainKHR(device, swapchain, pAllocator);
418}
Ian Elliottb2484122015-11-19 13:14:05 -0700419
Ian Elliott5bf16c32015-11-19 16:39:21 -0700420/*
421 * This is the trampoline entrypoint
422 * for GetSwapchainImagesKHR
423 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700424LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
425vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain,
426 uint32_t *pSwapchainImageCount,
427 VkImage *pSwapchainImages) {
Ian Elliott5bf16c32015-11-19 16:39:21 -0700428 const VkLayerDispatchTable *disp;
429 disp = loader_get_dispatch(device);
430 VkResult res = disp->GetSwapchainImagesKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700431 device, swapchain, pSwapchainImageCount, pSwapchainImages);
Ian Elliott5bf16c32015-11-19 16:39:21 -0700432 return res;
433}
434
435/*
436 * This is the trampoline entrypoint
437 * for AcquireNextImageKHR
438 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700439LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
440vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain,
441 uint64_t timeout, VkSemaphore semaphore, VkFence fence,
442 uint32_t *pImageIndex) {
Ian Elliott5bf16c32015-11-19 16:39:21 -0700443 const VkLayerDispatchTable *disp;
444 disp = loader_get_dispatch(device);
Jon Ashburn44aed662016-02-02 17:47:28 -0700445 VkResult res = disp->AcquireNextImageKHR(device, swapchain, timeout,
446 semaphore, fence, pImageIndex);
Ian Elliott5bf16c32015-11-19 16:39:21 -0700447 return res;
448}
449
450/*
451 * This is the trampoline entrypoint
452 * for QueuePresentKHR
453 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700454LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
455vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) {
Ian Elliott5bf16c32015-11-19 16:39:21 -0700456 const VkLayerDispatchTable *disp;
457 disp = loader_get_dispatch(queue);
458 VkResult res = disp->QueuePresentKHR(queue, pPresentInfo);
459 return res;
460}
Ian Elliottb2484122015-11-19 13:14:05 -0700461
Ian Elliottb2484122015-11-19 13:14:05 -0700462#ifdef VK_USE_PLATFORM_WIN32_KHR
463
464/*
465 * Functions for the VK_KHR_win32_surface extension:
466 */
467
468/*
469 * This is the trampoline entrypoint
470 * for CreateWin32SurfaceKHR
471 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700472LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
473vkCreateWin32SurfaceKHR(VkInstance instance,
474 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
475 const VkAllocationCallbacks *pAllocator,
476 VkSurfaceKHR *pSurface) {
Jon Ashburn25a158f2015-11-25 17:55:49 -0700477 const VkLayerInstanceDispatchTable *disp;
478 disp = loader_get_instance_dispatch(instance);
479 VkResult res;
480
Jon Ashburn44aed662016-02-02 17:47:28 -0700481 res = disp->CreateWin32SurfaceKHR(instance, pCreateInfo, pAllocator,
482 pSurface);
Jon Ashburn25a158f2015-11-25 17:55:49 -0700483 return res;
484}
485
486/*
487 * This is the instance chain terminator function
488 * for CreateWin32SurfaceKHR
489 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700490VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700491terminator_CreateWin32SurfaceKHR(VkInstance instance,
492 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
493 const VkAllocationCallbacks *pAllocator,
494 VkSurfaceKHR *pSurface) {
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700495 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliottb2484122015-11-19 13:14:05 -0700496 VkIcdSurfaceWin32 *pIcdSurface = NULL;
497
Jon Ashburn44aed662016-02-02 17:47:28 -0700498 pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceWin32),
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700499 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliottb2484122015-11-19 13:14:05 -0700500 if (pIcdSurface == NULL) {
501 return VK_ERROR_OUT_OF_HOST_MEMORY;
502 }
503
504 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WIN32;
Ian Elliottdcb176f2015-12-10 17:28:50 -0700505 pIcdSurface->hinstance = pCreateInfo->hinstance;
506 pIcdSurface->hwnd = pCreateInfo->hwnd;
Ian Elliottb2484122015-11-19 13:14:05 -0700507
Jon Ashburn44aed662016-02-02 17:47:28 -0700508 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliottb2484122015-11-19 13:14:05 -0700509
510 return VK_SUCCESS;
511}
Ian Elliott4e309e92015-11-24 15:39:10 -0700512
513/*
514 * This is the trampoline entrypoint
515 * for GetPhysicalDeviceWin32PresentationSupportKHR
516 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700517LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
518vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice,
519 uint32_t queueFamilyIndex) {
Jon Ashburn87660432016-03-01 19:51:07 -0700520 VkPhysicalDevice unwrapped_phys_dev =
521 loader_unwrap_physical_device(physicalDevice);
Ian Elliott4e309e92015-11-24 15:39:10 -0700522 const VkLayerInstanceDispatchTable *disp;
523 disp = loader_get_instance_dispatch(physicalDevice);
524 VkBool32 res = disp->GetPhysicalDeviceWin32PresentationSupportKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700525 unwrapped_phys_dev, queueFamilyIndex);
Ian Elliott4e309e92015-11-24 15:39:10 -0700526 return res;
527}
528
Ian Elliott4e309e92015-11-24 15:39:10 -0700529/*
530 * This is the instance chain terminator function
531 * for GetPhysicalDeviceWin32PresentationSupportKHR
532 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700533VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700534terminator_GetPhysicalDeviceWin32PresentationSupportKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700535 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex) {
536 struct loader_physical_device *phys_dev =
537 (struct loader_physical_device *)physicalDevice;
Ian Elliott4e309e92015-11-24 15:39:10 -0700538 struct loader_icd *icd = phys_dev->this_icd;
539
Jon Ashburn44aed662016-02-02 17:47:28 -0700540 assert(icd->GetPhysicalDeviceWin32PresentationSupportKHR &&
541 "loader: null GetPhysicalDeviceWin32PresentationSupportKHR ICD "
542 "pointer");
Ian Elliott4e309e92015-11-24 15:39:10 -0700543
544 return icd->GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev->phys_dev,
Jon Ashburn44aed662016-02-02 17:47:28 -0700545 queueFamilyIndex);
Ian Elliott4e309e92015-11-24 15:39:10 -0700546}
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700547#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliottb2484122015-11-19 13:14:05 -0700548
549#ifdef VK_USE_PLATFORM_MIR_KHR
550
551/*
552 * Functions for the VK_KHR_mir_surface extension:
553 */
554
555/*
556 * This is the trampoline entrypoint
557 * for CreateMirSurfaceKHR
558 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700559LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
560vkCreateMirSurfaceKHR(VkInstance instance,
561 const VkMirSurfaceCreateInfoKHR *pCreateInfo,
562 const VkAllocationCallbacks *pAllocator,
563 VkSurfaceKHR *pSurface) {
Jon Ashburn25a158f2015-11-25 17:55:49 -0700564 const VkLayerInstanceDispatchTable *disp;
565 disp = loader_get_instance_dispatch(instance);
566 VkResult res;
567
Jon Ashburn44aed662016-02-02 17:47:28 -0700568 res =
569 disp->CreateMirSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburn25a158f2015-11-25 17:55:49 -0700570 return res;
571}
572
573/*
574 * This is the instance chain terminator function
575 * for CreateMirSurfaceKHR
576 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700577VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700578terminator_CreateMirSurfaceKHR(VkInstance instance,
579 const VkMirSurfaceCreateInfoKHR *pCreateInfo,
580 const VkAllocationCallbacks *pAllocator,
581 VkSurfaceKHR *pSurface) {
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700582 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliottb2484122015-11-19 13:14:05 -0700583 VkIcdSurfaceMir *pIcdSurface = NULL;
584
Jon Ashburn44aed662016-02-02 17:47:28 -0700585 pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceMir),
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700586 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliottb2484122015-11-19 13:14:05 -0700587 if (pIcdSurface == NULL) {
588 return VK_ERROR_OUT_OF_HOST_MEMORY;
589 }
590
591 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_MIR;
Ian Elliottdcb176f2015-12-10 17:28:50 -0700592 pIcdSurface->connection = pCreateInfo->connection;
593 pIcdSurface->mirSurface = pCreateInfo->mirSurface;
Ian Elliottb2484122015-11-19 13:14:05 -0700594
Jon Ashburn44aed662016-02-02 17:47:28 -0700595 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliottb2484122015-11-19 13:14:05 -0700596
597 return VK_SUCCESS;
598}
Ian Elliott4e309e92015-11-24 15:39:10 -0700599
600/*
601 * This is the trampoline entrypoint
602 * for GetPhysicalDeviceMirPresentationSupportKHR
603 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700604LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
605vkGetPhysicalDeviceMirPresentationSupportKHR(VkPhysicalDevice physicalDevice,
606 uint32_t queueFamilyIndex,
607 MirConnection *connection) {
Jon Ashburn87660432016-03-01 19:51:07 -0700608 VkPhysicalDevice unwrapped_phys_dev =
609 loader_unwrap_physical_device(physicalDevice);
Ian Elliott4e309e92015-11-24 15:39:10 -0700610 const VkLayerInstanceDispatchTable *disp;
611 disp = loader_get_instance_dispatch(physicalDevice);
612 VkBool32 res = disp->GetPhysicalDeviceMirPresentationSupportKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700613 unwrapped_phys_dev, queueFamilyIndex, connection);
Ian Elliott4e309e92015-11-24 15:39:10 -0700614 return res;
615}
616
Ian Elliott4e309e92015-11-24 15:39:10 -0700617/*
618 * This is the instance chain terminator function
619 * for GetPhysicalDeviceMirPresentationSupportKHR
620 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700621VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700622terminator_GetPhysicalDeviceMirPresentationSupportKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700623 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
624 MirConnection *connection) {
625 struct loader_physical_device *phys_dev =
626 (struct loader_physical_device *)physicalDevice;
Ian Elliott4e309e92015-11-24 15:39:10 -0700627 struct loader_icd *icd = phys_dev->this_icd;
628
Jon Ashburn44aed662016-02-02 17:47:28 -0700629 assert(
630 icd->GetPhysicalDeviceMirPresentationSupportKHR &&
631 "loader: null GetPhysicalDeviceMirPresentationSupportKHR ICD pointer");
Ian Elliott4e309e92015-11-24 15:39:10 -0700632
Jon Ashburn44aed662016-02-02 17:47:28 -0700633 return icd->GetPhysicalDeviceMirPresentationSupportKHR(
634 phys_dev->phys_dev, queueFamilyIndex, connection);
Ian Elliott4e309e92015-11-24 15:39:10 -0700635}
Ian Elliottb2484122015-11-19 13:14:05 -0700636#endif // VK_USE_PLATFORM_MIR_KHR
637
638#ifdef VK_USE_PLATFORM_WAYLAND_KHR
639
640/*
641 * Functions for the VK_KHR_wayland_surface extension:
642 */
643
644/*
645 * This is the trampoline entrypoint
646 * for CreateWaylandSurfaceKHR
647 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700648LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
649vkCreateWaylandSurfaceKHR(VkInstance instance,
Jason Ekstrandcd0672c2016-02-12 17:25:03 -0800650 const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
Jon Ashburn44aed662016-02-02 17:47:28 -0700651 const VkAllocationCallbacks *pAllocator,
652 VkSurfaceKHR *pSurface) {
Jon Ashburn25a158f2015-11-25 17:55:49 -0700653 const VkLayerInstanceDispatchTable *disp;
654 disp = loader_get_instance_dispatch(instance);
655 VkResult res;
656
Jon Ashburn44aed662016-02-02 17:47:28 -0700657 res = disp->CreateWaylandSurfaceKHR(instance, pCreateInfo, pAllocator,
658 pSurface);
Jon Ashburn25a158f2015-11-25 17:55:49 -0700659 return res;
660}
661
662/*
663 * This is the instance chain terminator function
Mun, Gwan-gyeong3932b9e2016-02-22 09:33:58 +0900664 * for CreateWaylandSurfaceKHR
Jon Ashburn25a158f2015-11-25 17:55:49 -0700665 */
Jon Ashburna9c4a572016-02-26 13:14:27 -0700666VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(
667 VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
668 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700669 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliottb2484122015-11-19 13:14:05 -0700670 VkIcdSurfaceWayland *pIcdSurface = NULL;
671
Jon Ashburn44aed662016-02-02 17:47:28 -0700672 pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceWayland),
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700673 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliottb2484122015-11-19 13:14:05 -0700674 if (pIcdSurface == NULL) {
675 return VK_ERROR_OUT_OF_HOST_MEMORY;
676 }
677
678 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WAYLAND;
Ian Elliottdcb176f2015-12-10 17:28:50 -0700679 pIcdSurface->display = pCreateInfo->display;
680 pIcdSurface->surface = pCreateInfo->surface;
Ian Elliottb2484122015-11-19 13:14:05 -0700681
Jon Ashburn44aed662016-02-02 17:47:28 -0700682 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliottb2484122015-11-19 13:14:05 -0700683
684 return VK_SUCCESS;
685}
Ian Elliott4e309e92015-11-24 15:39:10 -0700686
687/*
688 * This is the trampoline entrypoint
689 * for GetPhysicalDeviceWaylandPresentationSupportKHR
690 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700691LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
692vkGetPhysicalDeviceWaylandPresentationSupportKHR(
693 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
694 struct wl_display *display) {
Jon Ashburn87660432016-03-01 19:51:07 -0700695 VkPhysicalDevice unwrapped_phys_dev =
696 loader_unwrap_physical_device(physicalDevice);
Ian Elliott4e309e92015-11-24 15:39:10 -0700697 const VkLayerInstanceDispatchTable *disp;
698 disp = loader_get_instance_dispatch(physicalDevice);
699 VkBool32 res = disp->GetPhysicalDeviceWaylandPresentationSupportKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700700 unwrapped_phys_dev, queueFamilyIndex, display);
Ian Elliott4e309e92015-11-24 15:39:10 -0700701 return res;
702}
703
Ian Elliott4e309e92015-11-24 15:39:10 -0700704/*
705 * This is the instance chain terminator function
706 * for GetPhysicalDeviceWaylandPresentationSupportKHR
707 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700708VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700709terminator_GetPhysicalDeviceWaylandPresentationSupportKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700710 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
711 struct wl_display *display) {
712 struct loader_physical_device *phys_dev =
713 (struct loader_physical_device *)physicalDevice;
Ian Elliott4e309e92015-11-24 15:39:10 -0700714 struct loader_icd *icd = phys_dev->this_icd;
715
Jon Ashburn44aed662016-02-02 17:47:28 -0700716 assert(icd->GetPhysicalDeviceWaylandPresentationSupportKHR &&
717 "loader: null GetPhysicalDeviceWaylandPresentationSupportKHR ICD "
718 "pointer");
Ian Elliott4e309e92015-11-24 15:39:10 -0700719
Jon Ashburn44aed662016-02-02 17:47:28 -0700720 return icd->GetPhysicalDeviceWaylandPresentationSupportKHR(
721 phys_dev->phys_dev, queueFamilyIndex, display);
Ian Elliott4e309e92015-11-24 15:39:10 -0700722}
Ian Elliottb2484122015-11-19 13:14:05 -0700723#endif // VK_USE_PLATFORM_WAYLAND_KHR
724
725#ifdef VK_USE_PLATFORM_XCB_KHR
726
727/*
728 * Functions for the VK_KHR_xcb_surface extension:
729 */
730
731/*
732 * This is the trampoline entrypoint
733 * for CreateXcbSurfaceKHR
734 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700735LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
736vkCreateXcbSurfaceKHR(VkInstance instance,
737 const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
738 const VkAllocationCallbacks *pAllocator,
739 VkSurfaceKHR *pSurface) {
Jon Ashburn25a158f2015-11-25 17:55:49 -0700740 const VkLayerInstanceDispatchTable *disp;
741 disp = loader_get_instance_dispatch(instance);
742 VkResult res;
743
Jon Ashburn44aed662016-02-02 17:47:28 -0700744 res =
745 disp->CreateXcbSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburn25a158f2015-11-25 17:55:49 -0700746 return res;
747}
748
749/*
750 * This is the instance chain terminator function
751 * for CreateXcbSurfaceKHR
752 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700753VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700754terminator_CreateXcbSurfaceKHR(VkInstance instance,
755 const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
756 const VkAllocationCallbacks *pAllocator,
757 VkSurfaceKHR *pSurface) {
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700758 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliottb2484122015-11-19 13:14:05 -0700759 VkIcdSurfaceXcb *pIcdSurface = NULL;
760
Jon Ashburn44aed662016-02-02 17:47:28 -0700761 pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceXcb),
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700762 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliottb2484122015-11-19 13:14:05 -0700763 if (pIcdSurface == NULL) {
764 return VK_ERROR_OUT_OF_HOST_MEMORY;
765 }
766
767 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XCB;
Ian Elliottdcb176f2015-12-10 17:28:50 -0700768 pIcdSurface->connection = pCreateInfo->connection;
769 pIcdSurface->window = pCreateInfo->window;
Ian Elliottb2484122015-11-19 13:14:05 -0700770
Jon Ashburn44aed662016-02-02 17:47:28 -0700771 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliottb2484122015-11-19 13:14:05 -0700772
773 return VK_SUCCESS;
774}
Ian Elliott4e309e92015-11-24 15:39:10 -0700775
776/*
777 * This is the trampoline entrypoint
778 * for GetPhysicalDeviceXcbPresentationSupportKHR
779 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700780LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
781vkGetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice,
782 uint32_t queueFamilyIndex,
783 xcb_connection_t *connection,
784 xcb_visualid_t visual_id) {
Jon Ashburn87660432016-03-01 19:51:07 -0700785 VkPhysicalDevice unwrapped_phys_dev =
786 loader_unwrap_physical_device(physicalDevice);
Ian Elliott4e309e92015-11-24 15:39:10 -0700787 const VkLayerInstanceDispatchTable *disp;
788 disp = loader_get_instance_dispatch(physicalDevice);
789 VkBool32 res = disp->GetPhysicalDeviceXcbPresentationSupportKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700790 unwrapped_phys_dev, queueFamilyIndex, connection, visual_id);
Ian Elliott4e309e92015-11-24 15:39:10 -0700791 return res;
792}
793
Ian Elliott4e309e92015-11-24 15:39:10 -0700794/*
795 * This is the instance chain terminator function
796 * for GetPhysicalDeviceXcbPresentationSupportKHR
797 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700798VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700799terminator_GetPhysicalDeviceXcbPresentationSupportKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700800 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
801 xcb_connection_t *connection, xcb_visualid_t visual_id) {
802 struct loader_physical_device *phys_dev =
803 (struct loader_physical_device *)physicalDevice;
Ian Elliott4e309e92015-11-24 15:39:10 -0700804 struct loader_icd *icd = phys_dev->this_icd;
805
Jon Ashburn44aed662016-02-02 17:47:28 -0700806 assert(
807 icd->GetPhysicalDeviceXcbPresentationSupportKHR &&
808 "loader: null GetPhysicalDeviceXcbPresentationSupportKHR ICD pointer");
Ian Elliott4e309e92015-11-24 15:39:10 -0700809
Jon Ashburn44aed662016-02-02 17:47:28 -0700810 return icd->GetPhysicalDeviceXcbPresentationSupportKHR(
811 phys_dev->phys_dev, queueFamilyIndex, connection, visual_id);
Ian Elliott4e309e92015-11-24 15:39:10 -0700812}
Ian Elliottb2484122015-11-19 13:14:05 -0700813#endif // VK_USE_PLATFORM_XCB_KHR
814
815#ifdef VK_USE_PLATFORM_XLIB_KHR
816
817/*
818 * Functions for the VK_KHR_xlib_surface extension:
819 */
820
821/*
822 * This is the trampoline entrypoint
823 * for CreateXlibSurfaceKHR
824 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700825LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
826vkCreateXlibSurfaceKHR(VkInstance instance,
827 const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
828 const VkAllocationCallbacks *pAllocator,
829 VkSurfaceKHR *pSurface) {
Jon Ashburn25a158f2015-11-25 17:55:49 -0700830 const VkLayerInstanceDispatchTable *disp;
831 disp = loader_get_instance_dispatch(instance);
832 VkResult res;
833
Jon Ashburn44aed662016-02-02 17:47:28 -0700834 res =
835 disp->CreateXlibSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburn25a158f2015-11-25 17:55:49 -0700836 return res;
837}
838
839/*
840 * This is the instance chain terminator function
841 * for CreateXlibSurfaceKHR
842 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700843VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700844terminator_CreateXlibSurfaceKHR(VkInstance instance,
845 const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
846 const VkAllocationCallbacks *pAllocator,
847 VkSurfaceKHR *pSurface) {
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700848 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliottb2484122015-11-19 13:14:05 -0700849 VkIcdSurfaceXlib *pIcdSurface = NULL;
850
Jon Ashburn44aed662016-02-02 17:47:28 -0700851 pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceXlib),
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700852 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliottb2484122015-11-19 13:14:05 -0700853 if (pIcdSurface == NULL) {
854 return VK_ERROR_OUT_OF_HOST_MEMORY;
855 }
856
857 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XLIB;
Ian Elliottdcb176f2015-12-10 17:28:50 -0700858 pIcdSurface->dpy = pCreateInfo->dpy;
859 pIcdSurface->window = pCreateInfo->window;
Ian Elliottb2484122015-11-19 13:14:05 -0700860
Jon Ashburn44aed662016-02-02 17:47:28 -0700861 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliottb2484122015-11-19 13:14:05 -0700862
863 return VK_SUCCESS;
864}
Ian Elliott4e309e92015-11-24 15:39:10 -0700865
866/*
867 * This is the trampoline entrypoint
868 * for GetPhysicalDeviceXlibPresentationSupportKHR
869 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700870LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
871vkGetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice,
872 uint32_t queueFamilyIndex,
873 Display *dpy, VisualID visualID) {
Jon Ashburn87660432016-03-01 19:51:07 -0700874 VkPhysicalDevice unwrapped_phys_dev =
875 loader_unwrap_physical_device(physicalDevice);
Ian Elliott4e309e92015-11-24 15:39:10 -0700876 const VkLayerInstanceDispatchTable *disp;
877 disp = loader_get_instance_dispatch(physicalDevice);
878 VkBool32 res = disp->GetPhysicalDeviceXlibPresentationSupportKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700879 unwrapped_phys_dev, queueFamilyIndex, dpy, visualID);
Ian Elliott4e309e92015-11-24 15:39:10 -0700880 return res;
881}
882
Ian Elliott4e309e92015-11-24 15:39:10 -0700883/*
884 * This is the instance chain terminator function
885 * for GetPhysicalDeviceXlibPresentationSupportKHR
886 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700887VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700888terminator_GetPhysicalDeviceXlibPresentationSupportKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700889 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display *dpy,
890 VisualID visualID) {
891 struct loader_physical_device *phys_dev =
892 (struct loader_physical_device *)physicalDevice;
Ian Elliott4e309e92015-11-24 15:39:10 -0700893 struct loader_icd *icd = phys_dev->this_icd;
894
Jon Ashburn44aed662016-02-02 17:47:28 -0700895 assert(
896 icd->GetPhysicalDeviceXlibPresentationSupportKHR &&
897 "loader: null GetPhysicalDeviceXlibPresentationSupportKHR ICD pointer");
Ian Elliott4e309e92015-11-24 15:39:10 -0700898
Jon Ashburn44aed662016-02-02 17:47:28 -0700899 return icd->GetPhysicalDeviceXlibPresentationSupportKHR(
900 phys_dev->phys_dev, queueFamilyIndex, dpy, visualID);
Ian Elliott4e309e92015-11-24 15:39:10 -0700901}
Ian Elliottb2484122015-11-19 13:14:05 -0700902#endif // VK_USE_PLATFORM_XLIB_KHR
903
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700904#ifdef VK_USE_PLATFORM_ANDROID_KHR
Ian Elliottb2484122015-11-19 13:14:05 -0700905
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700906/*
907 * Functions for the VK_KHR_android_surface extension:
908 */
909
910/*
911 * This is the trampoline entrypoint
912 * for CreateAndroidSurfaceKHR
913 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700914LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
915vkCreateAndroidSurfaceKHR(VkInstance instance, ANativeWindow *window,
916 const VkAllocationCallbacks *pAllocator,
917 VkSurfaceKHR *pSurface) {
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700918 const VkLayerInstanceDispatchTable *disp;
919 disp = loader_get_instance_dispatch(instance);
920 VkResult res;
921
922 res = disp->CreateAndroidSurfaceKHR(instance, window, pAllocator, pSurface);
923 return res;
924}
925
926/*
927 * This is the instance chain terminator function
928 * for CreateAndroidSurfaceKHR
929 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700930VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700931terminator_CreateAndroidSurfaceKHR(VkInstance instance, Window window,
932 const VkAllocationCallbacks *pAllocator,
933 VkSurfaceKHR *pSurface) {
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700934 struct loader_instance *ptr_instance = loader_get_instance(instance);
935 VkIcdSurfaceAndroid *pIcdSurface = NULL;
936
Jon Ashburn44aed662016-02-02 17:47:28 -0700937 pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceAndroid),
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700938 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
939 if (pIcdSurface == NULL) {
940 return VK_ERROR_OUT_OF_HOST_MEMORY;
941 }
942
943 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_ANDROID;
944 pIcdSurface->dpy = dpy;
945 pIcdSurface->window = window;
946
Jon Ashburn44aed662016-02-02 17:47:28 -0700947 *pSurface = (VkSurfaceKHR)pIcdSurface;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700948
949 return VK_SUCCESS;
950}
951
952#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliottb2484122015-11-19 13:14:05 -0700953
Jon Ashburn00df0452016-03-08 09:30:30 -0700954
955/*
956 * Functions for the VK_KHR_display instance extension:
957 */
958LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
959vkGetPhysicalDeviceDisplayPropertiesKHR(
960 VkPhysicalDevice physicalDevice,
961 uint32_t* pPropertyCount,
962 VkDisplayPropertiesKHR* pProperties)
963{
964 VkPhysicalDevice unwrapped_phys_dev =
965 loader_unwrap_physical_device(physicalDevice);
966 const VkLayerInstanceDispatchTable *disp;
967 disp = loader_get_instance_dispatch(physicalDevice);
968 VkResult res = disp->GetPhysicalDeviceDisplayPropertiesKHR(
969 unwrapped_phys_dev, pPropertyCount, pProperties);
970 return res;
971}
972
973VKAPI_ATTR VkResult VKAPI_CALL
974terminator_GetPhysicalDeviceDisplayPropertiesKHR(
975 VkPhysicalDevice physicalDevice,
976 uint32_t* pPropertyCount,
977 VkDisplayPropertiesKHR* pProperties)
978{
979 struct loader_physical_device *phys_dev =
980 (struct loader_physical_device *)physicalDevice;
981 struct loader_icd *icd = phys_dev->this_icd;
982
983 assert(
984 icd->GetPhysicalDeviceDisplayPropertiesKHR &&
985 "loader: null GetPhysicalDeviceDisplayPropertiesKHR ICD pointer");
986
987 return icd->GetPhysicalDeviceDisplayPropertiesKHR(
988 phys_dev->phys_dev, pPropertyCount, pProperties);
989}
990
991LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
992vkGetPhysicalDeviceDisplayPlanePropertiesKHR(
993 VkPhysicalDevice physicalDevice,
994 uint32_t* pPropertyCount,
995 VkDisplayPlanePropertiesKHR* pProperties)
996{
997 VkPhysicalDevice unwrapped_phys_dev =
998 loader_unwrap_physical_device(physicalDevice);
999 const VkLayerInstanceDispatchTable *disp;
1000 disp = loader_get_instance_dispatch(physicalDevice);
1001 VkResult res = disp->GetPhysicalDeviceDisplayPlanePropertiesKHR(
1002 unwrapped_phys_dev, pPropertyCount, pProperties);
1003 return res;
1004}
1005
1006VKAPI_ATTR VkResult VKAPI_CALL
1007terminator_GetPhysicalDeviceDisplayPlanePropertiesKHR(
1008 VkPhysicalDevice physicalDevice,
1009 uint32_t* pPropertyCount,
1010 VkDisplayPlanePropertiesKHR* pProperties)
1011{
1012 struct loader_physical_device *phys_dev =
1013 (struct loader_physical_device *)physicalDevice;
1014 struct loader_icd *icd = phys_dev->this_icd;
1015
1016 assert(
1017 icd->GetPhysicalDeviceDisplayPlanePropertiesKHR &&
1018 "loader: null GetPhysicalDeviceDisplayPlanePropertiesKHR ICD pointer");
1019
1020 return icd->GetPhysicalDeviceDisplayPlanePropertiesKHR(
1021 phys_dev->phys_dev, pPropertyCount, pProperties);
1022}
1023
1024LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1025vkGetDisplayPlaneSupportedDisplaysKHR(
1026 VkPhysicalDevice physicalDevice,
1027 uint32_t planeIndex,
1028 uint32_t* pDisplayCount,
1029 VkDisplayKHR* pDisplays)
1030{
1031 VkPhysicalDevice unwrapped_phys_dev =
1032 loader_unwrap_physical_device(physicalDevice);
1033 const VkLayerInstanceDispatchTable *disp;
1034 disp = loader_get_instance_dispatch(physicalDevice);
1035 VkResult res = disp->GetDisplayPlaneSupportedDisplaysKHR(
1036 unwrapped_phys_dev, planeIndex, pDisplayCount, pDisplays);
1037 return res;
1038}
1039
1040VKAPI_ATTR VkResult VKAPI_CALL
1041terminator_GetDisplayPlaneSupportedDisplaysKHR(
1042 VkPhysicalDevice physicalDevice,
1043 uint32_t planeIndex,
1044 uint32_t* pDisplayCount,
1045 VkDisplayKHR* pDisplays)
1046{
1047 struct loader_physical_device *phys_dev =
1048 (struct loader_physical_device *)physicalDevice;
1049 struct loader_icd *icd = phys_dev->this_icd;
1050
1051 assert(
1052 icd->GetDisplayPlaneSupportedDisplaysKHR &&
1053 "loader: null GetDisplayPlaneSupportedDisplaysKHR ICD pointer");
1054
1055 return icd->GetDisplayPlaneSupportedDisplaysKHR(
1056 phys_dev->phys_dev, planeIndex, pDisplayCount, pDisplays);
1057}
1058
1059LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1060vkGetDisplayModePropertiesKHR(
1061 VkPhysicalDevice physicalDevice,
1062 VkDisplayKHR display,
1063 uint32_t* pPropertyCount,
1064 VkDisplayModePropertiesKHR* pProperties)
1065{
1066 VkPhysicalDevice unwrapped_phys_dev =
1067 loader_unwrap_physical_device(physicalDevice);
1068 const VkLayerInstanceDispatchTable *disp;
1069 disp = loader_get_instance_dispatch(physicalDevice);
1070 VkResult res = disp->GetDisplayModePropertiesKHR(
1071 unwrapped_phys_dev, display, pPropertyCount, pProperties);
1072 return res;
1073}
1074
1075VKAPI_ATTR VkResult VKAPI_CALL
1076terminator_GetDisplayModePropertiesKHR(
1077 VkPhysicalDevice physicalDevice,
1078 VkDisplayKHR display,
1079 uint32_t* pPropertyCount,
1080 VkDisplayModePropertiesKHR* pProperties)
1081{
1082 struct loader_physical_device *phys_dev =
1083 (struct loader_physical_device *)physicalDevice;
1084 struct loader_icd *icd = phys_dev->this_icd;
1085
1086 assert(
1087 icd->GetDisplayModePropertiesKHR &&
1088 "loader: null GetDisplayModePropertiesKHR ICD pointer");
1089
1090 return icd->GetDisplayModePropertiesKHR(
1091 phys_dev->phys_dev, display, pPropertyCount, pProperties);
1092}
1093
1094LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1095vkCreateDisplayModeKHR(
1096 VkPhysicalDevice physicalDevice,
1097 VkDisplayKHR display,
1098 const VkDisplayModeCreateInfoKHR* pCreateInfo,
1099 const VkAllocationCallbacks* pAllocator,
1100 VkDisplayModeKHR* pMode)
1101{
1102 VkPhysicalDevice unwrapped_phys_dev =
1103 loader_unwrap_physical_device(physicalDevice);
1104 const VkLayerInstanceDispatchTable *disp;
1105 disp = loader_get_instance_dispatch(physicalDevice);
1106 VkResult res = disp->CreateDisplayModeKHR(
1107 unwrapped_phys_dev, display, pCreateInfo, pAllocator, pMode);
1108 return res;
1109}
1110
1111VKAPI_ATTR VkResult VKAPI_CALL
1112terminator_CreateDisplayModeKHR(
1113 VkPhysicalDevice physicalDevice,
1114 VkDisplayKHR display,
1115 const VkDisplayModeCreateInfoKHR* pCreateInfo,
1116 const VkAllocationCallbacks* pAllocator,
1117 VkDisplayModeKHR* pMode)
1118{
1119 struct loader_physical_device *phys_dev =
1120 (struct loader_physical_device *)physicalDevice;
1121 struct loader_icd *icd = phys_dev->this_icd;
1122
1123 assert(
1124 icd->CreateDisplayModeKHR &&
1125 "loader: null CreateDisplayModeKHR ICD pointer");
1126
1127 return icd->CreateDisplayModeKHR(
1128 phys_dev->phys_dev, display, pCreateInfo, pAllocator, pMode);
1129}
1130
1131LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1132vkGetDisplayPlaneCapabilitiesKHR(
1133 VkPhysicalDevice physicalDevice,
1134 VkDisplayModeKHR mode,
1135 uint32_t planeIndex,
1136 VkDisplayPlaneCapabilitiesKHR* pCapabilities)
1137{
1138 VkPhysicalDevice unwrapped_phys_dev =
1139 loader_unwrap_physical_device(physicalDevice);
1140 const VkLayerInstanceDispatchTable *disp;
1141 disp = loader_get_instance_dispatch(physicalDevice);
1142 VkResult res = disp->GetDisplayPlaneCapabilitiesKHR(
1143 unwrapped_phys_dev, mode, planeIndex, pCapabilities);
1144 return res;
1145}
1146
1147VKAPI_ATTR VkResult VKAPI_CALL
1148terminator_GetDisplayPlaneCapabilitiesKHR(
1149 VkPhysicalDevice physicalDevice,
1150 VkDisplayModeKHR mode,
1151 uint32_t planeIndex,
1152 VkDisplayPlaneCapabilitiesKHR* pCapabilities)
1153{
1154 struct loader_physical_device *phys_dev =
1155 (struct loader_physical_device *)physicalDevice;
1156 struct loader_icd *icd = phys_dev->this_icd;
1157
1158 assert(
1159 icd->GetDisplayPlaneCapabilitiesKHR &&
1160 "loader: null GetDisplayPlaneCapabilitiesKHR ICD pointer");
1161
1162 return icd->GetDisplayPlaneCapabilitiesKHR(
1163 phys_dev->phys_dev, mode, planeIndex, pCapabilities);
1164}
1165
1166LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1167vkCreateDisplayPlaneSurfaceKHR(
1168 VkInstance instance,
1169 const VkDisplaySurfaceCreateInfoKHR* pCreateInfo,
1170 const VkAllocationCallbacks* pAllocator,
1171 VkSurfaceKHR* pSurface)
1172{
1173 const VkLayerInstanceDispatchTable *disp;
1174 disp = loader_get_instance_dispatch(instance);
1175 VkResult res;
1176
1177 res = disp->CreateDisplayPlaneSurfaceKHR(instance, pCreateInfo, pAllocator,
1178 pSurface);
1179 return res;
1180}
1181
1182VKAPI_ATTR VkResult VKAPI_CALL
1183terminator_CreateDisplayPlaneSurfaceKHR(
1184 VkInstance instance,
1185 const VkDisplaySurfaceCreateInfoKHR* pCreateInfo,
1186 const VkAllocationCallbacks* pAllocator,
1187 VkSurfaceKHR* pSurface)
1188{
1189 struct loader_instance *inst = loader_get_instance(instance);
1190 VkIcdSurfaceDisplay *pIcdSurface = NULL;
1191
1192 pIcdSurface = loader_heap_alloc(inst, sizeof(VkIcdSurfaceDisplay),
1193 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
1194 if (pIcdSurface == NULL) {
1195 return VK_ERROR_OUT_OF_HOST_MEMORY;
1196 }
1197
1198 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_DISPLAY;
1199 pIcdSurface->displayMode = pCreateInfo->displayMode;
1200 pIcdSurface->planeIndex = pCreateInfo->planeIndex;
1201 pIcdSurface->planeStackIndex = pCreateInfo->planeStackIndex;
1202 pIcdSurface->transform = pCreateInfo->transform;
1203 pIcdSurface->globalAlpha = pCreateInfo->globalAlpha;
1204 pIcdSurface->alphaMode = pCreateInfo->alphaMode;
1205 pIcdSurface->imageExtent = pCreateInfo->imageExtent;
1206
1207 *pSurface = (VkSurfaceKHR)pIcdSurface;
1208
1209 return VK_SUCCESS;
1210}
1211
Ian Elliotta81e8ac2015-10-30 15:28:23 -06001212bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance,
Jon Ashburn44aed662016-02-02 17:47:28 -07001213 const char *name, void **addr) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -06001214 *addr = NULL;
1215
Ian Elliott5bf16c32015-11-19 16:39:21 -07001216 /*
1217 * Functions for the VK_KHR_surface extension:
1218 */
Ian Elliottb2484122015-11-19 13:14:05 -07001219 if (!strcmp("vkDestroySurfaceKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001220 *addr = ptr_instance->wsi_surface_enabled ? (void *)vkDestroySurfaceKHR
1221 : NULL;
Ian Elliottb2484122015-11-19 13:14:05 -07001222 return true;
1223 }
Ian Elliotta81e8ac2015-10-30 15:28:23 -06001224 if (!strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001225 *addr = ptr_instance->wsi_surface_enabled
1226 ? (void *)vkGetPhysicalDeviceSurfaceSupportKHR
1227 : NULL;
Ian Elliotta81e8ac2015-10-30 15:28:23 -06001228 return true;
1229 }
Ian Elliott8cda1802015-11-19 16:05:09 -07001230 if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001231 *addr = ptr_instance->wsi_surface_enabled
1232 ? (void *)vkGetPhysicalDeviceSurfaceCapabilitiesKHR
1233 : NULL;
Ian Elliott8cda1802015-11-19 16:05:09 -07001234 return true;
1235 }
1236 if (!strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001237 *addr = ptr_instance->wsi_surface_enabled
1238 ? (void *)vkGetPhysicalDeviceSurfaceFormatsKHR
1239 : NULL;
Ian Elliott8cda1802015-11-19 16:05:09 -07001240 return true;
1241 }
1242 if (!strcmp("vkGetPhysicalDeviceSurfacePresentModesKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001243 *addr = ptr_instance->wsi_surface_enabled
1244 ? (void *)vkGetPhysicalDeviceSurfacePresentModesKHR
1245 : NULL;
Ian Elliott8cda1802015-11-19 16:05:09 -07001246 return true;
1247 }
Ian Elliott5bf16c32015-11-19 16:39:21 -07001248
1249 /*
1250 * Functions for the VK_KHR_swapchain extension:
1251 *
1252 * Note: This is a device extension, and its functions are statically
1253 * exported from the loader. Per Khronos decisions, the the loader's GIPA
1254 * function will return the trampoline function for such device-extension
1255 * functions, regardless of whether the extension has been enabled.
1256 */
1257 if (!strcmp("vkCreateSwapchainKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001258 *addr = (void *)vkCreateSwapchainKHR;
Ian Elliott5bf16c32015-11-19 16:39:21 -07001259 return true;
1260 }
1261 if (!strcmp("vkDestroySwapchainKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001262 *addr = (void *)vkDestroySwapchainKHR;
Ian Elliott5bf16c32015-11-19 16:39:21 -07001263 return true;
1264 }
1265 if (!strcmp("vkGetSwapchainImagesKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001266 *addr = (void *)vkGetSwapchainImagesKHR;
Ian Elliott5bf16c32015-11-19 16:39:21 -07001267 return true;
1268 }
1269 if (!strcmp("vkAcquireNextImageKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001270 *addr = (void *)vkAcquireNextImageKHR;
Ian Elliott5bf16c32015-11-19 16:39:21 -07001271 return true;
1272 }
1273 if (!strcmp("vkQueuePresentKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001274 *addr = (void *)vkQueuePresentKHR;
Ian Elliott5bf16c32015-11-19 16:39:21 -07001275 return true;
1276 }
1277
Ian Elliottb2484122015-11-19 13:14:05 -07001278#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott5bf16c32015-11-19 16:39:21 -07001279 /*
1280 * Functions for the VK_KHR_win32_surface extension:
1281 */
Ian Elliottb2484122015-11-19 13:14:05 -07001282 if (!strcmp("vkCreateWin32SurfaceKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001283 *addr = ptr_instance->wsi_win32_surface_enabled
1284 ? (void *)vkCreateWin32SurfaceKHR
1285 : NULL;
Ian Elliottb2484122015-11-19 13:14:05 -07001286 return true;
1287 }
Ian Elliott4e309e92015-11-24 15:39:10 -07001288 if (!strcmp("vkGetPhysicalDeviceWin32PresentationSupportKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001289 *addr = ptr_instance->wsi_win32_surface_enabled
1290 ? (void *)vkGetPhysicalDeviceWin32PresentationSupportKHR
1291 : NULL;
Ian Elliott4e309e92015-11-24 15:39:10 -07001292 return true;
1293 }
Ian Elliottb2484122015-11-19 13:14:05 -07001294#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliottb2484122015-11-19 13:14:05 -07001295#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott5bf16c32015-11-19 16:39:21 -07001296 /*
1297 * Functions for the VK_KHR_mir_surface extension:
1298 */
Ian Elliottb2484122015-11-19 13:14:05 -07001299 if (!strcmp("vkCreateMirSurfaceKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001300 *addr = ptr_instance->wsi_mir_surface_enabled
1301 ? (void *)vkCreateMirSurfaceKHR
1302 : NULL;
Ian Elliottb2484122015-11-19 13:14:05 -07001303 return true;
1304 }
Ian Elliott4e309e92015-11-24 15:39:10 -07001305 if (!strcmp("vkGetPhysicalDeviceMirPresentationSupportKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001306 *addr = ptr_instance->wsi_mir_surface_enabled
1307 ? (void *)vkGetPhysicalDeviceMirPresentationSupportKHR
1308 : NULL;
Ian Elliott4e309e92015-11-24 15:39:10 -07001309 return true;
Jason Ekstrandcd0672c2016-02-12 17:25:03 -08001310 }
Ian Elliottb2484122015-11-19 13:14:05 -07001311#endif // VK_USE_PLATFORM_MIR_KHR
1312#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Jon Ashburna9c4a572016-02-26 13:14:27 -07001313 /*
1314 * Functions for the VK_KHR_wayland_surface extension:
1315 */
1316 if (!strcmp("vkCreateWaylandSurfaceKHR", name)) {
1317 *addr = ptr_instance->wsi_wayland_surface_enabled
1318 ? (void *)vkCreateWaylandSurfaceKHR
1319 : NULL;
1320 return true;
1321 }
1322 if (!strcmp("vkGetPhysicalDeviceWaylandPresentationSupportKHR", name)) {
1323 *addr = ptr_instance->wsi_wayland_surface_enabled
Jon Ashburn44aed662016-02-02 17:47:28 -07001324 ? (void *)vkGetPhysicalDeviceWaylandPresentationSupportKHR
1325 : NULL;
Jon Ashburna9c4a572016-02-26 13:14:27 -07001326 return true;
1327 }
Ian Elliottb2484122015-11-19 13:14:05 -07001328#endif // VK_USE_PLATFORM_WAYLAND_KHR
1329#ifdef VK_USE_PLATFORM_XCB_KHR
Jon Ashburna9c4a572016-02-26 13:14:27 -07001330 /*
1331 * Functions for the VK_KHR_xcb_surface extension:
1332 */
1333 if (!strcmp("vkCreateXcbSurfaceKHR", name)) {
1334 *addr = ptr_instance->wsi_xcb_surface_enabled
1335 ? (void *)vkCreateXcbSurfaceKHR
1336 : NULL;
1337 return true;
1338 }
1339 if (!strcmp("vkGetPhysicalDeviceXcbPresentationSupportKHR", name)) {
1340 *addr = ptr_instance->wsi_xcb_surface_enabled
1341 ? (void *)vkGetPhysicalDeviceXcbPresentationSupportKHR
1342 : NULL;
1343 return true;
1344 }
Ian Elliottb2484122015-11-19 13:14:05 -07001345#endif // VK_USE_PLATFORM_XCB_KHR
1346#ifdef VK_USE_PLATFORM_XLIB_KHR
Jon Ashburna9c4a572016-02-26 13:14:27 -07001347 /*
1348 * Functions for the VK_KHR_xlib_surface extension:
1349 */
1350 if (!strcmp("vkCreateXlibSurfaceKHR", name)) {
1351 *addr = ptr_instance->wsi_xlib_surface_enabled
1352 ? (void *)vkCreateXlibSurfaceKHR
1353 : NULL;
1354 return true;
1355 }
1356 if (!strcmp("vkGetPhysicalDeviceXlibPresentationSupportKHR", name)) {
1357 *addr = ptr_instance->wsi_xlib_surface_enabled
1358 ? (void *)vkGetPhysicalDeviceXlibPresentationSupportKHR
1359 : NULL;
1360 return true;
1361 }
Ian Elliottb2484122015-11-19 13:14:05 -07001362#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -07001363#ifdef VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburna9c4a572016-02-26 13:14:27 -07001364 /*
1365 * Functions for the VK_KHR_android_surface extension:
1366 */
1367 if (!strcmp("vkCreateAndroidSurfaceKHR", name)) {
1368 *addr = ptr_instance->wsi_xlib_surface_enabled
1369 ? (void *)vkCreateAndroidSurfaceKHR
1370 : NULL;
1371 return true;
1372 }
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -07001373#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliottb2484122015-11-19 13:14:05 -07001374
Jon Ashburn00df0452016-03-08 09:30:30 -07001375 /*
1376 * Functions for VK_KHR_display extension:
1377 */
1378 if (!strcmp("vkGetPhysicalDeviceDisplayPropertiesKHR", name)) {
1379 *addr = ptr_instance->wsi_display_enabled
1380 ? (void *)vkGetPhysicalDeviceDisplayPropertiesKHR
1381 : NULL;
1382 return true;
1383 }
1384 if (!strcmp("vkGetPhysicalDeviceDisplayPlanePropertiesKHR", name)) {
1385 *addr = ptr_instance->wsi_display_enabled
1386 ? (void *)vkGetPhysicalDeviceDisplayPlanePropertiesKHR
1387 : NULL;
1388 return true;
1389 }
1390 if (!strcmp("vkGetDisplayPlaneSupportedDisplaysKHR", name)) {
1391 *addr = ptr_instance->wsi_display_enabled
1392 ? (void *)vkGetDisplayPlaneSupportedDisplaysKHR
1393 : NULL;
1394 return true;
1395 }
1396 if (!strcmp("vkGetDisplayModePropertiesKHR", name)) {
1397 *addr = ptr_instance->wsi_display_enabled
1398 ? (void *)vkGetDisplayModePropertiesKHR
1399 : NULL;
1400 return true;
1401 }
1402 if (!strcmp("vkCreateDisplayModeKHR", name)) {
1403 *addr = ptr_instance->wsi_display_enabled
1404 ? (void *)vkCreateDisplayModeKHR
1405 : NULL;
1406 return true;
1407 }
1408 if (!strcmp("vkGetDisplayPlaneCapabilitiesKHR", name)) {
1409 *addr = ptr_instance->wsi_display_enabled
1410 ? (void *)vkGetDisplayPlaneCapabilitiesKHR
1411 : NULL;
1412 return true;
1413 }
1414 if (!strcmp("vkCreateDisplayPlaneSurfaceKHR", name)) {
1415 *addr = ptr_instance->wsi_display_enabled
1416 ? (void *)vkCreateDisplayPlaneSurfaceKHR
1417 : NULL;
1418 return true;
1419 }
Jon Ashburna9c4a572016-02-26 13:14:27 -07001420 return false;
Jon Ashburn00df0452016-03-08 09:30:30 -07001421}