blob: a0b2ad1f8f46be3c6c04a8844ceabe0b6d933b63 [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
Ian Elliott5a1bff52016-03-24 13:59:22 -060033#include <stdio.h>
Ian Elliotta81e8ac2015-10-30 15:28:23 -060034#include <stdlib.h>
35#include <string.h>
36#include "vk_loader_platform.h"
37#include "loader.h"
38#include "wsi.h"
Ian Elliottb2484122015-11-19 13:14:05 -070039#include <vulkan/vk_icd.h>
Ian Elliotta81e8ac2015-10-30 15:28:23 -060040
41static const VkExtensionProperties wsi_surface_extension_info = {
Jon Ashburn44aed662016-02-02 17:47:28 -070042 .extensionName = VK_KHR_SURFACE_EXTENSION_NAME,
43 .specVersion = VK_KHR_SURFACE_SPEC_VERSION,
Ian Elliotta81e8ac2015-10-30 15:28:23 -060044};
45
Ian Elliott3ce23f92015-11-19 11:58:08 -070046#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060047static const VkExtensionProperties wsi_win32_surface_extension_info = {
Jon Ashburn44aed662016-02-02 17:47:28 -070048 .extensionName = VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
49 .specVersion = VK_KHR_WIN32_SURFACE_SPEC_VERSION,
Ian Elliotta81e8ac2015-10-30 15:28:23 -060050};
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -070051#endif // VK_USE_PLATFORM_WIN32_KHR
52
Ian Elliott9c068c92015-10-30 17:45:05 -060053#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060054static const VkExtensionProperties wsi_mir_surface_extension_info = {
Jon Ashburn44aed662016-02-02 17:47:28 -070055 .extensionName = VK_KHR_MIR_SURFACE_EXTENSION_NAME,
56 .specVersion = VK_KHR_MIR_SURFACE_SPEC_VERSION,
Ian Elliotta81e8ac2015-10-30 15:28:23 -060057};
Ian Elliott9c068c92015-10-30 17:45:05 -060058#endif // VK_USE_PLATFORM_MIR_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060059
Ian Elliott9c068c92015-10-30 17:45:05 -060060#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060061static const VkExtensionProperties wsi_wayland_surface_extension_info = {
Jon Ashburn44aed662016-02-02 17:47:28 -070062 .extensionName = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME,
63 .specVersion = VK_KHR_WAYLAND_SURFACE_SPEC_VERSION,
Ian Elliotta81e8ac2015-10-30 15:28:23 -060064};
Ian Elliott9c068c92015-10-30 17:45:05 -060065#endif // VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060066
Ian Elliott9c068c92015-10-30 17:45:05 -060067#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060068static const VkExtensionProperties wsi_xcb_surface_extension_info = {
Jon Ashburn44aed662016-02-02 17:47:28 -070069 .extensionName = VK_KHR_XCB_SURFACE_EXTENSION_NAME,
70 .specVersion = VK_KHR_XCB_SURFACE_SPEC_VERSION,
Ian Elliotta81e8ac2015-10-30 15:28:23 -060071};
Ian Elliott9c068c92015-10-30 17:45:05 -060072#endif // VK_USE_PLATFORM_XCB_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060073
Ian Elliott9c068c92015-10-30 17:45:05 -060074#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060075static const VkExtensionProperties wsi_xlib_surface_extension_info = {
Jon Ashburn44aed662016-02-02 17:47:28 -070076 .extensionName = VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
77 .specVersion = VK_KHR_XLIB_SURFACE_SPEC_VERSION,
Ian Elliotta81e8ac2015-10-30 15:28:23 -060078};
Ian Elliott9c068c92015-10-30 17:45:05 -060079#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -070080
81#ifdef VK_USE_PLATFORM_ANDROID_KHR
82static const VkExtensionProperties wsi_android_surface_extension_info = {
Jon Ashburn44aed662016-02-02 17:47:28 -070083 .extensionName = VK_KHR_ANDROID_SURFACE_EXTENSION_NAME,
84 .specVersion = VK_KHR_ANDROID_SURFACE_REVISION,
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -070085};
86#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060087
Jon Ashburn44aed662016-02-02 17:47:28 -070088void wsi_create_instance(struct loader_instance *ptr_instance,
89 const VkInstanceCreateInfo *pCreateInfo) {
Ian Elliott9c068c92015-10-30 17:45:05 -060090 ptr_instance->wsi_surface_enabled = false;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -070091
92#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburn00df0452016-03-08 09:30:30 -070093 ptr_instance->wsi_win32_surface_enabled = false;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -070094#endif // VK_USE_PLATFORM_WIN32_KHR
95#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060096 ptr_instance->wsi_mir_surface_enabled = false;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -070097#endif // VK_USE_PLATFORM_MIR_KHR
98#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -060099 ptr_instance->wsi_wayland_surface_enabled = false;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700100#endif // VK_USE_PLATFORM_WAYLAND_KHR
101#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600102 ptr_instance->wsi_xcb_surface_enabled = false;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700103#endif // VK_USE_PLATFORM_XCB_KHR
104#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600105 ptr_instance->wsi_xlib_surface_enabled = false;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700106#endif // VK_USE_PLATFORM_XLIB_KHR
107#ifdef VK_USE_PLATFORM_ANDROID_KHR
108 ptr_instance->wsi_android_surface_enabled = false;
109#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600110
Jon Ashburn00df0452016-03-08 09:30:30 -0700111 ptr_instance->wsi_display_enabled = false;
112
Jon Ashburna4ae48b2016-01-11 13:12:43 -0700113 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Jon Ashburn44aed662016-02-02 17:47:28 -0700114 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
115 VK_KHR_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600116 ptr_instance->wsi_surface_enabled = true;
Ian Elliott3ce23f92015-11-19 11:58:08 -0700117 continue;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600118 }
Ian Elliott3ce23f92015-11-19 11:58:08 -0700119#ifdef VK_USE_PLATFORM_WIN32_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700120 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
121 VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700122 ptr_instance->wsi_win32_surface_enabled = true;
Ian Elliott3ce23f92015-11-19 11:58:08 -0700123 continue;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600124 }
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700125#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott9c068c92015-10-30 17:45:05 -0600126#ifdef VK_USE_PLATFORM_MIR_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700127 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
128 VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600129 ptr_instance->wsi_mir_surface_enabled = true;
Ian Elliott3ce23f92015-11-19 11:58:08 -0700130 continue;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600131 }
Ian Elliott9c068c92015-10-30 17:45:05 -0600132#endif // VK_USE_PLATFORM_MIR_KHR
133#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700134 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
135 VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600136 ptr_instance->wsi_wayland_surface_enabled = true;
Ian Elliott3ce23f92015-11-19 11:58:08 -0700137 continue;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600138 }
Ian Elliott9c068c92015-10-30 17:45:05 -0600139#endif // VK_USE_PLATFORM_WAYLAND_KHR
140#ifdef VK_USE_PLATFORM_XCB_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700141 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
142 VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600143 ptr_instance->wsi_xcb_surface_enabled = true;
Ian Elliott3ce23f92015-11-19 11:58:08 -0700144 continue;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600145 }
Ian Elliott9c068c92015-10-30 17:45:05 -0600146#endif // VK_USE_PLATFORM_XCB_KHR
147#ifdef VK_USE_PLATFORM_XLIB_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700148 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
149 VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600150 ptr_instance->wsi_xlib_surface_enabled = true;
Ian Elliott3ce23f92015-11-19 11:58:08 -0700151 continue;
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600152 }
Ian Elliott9c068c92015-10-30 17:45:05 -0600153#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700154#ifdef VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburn44aed662016-02-02 17:47:28 -0700155 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
156 VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0) {
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700157 ptr_instance->wsi_android_surface_enabled = true;
158 continue;
159 }
160#endif // VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburn00df0452016-03-08 09:30:30 -0700161 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
162 VK_KHR_DISPLAY_EXTENSION_NAME) == 0) {
163 ptr_instance->wsi_display_enabled = true;
164 continue;
165 }
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600166 }
167}
Jon Ashburnc666cff2016-03-25 12:49:35 -0600168/*
169 * Linux WSI surface extensions are not always compiled into the loader. (Assume
170 * for Windows the KHR_win32_surface is always compiled into loader). A given
171 * Linux build environment might not have the headers required for building one
172 * of the four extensions (Xlib, Xcb, Mir, Wayland). Thus, need to check if
173 * the built loader actually supports the particular Linux surface extension.
174 * If not supported by the built loader it will not be included in the list of
175 * enumerated instance extensions. This solves the issue where an ICD or layer
176 * advertises support for a given Linux surface extension but the loader was not
177 * built to support the extension. */
178bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop) {
179#ifndef VK_USE_PLATFORM_MIR_KHR
180 if (!strcmp(ext_prop->extensionName, "VK_KHR_mir_surface"))
181 return true;
182#endif // VK_USE_PLATFORM_MIR_KHR
183#ifndef VK_USE_PLATFORM_WAYLAND_KHR
184 if (!strcmp(ext_prop->extensionName, "VK_KHR_wayland_surface"))
185 return true;
186#endif // VK_USE_PLATFORM_WAYLAND_KHR
187#ifndef VK_USE_PLATFORM_XCB_KHR
188 if (!strcmp(ext_prop->extensionName, "VK_KHR_xcb_surface"))
189 return true;
190#endif // VK_USE_PLATFORM_XCB_KHR
191#ifndef VK_USE_PLATFORM_XLIB_KHR
192 if (!strcmp(ext_prop->extensionName, "VK_KHR_xlib_surface"))
193 return true;
194#endif // VK_USE_PLATFORM_XLIB_KHR
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600195
Jon Ashburnc666cff2016-03-25 12:49:35 -0600196 return false;
197}
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600198/*
Ian Elliottb2484122015-11-19 13:14:05 -0700199 * Functions for the VK_KHR_surface extension:
200 */
201
202/*
203 * This is the trampoline entrypoint
204 * for DestroySurfaceKHR
Ian Elliottb2484122015-11-19 13:14:05 -0700205 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700206LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
207vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
208 const VkAllocationCallbacks *pAllocator) {
Ian Elliott7b9f7822015-11-25 14:43:02 -0700209 const VkLayerInstanceDispatchTable *disp;
210 disp = loader_get_instance_dispatch(instance);
211 disp->DestroySurfaceKHR(instance, surface, pAllocator);
212}
213
Jon Ashburn00df0452016-03-08 09:30:30 -0700214// TODO probably need to lock around all the loader_get_instance() calls.
Ian Elliott7b9f7822015-11-25 14:43:02 -0700215/*
216 * This is the instance chain terminator function
217 * for DestroySurfaceKHR
218 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700219VKAPI_ATTR void VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700220terminator_DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
221 const VkAllocationCallbacks *pAllocator) {
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700222 struct loader_instance *ptr_instance = loader_get_instance(instance);
223
Mark Young2acdd152016-01-13 13:47:16 -0700224 loader_heap_free(ptr_instance, (void *)surface);
Ian Elliottb2484122015-11-19 13:14:05 -0700225}
226
227/*
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600228 * This is the trampoline entrypoint
229 * for GetPhysicalDeviceSurfaceSupportKHR
230 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700231LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
232vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,
233 uint32_t queueFamilyIndex,
234 VkSurfaceKHR surface,
235 VkBool32 *pSupported) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600236 const VkLayerInstanceDispatchTable *disp;
Jon Ashburn87660432016-03-01 19:51:07 -0700237 VkPhysicalDevice unwrapped_phys_dev =
238 loader_unwrap_physical_device(physicalDevice);
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600239 disp = loader_get_instance_dispatch(physicalDevice);
240 VkResult res = disp->GetPhysicalDeviceSurfaceSupportKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700241 unwrapped_phys_dev, queueFamilyIndex, surface, pSupported);
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600242 return res;
243}
244
245/*
246 * This is the instance chain terminator function
247 * for GetPhysicalDeviceSurfaceSupportKHR
248 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700249VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700250terminator_GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,
251 uint32_t queueFamilyIndex,
252 VkSurfaceKHR surface,
253 VkBool32 *pSupported) {
Ian Elliott5a1bff52016-03-24 13:59:22 -0600254 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn44aed662016-02-02 17:47:28 -0700255 struct loader_physical_device *phys_dev =
256 (struct loader_physical_device *)physicalDevice;
Ian Elliott5a1bff52016-03-24 13:59:22 -0600257 struct loader_instance *ptr_instance =
258 (struct loader_instance *)phys_dev->this_icd->this_instance;
259 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott04e11932016-03-24 15:49:02 -0600260 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
261 "VK_KHR_VK_KHR_surface extension not enabled. "
262 "vkGetPhysicalDeviceSurfaceSupportKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -0600263 return VK_SUCCESS;
264 }
265
266 // Next, if so, proceed with the implementation of this function:
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600267 struct loader_icd *icd = phys_dev->this_icd;
268
Jon Ashburn44aed662016-02-02 17:47:28 -0700269 assert(pSupported &&
270 "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported");
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600271 *pSupported = false;
272
Jon Ashburn44aed662016-02-02 17:47:28 -0700273 assert(icd->GetPhysicalDeviceSurfaceSupportKHR &&
274 "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer");
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600275
Jon Ashburn44aed662016-02-02 17:47:28 -0700276 return icd->GetPhysicalDeviceSurfaceSupportKHR(
277 phys_dev->phys_dev, queueFamilyIndex, surface, pSupported);
Ian Elliotta81e8ac2015-10-30 15:28:23 -0600278}
279
Ian Elliott8cda1802015-11-19 16:05:09 -0700280/*
281 * This is the trampoline entrypoint
282 * for GetPhysicalDeviceSurfaceCapabilitiesKHR
283 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700284LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
285vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
286 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
287 VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) {
Jon Ashburn87660432016-03-01 19:51:07 -0700288
Ian Elliott8cda1802015-11-19 16:05:09 -0700289 const VkLayerInstanceDispatchTable *disp;
Jon Ashburn87660432016-03-01 19:51:07 -0700290 VkPhysicalDevice unwrapped_phys_dev =
291 loader_unwrap_physical_device(physicalDevice);
Ian Elliott8cda1802015-11-19 16:05:09 -0700292 disp = loader_get_instance_dispatch(physicalDevice);
293 VkResult res = disp->GetPhysicalDeviceSurfaceCapabilitiesKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700294 unwrapped_phys_dev, surface, pSurfaceCapabilities);
Ian Elliott8cda1802015-11-19 16:05:09 -0700295 return res;
296}
297
298/*
299 * This is the instance chain terminator function
300 * for GetPhysicalDeviceSurfaceCapabilitiesKHR
301 */
Jon Ashburna9c4a572016-02-26 13:14:27 -0700302VKAPI_ATTR VkResult VKAPI_CALL
303terminator_GetPhysicalDeviceSurfaceCapabilitiesKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700304 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
305 VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) {
Ian Elliott5a1bff52016-03-24 13:59:22 -0600306 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn44aed662016-02-02 17:47:28 -0700307 struct loader_physical_device *phys_dev =
308 (struct loader_physical_device *)physicalDevice;
Ian Elliott5a1bff52016-03-24 13:59:22 -0600309 struct loader_instance *ptr_instance =
310 (struct loader_instance *)phys_dev->this_icd->this_instance;
311 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott04e11932016-03-24 15:49:02 -0600312 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
313 "VK_KHR_surface extension not enabled. "
314 "vkGetPhysicalDeviceSurfaceCapabilitiesKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -0600315 return VK_SUCCESS;
316 }
317
318 // Next, if so, proceed with the implementation of this function:
Ian Elliott8cda1802015-11-19 16:05:09 -0700319 struct loader_icd *icd = phys_dev->this_icd;
320
Jon Ashburn44aed662016-02-02 17:47:28 -0700321 assert(pSurfaceCapabilities && "GetPhysicalDeviceSurfaceCapabilitiesKHR: "
322 "Error, null pSurfaceCapabilities");
Ian Elliott8cda1802015-11-19 16:05:09 -0700323
Jon Ashburn44aed662016-02-02 17:47:28 -0700324 assert(icd->GetPhysicalDeviceSurfaceCapabilitiesKHR &&
325 "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer");
Ian Elliott8cda1802015-11-19 16:05:09 -0700326
Jon Ashburn44aed662016-02-02 17:47:28 -0700327 return icd->GetPhysicalDeviceSurfaceCapabilitiesKHR(
328 phys_dev->phys_dev, surface, pSurfaceCapabilities);
Ian Elliott8cda1802015-11-19 16:05:09 -0700329}
330
331/*
332 * This is the trampoline entrypoint
333 * for GetPhysicalDeviceSurfaceFormatsKHR
334 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700335LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
336vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
337 VkSurfaceKHR surface,
338 uint32_t *pSurfaceFormatCount,
339 VkSurfaceFormatKHR *pSurfaceFormats) {
Jon Ashburn87660432016-03-01 19:51:07 -0700340 VkPhysicalDevice unwrapped_phys_dev =
341 loader_unwrap_physical_device(physicalDevice);
Ian Elliott8cda1802015-11-19 16:05:09 -0700342 const VkLayerInstanceDispatchTable *disp;
343 disp = loader_get_instance_dispatch(physicalDevice);
344 VkResult res = disp->GetPhysicalDeviceSurfaceFormatsKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700345 unwrapped_phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats);
Ian Elliott8cda1802015-11-19 16:05:09 -0700346 return res;
347}
348
349/*
350 * This is the instance chain terminator function
351 * for GetPhysicalDeviceSurfaceFormatsKHR
352 */
Jon Ashburna9c4a572016-02-26 13:14:27 -0700353VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormatsKHR(
354 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
355 uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats) {
Ian Elliott5a1bff52016-03-24 13:59:22 -0600356 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn44aed662016-02-02 17:47:28 -0700357 struct loader_physical_device *phys_dev =
358 (struct loader_physical_device *)physicalDevice;
Ian Elliott5a1bff52016-03-24 13:59:22 -0600359 struct loader_instance *ptr_instance =
360 (struct loader_instance *)phys_dev->this_icd->this_instance;
361 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott04e11932016-03-24 15:49:02 -0600362 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
363 "VK_KHR_surface extension not enabled. "
364 "vkGetPhysicalDeviceSurfaceFormatsKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -0600365 return VK_SUCCESS;
366 }
367
368 // Next, if so, proceed with the implementation of this function:
Ian Elliott8cda1802015-11-19 16:05:09 -0700369 struct loader_icd *icd = phys_dev->this_icd;
370
Jon Ashburn44aed662016-02-02 17:47:28 -0700371 assert(
372 pSurfaceFormatCount &&
373 "GetPhysicalDeviceSurfaceFormatsKHR: Error, null pSurfaceFormatCount");
Ian Elliott8cda1802015-11-19 16:05:09 -0700374
Jon Ashburn44aed662016-02-02 17:47:28 -0700375 assert(icd->GetPhysicalDeviceSurfaceFormatsKHR &&
376 "loader: null GetPhysicalDeviceSurfaceFormatsKHR ICD pointer");
Ian Elliott8cda1802015-11-19 16:05:09 -0700377
Jon Ashburn44aed662016-02-02 17:47:28 -0700378 return icd->GetPhysicalDeviceSurfaceFormatsKHR(
379 phys_dev->phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats);
Ian Elliott8cda1802015-11-19 16:05:09 -0700380}
381
382/*
383 * This is the trampoline entrypoint
384 * for GetPhysicalDeviceSurfacePresentModesKHR
385 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700386LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
387vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
388 VkSurfaceKHR surface,
389 uint32_t *pPresentModeCount,
390 VkPresentModeKHR *pPresentModes) {
Jon Ashburn87660432016-03-01 19:51:07 -0700391 VkPhysicalDevice unwrapped_phys_dev =
392 loader_unwrap_physical_device(physicalDevice);
Ian Elliott8cda1802015-11-19 16:05:09 -0700393 const VkLayerInstanceDispatchTable *disp;
394 disp = loader_get_instance_dispatch(physicalDevice);
395 VkResult res = disp->GetPhysicalDeviceSurfacePresentModesKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700396 unwrapped_phys_dev, surface, pPresentModeCount, pPresentModes);
Ian Elliott8cda1802015-11-19 16:05:09 -0700397 return res;
398}
399
400/*
401 * This is the instance chain terminator function
402 * for GetPhysicalDeviceSurfacePresentModesKHR
403 */
Jon Ashburna9c4a572016-02-26 13:14:27 -0700404VKAPI_ATTR VkResult VKAPI_CALL
405terminator_GetPhysicalDeviceSurfacePresentModesKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700406 VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
407 uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes) {
Ian Elliott5a1bff52016-03-24 13:59:22 -0600408 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn44aed662016-02-02 17:47:28 -0700409 struct loader_physical_device *phys_dev =
410 (struct loader_physical_device *)physicalDevice;
Ian Elliott5a1bff52016-03-24 13:59:22 -0600411 struct loader_instance *ptr_instance =
412 (struct loader_instance *)phys_dev->this_icd->this_instance;
413 if (!ptr_instance->wsi_surface_enabled) {
Ian Elliott04e11932016-03-24 15:49:02 -0600414 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
415 "VK_KHR_surface extension not enabled. "
416 "vkGetPhysicalDeviceSurfacePresentModesKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -0600417 return VK_SUCCESS;
418 }
419
420 // Next, if so, proceed with the implementation of this function:
Ian Elliott8cda1802015-11-19 16:05:09 -0700421 struct loader_icd *icd = phys_dev->this_icd;
422
Jon Ashburn44aed662016-02-02 17:47:28 -0700423 assert(pPresentModeCount && "GetPhysicalDeviceSurfacePresentModesKHR: "
424 "Error, null pPresentModeCount");
Ian Elliott8cda1802015-11-19 16:05:09 -0700425
Jon Ashburn44aed662016-02-02 17:47:28 -0700426 assert(icd->GetPhysicalDeviceSurfacePresentModesKHR &&
427 "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer");
Ian Elliott8cda1802015-11-19 16:05:09 -0700428
Jon Ashburn44aed662016-02-02 17:47:28 -0700429 return icd->GetPhysicalDeviceSurfacePresentModesKHR(
430 phys_dev->phys_dev, surface, pPresentModeCount, pPresentModes);
Ian Elliott8cda1802015-11-19 16:05:09 -0700431}
432
Ian Elliottb2484122015-11-19 13:14:05 -0700433/*
434 * Functions for the VK_KHR_swapchain extension:
435 */
436
Ian Elliott5bf16c32015-11-19 16:39:21 -0700437/*
438 * This is the trampoline entrypoint
439 * for CreateSwapchainKHR
440 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700441LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
442vkCreateSwapchainKHR(VkDevice device,
443 const VkSwapchainCreateInfoKHR *pCreateInfo,
444 const VkAllocationCallbacks *pAllocator,
445 VkSwapchainKHR *pSwapchain) {
Ian Elliott5bf16c32015-11-19 16:39:21 -0700446 const VkLayerDispatchTable *disp;
447 disp = loader_get_dispatch(device);
Jon Ashburn44aed662016-02-02 17:47:28 -0700448 VkResult res =
449 disp->CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain);
Ian Elliott5bf16c32015-11-19 16:39:21 -0700450 return res;
451}
Ian Elliottb2484122015-11-19 13:14:05 -0700452
Ian Elliott5bf16c32015-11-19 16:39:21 -0700453/*
454 * This is the trampoline entrypoint
455 * for DestroySwapchainKHR
456 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700457LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL
458vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain,
459 const VkAllocationCallbacks *pAllocator) {
Ian Elliott5bf16c32015-11-19 16:39:21 -0700460 const VkLayerDispatchTable *disp;
461 disp = loader_get_dispatch(device);
462 disp->DestroySwapchainKHR(device, swapchain, pAllocator);
463}
Ian Elliottb2484122015-11-19 13:14:05 -0700464
Ian Elliott5bf16c32015-11-19 16:39:21 -0700465/*
466 * This is the trampoline entrypoint
467 * for GetSwapchainImagesKHR
468 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700469LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
470vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain,
471 uint32_t *pSwapchainImageCount,
472 VkImage *pSwapchainImages) {
Ian Elliott5bf16c32015-11-19 16:39:21 -0700473 const VkLayerDispatchTable *disp;
474 disp = loader_get_dispatch(device);
475 VkResult res = disp->GetSwapchainImagesKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700476 device, swapchain, pSwapchainImageCount, pSwapchainImages);
Ian Elliott5bf16c32015-11-19 16:39:21 -0700477 return res;
478}
479
480/*
481 * This is the trampoline entrypoint
482 * for AcquireNextImageKHR
483 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700484LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
485vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain,
486 uint64_t timeout, VkSemaphore semaphore, VkFence fence,
487 uint32_t *pImageIndex) {
Ian Elliott5bf16c32015-11-19 16:39:21 -0700488 const VkLayerDispatchTable *disp;
489 disp = loader_get_dispatch(device);
Jon Ashburn44aed662016-02-02 17:47:28 -0700490 VkResult res = disp->AcquireNextImageKHR(device, swapchain, timeout,
491 semaphore, fence, pImageIndex);
Ian Elliott5bf16c32015-11-19 16:39:21 -0700492 return res;
493}
494
495/*
496 * This is the trampoline entrypoint
497 * for QueuePresentKHR
498 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700499LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
500vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) {
Ian Elliott5bf16c32015-11-19 16:39:21 -0700501 const VkLayerDispatchTable *disp;
502 disp = loader_get_dispatch(queue);
503 VkResult res = disp->QueuePresentKHR(queue, pPresentInfo);
504 return res;
505}
Ian Elliottb2484122015-11-19 13:14:05 -0700506
Ian Elliottb2484122015-11-19 13:14:05 -0700507#ifdef VK_USE_PLATFORM_WIN32_KHR
508
509/*
510 * Functions for the VK_KHR_win32_surface extension:
511 */
512
513/*
514 * This is the trampoline entrypoint
515 * for CreateWin32SurfaceKHR
516 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700517LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
518vkCreateWin32SurfaceKHR(VkInstance instance,
519 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
520 const VkAllocationCallbacks *pAllocator,
521 VkSurfaceKHR *pSurface) {
Jon Ashburn25a158f2015-11-25 17:55:49 -0700522 const VkLayerInstanceDispatchTable *disp;
523 disp = loader_get_instance_dispatch(instance);
524 VkResult res;
525
Jon Ashburn44aed662016-02-02 17:47:28 -0700526 res = disp->CreateWin32SurfaceKHR(instance, pCreateInfo, pAllocator,
527 pSurface);
Jon Ashburn25a158f2015-11-25 17:55:49 -0700528 return res;
529}
530
531/*
532 * This is the instance chain terminator function
533 * for CreateWin32SurfaceKHR
534 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700535VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700536terminator_CreateWin32SurfaceKHR(VkInstance instance,
537 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
538 const VkAllocationCallbacks *pAllocator,
539 VkSurfaceKHR *pSurface) {
Ian Elliott5a1bff52016-03-24 13:59:22 -0600540 // First, check to ensure the appropriate extension was enabled:
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700541 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott5a1bff52016-03-24 13:59:22 -0600542 if (!ptr_instance->wsi_win32_surface_enabled) {
Ian Elliott04e11932016-03-24 15:49:02 -0600543 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
544 "VK_KHR_win32_surface extension not enabled. "
545 "vkCreateWin32SurfaceKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -0600546 return VK_SUCCESS;
547 }
548
549 // Next, if so, proceed with the implementation of this function:
Ian Elliottb2484122015-11-19 13:14:05 -0700550 VkIcdSurfaceWin32 *pIcdSurface = NULL;
551
Jon Ashburn44aed662016-02-02 17:47:28 -0700552 pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceWin32),
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700553 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliottb2484122015-11-19 13:14:05 -0700554 if (pIcdSurface == NULL) {
555 return VK_ERROR_OUT_OF_HOST_MEMORY;
556 }
557
558 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WIN32;
Ian Elliottdcb176f2015-12-10 17:28:50 -0700559 pIcdSurface->hinstance = pCreateInfo->hinstance;
560 pIcdSurface->hwnd = pCreateInfo->hwnd;
Ian Elliottb2484122015-11-19 13:14:05 -0700561
Jon Ashburn44aed662016-02-02 17:47:28 -0700562 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliottb2484122015-11-19 13:14:05 -0700563
564 return VK_SUCCESS;
565}
Ian Elliott4e309e92015-11-24 15:39:10 -0700566
567/*
568 * This is the trampoline entrypoint
569 * for GetPhysicalDeviceWin32PresentationSupportKHR
570 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700571LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
572vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice,
573 uint32_t queueFamilyIndex) {
Jon Ashburn87660432016-03-01 19:51:07 -0700574 VkPhysicalDevice unwrapped_phys_dev =
575 loader_unwrap_physical_device(physicalDevice);
Ian Elliott4e309e92015-11-24 15:39:10 -0700576 const VkLayerInstanceDispatchTable *disp;
577 disp = loader_get_instance_dispatch(physicalDevice);
578 VkBool32 res = disp->GetPhysicalDeviceWin32PresentationSupportKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700579 unwrapped_phys_dev, queueFamilyIndex);
Ian Elliott4e309e92015-11-24 15:39:10 -0700580 return res;
581}
582
Ian Elliott4e309e92015-11-24 15:39:10 -0700583/*
584 * This is the instance chain terminator function
585 * for GetPhysicalDeviceWin32PresentationSupportKHR
586 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700587VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700588terminator_GetPhysicalDeviceWin32PresentationSupportKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700589 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex) {
Ian Elliott5a1bff52016-03-24 13:59:22 -0600590 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn44aed662016-02-02 17:47:28 -0700591 struct loader_physical_device *phys_dev =
592 (struct loader_physical_device *)physicalDevice;
Ian Elliott5a1bff52016-03-24 13:59:22 -0600593 struct loader_instance *ptr_instance =
594 (struct loader_instance *)phys_dev->this_icd->this_instance;
595 if (!ptr_instance->wsi_win32_surface_enabled) {
Jon Ashburn9b2a8c92016-04-15 09:25:03 -0600596 loader_log(
597 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
598 "VK_KHR_win32_surface extension not enabled. "
599 "vkGetPhysicalDeviceWin32PresentationSupportKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -0600600 return VK_SUCCESS;
601 }
602
603 // Next, if so, proceed with the implementation of this function:
Ian Elliott4e309e92015-11-24 15:39:10 -0700604 struct loader_icd *icd = phys_dev->this_icd;
605
Jon Ashburn44aed662016-02-02 17:47:28 -0700606 assert(icd->GetPhysicalDeviceWin32PresentationSupportKHR &&
607 "loader: null GetPhysicalDeviceWin32PresentationSupportKHR ICD "
608 "pointer");
Ian Elliott4e309e92015-11-24 15:39:10 -0700609
610 return icd->GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev->phys_dev,
Jon Ashburn44aed662016-02-02 17:47:28 -0700611 queueFamilyIndex);
Ian Elliott4e309e92015-11-24 15:39:10 -0700612}
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -0700613#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliottb2484122015-11-19 13:14:05 -0700614
615#ifdef VK_USE_PLATFORM_MIR_KHR
616
617/*
618 * Functions for the VK_KHR_mir_surface extension:
619 */
620
621/*
622 * This is the trampoline entrypoint
623 * for CreateMirSurfaceKHR
624 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700625LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
626vkCreateMirSurfaceKHR(VkInstance instance,
627 const VkMirSurfaceCreateInfoKHR *pCreateInfo,
628 const VkAllocationCallbacks *pAllocator,
629 VkSurfaceKHR *pSurface) {
Jon Ashburn25a158f2015-11-25 17:55:49 -0700630 const VkLayerInstanceDispatchTable *disp;
631 disp = loader_get_instance_dispatch(instance);
632 VkResult res;
633
Jon Ashburn44aed662016-02-02 17:47:28 -0700634 res =
635 disp->CreateMirSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburn25a158f2015-11-25 17:55:49 -0700636 return res;
637}
638
639/*
640 * This is the instance chain terminator function
641 * for CreateMirSurfaceKHR
642 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700643VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700644terminator_CreateMirSurfaceKHR(VkInstance instance,
645 const VkMirSurfaceCreateInfoKHR *pCreateInfo,
646 const VkAllocationCallbacks *pAllocator,
647 VkSurfaceKHR *pSurface) {
Ian Elliott5a1bff52016-03-24 13:59:22 -0600648 // First, check to ensure the appropriate extension was enabled:
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700649 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott5a1bff52016-03-24 13:59:22 -0600650 if (!ptr_instance->wsi_mir_surface_enabled) {
Ian Elliott04e11932016-03-24 15:49:02 -0600651 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
652 "VK_KHR_mir_surface extension not enabled. "
653 "vkCreateMirSurfaceKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -0600654 return VK_SUCCESS;
655 }
656
657 // Next, if so, proceed with the implementation of this function:
Ian Elliottb2484122015-11-19 13:14:05 -0700658 VkIcdSurfaceMir *pIcdSurface = NULL;
659
Jon Ashburn44aed662016-02-02 17:47:28 -0700660 pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceMir),
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700661 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliottb2484122015-11-19 13:14:05 -0700662 if (pIcdSurface == NULL) {
663 return VK_ERROR_OUT_OF_HOST_MEMORY;
664 }
665
666 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_MIR;
Ian Elliottdcb176f2015-12-10 17:28:50 -0700667 pIcdSurface->connection = pCreateInfo->connection;
668 pIcdSurface->mirSurface = pCreateInfo->mirSurface;
Ian Elliottb2484122015-11-19 13:14:05 -0700669
Jon Ashburn44aed662016-02-02 17:47:28 -0700670 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliottb2484122015-11-19 13:14:05 -0700671
672 return VK_SUCCESS;
673}
Ian Elliott4e309e92015-11-24 15:39:10 -0700674
675/*
676 * This is the trampoline entrypoint
677 * for GetPhysicalDeviceMirPresentationSupportKHR
678 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700679LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
680vkGetPhysicalDeviceMirPresentationSupportKHR(VkPhysicalDevice physicalDevice,
681 uint32_t queueFamilyIndex,
682 MirConnection *connection) {
Jon Ashburn87660432016-03-01 19:51:07 -0700683 VkPhysicalDevice unwrapped_phys_dev =
684 loader_unwrap_physical_device(physicalDevice);
Ian Elliott4e309e92015-11-24 15:39:10 -0700685 const VkLayerInstanceDispatchTable *disp;
686 disp = loader_get_instance_dispatch(physicalDevice);
687 VkBool32 res = disp->GetPhysicalDeviceMirPresentationSupportKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700688 unwrapped_phys_dev, queueFamilyIndex, connection);
Ian Elliott4e309e92015-11-24 15:39:10 -0700689 return res;
690}
691
Ian Elliott4e309e92015-11-24 15:39:10 -0700692/*
693 * This is the instance chain terminator function
694 * for GetPhysicalDeviceMirPresentationSupportKHR
695 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700696VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700697terminator_GetPhysicalDeviceMirPresentationSupportKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700698 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
699 MirConnection *connection) {
Ian Elliott5a1bff52016-03-24 13:59:22 -0600700 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn44aed662016-02-02 17:47:28 -0700701 struct loader_physical_device *phys_dev =
702 (struct loader_physical_device *)physicalDevice;
Ian Elliott5a1bff52016-03-24 13:59:22 -0600703 struct loader_instance *ptr_instance =
704 (struct loader_instance *)phys_dev->this_icd->this_instance;
705 if (!ptr_instance->wsi_mir_surface_enabled) {
Jon Ashburn9b2a8c92016-04-15 09:25:03 -0600706 loader_log(
707 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
708 "VK_KHR_mir_surface extension not enabled. "
709 "vkGetPhysicalDeviceMirPresentationSupportKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -0600710 return VK_SUCCESS;
711 }
712
713 // Next, if so, proceed with the implementation of this function:
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(
717 icd->GetPhysicalDeviceMirPresentationSupportKHR &&
718 "loader: null GetPhysicalDeviceMirPresentationSupportKHR ICD pointer");
Ian Elliott4e309e92015-11-24 15:39:10 -0700719
Jon Ashburn44aed662016-02-02 17:47:28 -0700720 return icd->GetPhysicalDeviceMirPresentationSupportKHR(
721 phys_dev->phys_dev, queueFamilyIndex, connection);
Ian Elliott4e309e92015-11-24 15:39:10 -0700722}
Ian Elliottb2484122015-11-19 13:14:05 -0700723#endif // VK_USE_PLATFORM_MIR_KHR
724
725#ifdef VK_USE_PLATFORM_WAYLAND_KHR
726
727/*
728 * Functions for the VK_KHR_wayland_surface extension:
729 */
730
731/*
732 * This is the trampoline entrypoint
733 * for CreateWaylandSurfaceKHR
734 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700735LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
736vkCreateWaylandSurfaceKHR(VkInstance instance,
Jason Ekstrandcd0672c2016-02-12 17:25:03 -0800737 const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
Jon Ashburn44aed662016-02-02 17:47:28 -0700738 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 = disp->CreateWaylandSurfaceKHR(instance, pCreateInfo, pAllocator,
745 pSurface);
Jon Ashburn25a158f2015-11-25 17:55:49 -0700746 return res;
747}
748
749/*
750 * This is the instance chain terminator function
Mun, Gwan-gyeong3932b9e2016-02-22 09:33:58 +0900751 * for CreateWaylandSurfaceKHR
Jon Ashburn25a158f2015-11-25 17:55:49 -0700752 */
Jon Ashburna9c4a572016-02-26 13:14:27 -0700753VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(
754 VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo,
755 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Ian Elliott5a1bff52016-03-24 13:59:22 -0600756 // First, check to ensure the appropriate extension was enabled:
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700757 struct loader_instance *ptr_instance = loader_get_instance(instance);
Jon Ashburn4a61d8f2016-03-24 17:26:59 -0600758 if (!ptr_instance->wsi_wayland_surface_enabled) {
Ian Elliott04e11932016-03-24 15:49:02 -0600759 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
760 "VK_KHR_wayland_surface extension not enabled. "
761 "vkCreateWaylandSurfaceKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -0600762 return VK_SUCCESS;
763 }
764
765 // Next, if so, proceed with the implementation of this function:
Ian Elliottb2484122015-11-19 13:14:05 -0700766 VkIcdSurfaceWayland *pIcdSurface = NULL;
767
Jon Ashburn44aed662016-02-02 17:47:28 -0700768 pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceWayland),
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700769 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliottb2484122015-11-19 13:14:05 -0700770 if (pIcdSurface == NULL) {
771 return VK_ERROR_OUT_OF_HOST_MEMORY;
772 }
773
774 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WAYLAND;
Ian Elliottdcb176f2015-12-10 17:28:50 -0700775 pIcdSurface->display = pCreateInfo->display;
776 pIcdSurface->surface = pCreateInfo->surface;
Ian Elliottb2484122015-11-19 13:14:05 -0700777
Jon Ashburn44aed662016-02-02 17:47:28 -0700778 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliottb2484122015-11-19 13:14:05 -0700779
780 return VK_SUCCESS;
781}
Ian Elliott4e309e92015-11-24 15:39:10 -0700782
783/*
784 * This is the trampoline entrypoint
785 * for GetPhysicalDeviceWaylandPresentationSupportKHR
786 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700787LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
788vkGetPhysicalDeviceWaylandPresentationSupportKHR(
789 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
790 struct wl_display *display) {
Jon Ashburn87660432016-03-01 19:51:07 -0700791 VkPhysicalDevice unwrapped_phys_dev =
792 loader_unwrap_physical_device(physicalDevice);
Ian Elliott4e309e92015-11-24 15:39:10 -0700793 const VkLayerInstanceDispatchTable *disp;
794 disp = loader_get_instance_dispatch(physicalDevice);
795 VkBool32 res = disp->GetPhysicalDeviceWaylandPresentationSupportKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700796 unwrapped_phys_dev, queueFamilyIndex, display);
Ian Elliott4e309e92015-11-24 15:39:10 -0700797 return res;
798}
799
Ian Elliott4e309e92015-11-24 15:39:10 -0700800/*
801 * This is the instance chain terminator function
802 * for GetPhysicalDeviceWaylandPresentationSupportKHR
803 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700804VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700805terminator_GetPhysicalDeviceWaylandPresentationSupportKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700806 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
807 struct wl_display *display) {
Ian Elliott5a1bff52016-03-24 13:59:22 -0600808 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn44aed662016-02-02 17:47:28 -0700809 struct loader_physical_device *phys_dev =
810 (struct loader_physical_device *)physicalDevice;
Ian Elliott5a1bff52016-03-24 13:59:22 -0600811 struct loader_instance *ptr_instance =
812 (struct loader_instance *)phys_dev->this_icd->this_instance;
Jon Ashburn4a61d8f2016-03-24 17:26:59 -0600813 if (!ptr_instance->wsi_wayland_surface_enabled) {
Jon Ashburn9b2a8c92016-04-15 09:25:03 -0600814 loader_log(
815 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
816 "VK_KHR_wayland_surface extension not enabled. "
817 "vkGetPhysicalDeviceWaylandPresentationSupportKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -0600818 return VK_SUCCESS;
819 }
820
821 // Next, if so, proceed with the implementation of this function:
Ian Elliott4e309e92015-11-24 15:39:10 -0700822 struct loader_icd *icd = phys_dev->this_icd;
823
Jon Ashburn44aed662016-02-02 17:47:28 -0700824 assert(icd->GetPhysicalDeviceWaylandPresentationSupportKHR &&
825 "loader: null GetPhysicalDeviceWaylandPresentationSupportKHR ICD "
826 "pointer");
Ian Elliott4e309e92015-11-24 15:39:10 -0700827
Jon Ashburn44aed662016-02-02 17:47:28 -0700828 return icd->GetPhysicalDeviceWaylandPresentationSupportKHR(
829 phys_dev->phys_dev, queueFamilyIndex, display);
Ian Elliott4e309e92015-11-24 15:39:10 -0700830}
Ian Elliottb2484122015-11-19 13:14:05 -0700831#endif // VK_USE_PLATFORM_WAYLAND_KHR
832
833#ifdef VK_USE_PLATFORM_XCB_KHR
834
835/*
836 * Functions for the VK_KHR_xcb_surface extension:
837 */
838
839/*
840 * This is the trampoline entrypoint
841 * for CreateXcbSurfaceKHR
842 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700843LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
844vkCreateXcbSurfaceKHR(VkInstance instance,
845 const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
846 const VkAllocationCallbacks *pAllocator,
847 VkSurfaceKHR *pSurface) {
Jon Ashburn25a158f2015-11-25 17:55:49 -0700848 const VkLayerInstanceDispatchTable *disp;
849 disp = loader_get_instance_dispatch(instance);
850 VkResult res;
851
Jon Ashburn44aed662016-02-02 17:47:28 -0700852 res =
853 disp->CreateXcbSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburn25a158f2015-11-25 17:55:49 -0700854 return res;
855}
856
857/*
858 * This is the instance chain terminator function
859 * for CreateXcbSurfaceKHR
860 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700861VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700862terminator_CreateXcbSurfaceKHR(VkInstance instance,
863 const VkXcbSurfaceCreateInfoKHR *pCreateInfo,
864 const VkAllocationCallbacks *pAllocator,
865 VkSurfaceKHR *pSurface) {
Ian Elliott5a1bff52016-03-24 13:59:22 -0600866 // First, check to ensure the appropriate extension was enabled:
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700867 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott5a1bff52016-03-24 13:59:22 -0600868 if (!ptr_instance->wsi_xcb_surface_enabled) {
Ian Elliott04e11932016-03-24 15:49:02 -0600869 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
870 "VK_KHR_xcb_surface extension not enabled. "
871 "vkCreateXcbSurfaceKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -0600872 return VK_SUCCESS;
873 }
874
875 // Next, if so, proceed with the implementation of this function:
Ian Elliottb2484122015-11-19 13:14:05 -0700876 VkIcdSurfaceXcb *pIcdSurface = NULL;
877
Jon Ashburn44aed662016-02-02 17:47:28 -0700878 pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceXcb),
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700879 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliottb2484122015-11-19 13:14:05 -0700880 if (pIcdSurface == NULL) {
881 return VK_ERROR_OUT_OF_HOST_MEMORY;
882 }
883
884 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XCB;
Ian Elliottdcb176f2015-12-10 17:28:50 -0700885 pIcdSurface->connection = pCreateInfo->connection;
886 pIcdSurface->window = pCreateInfo->window;
Ian Elliottb2484122015-11-19 13:14:05 -0700887
Jon Ashburn44aed662016-02-02 17:47:28 -0700888 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliottb2484122015-11-19 13:14:05 -0700889
890 return VK_SUCCESS;
891}
Ian Elliott4e309e92015-11-24 15:39:10 -0700892
893/*
894 * This is the trampoline entrypoint
895 * for GetPhysicalDeviceXcbPresentationSupportKHR
896 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700897LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
898vkGetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice,
899 uint32_t queueFamilyIndex,
900 xcb_connection_t *connection,
901 xcb_visualid_t visual_id) {
Jon Ashburn87660432016-03-01 19:51:07 -0700902 VkPhysicalDevice unwrapped_phys_dev =
903 loader_unwrap_physical_device(physicalDevice);
Ian Elliott4e309e92015-11-24 15:39:10 -0700904 const VkLayerInstanceDispatchTable *disp;
905 disp = loader_get_instance_dispatch(physicalDevice);
906 VkBool32 res = disp->GetPhysicalDeviceXcbPresentationSupportKHR(
Jon Ashburn87660432016-03-01 19:51:07 -0700907 unwrapped_phys_dev, queueFamilyIndex, connection, visual_id);
Ian Elliott4e309e92015-11-24 15:39:10 -0700908 return res;
909}
910
Ian Elliott4e309e92015-11-24 15:39:10 -0700911/*
912 * This is the instance chain terminator function
913 * for GetPhysicalDeviceXcbPresentationSupportKHR
914 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700915VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700916terminator_GetPhysicalDeviceXcbPresentationSupportKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -0700917 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex,
918 xcb_connection_t *connection, xcb_visualid_t visual_id) {
Ian Elliott5a1bff52016-03-24 13:59:22 -0600919 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn44aed662016-02-02 17:47:28 -0700920 struct loader_physical_device *phys_dev =
921 (struct loader_physical_device *)physicalDevice;
Ian Elliott5a1bff52016-03-24 13:59:22 -0600922 struct loader_instance *ptr_instance =
923 (struct loader_instance *)phys_dev->this_icd->this_instance;
924 if (!ptr_instance->wsi_xcb_surface_enabled) {
Jon Ashburn9b2a8c92016-04-15 09:25:03 -0600925 loader_log(
926 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
927 "VK_KHR_xcb_surface extension not enabled. "
928 "vkGetPhysicalDeviceXcbPresentationSupportKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -0600929 return VK_SUCCESS;
930 }
931
932 // Next, if so, proceed with the implementation of this function:
Ian Elliott4e309e92015-11-24 15:39:10 -0700933 struct loader_icd *icd = phys_dev->this_icd;
934
Jon Ashburn44aed662016-02-02 17:47:28 -0700935 assert(
936 icd->GetPhysicalDeviceXcbPresentationSupportKHR &&
937 "loader: null GetPhysicalDeviceXcbPresentationSupportKHR ICD pointer");
Ian Elliott4e309e92015-11-24 15:39:10 -0700938
Jon Ashburn44aed662016-02-02 17:47:28 -0700939 return icd->GetPhysicalDeviceXcbPresentationSupportKHR(
940 phys_dev->phys_dev, queueFamilyIndex, connection, visual_id);
Ian Elliott4e309e92015-11-24 15:39:10 -0700941}
Ian Elliottb2484122015-11-19 13:14:05 -0700942#endif // VK_USE_PLATFORM_XCB_KHR
943
944#ifdef VK_USE_PLATFORM_XLIB_KHR
945
946/*
947 * Functions for the VK_KHR_xlib_surface extension:
948 */
949
950/*
951 * This is the trampoline entrypoint
952 * for CreateXlibSurfaceKHR
953 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700954LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
955vkCreateXlibSurfaceKHR(VkInstance instance,
956 const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
957 const VkAllocationCallbacks *pAllocator,
958 VkSurfaceKHR *pSurface) {
Jon Ashburn25a158f2015-11-25 17:55:49 -0700959 const VkLayerInstanceDispatchTable *disp;
960 disp = loader_get_instance_dispatch(instance);
961 VkResult res;
962
Jon Ashburn44aed662016-02-02 17:47:28 -0700963 res =
964 disp->CreateXlibSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
Jon Ashburn25a158f2015-11-25 17:55:49 -0700965 return res;
966}
967
968/*
969 * This is the instance chain terminator function
970 * for CreateXlibSurfaceKHR
971 */
Jon Ashburn44aed662016-02-02 17:47:28 -0700972VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -0700973terminator_CreateXlibSurfaceKHR(VkInstance instance,
974 const VkXlibSurfaceCreateInfoKHR *pCreateInfo,
975 const VkAllocationCallbacks *pAllocator,
976 VkSurfaceKHR *pSurface) {
Ian Elliott5a1bff52016-03-24 13:59:22 -0600977 // First, check to ensure the appropriate extension was enabled:
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700978 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott5a1bff52016-03-24 13:59:22 -0600979 if (!ptr_instance->wsi_xlib_surface_enabled) {
Ian Elliott04e11932016-03-24 15:49:02 -0600980 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
981 "VK_KHR_xlib_surface extension not enabled. "
982 "vkCreateXlibSurfaceKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -0600983 return VK_SUCCESS;
984 }
985
986 // Next, if so, proceed with the implementation of this function:
Ian Elliottb2484122015-11-19 13:14:05 -0700987 VkIcdSurfaceXlib *pIcdSurface = NULL;
988
Jon Ashburn44aed662016-02-02 17:47:28 -0700989 pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceXlib),
Ian Elliott40c4a1f2015-11-23 10:17:23 -0700990 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliottb2484122015-11-19 13:14:05 -0700991 if (pIcdSurface == NULL) {
992 return VK_ERROR_OUT_OF_HOST_MEMORY;
993 }
994
995 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XLIB;
Ian Elliottdcb176f2015-12-10 17:28:50 -0700996 pIcdSurface->dpy = pCreateInfo->dpy;
997 pIcdSurface->window = pCreateInfo->window;
Ian Elliottb2484122015-11-19 13:14:05 -0700998
Jon Ashburn44aed662016-02-02 17:47:28 -0700999 *pSurface = (VkSurfaceKHR)pIcdSurface;
Ian Elliottb2484122015-11-19 13:14:05 -07001000
1001 return VK_SUCCESS;
1002}
Ian Elliott4e309e92015-11-24 15:39:10 -07001003
1004/*
1005 * This is the trampoline entrypoint
1006 * for GetPhysicalDeviceXlibPresentationSupportKHR
1007 */
Jon Ashburn44aed662016-02-02 17:47:28 -07001008LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL
1009vkGetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice,
1010 uint32_t queueFamilyIndex,
1011 Display *dpy, VisualID visualID) {
Jon Ashburn87660432016-03-01 19:51:07 -07001012 VkPhysicalDevice unwrapped_phys_dev =
1013 loader_unwrap_physical_device(physicalDevice);
Ian Elliott4e309e92015-11-24 15:39:10 -07001014 const VkLayerInstanceDispatchTable *disp;
1015 disp = loader_get_instance_dispatch(physicalDevice);
1016 VkBool32 res = disp->GetPhysicalDeviceXlibPresentationSupportKHR(
Jon Ashburn87660432016-03-01 19:51:07 -07001017 unwrapped_phys_dev, queueFamilyIndex, dpy, visualID);
Ian Elliott4e309e92015-11-24 15:39:10 -07001018 return res;
1019}
1020
Ian Elliott4e309e92015-11-24 15:39:10 -07001021/*
1022 * This is the instance chain terminator function
1023 * for GetPhysicalDeviceXlibPresentationSupportKHR
1024 */
Jon Ashburn44aed662016-02-02 17:47:28 -07001025VKAPI_ATTR VkBool32 VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -07001026terminator_GetPhysicalDeviceXlibPresentationSupportKHR(
Jon Ashburn44aed662016-02-02 17:47:28 -07001027 VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display *dpy,
1028 VisualID visualID) {
Ian Elliott5a1bff52016-03-24 13:59:22 -06001029 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn44aed662016-02-02 17:47:28 -07001030 struct loader_physical_device *phys_dev =
1031 (struct loader_physical_device *)physicalDevice;
Ian Elliott5a1bff52016-03-24 13:59:22 -06001032 struct loader_instance *ptr_instance =
1033 (struct loader_instance *)phys_dev->this_icd->this_instance;
1034 if (!ptr_instance->wsi_xlib_surface_enabled) {
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001035 loader_log(
1036 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1037 "VK_KHR_xlib_surface extension not enabled. "
1038 "vkGetPhysicalDeviceXlibPresentationSupportKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -06001039 return VK_SUCCESS;
1040 }
1041
1042 // Next, if so, proceed with the implementation of this function:
Ian Elliott4e309e92015-11-24 15:39:10 -07001043 struct loader_icd *icd = phys_dev->this_icd;
1044
Jon Ashburn44aed662016-02-02 17:47:28 -07001045 assert(
1046 icd->GetPhysicalDeviceXlibPresentationSupportKHR &&
1047 "loader: null GetPhysicalDeviceXlibPresentationSupportKHR ICD pointer");
Ian Elliott4e309e92015-11-24 15:39:10 -07001048
Jon Ashburn44aed662016-02-02 17:47:28 -07001049 return icd->GetPhysicalDeviceXlibPresentationSupportKHR(
1050 phys_dev->phys_dev, queueFamilyIndex, dpy, visualID);
Ian Elliott4e309e92015-11-24 15:39:10 -07001051}
Ian Elliottb2484122015-11-19 13:14:05 -07001052#endif // VK_USE_PLATFORM_XLIB_KHR
1053
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -07001054#ifdef VK_USE_PLATFORM_ANDROID_KHR
Ian Elliottb2484122015-11-19 13:14:05 -07001055
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -07001056/*
1057 * Functions for the VK_KHR_android_surface extension:
1058 */
1059
1060/*
1061 * This is the trampoline entrypoint
1062 * for CreateAndroidSurfaceKHR
1063 */
Jon Ashburn44aed662016-02-02 17:47:28 -07001064LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1065vkCreateAndroidSurfaceKHR(VkInstance instance, ANativeWindow *window,
1066 const VkAllocationCallbacks *pAllocator,
1067 VkSurfaceKHR *pSurface) {
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -07001068 const VkLayerInstanceDispatchTable *disp;
1069 disp = loader_get_instance_dispatch(instance);
1070 VkResult res;
1071
1072 res = disp->CreateAndroidSurfaceKHR(instance, window, pAllocator, pSurface);
1073 return res;
1074}
1075
1076/*
1077 * This is the instance chain terminator function
1078 * for CreateAndroidSurfaceKHR
1079 */
Jon Ashburn44aed662016-02-02 17:47:28 -07001080VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburna9c4a572016-02-26 13:14:27 -07001081terminator_CreateAndroidSurfaceKHR(VkInstance instance, Window window,
1082 const VkAllocationCallbacks *pAllocator,
1083 VkSurfaceKHR *pSurface) {
Ian Elliott5a1bff52016-03-24 13:59:22 -06001084 // First, check to ensure the appropriate extension was enabled:
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -07001085 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott5a1bff52016-03-24 13:59:22 -06001086 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott04e11932016-03-24 15:49:02 -06001087 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1088 "VK_KHR_display extension not enabled. "
1089 "vkCreateAndroidSurfaceKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -06001090 return VK_SUCCESS;
1091 }
1092
1093 // Next, if so, proceed with the implementation of this function:
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -07001094 VkIcdSurfaceAndroid *pIcdSurface = NULL;
1095
Jon Ashburn44aed662016-02-02 17:47:28 -07001096 pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceAndroid),
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -07001097 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
1098 if (pIcdSurface == NULL) {
1099 return VK_ERROR_OUT_OF_HOST_MEMORY;
1100 }
1101
1102 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_ANDROID;
1103 pIcdSurface->dpy = dpy;
1104 pIcdSurface->window = window;
1105
Jon Ashburn44aed662016-02-02 17:47:28 -07001106 *pSurface = (VkSurfaceKHR)pIcdSurface;
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -07001107
1108 return VK_SUCCESS;
1109}
1110
1111#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliottb2484122015-11-19 13:14:05 -07001112
Jon Ashburn00df0452016-03-08 09:30:30 -07001113/*
1114 * Functions for the VK_KHR_display instance extension:
1115 */
1116LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001117vkGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice,
1118 uint32_t *pPropertyCount,
1119 VkDisplayPropertiesKHR *pProperties) {
Jon Ashburn00df0452016-03-08 09:30:30 -07001120 VkPhysicalDevice unwrapped_phys_dev =
1121 loader_unwrap_physical_device(physicalDevice);
1122 const VkLayerInstanceDispatchTable *disp;
1123 disp = loader_get_instance_dispatch(physicalDevice);
1124 VkResult res = disp->GetPhysicalDeviceDisplayPropertiesKHR(
1125 unwrapped_phys_dev, pPropertyCount, pProperties);
1126 return res;
1127}
1128
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001129VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPropertiesKHR(
1130 VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
1131 VkDisplayPropertiesKHR *pProperties) {
Ian Elliott5a1bff52016-03-24 13:59:22 -06001132 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn00df0452016-03-08 09:30:30 -07001133 struct loader_physical_device *phys_dev =
1134 (struct loader_physical_device *)physicalDevice;
Ian Elliott5a1bff52016-03-24 13:59:22 -06001135 struct loader_instance *ptr_instance =
1136 (struct loader_instance *)phys_dev->this_icd->this_instance;
1137 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott04e11932016-03-24 15:49:02 -06001138 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1139 "VK_KHR_display extension not enabled. "
1140 "vkGetPhysicalDeviceDisplayPropertiesKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -06001141 return VK_SUCCESS;
1142 }
1143
1144 // Next, if so, proceed with the implementation of this function:
Jon Ashburn00df0452016-03-08 09:30:30 -07001145 struct loader_icd *icd = phys_dev->this_icd;
1146
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001147 assert(icd->GetPhysicalDeviceDisplayPropertiesKHR &&
1148 "loader: null GetPhysicalDeviceDisplayPropertiesKHR ICD pointer");
Jon Ashburn00df0452016-03-08 09:30:30 -07001149
1150 return icd->GetPhysicalDeviceDisplayPropertiesKHR(
1151 phys_dev->phys_dev, pPropertyCount, pProperties);
1152}
1153
1154LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
1155vkGetPhysicalDeviceDisplayPlanePropertiesKHR(
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001156 VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
1157 VkDisplayPlanePropertiesKHR *pProperties) {
Jon Ashburn00df0452016-03-08 09:30:30 -07001158 VkPhysicalDevice unwrapped_phys_dev =
1159 loader_unwrap_physical_device(physicalDevice);
1160 const VkLayerInstanceDispatchTable *disp;
1161 disp = loader_get_instance_dispatch(physicalDevice);
1162 VkResult res = disp->GetPhysicalDeviceDisplayPlanePropertiesKHR(
1163 unwrapped_phys_dev, pPropertyCount, pProperties);
1164 return res;
1165}
1166
1167VKAPI_ATTR VkResult VKAPI_CALL
1168terminator_GetPhysicalDeviceDisplayPlanePropertiesKHR(
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001169 VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount,
1170 VkDisplayPlanePropertiesKHR *pProperties) {
Ian Elliott5a1bff52016-03-24 13:59:22 -06001171 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn00df0452016-03-08 09:30:30 -07001172 struct loader_physical_device *phys_dev =
1173 (struct loader_physical_device *)physicalDevice;
Ian Elliott5a1bff52016-03-24 13:59:22 -06001174 struct loader_instance *ptr_instance =
1175 (struct loader_instance *)phys_dev->this_icd->this_instance;
1176 if (!ptr_instance->wsi_display_enabled) {
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001177 loader_log(
1178 ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1179 "VK_KHR_display extension not enabled. "
1180 "vkGetPhysicalDeviceDisplayPlanePropertiesKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -06001181 return VK_SUCCESS;
1182 }
1183
1184 // Next, if so, proceed with the implementation of this function:
Jon Ashburn00df0452016-03-08 09:30:30 -07001185 struct loader_icd *icd = phys_dev->this_icd;
1186
1187 assert(
1188 icd->GetPhysicalDeviceDisplayPlanePropertiesKHR &&
1189 "loader: null GetPhysicalDeviceDisplayPlanePropertiesKHR ICD pointer");
1190
1191 return icd->GetPhysicalDeviceDisplayPlanePropertiesKHR(
1192 phys_dev->phys_dev, pPropertyCount, pProperties);
1193}
1194
1195LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001196vkGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice,
1197 uint32_t planeIndex,
1198 uint32_t *pDisplayCount,
1199 VkDisplayKHR *pDisplays) {
Jon Ashburn00df0452016-03-08 09:30:30 -07001200 VkPhysicalDevice unwrapped_phys_dev =
1201 loader_unwrap_physical_device(physicalDevice);
1202 const VkLayerInstanceDispatchTable *disp;
1203 disp = loader_get_instance_dispatch(physicalDevice);
1204 VkResult res = disp->GetDisplayPlaneSupportedDisplaysKHR(
1205 unwrapped_phys_dev, planeIndex, pDisplayCount, pDisplays);
1206 return res;
1207}
1208
1209VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001210terminator_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice,
1211 uint32_t planeIndex,
1212 uint32_t *pDisplayCount,
1213 VkDisplayKHR *pDisplays) {
Ian Elliott5a1bff52016-03-24 13:59:22 -06001214 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn00df0452016-03-08 09:30:30 -07001215 struct loader_physical_device *phys_dev =
1216 (struct loader_physical_device *)physicalDevice;
Ian Elliott5a1bff52016-03-24 13:59:22 -06001217 struct loader_instance *ptr_instance =
1218 (struct loader_instance *)phys_dev->this_icd->this_instance;
1219 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott04e11932016-03-24 15:49:02 -06001220 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1221 "VK_KHR_display extension not enabled. "
1222 "vkGetDisplayPlaneSupportedDisplaysKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -06001223 return VK_SUCCESS;
1224 }
1225
1226 // Next, if so, proceed with the implementation of this function:
Jon Ashburn00df0452016-03-08 09:30:30 -07001227 struct loader_icd *icd = phys_dev->this_icd;
1228
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001229 assert(icd->GetDisplayPlaneSupportedDisplaysKHR &&
1230 "loader: null GetDisplayPlaneSupportedDisplaysKHR ICD pointer");
Jon Ashburn00df0452016-03-08 09:30:30 -07001231
1232 return icd->GetDisplayPlaneSupportedDisplaysKHR(
1233 phys_dev->phys_dev, planeIndex, pDisplayCount, pDisplays);
1234}
1235
1236LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001237vkGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice,
1238 VkDisplayKHR display, uint32_t *pPropertyCount,
1239 VkDisplayModePropertiesKHR *pProperties) {
Jon Ashburn00df0452016-03-08 09:30:30 -07001240 VkPhysicalDevice unwrapped_phys_dev =
1241 loader_unwrap_physical_device(physicalDevice);
1242 const VkLayerInstanceDispatchTable *disp;
1243 disp = loader_get_instance_dispatch(physicalDevice);
1244 VkResult res = disp->GetDisplayModePropertiesKHR(
1245 unwrapped_phys_dev, display, pPropertyCount, pProperties);
1246 return res;
1247}
1248
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001249VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayModePropertiesKHR(
1250 VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1251 uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) {
Ian Elliott5a1bff52016-03-24 13:59:22 -06001252 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn00df0452016-03-08 09:30:30 -07001253 struct loader_physical_device *phys_dev =
1254 (struct loader_physical_device *)physicalDevice;
Ian Elliott5a1bff52016-03-24 13:59:22 -06001255 struct loader_instance *ptr_instance =
1256 (struct loader_instance *)phys_dev->this_icd->this_instance;
1257 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott04e11932016-03-24 15:49:02 -06001258 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1259 "VK_KHR_display extension not enabled. "
1260 "vkGetDisplayModePropertiesKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -06001261 return VK_SUCCESS;
1262 }
1263
1264 // Next, if so, proceed with the implementation of this function:
Jon Ashburn00df0452016-03-08 09:30:30 -07001265 struct loader_icd *icd = phys_dev->this_icd;
1266
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001267 assert(icd->GetDisplayModePropertiesKHR &&
1268 "loader: null GetDisplayModePropertiesKHR ICD pointer");
Jon Ashburn00df0452016-03-08 09:30:30 -07001269
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001270 return icd->GetDisplayModePropertiesKHR(phys_dev->phys_dev, display,
1271 pPropertyCount, pProperties);
Jon Ashburn00df0452016-03-08 09:30:30 -07001272}
1273
1274LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001275vkCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display,
1276 const VkDisplayModeCreateInfoKHR *pCreateInfo,
1277 const VkAllocationCallbacks *pAllocator,
1278 VkDisplayModeKHR *pMode) {
Jon Ashburn00df0452016-03-08 09:30:30 -07001279 VkPhysicalDevice unwrapped_phys_dev =
1280 loader_unwrap_physical_device(physicalDevice);
1281 const VkLayerInstanceDispatchTable *disp;
1282 disp = loader_get_instance_dispatch(physicalDevice);
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001283 VkResult res = disp->CreateDisplayModeKHR(unwrapped_phys_dev, display,
1284 pCreateInfo, pAllocator, pMode);
Jon Ashburn00df0452016-03-08 09:30:30 -07001285 return res;
1286}
1287
1288VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001289terminator_CreateDisplayModeKHR(VkPhysicalDevice physicalDevice,
1290 VkDisplayKHR display,
1291 const VkDisplayModeCreateInfoKHR *pCreateInfo,
1292 const VkAllocationCallbacks *pAllocator,
1293 VkDisplayModeKHR *pMode) {
Ian Elliott5a1bff52016-03-24 13:59:22 -06001294 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn00df0452016-03-08 09:30:30 -07001295 struct loader_physical_device *phys_dev =
1296 (struct loader_physical_device *)physicalDevice;
Ian Elliott5a1bff52016-03-24 13:59:22 -06001297 struct loader_instance *ptr_instance =
1298 (struct loader_instance *)phys_dev->this_icd->this_instance;
1299 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott04e11932016-03-24 15:49:02 -06001300 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1301 "VK_KHR_display extension not enabled. "
1302 "vkCreateDisplayModeKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -06001303 return VK_SUCCESS;
1304 }
1305
1306 // Next, if so, proceed with the implementation of this function:
Jon Ashburn00df0452016-03-08 09:30:30 -07001307 struct loader_icd *icd = phys_dev->this_icd;
1308
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001309 assert(icd->CreateDisplayModeKHR &&
1310 "loader: null CreateDisplayModeKHR ICD pointer");
Jon Ashburn00df0452016-03-08 09:30:30 -07001311
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001312 return icd->CreateDisplayModeKHR(phys_dev->phys_dev, display, pCreateInfo,
1313 pAllocator, pMode);
Jon Ashburn00df0452016-03-08 09:30:30 -07001314}
1315
1316LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001317vkGetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice,
1318 VkDisplayModeKHR mode, uint32_t planeIndex,
1319 VkDisplayPlaneCapabilitiesKHR *pCapabilities) {
Jon Ashburn00df0452016-03-08 09:30:30 -07001320 VkPhysicalDevice unwrapped_phys_dev =
1321 loader_unwrap_physical_device(physicalDevice);
1322 const VkLayerInstanceDispatchTable *disp;
1323 disp = loader_get_instance_dispatch(physicalDevice);
1324 VkResult res = disp->GetDisplayPlaneCapabilitiesKHR(
1325 unwrapped_phys_dev, mode, planeIndex, pCapabilities);
1326 return res;
1327}
1328
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001329VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneCapabilitiesKHR(
1330 VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex,
1331 VkDisplayPlaneCapabilitiesKHR *pCapabilities) {
Ian Elliott5a1bff52016-03-24 13:59:22 -06001332 // First, check to ensure the appropriate extension was enabled:
Jon Ashburn00df0452016-03-08 09:30:30 -07001333 struct loader_physical_device *phys_dev =
1334 (struct loader_physical_device *)physicalDevice;
Ian Elliott5a1bff52016-03-24 13:59:22 -06001335 struct loader_instance *ptr_instance =
1336 (struct loader_instance *)phys_dev->this_icd->this_instance;
1337 if (!ptr_instance->wsi_display_enabled) {
Ian Elliott04e11932016-03-24 15:49:02 -06001338 loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1339 "VK_KHR_display extension not enabled. "
1340 "vkGetDisplayPlaneCapabilitiesKHR not executed!\n");
Ian Elliott5a1bff52016-03-24 13:59:22 -06001341 return VK_SUCCESS;
1342 }
1343
1344 // Next, if so, proceed with the implementation of this function:
Jon Ashburn00df0452016-03-08 09:30:30 -07001345 struct loader_icd *icd = phys_dev->this_icd;
1346
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001347 assert(icd->GetDisplayPlaneCapabilitiesKHR &&
1348 "loader: null GetDisplayPlaneCapabilitiesKHR ICD pointer");
Jon Ashburn00df0452016-03-08 09:30:30 -07001349
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001350 return icd->GetDisplayPlaneCapabilitiesKHR(phys_dev->phys_dev, mode,
1351 planeIndex, pCapabilities);
Jon Ashburn00df0452016-03-08 09:30:30 -07001352}
1353
1354LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001355vkCreateDisplayPlaneSurfaceKHR(VkInstance instance,
1356 const VkDisplaySurfaceCreateInfoKHR *pCreateInfo,
1357 const VkAllocationCallbacks *pAllocator,
1358 VkSurfaceKHR *pSurface) {
Jon Ashburn00df0452016-03-08 09:30:30 -07001359 const VkLayerInstanceDispatchTable *disp;
1360 disp = loader_get_instance_dispatch(instance);
1361 VkResult res;
1362
1363 res = disp->CreateDisplayPlaneSurfaceKHR(instance, pCreateInfo, pAllocator,
1364 pSurface);
1365 return res;
1366}
1367
Jon Ashburn9b2a8c92016-04-15 09:25:03 -06001368VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR(
1369 VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo,
1370 const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) {
Jon Ashburn00df0452016-03-08 09:30:30 -07001371 struct loader_instance *inst = loader_get_instance(instance);
1372 VkIcdSurfaceDisplay *pIcdSurface = NULL;
1373
Petros Bantolas5ba5d5d2016-04-14 12:50:42 +01001374 if (!inst->wsi_surface_enabled) {
1375 loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
1376 "VK_KHR_surface extension not enabled. "
1377 "vkCreateDisplayPlaneSurfaceKHR not executed!\n");
1378 return VK_SUCCESS;
1379 }
1380
Jon Ashburn00df0452016-03-08 09:30:30 -07001381 pIcdSurface = loader_heap_alloc(inst, sizeof(VkIcdSurfaceDisplay),
1382 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
1383 if (pIcdSurface == NULL) {
1384 return VK_ERROR_OUT_OF_HOST_MEMORY;
1385 }
1386
1387 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_DISPLAY;
1388 pIcdSurface->displayMode = pCreateInfo->displayMode;
1389 pIcdSurface->planeIndex = pCreateInfo->planeIndex;
1390 pIcdSurface->planeStackIndex = pCreateInfo->planeStackIndex;
1391 pIcdSurface->transform = pCreateInfo->transform;
1392 pIcdSurface->globalAlpha = pCreateInfo->globalAlpha;
1393 pIcdSurface->alphaMode = pCreateInfo->alphaMode;
1394 pIcdSurface->imageExtent = pCreateInfo->imageExtent;
1395
1396 *pSurface = (VkSurfaceKHR)pIcdSurface;
1397
1398 return VK_SUCCESS;
1399}
1400
Ian Elliotta81e8ac2015-10-30 15:28:23 -06001401bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance,
Jon Ashburn44aed662016-02-02 17:47:28 -07001402 const char *name, void **addr) {
Ian Elliotta81e8ac2015-10-30 15:28:23 -06001403 *addr = NULL;
1404
Ian Elliott5bf16c32015-11-19 16:39:21 -07001405 /*
1406 * Functions for the VK_KHR_surface extension:
1407 */
Ian Elliottb2484122015-11-19 13:14:05 -07001408 if (!strcmp("vkDestroySurfaceKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001409 *addr = ptr_instance->wsi_surface_enabled ? (void *)vkDestroySurfaceKHR
1410 : NULL;
Ian Elliottb2484122015-11-19 13:14:05 -07001411 return true;
1412 }
Ian Elliotta81e8ac2015-10-30 15:28:23 -06001413 if (!strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001414 *addr = ptr_instance->wsi_surface_enabled
1415 ? (void *)vkGetPhysicalDeviceSurfaceSupportKHR
1416 : NULL;
Ian Elliotta81e8ac2015-10-30 15:28:23 -06001417 return true;
1418 }
Ian Elliott8cda1802015-11-19 16:05:09 -07001419 if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001420 *addr = ptr_instance->wsi_surface_enabled
1421 ? (void *)vkGetPhysicalDeviceSurfaceCapabilitiesKHR
1422 : NULL;
Ian Elliott8cda1802015-11-19 16:05:09 -07001423 return true;
1424 }
1425 if (!strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001426 *addr = ptr_instance->wsi_surface_enabled
1427 ? (void *)vkGetPhysicalDeviceSurfaceFormatsKHR
1428 : NULL;
Ian Elliott8cda1802015-11-19 16:05:09 -07001429 return true;
1430 }
1431 if (!strcmp("vkGetPhysicalDeviceSurfacePresentModesKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001432 *addr = ptr_instance->wsi_surface_enabled
1433 ? (void *)vkGetPhysicalDeviceSurfacePresentModesKHR
1434 : NULL;
Ian Elliott8cda1802015-11-19 16:05:09 -07001435 return true;
1436 }
Ian Elliott5bf16c32015-11-19 16:39:21 -07001437
1438 /*
1439 * Functions for the VK_KHR_swapchain extension:
1440 *
1441 * Note: This is a device extension, and its functions are statically
1442 * exported from the loader. Per Khronos decisions, the the loader's GIPA
1443 * function will return the trampoline function for such device-extension
1444 * functions, regardless of whether the extension has been enabled.
1445 */
1446 if (!strcmp("vkCreateSwapchainKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001447 *addr = (void *)vkCreateSwapchainKHR;
Ian Elliott5bf16c32015-11-19 16:39:21 -07001448 return true;
1449 }
1450 if (!strcmp("vkDestroySwapchainKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001451 *addr = (void *)vkDestroySwapchainKHR;
Ian Elliott5bf16c32015-11-19 16:39:21 -07001452 return true;
1453 }
1454 if (!strcmp("vkGetSwapchainImagesKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001455 *addr = (void *)vkGetSwapchainImagesKHR;
Ian Elliott5bf16c32015-11-19 16:39:21 -07001456 return true;
1457 }
1458 if (!strcmp("vkAcquireNextImageKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001459 *addr = (void *)vkAcquireNextImageKHR;
Ian Elliott5bf16c32015-11-19 16:39:21 -07001460 return true;
1461 }
1462 if (!strcmp("vkQueuePresentKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001463 *addr = (void *)vkQueuePresentKHR;
Ian Elliott5bf16c32015-11-19 16:39:21 -07001464 return true;
1465 }
1466
Ian Elliottb2484122015-11-19 13:14:05 -07001467#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott5bf16c32015-11-19 16:39:21 -07001468 /*
1469 * Functions for the VK_KHR_win32_surface extension:
1470 */
Ian Elliottb2484122015-11-19 13:14:05 -07001471 if (!strcmp("vkCreateWin32SurfaceKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001472 *addr = ptr_instance->wsi_win32_surface_enabled
1473 ? (void *)vkCreateWin32SurfaceKHR
1474 : NULL;
Ian Elliottb2484122015-11-19 13:14:05 -07001475 return true;
1476 }
Ian Elliott4e309e92015-11-24 15:39:10 -07001477 if (!strcmp("vkGetPhysicalDeviceWin32PresentationSupportKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001478 *addr = ptr_instance->wsi_win32_surface_enabled
1479 ? (void *)vkGetPhysicalDeviceWin32PresentationSupportKHR
1480 : NULL;
Ian Elliott4e309e92015-11-24 15:39:10 -07001481 return true;
1482 }
Ian Elliottb2484122015-11-19 13:14:05 -07001483#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliottb2484122015-11-19 13:14:05 -07001484#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott5bf16c32015-11-19 16:39:21 -07001485 /*
1486 * Functions for the VK_KHR_mir_surface extension:
1487 */
Ian Elliottb2484122015-11-19 13:14:05 -07001488 if (!strcmp("vkCreateMirSurfaceKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001489 *addr = ptr_instance->wsi_mir_surface_enabled
1490 ? (void *)vkCreateMirSurfaceKHR
1491 : NULL;
Ian Elliottb2484122015-11-19 13:14:05 -07001492 return true;
1493 }
Ian Elliott4e309e92015-11-24 15:39:10 -07001494 if (!strcmp("vkGetPhysicalDeviceMirPresentationSupportKHR", name)) {
Jon Ashburn44aed662016-02-02 17:47:28 -07001495 *addr = ptr_instance->wsi_mir_surface_enabled
1496 ? (void *)vkGetPhysicalDeviceMirPresentationSupportKHR
1497 : NULL;
Ian Elliott4e309e92015-11-24 15:39:10 -07001498 return true;
Jason Ekstrandcd0672c2016-02-12 17:25:03 -08001499 }
Ian Elliottb2484122015-11-19 13:14:05 -07001500#endif // VK_USE_PLATFORM_MIR_KHR
1501#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Jon Ashburna9c4a572016-02-26 13:14:27 -07001502 /*
1503 * Functions for the VK_KHR_wayland_surface extension:
1504 */
1505 if (!strcmp("vkCreateWaylandSurfaceKHR", name)) {
1506 *addr = ptr_instance->wsi_wayland_surface_enabled
1507 ? (void *)vkCreateWaylandSurfaceKHR
1508 : NULL;
1509 return true;
1510 }
1511 if (!strcmp("vkGetPhysicalDeviceWaylandPresentationSupportKHR", name)) {
1512 *addr = ptr_instance->wsi_wayland_surface_enabled
Jon Ashburn44aed662016-02-02 17:47:28 -07001513 ? (void *)vkGetPhysicalDeviceWaylandPresentationSupportKHR
1514 : NULL;
Jon Ashburna9c4a572016-02-26 13:14:27 -07001515 return true;
1516 }
Ian Elliottb2484122015-11-19 13:14:05 -07001517#endif // VK_USE_PLATFORM_WAYLAND_KHR
1518#ifdef VK_USE_PLATFORM_XCB_KHR
Jon Ashburna9c4a572016-02-26 13:14:27 -07001519 /*
1520 * Functions for the VK_KHR_xcb_surface extension:
1521 */
1522 if (!strcmp("vkCreateXcbSurfaceKHR", name)) {
1523 *addr = ptr_instance->wsi_xcb_surface_enabled
1524 ? (void *)vkCreateXcbSurfaceKHR
1525 : NULL;
1526 return true;
1527 }
1528 if (!strcmp("vkGetPhysicalDeviceXcbPresentationSupportKHR", name)) {
1529 *addr = ptr_instance->wsi_xcb_surface_enabled
1530 ? (void *)vkGetPhysicalDeviceXcbPresentationSupportKHR
1531 : NULL;
1532 return true;
1533 }
Ian Elliottb2484122015-11-19 13:14:05 -07001534#endif // VK_USE_PLATFORM_XCB_KHR
1535#ifdef VK_USE_PLATFORM_XLIB_KHR
Jon Ashburna9c4a572016-02-26 13:14:27 -07001536 /*
1537 * Functions for the VK_KHR_xlib_surface extension:
1538 */
1539 if (!strcmp("vkCreateXlibSurfaceKHR", name)) {
1540 *addr = ptr_instance->wsi_xlib_surface_enabled
1541 ? (void *)vkCreateXlibSurfaceKHR
1542 : NULL;
1543 return true;
1544 }
1545 if (!strcmp("vkGetPhysicalDeviceXlibPresentationSupportKHR", name)) {
1546 *addr = ptr_instance->wsi_xlib_surface_enabled
1547 ? (void *)vkGetPhysicalDeviceXlibPresentationSupportKHR
1548 : NULL;
1549 return true;
1550 }
Ian Elliottb2484122015-11-19 13:14:05 -07001551#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -07001552#ifdef VK_USE_PLATFORM_ANDROID_KHR
Jon Ashburna9c4a572016-02-26 13:14:27 -07001553 /*
1554 * Functions for the VK_KHR_android_surface extension:
1555 */
1556 if (!strcmp("vkCreateAndroidSurfaceKHR", name)) {
1557 *addr = ptr_instance->wsi_xlib_surface_enabled
1558 ? (void *)vkCreateAndroidSurfaceKHR
1559 : NULL;
1560 return true;
1561 }
Mark Lobodzinskib3e934d2015-12-10 16:25:21 -07001562#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliottb2484122015-11-19 13:14:05 -07001563
Jon Ashburn00df0452016-03-08 09:30:30 -07001564 /*
1565 * Functions for VK_KHR_display extension:
1566 */
1567 if (!strcmp("vkGetPhysicalDeviceDisplayPropertiesKHR", name)) {
1568 *addr = ptr_instance->wsi_display_enabled
1569 ? (void *)vkGetPhysicalDeviceDisplayPropertiesKHR
1570 : NULL;
1571 return true;
1572 }
1573 if (!strcmp("vkGetPhysicalDeviceDisplayPlanePropertiesKHR", name)) {
1574 *addr = ptr_instance->wsi_display_enabled
1575 ? (void *)vkGetPhysicalDeviceDisplayPlanePropertiesKHR
1576 : NULL;
1577 return true;
1578 }
1579 if (!strcmp("vkGetDisplayPlaneSupportedDisplaysKHR", name)) {
1580 *addr = ptr_instance->wsi_display_enabled
1581 ? (void *)vkGetDisplayPlaneSupportedDisplaysKHR
1582 : NULL;
1583 return true;
1584 }
1585 if (!strcmp("vkGetDisplayModePropertiesKHR", name)) {
1586 *addr = ptr_instance->wsi_display_enabled
1587 ? (void *)vkGetDisplayModePropertiesKHR
1588 : NULL;
1589 return true;
1590 }
1591 if (!strcmp("vkCreateDisplayModeKHR", name)) {
1592 *addr = ptr_instance->wsi_display_enabled
1593 ? (void *)vkCreateDisplayModeKHR
1594 : NULL;
1595 return true;
1596 }
1597 if (!strcmp("vkGetDisplayPlaneCapabilitiesKHR", name)) {
1598 *addr = ptr_instance->wsi_display_enabled
1599 ? (void *)vkGetDisplayPlaneCapabilitiesKHR
1600 : NULL;
1601 return true;
1602 }
1603 if (!strcmp("vkCreateDisplayPlaneSurfaceKHR", name)) {
1604 *addr = ptr_instance->wsi_display_enabled
1605 ? (void *)vkCreateDisplayPlaneSurfaceKHR
1606 : NULL;
1607 return true;
1608 }
Jon Ashburna9c4a572016-02-26 13:14:27 -07001609 return false;
Ian Elliott5a1bff52016-03-24 13:59:22 -06001610}