Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 1 | /* |
Lenny Komow | a1b5e44 | 2019-09-16 16:14:36 -0600 | [diff] [blame] | 2 | * Copyright (c) 2015-2016, 2019 The Khronos Group Inc. |
| 3 | * Copyright (c) 2015-2016, 2019 Valve Corporation |
| 4 | * Copyright (c) 2015-2016, 2019 LunarG, Inc. |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 5 | * |
Jon Ashburn | 4f80d67 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 9 | * |
Jon Ashburn | 4f80d67 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 11 | * |
Jon Ashburn | 4f80d67 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 17 | * |
| 18 | * Author: Ian Elliott <ian@lunarg.com> |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 19 | * Author: Jon Ashburn <jon@lunarg.com> |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 20 | * Author: Ian Elliott <ianelliott@google.com> |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 21 | * Author: Mark Lobodzinski <mark@lunarg.com> |
Lenny Komow | a1b5e44 | 2019-09-16 16:14:36 -0600 | [diff] [blame] | 22 | * Author: Lenny Komow <lenny@lunarg.com> |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 23 | */ |
| 24 | |
Tom Anderson | a835880 | 2018-07-25 17:10:16 -0700 | [diff] [blame] | 25 | #ifndef _GNU_SOURCE |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 26 | #define _GNU_SOURCE |
Tom Anderson | a835880 | 2018-07-25 17:10:16 -0700 | [diff] [blame] | 27 | #endif |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 28 | #include <stdio.h> |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 29 | #include <stdlib.h> |
| 30 | #include <string.h> |
| 31 | #include "vk_loader_platform.h" |
| 32 | #include "loader.h" |
| 33 | #include "wsi.h" |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 34 | #include <vulkan/vk_icd.h> |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 35 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 36 | // The first ICD/Loader interface that support querying the SurfaceKHR from |
| 37 | // the ICDs. |
| 38 | #define ICD_VER_SUPPORTS_ICD_SURFACE_KHR 3 |
| 39 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 40 | void wsi_create_instance(struct loader_instance *ptr_instance, const VkInstanceCreateInfo *pCreateInfo) { |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 41 | ptr_instance->wsi_surface_enabled = false; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 42 | |
| 43 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 44 | ptr_instance->wsi_win32_surface_enabled = false; |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 45 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 46 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 47 | ptr_instance->wsi_wayland_surface_enabled = false; |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 48 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 49 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 50 | ptr_instance->wsi_xcb_surface_enabled = false; |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 51 | #endif // VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 52 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 53 | ptr_instance->wsi_xlib_surface_enabled = false; |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 54 | #endif // VK_USE_PLATFORM_XLIB_KHR |
Nicolas Caramelli | fa696ca | 2020-07-04 22:53:59 +0200 | [diff] [blame] | 55 | #ifdef VK_USE_PLATFORM_DIRECTFB_EXT |
| 56 | ptr_instance->wsi_directfb_surface_enabled = false; |
| 57 | #endif // VK_USE_PLATFORM_DIRECTFB_EXT |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 58 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 59 | ptr_instance->wsi_android_surface_enabled = false; |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 60 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
Karl Schultz | d81ebfb | 2017-12-12 10:33:01 -0500 | [diff] [blame] | 61 | #ifdef VK_USE_PLATFORM_MACOS_MVK |
| 62 | ptr_instance->wsi_macos_surface_enabled = false; |
| 63 | #endif // VK_USE_PLATFORM_MACOS_MVK |
| 64 | #ifdef VK_USE_PLATFORM_IOS_MVK |
| 65 | ptr_instance->wsi_ios_surface_enabled = false; |
| 66 | #endif // VK_USE_PLATFORM_IOS_MVK |
Craig Stout | f3b74dc | 2020-10-26 12:05:15 -0700 | [diff] [blame] | 67 | #ifdef VK_USE_PLATFORM_FUCHSIA |
| 68 | ptr_instance->wsi_imagepipe_surface_enabled = false; |
| 69 | #endif // VK_USE_PLATFORM_FUCHSIA |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 70 | ptr_instance->wsi_display_enabled = false; |
Lenny Komow | 6113978 | 2018-05-31 11:32:31 -0600 | [diff] [blame] | 71 | ptr_instance->wsi_display_props2_enabled = false; |
Lenny Komow | a1b5e44 | 2019-09-16 16:14:36 -0600 | [diff] [blame] | 72 | #ifdef VK_USE_PLATFORM_METAL_EXT |
| 73 | ptr_instance->wsi_metal_surface_enabled = false; |
| 74 | #endif // VK_USE_PLATFORM_METAL_EXT |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 75 | |
Jon Ashburn | a0673ab | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 76 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 77 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 78 | ptr_instance->wsi_surface_enabled = true; |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 79 | continue; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 80 | } |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 81 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 82 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 83 | ptr_instance->wsi_win32_surface_enabled = true; |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 84 | continue; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 85 | } |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 86 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 87 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 88 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 89 | ptr_instance->wsi_wayland_surface_enabled = true; |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 90 | continue; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 91 | } |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 92 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 93 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 94 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 95 | ptr_instance->wsi_xcb_surface_enabled = true; |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 96 | continue; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 97 | } |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 98 | #endif // VK_USE_PLATFORM_XCB_KHR |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 99 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 100 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 101 | ptr_instance->wsi_xlib_surface_enabled = true; |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 102 | continue; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 103 | } |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 104 | #endif // VK_USE_PLATFORM_XLIB_KHR |
Nicolas Caramelli | fa696ca | 2020-07-04 22:53:59 +0200 | [diff] [blame] | 105 | #ifdef VK_USE_PLATFORM_DIRECTFB_EXT |
| 106 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_DIRECTFB_SURFACE_EXTENSION_NAME) == 0) { |
| 107 | ptr_instance->wsi_directfb_surface_enabled = true; |
| 108 | continue; |
| 109 | } |
| 110 | #endif // VK_USE_PLATFORM_DIRECTFB_EXT |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 111 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 112 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0) { |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 113 | ptr_instance->wsi_android_surface_enabled = true; |
| 114 | continue; |
| 115 | } |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 116 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
Karl Schultz | d81ebfb | 2017-12-12 10:33:01 -0500 | [diff] [blame] | 117 | #ifdef VK_USE_PLATFORM_MACOS_MVK |
| 118 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_MVK_MACOS_SURFACE_EXTENSION_NAME) == 0) { |
| 119 | ptr_instance->wsi_macos_surface_enabled = true; |
| 120 | continue; |
| 121 | } |
| 122 | #endif // VK_USE_PLATFORM_MACOS_MVK |
| 123 | #ifdef VK_USE_PLATFORM_IOS_MVK |
| 124 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_MVK_IOS_SURFACE_EXTENSION_NAME) == 0) { |
| 125 | ptr_instance->wsi_ios_surface_enabled = true; |
| 126 | continue; |
| 127 | } |
| 128 | #endif // VK_USE_PLATFORM_IOS_MVK |
Craig Stout | f3b74dc | 2020-10-26 12:05:15 -0700 | [diff] [blame] | 129 | #ifdef VK_USE_PLATFORM_FUCHSIA |
| 130 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_FUCHSIA_IMAGEPIPE_SURFACE_EXTENSION_NAME) == 0) { |
| 131 | ptr_instance->wsi_imagepipe_surface_enabled = true; |
| 132 | continue; |
| 133 | } |
| 134 | #endif // VK_USE_PLATFORM_FUCHSIA |
Bryan Law-Smith | 5730569 | 2019-04-01 09:45:55 +0100 | [diff] [blame] | 135 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME) == 0) { |
| 136 | ptr_instance->wsi_headless_surface_enabled = true; |
| 137 | continue; |
| 138 | } |
Lenny Komow | a1b5e44 | 2019-09-16 16:14:36 -0600 | [diff] [blame] | 139 | #if defined(VK_USE_PLATFORM_METAL_EXT) |
| 140 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_METAL_SURFACE_EXTENSION_NAME) == 0) { |
| 141 | ptr_instance->wsi_metal_surface_enabled = true; |
| 142 | continue; |
| 143 | } |
| 144 | #endif |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 145 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_DISPLAY_EXTENSION_NAME) == 0) { |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 146 | ptr_instance->wsi_display_enabled = true; |
| 147 | continue; |
| 148 | } |
Lenny Komow | 6113978 | 2018-05-31 11:32:31 -0600 | [diff] [blame] | 149 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_GET_DISPLAY_PROPERTIES_2_EXTENSION_NAME) == 0) { |
| 150 | ptr_instance->wsi_display_props2_enabled = true; |
| 151 | continue; |
| 152 | } |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 153 | } |
| 154 | } |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 155 | |
| 156 | // Linux WSI surface extensions are not always compiled into the loader. (Assume |
| 157 | // for Windows the KHR_win32_surface is always compiled into loader). A given |
| 158 | // Linux build environment might not have the headers required for building one |
Tony-LunarG | 0366721 | 2018-10-23 14:08:03 -0600 | [diff] [blame] | 159 | // of the three extensions (Xlib, Xcb, Wayland). Thus, need to check if |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 160 | // the built loader actually supports the particular Linux surface extension. |
| 161 | // If not supported by the built loader it will not be included in the list of |
| 162 | // enumerated instance extensions. This solves the issue where an ICD or layer |
| 163 | // advertises support for a given Linux surface extension but the loader was not |
| 164 | // built to support the extension. |
Jon Ashburn | ae8f1e8 | 2016-03-25 12:49:35 -0600 | [diff] [blame] | 165 | bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop) { |
Jon Ashburn | ae8f1e8 | 2016-03-25 12:49:35 -0600 | [diff] [blame] | 166 | #ifndef VK_USE_PLATFORM_WAYLAND_KHR |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 167 | if (!strcmp(ext_prop->extensionName, "VK_KHR_wayland_surface")) return true; |
| 168 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Jon Ashburn | ae8f1e8 | 2016-03-25 12:49:35 -0600 | [diff] [blame] | 169 | #ifndef VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 170 | if (!strcmp(ext_prop->extensionName, "VK_KHR_xcb_surface")) return true; |
| 171 | #endif // VK_USE_PLATFORM_XCB_KHR |
Jon Ashburn | ae8f1e8 | 2016-03-25 12:49:35 -0600 | [diff] [blame] | 172 | #ifndef VK_USE_PLATFORM_XLIB_KHR |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 173 | if (!strcmp(ext_prop->extensionName, "VK_KHR_xlib_surface")) return true; |
| 174 | #endif // VK_USE_PLATFORM_XLIB_KHR |
Nicolas Caramelli | fa696ca | 2020-07-04 22:53:59 +0200 | [diff] [blame] | 175 | #ifndef VK_USE_PLATFORM_DIRECTFB_EXT |
| 176 | if (!strcmp(ext_prop->extensionName, "VK_EXT_directfb_surface")) return true; |
| 177 | #endif // VK_USE_PLATFORM_DIRECTFB_EXT |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 178 | |
Jon Ashburn | ae8f1e8 | 2016-03-25 12:49:35 -0600 | [diff] [blame] | 179 | return false; |
| 180 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 181 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 182 | // Functions for the VK_KHR_surface extension: |
| 183 | |
| 184 | // This is the trampoline entrypoint for DestroySurfaceKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 185 | LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, |
| 186 | const VkAllocationCallbacks *pAllocator) { |
Ian Elliott | abf5066 | 2015-11-25 14:43:02 -0700 | [diff] [blame] | 187 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 188 | disp = loader_get_instance_layer_dispatch(instance); |
Ian Elliott | abf5066 | 2015-11-25 14:43:02 -0700 | [diff] [blame] | 189 | disp->DestroySurfaceKHR(instance, surface, pAllocator); |
| 190 | } |
| 191 | |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 192 | // TODO probably need to lock around all the loader_get_instance() calls. |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 193 | |
| 194 | // This is the instance chain terminator function for DestroySurfaceKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 195 | VKAPI_ATTR void VKAPI_CALL terminator_DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, |
| 196 | const VkAllocationCallbacks *pAllocator) { |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 197 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
| 198 | |
Karl Schultz | a9e989f | 2016-11-19 09:02:27 -0700 | [diff] [blame] | 199 | VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; |
Mark Young | 11e9d47 | 2016-10-17 12:27:36 -0600 | [diff] [blame] | 200 | if (NULL != icd_surface) { |
| 201 | if (NULL != icd_surface->real_icd_surfaces) { |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 202 | uint32_t i = 0; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 203 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
| 204 | if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 205 | if (NULL != icd_term->dispatch.DestroySurfaceKHR && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[i]) { |
| 206 | icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, icd_surface->real_icd_surfaces[i], pAllocator); |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 207 | icd_surface->real_icd_surfaces[i] = (VkSurfaceKHR)NULL; |
Mark Young | 11e9d47 | 2016-10-17 12:27:36 -0600 | [diff] [blame] | 208 | } |
| 209 | } else { |
| 210 | // The real_icd_surface for any ICD not supporting the |
| 211 | // proper interface version should be NULL. If not, then |
| 212 | // we have a problem. |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 213 | assert((VkSurfaceKHR)NULL == icd_surface->real_icd_surfaces[i]); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 214 | } |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 215 | } |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 216 | loader_instance_heap_free(ptr_instance, icd_surface->real_icd_surfaces); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 217 | } |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 218 | |
Karl Schultz | a9e989f | 2016-11-19 09:02:27 -0700 | [diff] [blame] | 219 | loader_instance_heap_free(ptr_instance, (void *)(uintptr_t)surface); |
Mark Young | 11e9d47 | 2016-10-17 12:27:36 -0600 | [diff] [blame] | 220 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 221 | } |
| 222 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 223 | // This is the trampoline entrypoint for GetPhysicalDeviceSurfaceSupportKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 224 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, |
| 225 | uint32_t queueFamilyIndex, VkSurfaceKHR surface, |
| 226 | VkBool32 *pSupported) { |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 227 | const VkLayerInstanceDispatchTable *disp; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 228 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 229 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 230 | VkResult res = disp->GetPhysicalDeviceSurfaceSupportKHR(unwrapped_phys_dev, queueFamilyIndex, surface, pSupported); |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 231 | return res; |
| 232 | } |
| 233 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 234 | // This is the instance chain terminator function for |
| 235 | // GetPhysicalDeviceSurfaceSupportKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 236 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, |
| 237 | uint32_t queueFamilyIndex, VkSurfaceKHR surface, |
| 238 | VkBool32 *pSupported) { |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 239 | // First, check to ensure the appropriate extension was enabled: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 240 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 241 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 242 | struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 243 | if (!ptr_instance->wsi_surface_enabled) { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 244 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 245 | "VK_KHR_surface extension not enabled. vkGetPhysicalDeviceSurfaceSupportKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 246 | return VK_SUCCESS; |
| 247 | } |
| 248 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 249 | if (NULL == pSupported) { |
| 250 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 251 | "NULL pointer passed into vkGetPhysicalDeviceSurfaceSupportKHR for pSupported!\n"); |
| 252 | assert(false && "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported"); |
| 253 | } |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 254 | *pSupported = false; |
| 255 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 256 | if (NULL == icd_term->dispatch.GetPhysicalDeviceSurfaceSupportKHR) { |
| 257 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 258 | "ICD for selected physical device is not exporting vkGetPhysicalDeviceSurfaceSupportKHR!\n"); |
| 259 | assert(false && "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer"); |
| 260 | } |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 261 | |
Karl Schultz | a9e989f | 2016-11-19 09:02:27 -0700 | [diff] [blame] | 262 | VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 263 | if (NULL != icd_surface->real_icd_surfaces && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 264 | return icd_term->dispatch.GetPhysicalDeviceSurfaceSupportKHR( |
| 265 | phys_dev_term->phys_dev, queueFamilyIndex, icd_surface->real_icd_surfaces[phys_dev_term->icd_index], pSupported); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 266 | } |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 267 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 268 | return icd_term->dispatch.GetPhysicalDeviceSurfaceSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, surface, pSupported); |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 269 | } |
| 270 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 271 | // This is the trampoline entrypoint for GetPhysicalDeviceSurfaceCapabilitiesKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 272 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR( |
| 273 | VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) { |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 274 | const VkLayerInstanceDispatchTable *disp; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 275 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 276 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 277 | VkResult res = disp->GetPhysicalDeviceSurfaceCapabilitiesKHR(unwrapped_phys_dev, surface, pSurfaceCapabilities); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 278 | return res; |
| 279 | } |
| 280 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 281 | // This is the instance chain terminator function for |
| 282 | // GetPhysicalDeviceSurfaceCapabilitiesKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 283 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, |
| 284 | VkSurfaceKHR surface, |
| 285 | VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) { |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 286 | // First, check to ensure the appropriate extension was enabled: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 287 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 288 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 289 | struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 290 | if (!ptr_instance->wsi_surface_enabled) { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 291 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 292 | "VK_KHR_surface extension not enabled. vkGetPhysicalDeviceSurfaceCapabilitiesKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 293 | return VK_SUCCESS; |
| 294 | } |
| 295 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 296 | if (NULL == pSurfaceCapabilities) { |
| 297 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 298 | "NULL pointer passed into vkGetPhysicalDeviceSurfaceCapabilitiesKHR for pSurfaceCapabilities!\n"); |
| 299 | assert(false && "GetPhysicalDeviceSurfaceCapabilitiesKHR: Error, null pSurfaceCapabilities"); |
| 300 | } |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 301 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 302 | if (NULL == icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilitiesKHR) { |
| 303 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 304 | "ICD for selected physical device is not exporting vkGetPhysicalDeviceSurfaceCapabilitiesKHR!\n"); |
| 305 | assert(false && "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer"); |
| 306 | } |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 307 | |
Karl Schultz | a9e989f | 2016-11-19 09:02:27 -0700 | [diff] [blame] | 308 | VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 309 | if (NULL != icd_surface->real_icd_surfaces && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 310 | return icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilitiesKHR( |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 311 | phys_dev_term->phys_dev, icd_surface->real_icd_surfaces[phys_dev_term->icd_index], pSurfaceCapabilities); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 312 | } |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 313 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 314 | return icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev_term->phys_dev, surface, pSurfaceCapabilities); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 315 | } |
| 316 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 317 | // This is the trampoline entrypoint for GetPhysicalDeviceSurfaceFormatsKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 318 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, |
| 319 | VkSurfaceKHR surface, |
| 320 | uint32_t *pSurfaceFormatCount, |
| 321 | VkSurfaceFormatKHR *pSurfaceFormats) { |
| 322 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 323 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 324 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 325 | VkResult res = disp->GetPhysicalDeviceSurfaceFormatsKHR(unwrapped_phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 326 | return res; |
| 327 | } |
| 328 | |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 329 | // This is the instance chain terminator function for |
| 330 | // GetPhysicalDeviceSurfaceFormatsKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 331 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, |
| 332 | uint32_t *pSurfaceFormatCount, |
| 333 | VkSurfaceFormatKHR *pSurfaceFormats) { |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 334 | // First, check to ensure the appropriate extension was enabled: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 335 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 336 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 337 | struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 338 | if (!ptr_instance->wsi_surface_enabled) { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 339 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 340 | "VK_KHR_surface extension not enabled. vkGetPhysicalDeviceSurfaceFormatsKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 341 | return VK_SUCCESS; |
| 342 | } |
| 343 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 344 | if (NULL == pSurfaceFormatCount) { |
| 345 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 346 | "NULL pointer passed into vkGetPhysicalDeviceSurfaceFormatsKHR for pSurfaceFormatCount!\n"); |
| 347 | assert(false && "GetPhysicalDeviceSurfaceFormatsKHR(: Error, null pSurfaceFormatCount"); |
| 348 | } |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 349 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 350 | if (NULL == icd_term->dispatch.GetPhysicalDeviceSurfaceFormatsKHR) { |
| 351 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 352 | "ICD for selected physical device is not exporting vkGetPhysicalDeviceSurfaceCapabilitiesKHR!\n"); |
| 353 | assert(false && "loader: null GetPhysicalDeviceSurfaceFormatsKHR ICD pointer"); |
| 354 | } |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 355 | |
Karl Schultz | a9e989f | 2016-11-19 09:02:27 -0700 | [diff] [blame] | 356 | VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 357 | if (NULL != icd_surface->real_icd_surfaces && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 358 | return icd_term->dispatch.GetPhysicalDeviceSurfaceFormatsKHR(phys_dev_term->phys_dev, |
| 359 | icd_surface->real_icd_surfaces[phys_dev_term->icd_index], |
| 360 | pSurfaceFormatCount, pSurfaceFormats); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 361 | } |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 362 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 363 | return icd_term->dispatch.GetPhysicalDeviceSurfaceFormatsKHR(phys_dev_term->phys_dev, surface, pSurfaceFormatCount, |
| 364 | pSurfaceFormats); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 365 | } |
| 366 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 367 | // This is the trampoline entrypoint for GetPhysicalDeviceSurfacePresentModesKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 368 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, |
| 369 | VkSurfaceKHR surface, |
| 370 | uint32_t *pPresentModeCount, |
| 371 | VkPresentModeKHR *pPresentModes) { |
| 372 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 373 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 374 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 375 | VkResult res = disp->GetPhysicalDeviceSurfacePresentModesKHR(unwrapped_phys_dev, surface, pPresentModeCount, pPresentModes); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 376 | return res; |
| 377 | } |
| 378 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 379 | // This is the instance chain terminator function for |
| 380 | // GetPhysicalDeviceSurfacePresentModesKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 381 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, |
| 382 | VkSurfaceKHR surface, uint32_t *pPresentModeCount, |
| 383 | VkPresentModeKHR *pPresentModes) { |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 384 | // First, check to ensure the appropriate extension was enabled: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 385 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 386 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 387 | struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 388 | if (!ptr_instance->wsi_surface_enabled) { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 389 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 390 | "VK_KHR_surface extension not enabled. vkGetPhysicalDeviceSurfacePresentModesKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 391 | return VK_SUCCESS; |
| 392 | } |
| 393 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 394 | if (NULL == pPresentModeCount) { |
| 395 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 396 | "NULL pointer passed into vkGetPhysicalDeviceSurfacePresentModesKHR for pPresentModeCount!\n"); |
| 397 | assert(false && "GetPhysicalDeviceSurfacePresentModesKHR(: Error, null pPresentModeCount"); |
| 398 | } |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 399 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 400 | if (NULL == icd_term->dispatch.GetPhysicalDeviceSurfacePresentModesKHR) { |
| 401 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 402 | "ICD for selected physical device is not exporting vkGetPhysicalDeviceSurfacePresentModesKHR!\n"); |
| 403 | assert(false && "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer"); |
| 404 | } |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 405 | |
Karl Schultz | a9e989f | 2016-11-19 09:02:27 -0700 | [diff] [blame] | 406 | VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 407 | if (NULL != icd_surface->real_icd_surfaces && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 408 | return icd_term->dispatch.GetPhysicalDeviceSurfacePresentModesKHR( |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 409 | phys_dev_term->phys_dev, icd_surface->real_icd_surfaces[phys_dev_term->icd_index], pPresentModeCount, pPresentModes); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 410 | } |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 411 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 412 | return icd_term->dispatch.GetPhysicalDeviceSurfacePresentModesKHR(phys_dev_term->phys_dev, surface, pPresentModeCount, |
| 413 | pPresentModes); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 414 | } |
| 415 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 416 | // Functions for the VK_KHR_swapchain extension: |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 417 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 418 | // This is the trampoline entrypoint for CreateSwapchainKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 419 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, |
| 420 | const VkAllocationCallbacks *pAllocator, |
| 421 | VkSwapchainKHR *pSwapchain) { |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 422 | const VkLayerDispatchTable *disp; |
| 423 | disp = loader_get_dispatch(device); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 424 | return disp->CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain); |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 425 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 426 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 427 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, |
Karl Schultz | d81ebfb | 2017-12-12 10:33:01 -0500 | [diff] [blame] | 428 | const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 429 | uint32_t icd_index = 0; |
| 430 | struct loader_device *dev; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 431 | struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, &icd_index); |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 432 | if (NULL != icd_term && NULL != icd_term->dispatch.CreateSwapchainKHR) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 433 | VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)pCreateInfo->surface; |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 434 | if (NULL != icd_surface->real_icd_surfaces) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 435 | if ((VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[icd_index]) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 436 | // We found the ICD, and there is an ICD KHR surface |
| 437 | // associated with it, so copy the CreateInfo struct |
| 438 | // and point it at the ICD's surface. |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 439 | VkSwapchainCreateInfoKHR *pCreateCopy = loader_stack_alloc(sizeof(VkSwapchainCreateInfoKHR)); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 440 | if (NULL == pCreateCopy) { |
| 441 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 442 | } |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 443 | memcpy(pCreateCopy, pCreateInfo, sizeof(VkSwapchainCreateInfoKHR)); |
| 444 | pCreateCopy->surface = icd_surface->real_icd_surfaces[icd_index]; |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 445 | return icd_term->dispatch.CreateSwapchainKHR(device, pCreateCopy, pAllocator, pSwapchain); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 446 | } |
| 447 | } |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 448 | return icd_term->dispatch.CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 449 | } |
| 450 | return VK_SUCCESS; |
| 451 | } |
| 452 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 453 | // This is the trampoline entrypoint for DestroySwapchainKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 454 | LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, |
| 455 | const VkAllocationCallbacks *pAllocator) { |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 456 | const VkLayerDispatchTable *disp; |
| 457 | disp = loader_get_dispatch(device); |
| 458 | disp->DestroySwapchainKHR(device, swapchain, pAllocator); |
| 459 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 460 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 461 | // This is the trampoline entrypoint for GetSwapchainImagesKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 462 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, |
| 463 | uint32_t *pSwapchainImageCount, VkImage *pSwapchainImages) { |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 464 | const VkLayerDispatchTable *disp; |
| 465 | disp = loader_get_dispatch(device); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 466 | return disp->GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages); |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 467 | } |
| 468 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 469 | // This is the trampoline entrypoint for AcquireNextImageKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 470 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, |
| 471 | VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex) { |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 472 | const VkLayerDispatchTable *disp; |
| 473 | disp = loader_get_dispatch(device); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 474 | return disp->AcquireNextImageKHR(device, swapchain, timeout, semaphore, fence, pImageIndex); |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 475 | } |
| 476 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 477 | // This is the trampoline entrypoint for QueuePresentKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 478 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) { |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 479 | const VkLayerDispatchTable *disp; |
| 480 | disp = loader_get_dispatch(queue); |
Mark Young | 76b3fe0 | 2016-09-08 12:28:38 -0600 | [diff] [blame] | 481 | return disp->QueuePresentKHR(queue, pPresentInfo); |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 482 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 483 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 484 | static VkIcdSurface *AllocateIcdSurfaceStruct(struct loader_instance *instance, size_t base_size, size_t platform_size) { |
Mark Young | f27962c | 2016-09-16 10:18:42 -0600 | [diff] [blame] | 485 | // Next, if so, proceed with the implementation of this function: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 486 | VkIcdSurface *pIcdSurface = loader_instance_heap_alloc(instance, sizeof(VkIcdSurface), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); |
Mark Young | f27962c | 2016-09-16 10:18:42 -0600 | [diff] [blame] | 487 | if (pIcdSurface != NULL) { |
| 488 | // Setup the new sizes and offsets so we can grow the structures in the |
| 489 | // future without having problems |
| 490 | pIcdSurface->base_size = (uint32_t)base_size; |
| 491 | pIcdSurface->platform_size = (uint32_t)platform_size; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 492 | pIcdSurface->non_platform_offset = (uint32_t)((uint8_t *)(&pIcdSurface->base_size) - (uint8_t *)pIcdSurface); |
Mark Young | f27962c | 2016-09-16 10:18:42 -0600 | [diff] [blame] | 493 | pIcdSurface->entire_size = sizeof(VkIcdSurface); |
| 494 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 495 | pIcdSurface->real_icd_surfaces = loader_instance_heap_alloc(instance, sizeof(VkSurfaceKHR) * instance->total_icd_count, |
| 496 | VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); |
Mark Young | 5117fdc | 2016-12-13 17:19:32 -0700 | [diff] [blame] | 497 | if (pIcdSurface->real_icd_surfaces == NULL) { |
| 498 | loader_instance_heap_free(instance, pIcdSurface); |
| 499 | pIcdSurface = NULL; |
Mark Young | f27962c | 2016-09-16 10:18:42 -0600 | [diff] [blame] | 500 | } else { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 501 | memset(pIcdSurface->real_icd_surfaces, 0, sizeof(VkSurfaceKHR) * instance->total_icd_count); |
Mark Young | f27962c | 2016-09-16 10:18:42 -0600 | [diff] [blame] | 502 | } |
| 503 | } |
| 504 | return pIcdSurface; |
| 505 | } |
| 506 | |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 507 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 508 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 509 | // Functions for the VK_KHR_win32_surface extension: |
| 510 | |
| 511 | // This is the trampoline entrypoint for CreateWin32SurfaceKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 512 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(VkInstance instance, |
| 513 | const VkWin32SurfaceCreateInfoKHR *pCreateInfo, |
| 514 | const VkAllocationCallbacks *pAllocator, |
| 515 | VkSurfaceKHR *pSurface) { |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 516 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 517 | disp = loader_get_instance_layer_dispatch(instance); |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 518 | VkResult res; |
| 519 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 520 | res = disp->CreateWin32SurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 521 | return res; |
| 522 | } |
| 523 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 524 | // This is the instance chain terminator function for CreateWin32SurfaceKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 525 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, |
| 526 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 527 | VkResult vkRes = VK_SUCCESS; |
Mark Young | d7fb159 | 2016-10-12 14:18:44 -0600 | [diff] [blame] | 528 | VkIcdSurface *pIcdSurface = NULL; |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 529 | uint32_t i = 0; |
| 530 | |
Mark Young | f27962c | 2016-09-16 10:18:42 -0600 | [diff] [blame] | 531 | // Initialize pSurface to NULL just to be safe. |
| 532 | *pSurface = VK_NULL_HANDLE; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 533 | // First, check to ensure the appropriate extension was enabled: |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 534 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 535 | if (!ptr_instance->wsi_win32_surface_enabled) { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 536 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 537 | "VK_KHR_win32_surface extension not enabled. vkCreateWin32SurfaceKHR not executed!\n"); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 538 | vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; |
| 539 | goto out; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 540 | } |
| 541 | |
| 542 | // Next, if so, proceed with the implementation of this function: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 543 | pIcdSurface = AllocateIcdSurfaceStruct(ptr_instance, sizeof(pIcdSurface->win_surf.base), sizeof(pIcdSurface->win_surf)); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 544 | if (pIcdSurface == NULL) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 545 | vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; |
| 546 | goto out; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 547 | } |
| 548 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 549 | pIcdSurface->win_surf.base.platform = VK_ICD_WSI_PLATFORM_WIN32; |
| 550 | pIcdSurface->win_surf.hinstance = pCreateInfo->hinstance; |
| 551 | pIcdSurface->win_surf.hwnd = pCreateInfo->hwnd; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 552 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 553 | // Loop through each ICD and determine if they need to create a surface |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 554 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
| 555 | if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 556 | if (NULL != icd_term->dispatch.CreateWin32SurfaceKHR) { |
| 557 | vkRes = icd_term->dispatch.CreateWin32SurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, |
| 558 | &pIcdSurface->real_icd_surfaces[i]); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 559 | if (VK_SUCCESS != vkRes) { |
| 560 | goto out; |
| 561 | } |
| 562 | } |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | *pSurface = (VkSurfaceKHR)(pIcdSurface); |
| 567 | |
| 568 | out: |
| 569 | |
| 570 | if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { |
| 571 | if (NULL != pIcdSurface->real_icd_surfaces) { |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 572 | i = 0; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 573 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 574 | if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { |
| 575 | icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 576 | } |
| 577 | } |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 578 | loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 579 | } |
| 580 | loader_instance_heap_free(ptr_instance, pIcdSurface); |
| 581 | } |
| 582 | |
| 583 | return vkRes; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 584 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 585 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 586 | // This is the trampoline entrypoint for |
| 587 | // GetPhysicalDeviceWin32PresentationSupportKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 588 | LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice, |
| 589 | uint32_t queueFamilyIndex) { |
| 590 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 591 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 592 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 593 | VkBool32 res = disp->GetPhysicalDeviceWin32PresentationSupportKHR(unwrapped_phys_dev, queueFamilyIndex); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 594 | return res; |
| 595 | } |
| 596 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 597 | // This is the instance chain terminator function for |
| 598 | // GetPhysicalDeviceWin32PresentationSupportKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 599 | VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice, |
| 600 | uint32_t queueFamilyIndex) { |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 601 | // First, check to ensure the appropriate extension was enabled: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 602 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 603 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 604 | struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 605 | if (!ptr_instance->wsi_win32_surface_enabled) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 606 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 607 | "VK_KHR_win32_surface extension not enabled. vkGetPhysicalDeviceWin32PresentationSupportKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 608 | return VK_SUCCESS; |
| 609 | } |
| 610 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 611 | if (NULL == icd_term->dispatch.GetPhysicalDeviceWin32PresentationSupportKHR) { |
| 612 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 613 | "ICD for selected physical device is not exporting vkGetPhysicalDeviceWin32PresentationSupportKHR!\n"); |
| 614 | assert(false && "loader: null GetPhysicalDeviceWin32PresentationSupportKHR ICD pointer"); |
| 615 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 616 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 617 | return icd_term->dispatch.GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 618 | } |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 619 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 620 | |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 621 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
| 622 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 623 | // This is the trampoline entrypoint for CreateWaylandSurfaceKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 624 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR(VkInstance instance, |
| 625 | const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, |
| 626 | const VkAllocationCallbacks *pAllocator, |
| 627 | VkSurfaceKHR *pSurface) { |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 628 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 629 | disp = loader_get_instance_layer_dispatch(instance); |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 630 | VkResult res; |
| 631 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 632 | res = disp->CreateWaylandSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 633 | return res; |
| 634 | } |
| 635 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 636 | // This is the instance chain terminator function for CreateWaylandSurfaceKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 637 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR(VkInstance instance, |
| 638 | const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, |
| 639 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 640 | VkResult vkRes = VK_SUCCESS; |
Mark Young | d7fb159 | 2016-10-12 14:18:44 -0600 | [diff] [blame] | 641 | VkIcdSurface *pIcdSurface = NULL; |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 642 | uint32_t i = 0; |
| 643 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 644 | // First, check to ensure the appropriate extension was enabled: |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 645 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
Jon Ashburn | 436d6a3 | 2016-03-24 17:26:59 -0600 | [diff] [blame] | 646 | if (!ptr_instance->wsi_wayland_surface_enabled) { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 647 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 648 | "VK_KHR_wayland_surface extension not enabled. vkCreateWaylandSurfaceKHR not executed!\n"); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 649 | vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; |
| 650 | goto out; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | // Next, if so, proceed with the implementation of this function: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 654 | pIcdSurface = AllocateIcdSurfaceStruct(ptr_instance, sizeof(pIcdSurface->wayland_surf.base), sizeof(pIcdSurface->wayland_surf)); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 655 | if (pIcdSurface == NULL) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 656 | vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; |
| 657 | goto out; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 658 | } |
| 659 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 660 | pIcdSurface->wayland_surf.base.platform = VK_ICD_WSI_PLATFORM_WAYLAND; |
| 661 | pIcdSurface->wayland_surf.display = pCreateInfo->display; |
| 662 | pIcdSurface->wayland_surf.surface = pCreateInfo->surface; |
| 663 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 664 | // Loop through each ICD and determine if they need to create a surface |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 665 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
| 666 | if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 667 | if (NULL != icd_term->dispatch.CreateWaylandSurfaceKHR) { |
| 668 | vkRes = icd_term->dispatch.CreateWaylandSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, |
| 669 | &pIcdSurface->real_icd_surfaces[i]); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 670 | if (VK_SUCCESS != vkRes) { |
| 671 | goto out; |
| 672 | } |
| 673 | } |
| 674 | } |
| 675 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 676 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 677 | *pSurface = (VkSurfaceKHR)pIcdSurface; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 678 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 679 | out: |
| 680 | |
| 681 | if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { |
| 682 | if (NULL != pIcdSurface->real_icd_surfaces) { |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 683 | i = 0; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 684 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 685 | if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { |
| 686 | icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 687 | } |
| 688 | } |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 689 | loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 690 | } |
| 691 | loader_instance_heap_free(ptr_instance, pIcdSurface); |
| 692 | } |
| 693 | |
| 694 | return vkRes; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 695 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 696 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 697 | // This is the trampoline entrypoint for |
| 698 | // GetPhysicalDeviceWaylandPresentationSupportKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 699 | LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR(VkPhysicalDevice physicalDevice, |
| 700 | uint32_t queueFamilyIndex, |
| 701 | struct wl_display *display) { |
| 702 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 703 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 704 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 705 | VkBool32 res = disp->GetPhysicalDeviceWaylandPresentationSupportKHR(unwrapped_phys_dev, queueFamilyIndex, display); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 706 | return res; |
| 707 | } |
| 708 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 709 | // This is the instance chain terminator function for |
| 710 | // GetPhysicalDeviceWaylandPresentationSupportKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 711 | VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceWaylandPresentationSupportKHR(VkPhysicalDevice physicalDevice, |
| 712 | uint32_t queueFamilyIndex, |
| 713 | struct wl_display *display) { |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 714 | // First, check to ensure the appropriate extension was enabled: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 715 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 716 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 717 | struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; |
Jon Ashburn | 436d6a3 | 2016-03-24 17:26:59 -0600 | [diff] [blame] | 718 | if (!ptr_instance->wsi_wayland_surface_enabled) { |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 719 | loader_log( |
| 720 | ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 721 | "VK_KHR_wayland_surface extension not enabled. vkGetPhysicalDeviceWaylandPresentationSupportKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 722 | return VK_SUCCESS; |
| 723 | } |
| 724 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 725 | if (NULL == icd_term->dispatch.GetPhysicalDeviceWaylandPresentationSupportKHR) { |
| 726 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 727 | "ICD for selected physical device is not exporting vkGetPhysicalDeviceWaylandPresentationSupportKHR!\n"); |
| 728 | assert(false && "loader: null GetPhysicalDeviceWaylandPresentationSupportKHR ICD pointer"); |
| 729 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 730 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 731 | return icd_term->dispatch.GetPhysicalDeviceWaylandPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, display); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 732 | } |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 733 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 734 | |
| 735 | #ifdef VK_USE_PLATFORM_XCB_KHR |
| 736 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 737 | // Functions for the VK_KHR_xcb_surface extension: |
| 738 | |
| 739 | // This is the trampoline entrypoint for CreateXcbSurfaceKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 740 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR(VkInstance instance, |
| 741 | const VkXcbSurfaceCreateInfoKHR *pCreateInfo, |
| 742 | const VkAllocationCallbacks *pAllocator, |
| 743 | VkSurfaceKHR *pSurface) { |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 744 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 745 | disp = loader_get_instance_layer_dispatch(instance); |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 746 | VkResult res; |
| 747 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 748 | res = disp->CreateXcbSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 749 | return res; |
| 750 | } |
| 751 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 752 | // This is the instance chain terminator function for CreateXcbSurfaceKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 753 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXcbSurfaceKHR(VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo, |
| 754 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 755 | VkResult vkRes = VK_SUCCESS; |
Mark Young | d7fb159 | 2016-10-12 14:18:44 -0600 | [diff] [blame] | 756 | VkIcdSurface *pIcdSurface = NULL; |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 757 | uint32_t i = 0; |
| 758 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 759 | // First, check to ensure the appropriate extension was enabled: |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 760 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 761 | if (!ptr_instance->wsi_xcb_surface_enabled) { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 762 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 763 | "VK_KHR_xcb_surface extension not enabled. vkCreateXcbSurfaceKHR not executed!\n"); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 764 | vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; |
| 765 | goto out; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 766 | } |
| 767 | |
| 768 | // Next, if so, proceed with the implementation of this function: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 769 | pIcdSurface = AllocateIcdSurfaceStruct(ptr_instance, sizeof(pIcdSurface->xcb_surf.base), sizeof(pIcdSurface->xcb_surf)); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 770 | if (pIcdSurface == NULL) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 771 | vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; |
| 772 | goto out; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 773 | } |
| 774 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 775 | pIcdSurface->xcb_surf.base.platform = VK_ICD_WSI_PLATFORM_XCB; |
| 776 | pIcdSurface->xcb_surf.connection = pCreateInfo->connection; |
| 777 | pIcdSurface->xcb_surf.window = pCreateInfo->window; |
| 778 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 779 | // Loop through each ICD and determine if they need to create a surface |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 780 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
| 781 | if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 782 | if (NULL != icd_term->dispatch.CreateXcbSurfaceKHR) { |
| 783 | vkRes = icd_term->dispatch.CreateXcbSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, |
| 784 | &pIcdSurface->real_icd_surfaces[i]); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 785 | if (VK_SUCCESS != vkRes) { |
| 786 | goto out; |
| 787 | } |
| 788 | } |
| 789 | } |
| 790 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 791 | |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 792 | *pSurface = (VkSurfaceKHR)pIcdSurface; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 793 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 794 | out: |
| 795 | |
| 796 | if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { |
| 797 | if (NULL != pIcdSurface->real_icd_surfaces) { |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 798 | i = 0; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 799 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 800 | if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { |
| 801 | icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 802 | } |
| 803 | } |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 804 | loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 805 | } |
| 806 | loader_instance_heap_free(ptr_instance, pIcdSurface); |
| 807 | } |
| 808 | |
| 809 | return vkRes; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 810 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 811 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 812 | // This is the trampoline entrypoint for |
| 813 | // GetPhysicalDeviceXcbPresentationSupportKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 814 | LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice, |
| 815 | uint32_t queueFamilyIndex, |
| 816 | xcb_connection_t *connection, |
| 817 | xcb_visualid_t visual_id) { |
| 818 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 819 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 820 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 821 | VkBool32 res = disp->GetPhysicalDeviceXcbPresentationSupportKHR(unwrapped_phys_dev, queueFamilyIndex, connection, visual_id); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 822 | return res; |
| 823 | } |
| 824 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 825 | // This is the instance chain terminator function for |
| 826 | // GetPhysicalDeviceXcbPresentationSupportKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 827 | VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice, |
| 828 | uint32_t queueFamilyIndex, |
| 829 | xcb_connection_t *connection, |
| 830 | xcb_visualid_t visual_id) { |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 831 | // First, check to ensure the appropriate extension was enabled: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 832 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 833 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 834 | struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 835 | if (!ptr_instance->wsi_xcb_surface_enabled) { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 836 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 837 | "VK_KHR_xcb_surface extension not enabled. vkGetPhysicalDeviceXcbPresentationSupportKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 838 | return VK_SUCCESS; |
| 839 | } |
| 840 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 841 | if (NULL == icd_term->dispatch.GetPhysicalDeviceXcbPresentationSupportKHR) { |
| 842 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 843 | "ICD for selected physical device is not exporting vkGetPhysicalDeviceXcbPresentationSupportKHR!\n"); |
| 844 | assert(false && "loader: null GetPhysicalDeviceXcbPresentationSupportKHR ICD pointer"); |
| 845 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 846 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 847 | return icd_term->dispatch.GetPhysicalDeviceXcbPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, connection, |
| 848 | visual_id); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 849 | } |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 850 | #endif // VK_USE_PLATFORM_XCB_KHR |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 851 | |
| 852 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
| 853 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 854 | // Functions for the VK_KHR_xlib_surface extension: |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 855 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 856 | // This is the trampoline entrypoint for CreateXlibSurfaceKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 857 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(VkInstance instance, |
| 858 | const VkXlibSurfaceCreateInfoKHR *pCreateInfo, |
| 859 | const VkAllocationCallbacks *pAllocator, |
| 860 | VkSurfaceKHR *pSurface) { |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 861 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 862 | disp = loader_get_instance_layer_dispatch(instance); |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 863 | VkResult res; |
| 864 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 865 | res = disp->CreateXlibSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 866 | return res; |
| 867 | } |
| 868 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 869 | // This is the instance chain terminator function for CreateXlibSurfaceKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 870 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXlibSurfaceKHR(VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo, |
| 871 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 872 | VkResult vkRes = VK_SUCCESS; |
Mark Young | d7fb159 | 2016-10-12 14:18:44 -0600 | [diff] [blame] | 873 | VkIcdSurface *pIcdSurface = NULL; |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 874 | uint32_t i = 0; |
| 875 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 876 | // First, check to ensure the appropriate extension was enabled: |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 877 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 878 | if (!ptr_instance->wsi_xlib_surface_enabled) { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 879 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 880 | "VK_KHR_xlib_surface extension not enabled. vkCreateXlibSurfaceKHR not executed!\n"); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 881 | vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; |
| 882 | goto out; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 883 | } |
| 884 | |
| 885 | // Next, if so, proceed with the implementation of this function: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 886 | pIcdSurface = AllocateIcdSurfaceStruct(ptr_instance, sizeof(pIcdSurface->xlib_surf.base), sizeof(pIcdSurface->xlib_surf)); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 887 | if (pIcdSurface == NULL) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 888 | vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; |
| 889 | goto out; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 890 | } |
| 891 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 892 | pIcdSurface->xlib_surf.base.platform = VK_ICD_WSI_PLATFORM_XLIB; |
| 893 | pIcdSurface->xlib_surf.dpy = pCreateInfo->dpy; |
| 894 | pIcdSurface->xlib_surf.window = pCreateInfo->window; |
| 895 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 896 | // Loop through each ICD and determine if they need to create a surface |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 897 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
| 898 | if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 899 | if (NULL != icd_term->dispatch.CreateXlibSurfaceKHR) { |
| 900 | vkRes = icd_term->dispatch.CreateXlibSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, |
| 901 | &pIcdSurface->real_icd_surfaces[i]); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 902 | if (VK_SUCCESS != vkRes) { |
| 903 | goto out; |
| 904 | } |
| 905 | } |
| 906 | } |
| 907 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 908 | |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 909 | *pSurface = (VkSurfaceKHR)pIcdSurface; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 910 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 911 | out: |
| 912 | |
| 913 | if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { |
| 914 | if (NULL != pIcdSurface->real_icd_surfaces) { |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 915 | i = 0; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 916 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 917 | if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { |
| 918 | icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 919 | } |
| 920 | } |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 921 | loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 922 | } |
| 923 | loader_instance_heap_free(ptr_instance, pIcdSurface); |
| 924 | } |
| 925 | |
| 926 | return vkRes; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 927 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 928 | |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 929 | // This is the trampoline entrypoint for |
| 930 | // GetPhysicalDeviceXlibPresentationSupportKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 931 | LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice, |
| 932 | uint32_t queueFamilyIndex, Display *dpy, |
| 933 | VisualID visualID) { |
| 934 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 935 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 936 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 937 | VkBool32 res = disp->GetPhysicalDeviceXlibPresentationSupportKHR(unwrapped_phys_dev, queueFamilyIndex, dpy, visualID); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 938 | return res; |
| 939 | } |
| 940 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 941 | // This is the instance chain terminator function for |
| 942 | // GetPhysicalDeviceXlibPresentationSupportKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 943 | VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice, |
| 944 | uint32_t queueFamilyIndex, Display *dpy, |
| 945 | VisualID visualID) { |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 946 | // First, check to ensure the appropriate extension was enabled: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 947 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 948 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 949 | struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 950 | if (!ptr_instance->wsi_xlib_surface_enabled) { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 951 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 952 | "VK_KHR_xlib_surface extension not enabled. vkGetPhysicalDeviceXlibPresentationSupportKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 953 | return VK_SUCCESS; |
| 954 | } |
| 955 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 956 | if (NULL == icd_term->dispatch.GetPhysicalDeviceXlibPresentationSupportKHR) { |
| 957 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 958 | "ICD for selected physical device is not exporting vkGetPhysicalDeviceXlibPresentationSupportKHR!\n"); |
| 959 | assert(false && "loader: null GetPhysicalDeviceXlibPresentationSupportKHR ICD pointer"); |
| 960 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 961 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 962 | return icd_term->dispatch.GetPhysicalDeviceXlibPresentationSupportKHR(phys_dev_term->phys_dev, queueFamilyIndex, dpy, visualID); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 963 | } |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 964 | #endif // VK_USE_PLATFORM_XLIB_KHR |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 965 | |
Nicolas Caramelli | fa696ca | 2020-07-04 22:53:59 +0200 | [diff] [blame] | 966 | #ifdef VK_USE_PLATFORM_DIRECTFB_EXT |
| 967 | |
| 968 | // Functions for the VK_EXT_directfb_surface extension: |
| 969 | |
| 970 | // This is the trampoline entrypoint for CreateDirectFBSurfaceEXT |
| 971 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDirectFBSurfaceEXT(VkInstance instance, |
| 972 | const VkDirectFBSurfaceCreateInfoEXT *pCreateInfo, |
| 973 | const VkAllocationCallbacks *pAllocator, |
| 974 | VkSurfaceKHR *pSurface) { |
| 975 | const VkLayerInstanceDispatchTable *disp; |
| 976 | disp = loader_get_instance_layer_dispatch(instance); |
| 977 | VkResult res; |
| 978 | |
| 979 | res = disp->CreateDirectFBSurfaceEXT(instance, pCreateInfo, pAllocator, pSurface); |
| 980 | return res; |
| 981 | } |
| 982 | |
| 983 | // This is the instance chain terminator function for CreateDirectFBSurfaceEXT |
| 984 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDirectFBSurfaceEXT(VkInstance instance, |
| 985 | const VkDirectFBSurfaceCreateInfoEXT *pCreateInfo, |
| 986 | const VkAllocationCallbacks *pAllocator, |
| 987 | VkSurfaceKHR *pSurface) { |
| 988 | VkResult vkRes = VK_SUCCESS; |
| 989 | VkIcdSurface *pIcdSurface = NULL; |
| 990 | uint32_t i = 0; |
| 991 | |
| 992 | // First, check to ensure the appropriate extension was enabled: |
| 993 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
| 994 | if (!ptr_instance->wsi_directfb_surface_enabled) { |
| 995 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 996 | "VK_EXT_directfb_surface extension not enabled. vkCreateDirectFBSurfaceEXT not executed!\n"); |
| 997 | vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; |
| 998 | goto out; |
| 999 | } |
| 1000 | |
| 1001 | // Next, if so, proceed with the implementation of this function: |
| 1002 | pIcdSurface = |
| 1003 | AllocateIcdSurfaceStruct(ptr_instance, sizeof(pIcdSurface->directfb_surf.base), sizeof(pIcdSurface->directfb_surf)); |
| 1004 | if (pIcdSurface == NULL) { |
| 1005 | vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; |
| 1006 | goto out; |
| 1007 | } |
| 1008 | |
| 1009 | pIcdSurface->directfb_surf.base.platform = VK_ICD_WSI_PLATFORM_DIRECTFB; |
| 1010 | pIcdSurface->directfb_surf.dfb = pCreateInfo->dfb; |
| 1011 | pIcdSurface->directfb_surf.surface = pCreateInfo->surface; |
| 1012 | |
| 1013 | // Loop through each ICD and determine if they need to create a surface |
| 1014 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
| 1015 | if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { |
| 1016 | if (NULL != icd_term->dispatch.CreateDirectFBSurfaceEXT) { |
| 1017 | vkRes = icd_term->dispatch.CreateDirectFBSurfaceEXT(icd_term->instance, pCreateInfo, pAllocator, |
| 1018 | &pIcdSurface->real_icd_surfaces[i]); |
| 1019 | if (VK_SUCCESS != vkRes) { |
| 1020 | goto out; |
| 1021 | } |
| 1022 | } |
| 1023 | } |
| 1024 | } |
| 1025 | |
| 1026 | *pSurface = (VkSurfaceKHR)pIcdSurface; |
| 1027 | |
| 1028 | out: |
| 1029 | |
| 1030 | if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { |
| 1031 | if (NULL != pIcdSurface->real_icd_surfaces) { |
| 1032 | i = 0; |
| 1033 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
| 1034 | if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { |
| 1035 | icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); |
| 1036 | } |
| 1037 | } |
| 1038 | loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces); |
| 1039 | } |
| 1040 | loader_instance_heap_free(ptr_instance, pIcdSurface); |
| 1041 | } |
| 1042 | |
| 1043 | return vkRes; |
| 1044 | } |
| 1045 | |
| 1046 | // This is the trampoline entrypoint for |
| 1047 | // GetPhysicalDeviceDirectFBPresentationSupportEXT |
| 1048 | LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceDirectFBPresentationSupportEXT(VkPhysicalDevice physicalDevice, |
| 1049 | uint32_t queueFamilyIndex, |
| 1050 | IDirectFB *dfb) { |
| 1051 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
| 1052 | const VkLayerInstanceDispatchTable *disp; |
| 1053 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
| 1054 | VkBool32 res = disp->GetPhysicalDeviceDirectFBPresentationSupportEXT(unwrapped_phys_dev, queueFamilyIndex, dfb); |
| 1055 | return res; |
| 1056 | } |
| 1057 | |
| 1058 | // This is the instance chain terminator function for |
| 1059 | // GetPhysicalDeviceDirectFBPresentationSupportEXT |
| 1060 | VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceDirectFBPresentationSupportEXT(VkPhysicalDevice physicalDevice, |
| 1061 | uint32_t queueFamilyIndex, |
| 1062 | IDirectFB *dfb) { |
| 1063 | // First, check to ensure the appropriate extension was enabled: |
| 1064 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
| 1065 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
| 1066 | struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; |
| 1067 | if (!ptr_instance->wsi_directfb_surface_enabled) { |
| 1068 | loader_log( |
| 1069 | ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1070 | "VK_EXT_directfb_surface extension not enabled. vkGetPhysicalDeviceWaylandPresentationSupportKHR not executed!\n"); |
| 1071 | return VK_SUCCESS; |
| 1072 | } |
| 1073 | |
| 1074 | if (NULL == icd_term->dispatch.GetPhysicalDeviceDirectFBPresentationSupportEXT) { |
| 1075 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1076 | "ICD for selected physical device is not exporting vkGetPhysicalDeviceDirectFBPresentationSupportEXT!\n"); |
| 1077 | assert(false && "loader: null GetPhysicalDeviceDirectFBPresentationSupportEXT ICD pointer"); |
| 1078 | } |
| 1079 | |
| 1080 | return icd_term->dispatch.GetPhysicalDeviceDirectFBPresentationSupportEXT(phys_dev_term->phys_dev, queueFamilyIndex, dfb); |
| 1081 | } |
| 1082 | #endif // VK_USE_PLATFORM_DIRECTFB_EXT |
| 1083 | |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 1084 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1085 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1086 | // Functions for the VK_KHR_android_surface extension: |
| 1087 | |
| 1088 | // This is the trampoline entrypoint for CreateAndroidSurfaceKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1089 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR(VkInstance instance, ANativeWindow *window, |
| 1090 | const VkAllocationCallbacks *pAllocator, |
| 1091 | VkSurfaceKHR *pSurface) { |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 1092 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 1093 | disp = loader_get_instance_layer_dispatch(instance); |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 1094 | VkResult res; |
| 1095 | |
| 1096 | res = disp->CreateAndroidSurfaceKHR(instance, window, pAllocator, pSurface); |
| 1097 | return res; |
| 1098 | } |
| 1099 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1100 | // This is the instance chain terminator function for CreateAndroidSurfaceKHR |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1101 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateAndroidSurfaceKHR(VkInstance instance, Window window, |
| 1102 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1103 | // First, check to ensure the appropriate extension was enabled: |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 1104 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1105 | if (!ptr_instance->wsi_display_enabled) { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 1106 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1107 | "VK_KHR_display extension not enabled. vkCreateAndroidSurfaceKHR not executed!\n"); |
Jeremy Hayes | 0231e1c | 2016-06-14 11:50:02 -0600 | [diff] [blame] | 1108 | return VK_ERROR_EXTENSION_NOT_PRESENT; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1109 | } |
| 1110 | |
| 1111 | // Next, if so, proceed with the implementation of this function: |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1112 | VkIcdSurfaceAndroid *pIcdSurface = |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1113 | loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceAndroid), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 1114 | if (pIcdSurface == NULL) { |
| 1115 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 1116 | } |
| 1117 | |
| 1118 | pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_ANDROID; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 1119 | pIcdSurface->window = window; |
| 1120 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1121 | *pSurface = (VkSurfaceKHR)pIcdSurface; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 1122 | |
| 1123 | return VK_SUCCESS; |
| 1124 | } |
| 1125 | |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 1126 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1127 | |
Bryan Law-Smith | 5730569 | 2019-04-01 09:45:55 +0100 | [diff] [blame] | 1128 | // Functions for the VK_EXT_headless_surface extension: |
| 1129 | |
| 1130 | VKAPI_ATTR VkResult VKAPI_CALL vkCreateHeadlessSurfaceEXT(VkInstance instance, const VkHeadlessSurfaceCreateInfoEXT *pCreateInfo, |
| 1131 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
| 1132 | const VkLayerInstanceDispatchTable *disp; |
| 1133 | disp = loader_get_instance_layer_dispatch(instance); |
| 1134 | VkResult res; |
| 1135 | |
| 1136 | res = disp->CreateHeadlessSurfaceEXT(instance, pCreateInfo, pAllocator, pSurface); |
| 1137 | return res; |
| 1138 | } |
| 1139 | |
| 1140 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateHeadlessSurfaceEXT(VkInstance instance, |
| 1141 | const VkHeadlessSurfaceCreateInfoEXT *pCreateInfo, |
| 1142 | const VkAllocationCallbacks *pAllocator, |
| 1143 | VkSurfaceKHR *pSurface) { |
| 1144 | struct loader_instance *inst = loader_get_instance(instance); |
| 1145 | VkIcdSurface *pIcdSurface = NULL; |
| 1146 | VkResult vkRes = VK_SUCCESS; |
| 1147 | uint32_t i = 0; |
| 1148 | |
| 1149 | if (!inst->wsi_headless_surface_enabled) { |
| 1150 | loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1151 | "VK_EXT_headless_surface extension not enabled. " |
| 1152 | "vkCreateHeadlessSurfaceEXT not executed!\n"); |
| 1153 | return VK_SUCCESS; |
| 1154 | } |
| 1155 | |
| 1156 | // Next, if so, proceed with the implementation of this function: |
| 1157 | pIcdSurface = AllocateIcdSurfaceStruct(inst, sizeof(pIcdSurface->headless_surf.base), sizeof(pIcdSurface->headless_surf)); |
| 1158 | if (pIcdSurface == NULL) { |
| 1159 | vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; |
| 1160 | goto out; |
| 1161 | } |
| 1162 | |
| 1163 | pIcdSurface->headless_surf.base.platform = VK_ICD_WSI_PLATFORM_HEADLESS; |
| 1164 | // Loop through each ICD and determine if they need to create a surface |
| 1165 | for (struct loader_icd_term *icd_term = inst->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
| 1166 | if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { |
| 1167 | if (NULL != icd_term->dispatch.CreateHeadlessSurfaceEXT) { |
| 1168 | vkRes = icd_term->dispatch.CreateHeadlessSurfaceEXT(icd_term->instance, pCreateInfo, pAllocator, |
| 1169 | &pIcdSurface->real_icd_surfaces[i]); |
| 1170 | if (VK_SUCCESS != vkRes) { |
| 1171 | goto out; |
| 1172 | } |
| 1173 | } |
| 1174 | } |
| 1175 | } |
| 1176 | |
| 1177 | *pSurface = (VkSurfaceKHR)pIcdSurface; |
| 1178 | |
| 1179 | out: |
| 1180 | |
| 1181 | if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { |
| 1182 | if (NULL != pIcdSurface->real_icd_surfaces) { |
| 1183 | i = 0; |
| 1184 | for (struct loader_icd_term *icd_term = inst->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
| 1185 | if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { |
| 1186 | icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); |
| 1187 | } |
| 1188 | } |
| 1189 | loader_instance_heap_free(inst, pIcdSurface->real_icd_surfaces); |
| 1190 | } |
| 1191 | loader_instance_heap_free(inst, pIcdSurface); |
| 1192 | } |
| 1193 | |
| 1194 | return vkRes; |
| 1195 | } |
| 1196 | |
Karl Schultz | d81ebfb | 2017-12-12 10:33:01 -0500 | [diff] [blame] | 1197 | #ifdef VK_USE_PLATFORM_MACOS_MVK |
| 1198 | |
| 1199 | // Functions for the VK_MVK_macos_surface extension: |
| 1200 | |
| 1201 | // This is the trampoline entrypoint for CreateMacOSSurfaceMVK |
| 1202 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateMacOSSurfaceMVK(VkInstance instance, |
| 1203 | const VkMacOSSurfaceCreateInfoMVK *pCreateInfo, |
| 1204 | const VkAllocationCallbacks *pAllocator, |
| 1205 | VkSurfaceKHR *pSurface) { |
| 1206 | const VkLayerInstanceDispatchTable *disp; |
| 1207 | disp = loader_get_instance_layer_dispatch(instance); |
| 1208 | VkResult res; |
| 1209 | |
| 1210 | res = disp->CreateMacOSSurfaceMVK(instance, pCreateInfo, pAllocator, pSurface); |
| 1211 | return res; |
| 1212 | } |
| 1213 | |
| 1214 | // This is the instance chain terminator function for CreateMacOSSurfaceKHR |
| 1215 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMacOSSurfaceMVK(VkInstance instance, const VkMacOSSurfaceCreateInfoMVK *pCreateInfo, |
| 1216 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
| 1217 | VkResult vkRes = VK_SUCCESS; |
| 1218 | VkIcdSurface *pIcdSurface = NULL; |
| 1219 | uint32_t i = 0; |
| 1220 | |
| 1221 | // First, check to ensure the appropriate extension was enabled: |
| 1222 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
| 1223 | if (!ptr_instance->wsi_macos_surface_enabled) { |
| 1224 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1225 | "VK_MVK_macos_surface extension not enabled. vkCreateMacOSSurfaceMVK not executed!\n"); |
| 1226 | vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; |
| 1227 | goto out; |
| 1228 | } |
| 1229 | |
| 1230 | // Next, if so, proceed with the implementation of this function: |
| 1231 | pIcdSurface = AllocateIcdSurfaceStruct(ptr_instance, sizeof(pIcdSurface->macos_surf.base), sizeof(pIcdSurface->macos_surf)); |
| 1232 | if (pIcdSurface == NULL) { |
| 1233 | vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; |
| 1234 | goto out; |
| 1235 | } |
| 1236 | |
| 1237 | pIcdSurface->macos_surf.base.platform = VK_ICD_WSI_PLATFORM_MACOS; |
| 1238 | pIcdSurface->macos_surf.pView = pCreateInfo->pView; |
| 1239 | |
| 1240 | // Loop through each ICD and determine if they need to create a surface |
| 1241 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
| 1242 | if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { |
| 1243 | if (NULL != icd_term->dispatch.CreateMacOSSurfaceMVK) { |
| 1244 | vkRes = icd_term->dispatch.CreateMacOSSurfaceMVK(icd_term->instance, pCreateInfo, pAllocator, |
| 1245 | &pIcdSurface->real_icd_surfaces[i]); |
| 1246 | if (VK_SUCCESS != vkRes) { |
| 1247 | goto out; |
| 1248 | } |
| 1249 | } |
| 1250 | } |
| 1251 | } |
| 1252 | |
| 1253 | *pSurface = (VkSurfaceKHR)pIcdSurface; |
| 1254 | |
| 1255 | out: |
| 1256 | |
| 1257 | if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { |
| 1258 | if (NULL != pIcdSurface->real_icd_surfaces) { |
| 1259 | i = 0; |
| 1260 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
| 1261 | if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { |
| 1262 | icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); |
| 1263 | } |
| 1264 | } |
| 1265 | loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces); |
| 1266 | } |
| 1267 | loader_instance_heap_free(ptr_instance, pIcdSurface); |
| 1268 | } |
| 1269 | |
| 1270 | return vkRes; |
| 1271 | } |
| 1272 | |
| 1273 | #endif // VK_USE_PLATFORM_MACOS_MVK |
| 1274 | |
| 1275 | #ifdef VK_USE_PLATFORM_IOS_MVK |
| 1276 | |
| 1277 | // Functions for the VK_MVK_ios_surface extension: |
| 1278 | |
| 1279 | // This is the trampoline entrypoint for CreateIOSSurfaceMVK |
| 1280 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateIOSSurfaceMVK(VkInstance instance, |
| 1281 | const VkIOSSurfaceCreateInfoMVK *pCreateInfo, |
| 1282 | const VkAllocationCallbacks *pAllocator, |
| 1283 | VkSurfaceKHR *pSurface) { |
| 1284 | const VkLayerInstanceDispatchTable *disp; |
| 1285 | disp = loader_get_instance_layer_dispatch(instance); |
| 1286 | VkResult res; |
| 1287 | |
| 1288 | res = disp->CreateIOSSurfaceMVK(instance, pCreateInfo, pAllocator, pSurface); |
| 1289 | return res; |
| 1290 | } |
| 1291 | |
| 1292 | // This is the instance chain terminator function for CreateIOSSurfaceKHR |
| 1293 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateIOSSurfaceMVK(VkInstance instance, const VkIOSSurfaceCreateInfoMVK *pCreateInfo, |
| 1294 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
| 1295 | // First, check to ensure the appropriate extension was enabled: |
| 1296 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
| 1297 | if (!ptr_instance->wsi_ios_surface_enabled) { |
| 1298 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1299 | "VK_MVK_ios_surface extension not enabled. vkCreateIOSSurfaceMVK not executed!\n"); |
| 1300 | return VK_ERROR_EXTENSION_NOT_PRESENT; |
| 1301 | } |
| 1302 | |
| 1303 | // Next, if so, proceed with the implementation of this function: |
| 1304 | VkIcdSurfaceIOS *pIcdSurface = |
| 1305 | loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceIOS), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); |
| 1306 | if (pIcdSurface == NULL) { |
| 1307 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 1308 | } |
| 1309 | |
| 1310 | pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_IOS; |
| 1311 | pIcdSurface->pView = pCreateInfo->pView; |
| 1312 | |
| 1313 | *pSurface = (VkSurfaceKHR)pIcdSurface; |
| 1314 | |
| 1315 | return VK_SUCCESS; |
| 1316 | } |
| 1317 | |
| 1318 | #endif // VK_USE_PLATFORM_IOS_MVK |
| 1319 | |
Lenny Komow | a1b5e44 | 2019-09-16 16:14:36 -0600 | [diff] [blame] | 1320 | #if defined(VK_USE_PLATFORM_METAL_EXT) |
| 1321 | |
| 1322 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateMetalSurfaceEXT(VkInstance instance, |
| 1323 | const VkMetalSurfaceCreateInfoEXT *pCreateInfo, |
| 1324 | const VkAllocationCallbacks *pAllocator, |
| 1325 | VkSurfaceKHR *pSurface) { |
| 1326 | const VkLayerInstanceDispatchTable *disp = loader_get_instance_layer_dispatch(instance); |
| 1327 | return disp->CreateMetalSurfaceEXT(instance, pCreateInfo, pAllocator, pSurface); |
| 1328 | } |
| 1329 | |
| 1330 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMetalSurfaceEXT(VkInstance instance, const VkMetalSurfaceCreateInfoEXT *pCreateInfo, |
| 1331 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
| 1332 | VkResult result = VK_SUCCESS; |
| 1333 | VkIcdSurface *icd_surface = NULL; |
| 1334 | uint32_t i; |
| 1335 | |
| 1336 | // First, check to ensure the appropriate extension was enabled: |
| 1337 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
| 1338 | if (!ptr_instance->wsi_metal_surface_enabled) { |
| 1339 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1340 | "VK_EXT_metal_surface extension not enabled. vkCreateMetalSurfaceEXT will not be executed.\n"); |
| 1341 | } |
| 1342 | |
| 1343 | // Next, if so, proceed with the implementation of this function: |
| 1344 | icd_surface = AllocateIcdSurfaceStruct(ptr_instance, sizeof(icd_surface->metal_surf.base), sizeof(icd_surface->metal_surf)); |
| 1345 | if (icd_surface == NULL) { |
| 1346 | result = VK_ERROR_OUT_OF_HOST_MEMORY; |
| 1347 | goto out; |
| 1348 | } |
| 1349 | |
| 1350 | icd_surface->metal_surf.base.platform = VK_ICD_WSI_PLATFORM_METAL; |
| 1351 | icd_surface->metal_surf.pLayer = pCreateInfo->pLayer; |
| 1352 | |
| 1353 | // Loop through each ICD and determine if they need to create a surface |
| 1354 | i = 0; |
| 1355 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, ++i) { |
| 1356 | if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { |
| 1357 | if (icd_term->dispatch.CreateMetalSurfaceEXT != NULL) { |
| 1358 | result = icd_term->dispatch.CreateMetalSurfaceEXT(icd_term->instance, pCreateInfo, pAllocator, |
| 1359 | &icd_surface->real_icd_surfaces[i]); |
| 1360 | if (result != VK_SUCCESS) { |
| 1361 | goto out; |
| 1362 | } |
| 1363 | } |
| 1364 | } |
| 1365 | } |
| 1366 | *pSurface = (VkSurfaceKHR)icd_surface; |
| 1367 | |
| 1368 | out: |
| 1369 | if (result != VK_SUCCESS && icd_surface != NULL) { |
| 1370 | if (icd_surface->real_icd_surfaces != NULL) { |
| 1371 | i = 0; |
| 1372 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, ++i) { |
| 1373 | if (icd_surface->real_icd_surfaces[i] == VK_NULL_HANDLE && icd_term->dispatch.DestroySurfaceKHR != NULL) { |
| 1374 | icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, icd_surface->real_icd_surfaces[i], pAllocator); |
| 1375 | } |
| 1376 | } |
| 1377 | loader_instance_heap_free(ptr_instance, icd_surface->real_icd_surfaces); |
| 1378 | } |
| 1379 | loader_instance_heap_free(ptr_instance, icd_surface); |
| 1380 | } |
| 1381 | return result; |
| 1382 | } |
| 1383 | |
| 1384 | #endif |
| 1385 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1386 | // Functions for the VK_KHR_display instance extension: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1387 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, |
| 1388 | uint32_t *pPropertyCount, |
| 1389 | VkDisplayPropertiesKHR *pProperties) { |
| 1390 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1391 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 1392 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1393 | VkResult res = disp->GetPhysicalDeviceDisplayPropertiesKHR(unwrapped_phys_dev, pPropertyCount, pProperties); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1394 | return res; |
| 1395 | } |
| 1396 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1397 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, |
| 1398 | uint32_t *pPropertyCount, |
| 1399 | VkDisplayPropertiesKHR *pProperties) { |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1400 | // First, check to ensure the appropriate extension was enabled: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1401 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1402 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1403 | struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1404 | if (!ptr_instance->wsi_display_enabled) { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 1405 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1406 | "VK_KHR_display extension not enabled. vkGetPhysicalDeviceDisplayPropertiesKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1407 | return VK_SUCCESS; |
| 1408 | } |
| 1409 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1410 | if (NULL == icd_term->dispatch.GetPhysicalDeviceDisplayPropertiesKHR) { |
| 1411 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1412 | "ICD for selected physical device is not exporting vkGetPhysicalDeviceDisplayPropertiesKHR!\n"); |
| 1413 | assert(false && "loader: null GetPhysicalDeviceDisplayPropertiesKHR ICD pointer"); |
| 1414 | } |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1415 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1416 | return icd_term->dispatch.GetPhysicalDeviceDisplayPropertiesKHR(phys_dev_term->phys_dev, pPropertyCount, pProperties); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1417 | } |
| 1418 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1419 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPlanePropertiesKHR( |
| 1420 | VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkDisplayPlanePropertiesKHR *pProperties) { |
| 1421 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1422 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 1423 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1424 | VkResult res = disp->GetPhysicalDeviceDisplayPlanePropertiesKHR(unwrapped_phys_dev, pPropertyCount, pProperties); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1425 | return res; |
| 1426 | } |
| 1427 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1428 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPlanePropertiesKHR(VkPhysicalDevice physicalDevice, |
| 1429 | uint32_t *pPropertyCount, |
| 1430 | VkDisplayPlanePropertiesKHR *pProperties) { |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1431 | // First, check to ensure the appropriate extension was enabled: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1432 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1433 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1434 | struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1435 | if (!ptr_instance->wsi_display_enabled) { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 1436 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1437 | "VK_KHR_display extension not enabled. vkGetPhysicalDeviceDisplayPlanePropertiesKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1438 | return VK_SUCCESS; |
| 1439 | } |
| 1440 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1441 | if (NULL == icd_term->dispatch.GetPhysicalDeviceDisplayPlanePropertiesKHR) { |
| 1442 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1443 | "ICD for selected physical device is not exporting vkGetPhysicalDeviceDisplayPlanePropertiesKHR!\n"); |
| 1444 | assert(false && "loader: null GetPhysicalDeviceDisplayPlanePropertiesKHR ICD pointer"); |
| 1445 | } |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1446 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1447 | return icd_term->dispatch.GetPhysicalDeviceDisplayPlanePropertiesKHR(phys_dev_term->phys_dev, pPropertyCount, pProperties); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1448 | } |
| 1449 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1450 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, |
| 1451 | uint32_t planeIndex, uint32_t *pDisplayCount, |
| 1452 | VkDisplayKHR *pDisplays) { |
| 1453 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1454 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 1455 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1456 | VkResult res = disp->GetDisplayPlaneSupportedDisplaysKHR(unwrapped_phys_dev, planeIndex, pDisplayCount, pDisplays); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1457 | return res; |
| 1458 | } |
| 1459 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1460 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex, |
| 1461 | uint32_t *pDisplayCount, VkDisplayKHR *pDisplays) { |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1462 | // First, check to ensure the appropriate extension was enabled: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1463 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1464 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1465 | struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1466 | if (!ptr_instance->wsi_display_enabled) { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 1467 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1468 | "VK_KHR_display extension not enabled. vkGetDisplayPlaneSupportedDisplaysKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1469 | return VK_SUCCESS; |
| 1470 | } |
| 1471 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1472 | if (NULL == icd_term->dispatch.GetDisplayPlaneSupportedDisplaysKHR) { |
| 1473 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1474 | "ICD for selected physical device is not exporting vkGetDisplayPlaneSupportedDisplaysKHR!\n"); |
| 1475 | assert(false && "loader: null GetDisplayPlaneSupportedDisplaysKHR ICD pointer"); |
| 1476 | } |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1477 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1478 | return icd_term->dispatch.GetDisplayPlaneSupportedDisplaysKHR(phys_dev_term->phys_dev, planeIndex, pDisplayCount, pDisplays); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1479 | } |
| 1480 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1481 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 1482 | uint32_t *pPropertyCount, |
| 1483 | VkDisplayModePropertiesKHR *pProperties) { |
| 1484 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1485 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 1486 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1487 | VkResult res = disp->GetDisplayModePropertiesKHR(unwrapped_phys_dev, display, pPropertyCount, pProperties); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1488 | return res; |
| 1489 | } |
| 1490 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1491 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 1492 | uint32_t *pPropertyCount, |
| 1493 | VkDisplayModePropertiesKHR *pProperties) { |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1494 | // First, check to ensure the appropriate extension was enabled: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1495 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1496 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1497 | struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1498 | if (!ptr_instance->wsi_display_enabled) { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 1499 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1500 | "VK_KHR_display extension not enabled. vkGetDisplayModePropertiesKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1501 | return VK_SUCCESS; |
| 1502 | } |
| 1503 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1504 | if (NULL == icd_term->dispatch.GetDisplayModePropertiesKHR) { |
| 1505 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1506 | "ICD for selected physical device is not exporting vkGetDisplayModePropertiesKHR!\n"); |
| 1507 | assert(false && "loader: null GetDisplayModePropertiesKHR ICD pointer"); |
| 1508 | } |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1509 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1510 | return icd_term->dispatch.GetDisplayModePropertiesKHR(phys_dev_term->phys_dev, display, pPropertyCount, pProperties); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1511 | } |
| 1512 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1513 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 1514 | const VkDisplayModeCreateInfoKHR *pCreateInfo, |
| 1515 | const VkAllocationCallbacks *pAllocator, |
| 1516 | VkDisplayModeKHR *pMode) { |
| 1517 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1518 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 1519 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1520 | VkResult res = disp->CreateDisplayModeKHR(unwrapped_phys_dev, display, pCreateInfo, pAllocator, pMode); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1521 | return res; |
| 1522 | } |
| 1523 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1524 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 1525 | const VkDisplayModeCreateInfoKHR *pCreateInfo, |
| 1526 | const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) { |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1527 | // First, check to ensure the appropriate extension was enabled: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1528 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1529 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1530 | struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1531 | if (!ptr_instance->wsi_display_enabled) { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 1532 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1533 | "VK_KHR_display extension not enabled. vkCreateDisplayModeKHR not executed!\n"); |
Jeremy Hayes | 0231e1c | 2016-06-14 11:50:02 -0600 | [diff] [blame] | 1534 | return VK_ERROR_EXTENSION_NOT_PRESENT; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1535 | } |
| 1536 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1537 | if (NULL == icd_term->dispatch.CreateDisplayModeKHR) { |
| 1538 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1539 | "ICD for selected physical device is not exporting vkCreateDisplayModeKHR!\n"); |
| 1540 | assert(false && "loader: null CreateDisplayModeKHR ICD pointer"); |
| 1541 | } |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1542 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1543 | return icd_term->dispatch.CreateDisplayModeKHR(phys_dev_term->phys_dev, display, pCreateInfo, pAllocator, pMode); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1544 | } |
| 1545 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1546 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, |
| 1547 | VkDisplayModeKHR mode, uint32_t planeIndex, |
| 1548 | VkDisplayPlaneCapabilitiesKHR *pCapabilities) { |
| 1549 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1550 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 1551 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1552 | VkResult res = disp->GetDisplayPlaneCapabilitiesKHR(unwrapped_phys_dev, mode, planeIndex, pCapabilities); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1553 | return res; |
| 1554 | } |
| 1555 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1556 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, |
| 1557 | uint32_t planeIndex, |
| 1558 | VkDisplayPlaneCapabilitiesKHR *pCapabilities) { |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1559 | // First, check to ensure the appropriate extension was enabled: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1560 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1561 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1562 | struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1563 | if (!ptr_instance->wsi_display_enabled) { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 1564 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1565 | "VK_KHR_display extension not enabled. vkGetDisplayPlaneCapabilitiesKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1566 | return VK_SUCCESS; |
| 1567 | } |
| 1568 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1569 | if (NULL == icd_term->dispatch.GetDisplayPlaneCapabilitiesKHR) { |
| 1570 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1571 | "ICD for selected physical device is not exporting vkGetDisplayPlaneCapabilitiesKHR!\n"); |
| 1572 | assert(false && "loader: null GetDisplayPlaneCapabilitiesKHR ICD pointer"); |
| 1573 | } |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1574 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1575 | return icd_term->dispatch.GetDisplayPlaneCapabilitiesKHR(phys_dev_term->phys_dev, mode, planeIndex, pCapabilities); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1576 | } |
| 1577 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1578 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayPlaneSurfaceKHR(VkInstance instance, |
| 1579 | const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, |
| 1580 | const VkAllocationCallbacks *pAllocator, |
| 1581 | VkSurfaceKHR *pSurface) { |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1582 | const VkLayerInstanceDispatchTable *disp; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 1583 | disp = loader_get_instance_layer_dispatch(instance); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1584 | VkResult res; |
| 1585 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1586 | res = disp->CreateDisplayPlaneSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1587 | return res; |
| 1588 | } |
| 1589 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1590 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR(VkInstance instance, |
| 1591 | const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, |
| 1592 | const VkAllocationCallbacks *pAllocator, |
| 1593 | VkSurfaceKHR *pSurface) { |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1594 | struct loader_instance *inst = loader_get_instance(instance); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1595 | VkIcdSurface *pIcdSurface = NULL; |
Mark Young | f06def9 | 2016-11-01 19:20:41 -0600 | [diff] [blame] | 1596 | VkResult vkRes = VK_SUCCESS; |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 1597 | uint32_t i = 0; |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1598 | |
Mark Young | f06def9 | 2016-11-01 19:20:41 -0600 | [diff] [blame] | 1599 | if (!inst->wsi_display_enabled) { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 1600 | loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1601 | "VK_KHR_surface extension not enabled. vkCreateDisplayPlaneSurfaceKHR not executed!\n"); |
Mark Young | f06def9 | 2016-11-01 19:20:41 -0600 | [diff] [blame] | 1602 | vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; |
| 1603 | goto out; |
Petros Bantolas | f309586 | 2016-04-14 12:50:42 +0100 | [diff] [blame] | 1604 | } |
| 1605 | |
Piers Daniell | c21fde5 | 2016-12-13 16:51:49 -0700 | [diff] [blame] | 1606 | // Next, if so, proceed with the implementation of this function: |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1607 | pIcdSurface = AllocateIcdSurfaceStruct(inst, sizeof(pIcdSurface->display_surf.base), sizeof(pIcdSurface->display_surf)); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1608 | if (pIcdSurface == NULL) { |
Mark Young | f06def9 | 2016-11-01 19:20:41 -0600 | [diff] [blame] | 1609 | vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; |
| 1610 | goto out; |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1611 | } |
| 1612 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1613 | pIcdSurface->display_surf.base.platform = VK_ICD_WSI_PLATFORM_DISPLAY; |
| 1614 | pIcdSurface->display_surf.displayMode = pCreateInfo->displayMode; |
| 1615 | pIcdSurface->display_surf.planeIndex = pCreateInfo->planeIndex; |
| 1616 | pIcdSurface->display_surf.planeStackIndex = pCreateInfo->planeStackIndex; |
| 1617 | pIcdSurface->display_surf.transform = pCreateInfo->transform; |
| 1618 | pIcdSurface->display_surf.globalAlpha = pCreateInfo->globalAlpha; |
| 1619 | pIcdSurface->display_surf.alphaMode = pCreateInfo->alphaMode; |
| 1620 | pIcdSurface->display_surf.imageExtent = pCreateInfo->imageExtent; |
| 1621 | |
Mark Young | f06def9 | 2016-11-01 19:20:41 -0600 | [diff] [blame] | 1622 | // Loop through each ICD and determine if they need to create a surface |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1623 | for (struct loader_icd_term *icd_term = inst->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
| 1624 | if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1625 | if (NULL != icd_term->dispatch.CreateDisplayPlaneSurfaceKHR) { |
| 1626 | vkRes = icd_term->dispatch.CreateDisplayPlaneSurfaceKHR(icd_term->instance, pCreateInfo, pAllocator, |
| 1627 | &pIcdSurface->real_icd_surfaces[i]); |
Mark Young | f06def9 | 2016-11-01 19:20:41 -0600 | [diff] [blame] | 1628 | if (VK_SUCCESS != vkRes) { |
| 1629 | goto out; |
| 1630 | } |
| 1631 | } |
| 1632 | } |
| 1633 | } |
| 1634 | |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 1635 | *pSurface = (VkSurfaceKHR)pIcdSurface; |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1636 | |
Mark Young | f06def9 | 2016-11-01 19:20:41 -0600 | [diff] [blame] | 1637 | out: |
| 1638 | |
| 1639 | if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { |
| 1640 | if (NULL != pIcdSurface->real_icd_surfaces) { |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 1641 | i = 0; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1642 | for (struct loader_icd_term *icd_term = inst->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1643 | if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { |
| 1644 | icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); |
Mark Young | f06def9 | 2016-11-01 19:20:41 -0600 | [diff] [blame] | 1645 | } |
| 1646 | } |
| 1647 | loader_instance_heap_free(inst, pIcdSurface->real_icd_surfaces); |
| 1648 | } |
| 1649 | loader_instance_heap_free(inst, pIcdSurface); |
| 1650 | } |
| 1651 | |
| 1652 | return vkRes; |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1653 | } |
| 1654 | |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 1655 | // EXT_display_swapchain Extension command |
| 1656 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1657 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, |
| 1658 | const VkSwapchainCreateInfoKHR *pCreateInfos, |
| 1659 | const VkAllocationCallbacks *pAllocator, |
| 1660 | VkSwapchainKHR *pSwapchains) { |
Mark Young | 2a2122f | 2016-09-08 18:36:32 -0600 | [diff] [blame] | 1661 | const VkLayerDispatchTable *disp; |
| 1662 | disp = loader_get_dispatch(device); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1663 | return disp->CreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, pAllocator, pSwapchains); |
Mark Young | f2eabea | 2016-07-01 15:18:27 -0600 | [diff] [blame] | 1664 | } |
| 1665 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1666 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, |
| 1667 | const VkSwapchainCreateInfoKHR *pCreateInfos, |
| 1668 | const VkAllocationCallbacks *pAllocator, |
| 1669 | VkSwapchainKHR *pSwapchains) { |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 1670 | uint32_t icd_index = 0; |
| 1671 | struct loader_device *dev; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1672 | struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, &icd_index); |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1673 | if (NULL != icd_term && NULL != icd_term->dispatch.CreateSharedSwapchainsKHR) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1674 | VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)pCreateInfos->surface; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 1675 | if (NULL != icd_surface->real_icd_surfaces) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1676 | if ((VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[icd_index]) { |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 1677 | // We found the ICD, and there is an ICD KHR surface |
| 1678 | // associated with it, so copy the CreateInfo struct |
| 1679 | // and point it at the ICD's surface. |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1680 | VkSwapchainCreateInfoKHR *pCreateCopy = loader_stack_alloc(sizeof(VkSwapchainCreateInfoKHR) * swapchainCount); |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 1681 | if (NULL == pCreateCopy) { |
| 1682 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 1683 | } |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1684 | memcpy(pCreateCopy, pCreateInfos, sizeof(VkSwapchainCreateInfoKHR) * swapchainCount); |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 1685 | for (uint32_t sc = 0; sc < swapchainCount; sc++) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 1686 | pCreateCopy[sc].surface = icd_surface->real_icd_surfaces[icd_index]; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 1687 | } |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1688 | return icd_term->dispatch.CreateSharedSwapchainsKHR(device, swapchainCount, pCreateCopy, pAllocator, pSwapchains); |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 1689 | } |
| 1690 | } |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 1691 | return icd_term->dispatch.CreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, pAllocator, pSwapchains); |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 1692 | } |
| 1693 | return VK_SUCCESS; |
| 1694 | } |
| 1695 | |
Lenny Komow | dbaaad6 | 2017-10-02 15:08:53 -0600 | [diff] [blame] | 1696 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupPresentCapabilitiesKHR( |
| 1697 | VkDevice device, |
| 1698 | VkDeviceGroupPresentCapabilitiesKHR* pDeviceGroupPresentCapabilities) { |
| 1699 | const VkLayerDispatchTable *disp = loader_get_dispatch(device); |
| 1700 | return disp->GetDeviceGroupPresentCapabilitiesKHR(device, pDeviceGroupPresentCapabilities); |
| 1701 | } |
Lenny Komow | 3121743 | 2017-10-02 15:08:53 -0600 | [diff] [blame] | 1702 | |
Lenny Komow | dbaaad6 | 2017-10-02 15:08:53 -0600 | [diff] [blame] | 1703 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModesKHR( |
| 1704 | VkDevice device, |
| 1705 | VkSurfaceKHR surface, |
| 1706 | VkDeviceGroupPresentModeFlagsKHR* pModes) { |
| 1707 | const VkLayerDispatchTable *disp = loader_get_dispatch(device); |
| 1708 | return disp->GetDeviceGroupSurfacePresentModesKHR(device, surface, pModes); |
| 1709 | } |
| 1710 | |
Lenny Komow | 7871f78 | 2017-10-11 15:39:38 -0600 | [diff] [blame] | 1711 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDeviceGroupSurfacePresentModesKHR( |
| 1712 | VkDevice device, |
| 1713 | VkSurfaceKHR surface, |
| 1714 | VkDeviceGroupPresentModeFlagsKHR* pModes) { |
| 1715 | uint32_t icd_index = 0; |
| 1716 | struct loader_device *dev; |
| 1717 | struct loader_icd_term *icd_term = loader_get_icd_and_device(device, &dev, &icd_index); |
| 1718 | if (NULL != icd_term && NULL != icd_term->dispatch.GetDeviceGroupSurfacePresentModesKHR) { |
| 1719 | VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; |
| 1720 | if (NULL != icd_surface->real_icd_surfaces && (VkSurfaceKHR)NULL != icd_surface->real_icd_surfaces[icd_index]) { |
| 1721 | return icd_term->dispatch.GetDeviceGroupSurfacePresentModesKHR(device, icd_surface->real_icd_surfaces[icd_index], pModes); |
| 1722 | } |
| 1723 | return icd_term->dispatch.GetDeviceGroupSurfacePresentModesKHR(device, surface, pModes); |
| 1724 | } |
| 1725 | return VK_SUCCESS; |
| 1726 | } |
| 1727 | |
Lenny Komow | dbaaad6 | 2017-10-02 15:08:53 -0600 | [diff] [blame] | 1728 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDevicePresentRectanglesKHR( |
Lenny Komow | 3121743 | 2017-10-02 15:08:53 -0600 | [diff] [blame] | 1729 | VkPhysicalDevice physicalDevice, |
| 1730 | VkSurfaceKHR surface, |
| 1731 | uint32_t* pRectCount, |
| 1732 | VkRect2D* pRects) { |
| 1733 | const VkLayerInstanceDispatchTable *disp; |
| 1734 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
| 1735 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
| 1736 | return disp->GetPhysicalDevicePresentRectanglesKHR(unwrapped_phys_dev, surface, pRectCount, pRects); |
| 1737 | } |
| 1738 | |
| 1739 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDevicePresentRectanglesKHR( |
| 1740 | VkPhysicalDevice physicalDevice, |
| 1741 | VkSurfaceKHR surface, |
| 1742 | uint32_t* pRectCount, |
| 1743 | VkRect2D* pRects) { |
| 1744 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
| 1745 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
| 1746 | if (NULL == icd_term->dispatch.GetPhysicalDevicePresentRectanglesKHR) { |
| 1747 | loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1748 | "ICD associated with VkPhysicalDevice does not support GetPhysicalDevicePresentRectanglesKHX"); |
| 1749 | } |
| 1750 | VkIcdSurface *icd_surface = (VkIcdSurface *)(surface); |
| 1751 | uint8_t icd_index = phys_dev_term->icd_index; |
| 1752 | if (NULL != icd_surface->real_icd_surfaces && NULL != (void *)icd_surface->real_icd_surfaces[icd_index]) { |
| 1753 | return icd_term->dispatch.GetPhysicalDevicePresentRectanglesKHR(phys_dev_term->phys_dev, icd_surface->real_icd_surfaces[icd_index], pRectCount, pRects); |
| 1754 | } |
| 1755 | return icd_term->dispatch.GetPhysicalDevicePresentRectanglesKHR(phys_dev_term->phys_dev, surface, pRectCount, pRects); |
| 1756 | } |
| 1757 | |
Lenny Komow | dbaaad6 | 2017-10-02 15:08:53 -0600 | [diff] [blame] | 1758 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImage2KHR( |
| 1759 | VkDevice device, |
| 1760 | const VkAcquireNextImageInfoKHR* pAcquireInfo, |
| 1761 | uint32_t* pImageIndex) { |
| 1762 | const VkLayerDispatchTable *disp = loader_get_dispatch(device); |
| 1763 | return disp->AcquireNextImage2KHR(device, pAcquireInfo, pImageIndex); |
| 1764 | } |
| 1765 | |
Lenny Komow | 6113978 | 2018-05-31 11:32:31 -0600 | [diff] [blame] | 1766 | // ---- VK_KHR_get_display_properties2 extension trampoline/terminators |
| 1767 | |
| 1768 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, |
| 1769 | uint32_t *pPropertyCount, |
| 1770 | VkDisplayProperties2KHR *pProperties) { |
| 1771 | const VkLayerInstanceDispatchTable *disp; |
| 1772 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
| 1773 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
| 1774 | return disp->GetPhysicalDeviceDisplayProperties2KHR(unwrapped_phys_dev, pPropertyCount, pProperties); |
| 1775 | } |
| 1776 | |
| 1777 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, |
| 1778 | uint32_t *pPropertyCount, |
| 1779 | VkDisplayProperties2KHR *pProperties) { |
| 1780 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
| 1781 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
| 1782 | |
| 1783 | // If the function is available in the driver, just call into it |
| 1784 | if (icd_term->dispatch.GetPhysicalDeviceDisplayProperties2KHR != NULL) { |
| 1785 | return icd_term->dispatch.GetPhysicalDeviceDisplayProperties2KHR(phys_dev_term->phys_dev, pPropertyCount, pProperties); |
| 1786 | } |
| 1787 | |
| 1788 | // We have to emulate the function. |
| 1789 | loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, |
| 1790 | "vkGetPhysicalDeviceDisplayProperties2KHR: Emulating call in ICD \"%s\"", icd_term->scanned_icd->lib_name); |
| 1791 | |
| 1792 | // If the icd doesn't support VK_KHR_display, then no properties are available |
| 1793 | if (icd_term->dispatch.GetPhysicalDeviceDisplayPropertiesKHR == NULL) { |
| 1794 | *pPropertyCount = 0; |
| 1795 | return VK_SUCCESS; |
| 1796 | } |
| 1797 | |
| 1798 | // If we aren't writing to pProperties, then emulation is straightforward |
| 1799 | if (pProperties == NULL || *pPropertyCount == 0) { |
| 1800 | return icd_term->dispatch.GetPhysicalDeviceDisplayPropertiesKHR(phys_dev_term->phys_dev, pPropertyCount, NULL); |
| 1801 | } |
| 1802 | |
| 1803 | // If we do have to write to pProperties, then we need to write to a temporary array of VkDisplayPropertiesKHR and copy it |
| 1804 | VkDisplayPropertiesKHR *properties = loader_stack_alloc(*pPropertyCount * sizeof(VkDisplayPropertiesKHR)); |
| 1805 | if (properties == NULL) { |
| 1806 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 1807 | } |
| 1808 | VkResult res = icd_term->dispatch.GetPhysicalDeviceDisplayPropertiesKHR(phys_dev_term->phys_dev, pPropertyCount, properties); |
| 1809 | if (res < 0) { |
| 1810 | return res; |
| 1811 | } |
| 1812 | for (uint32_t i = 0; i < *pPropertyCount; ++i) { |
| 1813 | memcpy(&pProperties[i].displayProperties, &properties[i], sizeof(VkDisplayPropertiesKHR)); |
| 1814 | } |
| 1815 | return res; |
| 1816 | } |
| 1817 | |
| 1818 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPlaneProperties2KHR( |
| 1819 | VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkDisplayPlaneProperties2KHR *pProperties) { |
| 1820 | const VkLayerInstanceDispatchTable *disp; |
| 1821 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
| 1822 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
| 1823 | return disp->GetPhysicalDeviceDisplayPlaneProperties2KHR(unwrapped_phys_dev, pPropertyCount, pProperties); |
| 1824 | } |
| 1825 | |
| 1826 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPlaneProperties2KHR(VkPhysicalDevice physicalDevice, |
| 1827 | uint32_t *pPropertyCount, |
| 1828 | VkDisplayPlaneProperties2KHR *pProperties) { |
| 1829 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
| 1830 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
| 1831 | |
| 1832 | // If the function is available in the driver, just call into it |
| 1833 | if (icd_term->dispatch.GetPhysicalDeviceDisplayPlaneProperties2KHR != NULL) { |
| 1834 | return icd_term->dispatch.GetPhysicalDeviceDisplayPlaneProperties2KHR(phys_dev_term->phys_dev, pPropertyCount, pProperties); |
| 1835 | } |
| 1836 | |
| 1837 | // We have to emulate the function. |
| 1838 | loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, |
| 1839 | "vkGetPhysicalDeviceDisplayPlaneProperties2KHR: Emulating call in ICD \"%s\"", icd_term->scanned_icd->lib_name); |
| 1840 | |
| 1841 | // If the icd doesn't support VK_KHR_display, then no properties are available |
| 1842 | if (icd_term->dispatch.GetPhysicalDeviceDisplayPlanePropertiesKHR == NULL) { |
| 1843 | *pPropertyCount = 0; |
| 1844 | return VK_SUCCESS; |
| 1845 | } |
| 1846 | |
| 1847 | // If we aren't writing to pProperties, then emulation is straightforward |
| 1848 | if (pProperties == NULL || *pPropertyCount == 0) { |
| 1849 | return icd_term->dispatch.GetPhysicalDeviceDisplayPlanePropertiesKHR(phys_dev_term->phys_dev, pPropertyCount, NULL); |
| 1850 | } |
| 1851 | |
| 1852 | // If we do have to write to pProperties, then we need to write to a temporary array of VkDisplayPlanePropertiesKHR and copy it |
| 1853 | VkDisplayPlanePropertiesKHR *properties = loader_stack_alloc(*pPropertyCount * sizeof(VkDisplayPlanePropertiesKHR)); |
| 1854 | if (properties == NULL) { |
| 1855 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 1856 | } |
| 1857 | VkResult res = |
| 1858 | icd_term->dispatch.GetPhysicalDeviceDisplayPlanePropertiesKHR(phys_dev_term->phys_dev, pPropertyCount, properties); |
| 1859 | if (res < 0) { |
| 1860 | return res; |
| 1861 | } |
| 1862 | for (uint32_t i = 0; i < *pPropertyCount; ++i) { |
| 1863 | memcpy(&pProperties[i].displayPlaneProperties, &properties[i], sizeof(VkDisplayPlanePropertiesKHR)); |
| 1864 | } |
| 1865 | return res; |
| 1866 | } |
| 1867 | |
| 1868 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 1869 | uint32_t *pPropertyCount, |
| 1870 | VkDisplayModeProperties2KHR *pProperties) { |
| 1871 | const VkLayerInstanceDispatchTable *disp; |
| 1872 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
| 1873 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
| 1874 | return disp->GetDisplayModeProperties2KHR(unwrapped_phys_dev, display, pPropertyCount, pProperties); |
| 1875 | } |
| 1876 | |
| 1877 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 1878 | uint32_t *pPropertyCount, |
| 1879 | VkDisplayModeProperties2KHR *pProperties) { |
| 1880 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
| 1881 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
| 1882 | |
| 1883 | // If the function is available in the driver, just call into it |
| 1884 | if (icd_term->dispatch.GetDisplayModeProperties2KHR != NULL) { |
| 1885 | return icd_term->dispatch.GetDisplayModeProperties2KHR(phys_dev_term->phys_dev, display, pPropertyCount, pProperties); |
| 1886 | } |
| 1887 | |
| 1888 | // We have to emulate the function. |
| 1889 | loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, |
| 1890 | "vkGetDisplayModeProperties2KHR: Emulating call in ICD \"%s\"", icd_term->scanned_icd->lib_name); |
| 1891 | |
| 1892 | // If the icd doesn't support VK_KHR_display, then no properties are available |
| 1893 | if (icd_term->dispatch.GetDisplayModePropertiesKHR == NULL) { |
| 1894 | *pPropertyCount = 0; |
| 1895 | return VK_SUCCESS; |
| 1896 | } |
| 1897 | |
| 1898 | // If we aren't writing to pProperties, then emulation is straightforward |
| 1899 | if (pProperties == NULL || *pPropertyCount == 0) { |
| 1900 | return icd_term->dispatch.GetDisplayModePropertiesKHR(phys_dev_term->phys_dev, display, pPropertyCount, NULL); |
| 1901 | } |
| 1902 | |
| 1903 | // If we do have to write to pProperties, then we need to write to a temporary array of VkDisplayModePropertiesKHR and copy it |
| 1904 | VkDisplayModePropertiesKHR *properties = loader_stack_alloc(*pPropertyCount * sizeof(VkDisplayModePropertiesKHR)); |
| 1905 | if (properties == NULL) { |
| 1906 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 1907 | } |
| 1908 | VkResult res = icd_term->dispatch.GetDisplayModePropertiesKHR(phys_dev_term->phys_dev, display, pPropertyCount, properties); |
| 1909 | if (res < 0) { |
| 1910 | return res; |
| 1911 | } |
| 1912 | for (uint32_t i = 0; i < *pPropertyCount; ++i) { |
| 1913 | memcpy(&pProperties[i].displayModeProperties, &properties[i], sizeof(VkDisplayModePropertiesKHR)); |
| 1914 | } |
| 1915 | return res; |
| 1916 | } |
| 1917 | |
| 1918 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneCapabilities2KHR(VkPhysicalDevice physicalDevice, |
| 1919 | const VkDisplayPlaneInfo2KHR *pDisplayPlaneInfo, |
| 1920 | VkDisplayPlaneCapabilities2KHR *pCapabilities) { |
| 1921 | const VkLayerInstanceDispatchTable *disp; |
| 1922 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
| 1923 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
| 1924 | return disp->GetDisplayPlaneCapabilities2KHR(unwrapped_phys_dev, pDisplayPlaneInfo, pCapabilities); |
| 1925 | } |
| 1926 | |
| 1927 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneCapabilities2KHR(VkPhysicalDevice physicalDevice, |
| 1928 | const VkDisplayPlaneInfo2KHR *pDisplayPlaneInfo, |
| 1929 | VkDisplayPlaneCapabilities2KHR *pCapabilities) { |
| 1930 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
| 1931 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
| 1932 | |
| 1933 | // If the function is abailable in the driver, just call into it |
| 1934 | if (icd_term->dispatch.GetDisplayPlaneCapabilities2KHR != NULL) { |
| 1935 | return icd_term->dispatch.GetDisplayPlaneCapabilities2KHR(phys_dev_term->phys_dev, pDisplayPlaneInfo, pCapabilities); |
| 1936 | } |
| 1937 | |
| 1938 | // We have to emulate the function. |
| 1939 | loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, |
| 1940 | "vkGetDisplayPlaneCapabilities2KHR: Emulating call in ICD \"%s\"", icd_term->scanned_icd->lib_name); |
| 1941 | |
| 1942 | // Just call into the old version of the function. |
| 1943 | // If the icd doesn't support VK_KHR_display, there are zero planes and this call is invalid (and will crash) |
| 1944 | return icd_term->dispatch.GetDisplayPlaneCapabilitiesKHR(phys_dev_term->phys_dev, pDisplayPlaneInfo->mode, |
| 1945 | pDisplayPlaneInfo->planeIndex, &pCapabilities->capabilities); |
| 1946 | } |
| 1947 | |
Craig Stout | f3b74dc | 2020-10-26 12:05:15 -0700 | [diff] [blame] | 1948 | #ifdef VK_USE_PLATFORM_FUCHSIA |
| 1949 | |
| 1950 | // This is the trampoline entrypoint for CreateImagePipeSurfaceFUCHSIA |
| 1951 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateImagePipeSurfaceFUCHSIA(VkInstance instance, |
| 1952 | const VkImagePipeSurfaceCreateInfoFUCHSIA *pCreateInfo, |
| 1953 | const VkAllocationCallbacks *pAllocator, |
| 1954 | VkSurfaceKHR *pSurface) { |
| 1955 | const VkLayerInstanceDispatchTable *disp; |
| 1956 | disp = loader_get_instance_layer_dispatch(instance); |
| 1957 | VkResult res; |
| 1958 | |
| 1959 | res = disp->CreateImagePipeSurfaceFUCHSIA(instance, pCreateInfo, pAllocator, pSurface); |
| 1960 | return res; |
| 1961 | } |
| 1962 | |
| 1963 | // This is the instance chain terminator function for CreateImagePipeSurfaceFUCHSIA |
| 1964 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateImagePipeSurfaceFUCHSIA(VkInstance instance, |
| 1965 | const VkImagePipeSurfaceCreateInfoFUCHSIA *pCreateInfo, |
| 1966 | const VkAllocationCallbacks *pAllocator, |
| 1967 | VkSurfaceKHR *pSurface) { |
| 1968 | VkResult vkRes = VK_SUCCESS; |
| 1969 | VkIcdSurface *pIcdSurface = NULL; |
| 1970 | uint32_t i = 0; |
| 1971 | |
| 1972 | // Initialize pSurface to NULL just to be safe. |
| 1973 | *pSurface = VK_NULL_HANDLE; |
| 1974 | // First, check to ensure the appropriate extension was enabled: |
| 1975 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
| 1976 | if (!ptr_instance->wsi_imagepipe_surface_enabled) { |
| 1977 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1978 | "VK_FUCHSIA_imagepipe_surface extension not enabled. " |
| 1979 | "vkCreateImagePipeSurfaceFUCHSIA not executed!\n"); |
| 1980 | vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; |
| 1981 | goto out; |
| 1982 | } |
| 1983 | |
| 1984 | // Next, if so, proceed with the implementation of this function: |
| 1985 | pIcdSurface = |
| 1986 | AllocateIcdSurfaceStruct(ptr_instance, sizeof(pIcdSurface->imagepipe_surf.base), sizeof(pIcdSurface->imagepipe_surf)); |
| 1987 | if (pIcdSurface == NULL) { |
| 1988 | vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; |
| 1989 | goto out; |
| 1990 | } |
| 1991 | |
| 1992 | pIcdSurface->imagepipe_surf.base.platform = VK_ICD_WSI_PLATFORM_FUCHSIA; |
| 1993 | |
| 1994 | // Loop through each ICD and determine if they need to create a surface |
| 1995 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
| 1996 | if (icd_term->scanned_icd->interface_version >= ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { |
| 1997 | if (NULL != icd_term->dispatch.CreateImagePipeSurfaceFUCHSIA) { |
| 1998 | vkRes = icd_term->dispatch.CreateImagePipeSurfaceFUCHSIA(icd_term->instance, pCreateInfo, pAllocator, |
| 1999 | &pIcdSurface->real_icd_surfaces[i]); |
| 2000 | if (VK_SUCCESS != vkRes) { |
| 2001 | goto out; |
| 2002 | } |
| 2003 | } |
| 2004 | } |
| 2005 | } |
| 2006 | |
| 2007 | *pSurface = (VkSurfaceKHR)(pIcdSurface); |
| 2008 | |
| 2009 | out: |
| 2010 | |
| 2011 | if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { |
| 2012 | if (NULL != pIcdSurface->real_icd_surfaces) { |
| 2013 | i = 0; |
| 2014 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; icd_term != NULL; icd_term = icd_term->next, i++) { |
| 2015 | if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && NULL != icd_term->dispatch.DestroySurfaceKHR) { |
| 2016 | icd_term->dispatch.DestroySurfaceKHR(icd_term->instance, pIcdSurface->real_icd_surfaces[i], pAllocator); |
| 2017 | } |
| 2018 | } |
| 2019 | loader_instance_heap_free(ptr_instance, pIcdSurface->real_icd_surfaces); |
| 2020 | } |
| 2021 | loader_instance_heap_free(ptr_instance, pIcdSurface); |
| 2022 | } |
| 2023 | |
| 2024 | return vkRes; |
| 2025 | } |
| 2026 | #endif // VK_USE_PLATFORM_FUCHSIA |
| 2027 | |
Joshua Ashton | 03cc64b | 2020-03-12 04:42:26 +0000 | [diff] [blame] | 2028 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 2029 | vkGetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
| 2030 | VkSurfaceCapabilities2KHR *pSurfaceCapabilities) { |
| 2031 | const VkLayerInstanceDispatchTable *disp; |
| 2032 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
| 2033 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
| 2034 | return disp->GetPhysicalDeviceSurfaceCapabilities2KHR(unwrapped_phys_dev, pSurfaceInfo, pSurfaceCapabilities); |
| 2035 | } |
| 2036 | |
| 2037 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilities2KHR( |
| 2038 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
| 2039 | VkSurfaceCapabilities2KHR *pSurfaceCapabilities) { |
| 2040 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
| 2041 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Joshua Ashton | 64c3693 | 2020-03-12 22:57:49 +0000 | [diff] [blame] | 2042 | struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; |
| 2043 | |
| 2044 | if (!ptr_instance->wsi_surface_enabled) { |
| 2045 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 2046 | "VK_KHR_surface extension not enabled. vkGetPhysicalDeviceSurfaceCapabilities2KHR not executed!\n"); |
| 2047 | return VK_SUCCESS; |
| 2048 | } |
Joshua Ashton | 03cc64b | 2020-03-12 04:42:26 +0000 | [diff] [blame] | 2049 | |
| 2050 | VkIcdSurface *icd_surface = (VkIcdSurface *)(pSurfaceInfo->surface); |
| 2051 | uint8_t icd_index = phys_dev_term->icd_index; |
| 2052 | |
| 2053 | if (icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2KHR != NULL) { |
| 2054 | VkBaseOutStructure *pNext = (VkBaseOutStructure *)pSurfaceCapabilities->pNext; |
| 2055 | while (pNext != NULL) { |
| 2056 | if ((int)pNext->sType == VK_STRUCTURE_TYPE_SURFACE_PROTECTED_CAPABILITIES_KHR) { |
| 2057 | // Not all ICDs may be supporting VK_KHR_surface_protected_capabilities |
| 2058 | // Initialize VkSurfaceProtectedCapabilitiesKHR.supportsProtected to false and |
| 2059 | // if an ICD supports protected surfaces, it will reset it to true accordingly. |
| 2060 | ((VkSurfaceProtectedCapabilitiesKHR *)pNext)->supportsProtected = VK_FALSE; |
| 2061 | } |
| 2062 | pNext = (VkBaseOutStructure *)pNext->pNext; |
| 2063 | } |
| 2064 | |
| 2065 | // Pass the call to the driver, possibly unwrapping the ICD surface |
| 2066 | if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) { |
| 2067 | VkPhysicalDeviceSurfaceInfo2KHR info_copy = *pSurfaceInfo; |
| 2068 | info_copy.surface = icd_surface->real_icd_surfaces[icd_index]; |
| 2069 | return icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2KHR(phys_dev_term->phys_dev, &info_copy, |
| 2070 | pSurfaceCapabilities); |
| 2071 | } else { |
| 2072 | return icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilities2KHR(phys_dev_term->phys_dev, pSurfaceInfo, |
| 2073 | pSurfaceCapabilities); |
| 2074 | } |
| 2075 | } else { |
| 2076 | // Emulate the call |
| 2077 | loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, |
| 2078 | "vkGetPhysicalDeviceSurfaceCapabilities2KHR: Emulating call in ICD \"%s\" using " |
| 2079 | "vkGetPhysicalDeviceSurfaceCapabilitiesKHR", |
| 2080 | icd_term->scanned_icd->lib_name); |
| 2081 | |
| 2082 | if (pSurfaceInfo->pNext != NULL) { |
| 2083 | loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, |
| 2084 | "vkGetPhysicalDeviceSurfaceCapabilities2KHR: Emulation found unrecognized structure type in " |
| 2085 | "pSurfaceInfo->pNext - this struct will be ignored"); |
| 2086 | } |
| 2087 | |
| 2088 | // Write to the VkSurfaceCapabilities2KHR struct |
| 2089 | VkSurfaceKHR surface = pSurfaceInfo->surface; |
| 2090 | if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) { |
| 2091 | surface = icd_surface->real_icd_surfaces[icd_index]; |
| 2092 | } |
| 2093 | VkResult res = icd_term->dispatch.GetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev_term->phys_dev, surface, |
| 2094 | &pSurfaceCapabilities->surfaceCapabilities); |
| 2095 | |
| 2096 | if (pSurfaceCapabilities->pNext != NULL) { |
| 2097 | loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, |
| 2098 | "vkGetPhysicalDeviceSurfaceCapabilities2KHR: Emulation found unrecognized structure type in " |
| 2099 | "pSurfaceCapabilities->pNext - this struct will be ignored"); |
| 2100 | } |
| 2101 | return res; |
| 2102 | } |
| 2103 | } |
| 2104 | |
| 2105 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 2106 | vkGetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
| 2107 | uint32_t *pSurfaceFormatCount, VkSurfaceFormat2KHR *pSurfaceFormats) { |
| 2108 | const VkLayerInstanceDispatchTable *disp; |
| 2109 | VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); |
| 2110 | disp = loader_get_instance_layer_dispatch(physicalDevice); |
| 2111 | return disp->GetPhysicalDeviceSurfaceFormats2KHR(unwrapped_phys_dev, pSurfaceInfo, pSurfaceFormatCount, pSurfaceFormats); |
| 2112 | } |
| 2113 | |
| 2114 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice, |
| 2115 | const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
| 2116 | uint32_t *pSurfaceFormatCount, |
| 2117 | VkSurfaceFormat2KHR *pSurfaceFormats) { |
| 2118 | struct loader_physical_device_term *phys_dev_term = (struct loader_physical_device_term *)physicalDevice; |
| 2119 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Joshua Ashton | 64c3693 | 2020-03-12 22:57:49 +0000 | [diff] [blame] | 2120 | struct loader_instance *ptr_instance = (struct loader_instance *)icd_term->this_instance; |
| 2121 | |
| 2122 | if (!ptr_instance->wsi_surface_enabled) { |
| 2123 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 2124 | "VK_KHR_surface extension not enabled. vkGetPhysicalDeviceSurfaceFormats2KHR not executed!\n"); |
| 2125 | return VK_SUCCESS; |
| 2126 | } |
Joshua Ashton | 03cc64b | 2020-03-12 04:42:26 +0000 | [diff] [blame] | 2127 | |
| 2128 | VkIcdSurface *icd_surface = (VkIcdSurface *)(pSurfaceInfo->surface); |
| 2129 | uint8_t icd_index = phys_dev_term->icd_index; |
| 2130 | |
| 2131 | if (icd_term->dispatch.GetPhysicalDeviceSurfaceFormats2KHR != NULL) { |
| 2132 | // Pass the call to the driver, possibly unwrapping the ICD surface |
| 2133 | if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) { |
| 2134 | VkPhysicalDeviceSurfaceInfo2KHR info_copy = *pSurfaceInfo; |
| 2135 | info_copy.surface = icd_surface->real_icd_surfaces[icd_index]; |
| 2136 | return icd_term->dispatch.GetPhysicalDeviceSurfaceFormats2KHR(phys_dev_term->phys_dev, &info_copy, pSurfaceFormatCount, |
| 2137 | pSurfaceFormats); |
| 2138 | } else { |
| 2139 | return icd_term->dispatch.GetPhysicalDeviceSurfaceFormats2KHR(phys_dev_term->phys_dev, pSurfaceInfo, |
| 2140 | pSurfaceFormatCount, pSurfaceFormats); |
| 2141 | } |
| 2142 | } else { |
| 2143 | // Emulate the call |
| 2144 | loader_log(icd_term->this_instance, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, |
| 2145 | "vkGetPhysicalDeviceSurfaceFormats2KHR: Emulating call in ICD \"%s\" using vkGetPhysicalDeviceSurfaceFormatsKHR", |
| 2146 | icd_term->scanned_icd->lib_name); |
| 2147 | |
| 2148 | if (pSurfaceInfo->pNext != NULL) { |
| 2149 | loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, |
| 2150 | "vkGetPhysicalDeviceSurfaceFormats2KHR: Emulation found unrecognized structure type in pSurfaceInfo->pNext " |
| 2151 | "- this struct will be ignored"); |
| 2152 | } |
| 2153 | |
| 2154 | VkSurfaceKHR surface = pSurfaceInfo->surface; |
| 2155 | if (icd_surface->real_icd_surfaces != NULL && (void *)icd_surface->real_icd_surfaces[icd_index] != NULL) { |
| 2156 | surface = icd_surface->real_icd_surfaces[icd_index]; |
| 2157 | } |
| 2158 | |
| 2159 | if (*pSurfaceFormatCount == 0 || pSurfaceFormats == NULL) { |
| 2160 | // Write to pSurfaceFormatCount |
| 2161 | return icd_term->dispatch.GetPhysicalDeviceSurfaceFormatsKHR(phys_dev_term->phys_dev, surface, pSurfaceFormatCount, |
| 2162 | NULL); |
| 2163 | } else { |
| 2164 | // Allocate a temporary array for the output of the old function |
| 2165 | VkSurfaceFormatKHR *formats = loader_stack_alloc(*pSurfaceFormatCount * sizeof(VkSurfaceFormatKHR)); |
| 2166 | if (formats == NULL) { |
| 2167 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 2168 | } |
| 2169 | |
| 2170 | VkResult res = icd_term->dispatch.GetPhysicalDeviceSurfaceFormatsKHR(phys_dev_term->phys_dev, surface, |
| 2171 | pSurfaceFormatCount, formats); |
| 2172 | for (uint32_t i = 0; i < *pSurfaceFormatCount; ++i) { |
| 2173 | pSurfaceFormats[i].surfaceFormat = formats[i]; |
| 2174 | if (pSurfaceFormats[i].pNext != NULL) { |
| 2175 | loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, |
| 2176 | "vkGetPhysicalDeviceSurfaceFormats2KHR: Emulation found unrecognized structure type in " |
| 2177 | "pSurfaceFormats[%d].pNext - this struct will be ignored", |
| 2178 | i); |
| 2179 | } |
| 2180 | } |
| 2181 | return res; |
| 2182 | } |
| 2183 | } |
| 2184 | } |
| 2185 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2186 | bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char *name, void **addr) { |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 2187 | *addr = NULL; |
| 2188 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 2189 | // Functions for the VK_KHR_surface extension: |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 2190 | if (!strcmp("vkDestroySurfaceKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2191 | *addr = ptr_instance->wsi_surface_enabled ? (void *)vkDestroySurfaceKHR : NULL; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 2192 | return true; |
| 2193 | } |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 2194 | if (!strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2195 | *addr = ptr_instance->wsi_surface_enabled ? (void *)vkGetPhysicalDeviceSurfaceSupportKHR : NULL; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 2196 | return true; |
| 2197 | } |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 2198 | if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2199 | *addr = ptr_instance->wsi_surface_enabled ? (void *)vkGetPhysicalDeviceSurfaceCapabilitiesKHR : NULL; |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 2200 | return true; |
| 2201 | } |
| 2202 | if (!strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2203 | *addr = ptr_instance->wsi_surface_enabled ? (void *)vkGetPhysicalDeviceSurfaceFormatsKHR : NULL; |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 2204 | return true; |
| 2205 | } |
| 2206 | if (!strcmp("vkGetPhysicalDeviceSurfacePresentModesKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2207 | *addr = ptr_instance->wsi_surface_enabled ? (void *)vkGetPhysicalDeviceSurfacePresentModesKHR : NULL; |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 2208 | return true; |
| 2209 | } |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 2210 | |
Lenny Komow | dbaaad6 | 2017-10-02 15:08:53 -0600 | [diff] [blame] | 2211 | if (!strcmp("vkGetDeviceGroupPresentCapabilitiesKHR", name)) { |
| 2212 | *addr = ptr_instance->wsi_surface_enabled ? (void *)vkGetDeviceGroupPresentCapabilitiesKHR : NULL; |
| 2213 | return true; |
| 2214 | } |
| 2215 | |
| 2216 | if (!strcmp("vkGetDeviceGroupSurfacePresentModesKHR", name)) { |
| 2217 | *addr = ptr_instance->wsi_surface_enabled ? (void *)vkGetDeviceGroupSurfacePresentModesKHR : NULL; |
| 2218 | return true; |
| 2219 | } |
| 2220 | |
| 2221 | if (!strcmp("vkGetPhysicalDevicePresentRectanglesKHR", name)) { |
| 2222 | *addr = ptr_instance->wsi_surface_enabled ? (void *)vkGetPhysicalDevicePresentRectanglesKHR : NULL; |
| 2223 | return true; |
| 2224 | } |
| 2225 | |
Joshua Ashton | 03cc64b | 2020-03-12 04:42:26 +0000 | [diff] [blame] | 2226 | // Functions for VK_KHR_get_surface_capabilities2 extension: |
| 2227 | if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilities2KHR", name)) { |
| 2228 | *addr = ptr_instance->wsi_surface_enabled ? (void *)vkGetPhysicalDeviceSurfaceCapabilities2KHR : NULL; |
| 2229 | return true; |
| 2230 | } |
| 2231 | |
| 2232 | if (!strcmp("vkGetPhysicalDeviceSurfaceFormats2KHR", name)) { |
| 2233 | *addr = ptr_instance->wsi_surface_enabled ? (void *)vkGetPhysicalDeviceSurfaceFormats2KHR : NULL; |
| 2234 | return true; |
| 2235 | } |
| 2236 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 2237 | // Functions for the VK_KHR_swapchain extension: |
| 2238 | |
| 2239 | // Note: This is a device extension, and its functions are statically |
| 2240 | // exported from the loader. Per Khronos decisions, the loader's GIPA |
| 2241 | // function will return the trampoline function for such device-extension |
| 2242 | // functions, regardless of whether the extension has been enabled. |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 2243 | if (!strcmp("vkCreateSwapchainKHR", name)) { |
Lenny Komow | f1872d8 | 2018-02-23 11:28:38 -0700 | [diff] [blame] | 2244 | *addr = (void *)vkCreateSwapchainKHR; |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 2245 | return true; |
| 2246 | } |
| 2247 | if (!strcmp("vkDestroySwapchainKHR", name)) { |
Lenny Komow | f1872d8 | 2018-02-23 11:28:38 -0700 | [diff] [blame] | 2248 | *addr = (void *)vkDestroySwapchainKHR; |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 2249 | return true; |
| 2250 | } |
| 2251 | if (!strcmp("vkGetSwapchainImagesKHR", name)) { |
Lenny Komow | f1872d8 | 2018-02-23 11:28:38 -0700 | [diff] [blame] | 2252 | *addr = (void *)vkGetSwapchainImagesKHR; |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 2253 | return true; |
| 2254 | } |
| 2255 | if (!strcmp("vkAcquireNextImageKHR", name)) { |
Lenny Komow | f1872d8 | 2018-02-23 11:28:38 -0700 | [diff] [blame] | 2256 | *addr = (void *)vkAcquireNextImageKHR; |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 2257 | return true; |
| 2258 | } |
| 2259 | if (!strcmp("vkQueuePresentKHR", name)) { |
Lenny Komow | f1872d8 | 2018-02-23 11:28:38 -0700 | [diff] [blame] | 2260 | *addr = (void *)vkQueuePresentKHR; |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 2261 | return true; |
| 2262 | } |
Lenny Komow | dbaaad6 | 2017-10-02 15:08:53 -0600 | [diff] [blame] | 2263 | if (!strcmp("vkAcquireNextImage2KHR", name)) { |
Lenny Komow | f1872d8 | 2018-02-23 11:28:38 -0700 | [diff] [blame] | 2264 | *addr = (void *)vkAcquireNextImage2KHR; |
Lenny Komow | dbaaad6 | 2017-10-02 15:08:53 -0600 | [diff] [blame] | 2265 | return true; |
| 2266 | } |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 2267 | |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 2268 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 2269 | |
| 2270 | // Functions for the VK_KHR_win32_surface extension: |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 2271 | if (!strcmp("vkCreateWin32SurfaceKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2272 | *addr = ptr_instance->wsi_win32_surface_enabled ? (void *)vkCreateWin32SurfaceKHR : NULL; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 2273 | return true; |
| 2274 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 2275 | if (!strcmp("vkGetPhysicalDeviceWin32PresentationSupportKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2276 | *addr = ptr_instance->wsi_win32_surface_enabled ? (void *)vkGetPhysicalDeviceWin32PresentationSupportKHR : NULL; |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 2277 | return true; |
| 2278 | } |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 2279 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 2280 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 2281 | |
| 2282 | // Functions for the VK_KHR_wayland_surface extension: |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 2283 | if (!strcmp("vkCreateWaylandSurfaceKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2284 | *addr = ptr_instance->wsi_wayland_surface_enabled ? (void *)vkCreateWaylandSurfaceKHR : NULL; |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 2285 | return true; |
| 2286 | } |
| 2287 | if (!strcmp("vkGetPhysicalDeviceWaylandPresentationSupportKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2288 | *addr = ptr_instance->wsi_wayland_surface_enabled ? (void *)vkGetPhysicalDeviceWaylandPresentationSupportKHR : NULL; |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 2289 | return true; |
| 2290 | } |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 2291 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 2292 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 2293 | |
| 2294 | // Functions for the VK_KHR_xcb_surface extension: |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 2295 | if (!strcmp("vkCreateXcbSurfaceKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2296 | *addr = ptr_instance->wsi_xcb_surface_enabled ? (void *)vkCreateXcbSurfaceKHR : NULL; |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 2297 | return true; |
| 2298 | } |
| 2299 | if (!strcmp("vkGetPhysicalDeviceXcbPresentationSupportKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2300 | *addr = ptr_instance->wsi_xcb_surface_enabled ? (void *)vkGetPhysicalDeviceXcbPresentationSupportKHR : NULL; |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 2301 | return true; |
| 2302 | } |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 2303 | #endif // VK_USE_PLATFORM_XCB_KHR |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 2304 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 2305 | |
| 2306 | // Functions for the VK_KHR_xlib_surface extension: |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 2307 | if (!strcmp("vkCreateXlibSurfaceKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2308 | *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *)vkCreateXlibSurfaceKHR : NULL; |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 2309 | return true; |
| 2310 | } |
| 2311 | if (!strcmp("vkGetPhysicalDeviceXlibPresentationSupportKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2312 | *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *)vkGetPhysicalDeviceXlibPresentationSupportKHR : NULL; |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 2313 | return true; |
| 2314 | } |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 2315 | #endif // VK_USE_PLATFORM_XLIB_KHR |
Nicolas Caramelli | fa696ca | 2020-07-04 22:53:59 +0200 | [diff] [blame] | 2316 | #ifdef VK_USE_PLATFORM_DIRECTFB_EXT |
| 2317 | |
| 2318 | // Functions for the VK_EXT_directfb_surface extension: |
| 2319 | if (!strcmp("vkCreateDirectFBSurfaceEXT", name)) { |
| 2320 | *addr = ptr_instance->wsi_directfb_surface_enabled ? (void *)vkCreateDirectFBSurfaceEXT : NULL; |
| 2321 | return true; |
| 2322 | } |
| 2323 | if (!strcmp("vkGetPhysicalDeviceDirectFBPresentationSupportEXT", name)) { |
| 2324 | *addr = ptr_instance->wsi_directfb_surface_enabled ? (void *)vkGetPhysicalDeviceDirectFBPresentationSupportEXT : NULL; |
| 2325 | return true; |
| 2326 | } |
| 2327 | #endif // VK_USE_PLATFORM_DIRECTFB_EXT |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 2328 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 2329 | |
| 2330 | // Functions for the VK_KHR_android_surface extension: |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 2331 | if (!strcmp("vkCreateAndroidSurfaceKHR", name)) { |
Karl Schultz | d81ebfb | 2017-12-12 10:33:01 -0500 | [diff] [blame] | 2332 | *addr = ptr_instance->wsi_android_surface_enabled ? (void *)vkCreateAndroidSurfaceKHR : NULL; |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 2333 | return true; |
| 2334 | } |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 2335 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
Bryan Law-Smith | 5730569 | 2019-04-01 09:45:55 +0100 | [diff] [blame] | 2336 | |
Karl Schultz | d81ebfb | 2017-12-12 10:33:01 -0500 | [diff] [blame] | 2337 | #ifdef VK_USE_PLATFORM_MACOS_MVK |
| 2338 | |
| 2339 | // Functions for the VK_MVK_macos_surface extension: |
| 2340 | if (!strcmp("vkCreateMacOSSurfaceMVK", name)) { |
| 2341 | *addr = ptr_instance->wsi_macos_surface_enabled ? (void *)vkCreateMacOSSurfaceMVK : NULL; |
| 2342 | return true; |
| 2343 | } |
| 2344 | #endif // VK_USE_PLATFORM_MACOS_MVK |
| 2345 | #ifdef VK_USE_PLATFORM_IOS_MVK |
| 2346 | |
| 2347 | // Functions for the VK_MVK_ios_surface extension: |
| 2348 | if (!strcmp("vkCreateIOSSurfaceMVK", name)) { |
| 2349 | *addr = ptr_instance->wsi_ios_surface_enabled ? (void *)vkCreateIOSSurfaceMVK : NULL; |
| 2350 | return true; |
| 2351 | } |
| 2352 | #endif // VK_USE_PLATFORM_IOS_MVK |
Craig Stout | f3b74dc | 2020-10-26 12:05:15 -0700 | [diff] [blame] | 2353 | #ifdef VK_USE_PLATFORM_FUCHSIA |
| 2354 | |
| 2355 | // Functions for the VK_FUCHSIA_imagepipe_surface extension: |
| 2356 | if (!strcmp("vkCreateImagePipeSurfaceFUCHSIA", name)) { |
| 2357 | *addr = ptr_instance->wsi_imagepipe_surface_enabled ? (void *)vkCreateImagePipeSurfaceFUCHSIA : NULL; |
| 2358 | return true; |
| 2359 | } |
| 2360 | |
| 2361 | #endif // VK_USE_PLATFORM_FUCHSIA |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 2362 | |
Bryan Law-Smith | 5730569 | 2019-04-01 09:45:55 +0100 | [diff] [blame] | 2363 | // Functions for the VK_EXT_headless_surface extension: |
| 2364 | if (!strcmp("vkCreateHeadlessSurfaceEXT", name)) { |
| 2365 | *addr = ptr_instance->wsi_headless_surface_enabled ? (void *)vkCreateHeadlessSurfaceEXT : NULL; |
| 2366 | return true; |
| 2367 | } |
| 2368 | |
Lenny Komow | a1b5e44 | 2019-09-16 16:14:36 -0600 | [diff] [blame] | 2369 | #if defined(VK_USE_PLATFORM_METAL_EXT) |
| 2370 | // Functions for the VK_MVK_macos_surface extension: |
| 2371 | if (!strcmp("vkCreateMetalSurfaceEXT", name)) { |
| 2372 | *addr = ptr_instance->wsi_metal_surface_enabled ? (void *)vkCreateMetalSurfaceEXT : NULL; |
| 2373 | return true; |
| 2374 | } |
| 2375 | #endif // VK_USE_PLATFORM_METAL_EXT |
| 2376 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 2377 | // Functions for VK_KHR_display extension: |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 2378 | if (!strcmp("vkGetPhysicalDeviceDisplayPropertiesKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2379 | *addr = ptr_instance->wsi_display_enabled ? (void *)vkGetPhysicalDeviceDisplayPropertiesKHR : NULL; |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 2380 | return true; |
| 2381 | } |
| 2382 | if (!strcmp("vkGetPhysicalDeviceDisplayPlanePropertiesKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2383 | *addr = ptr_instance->wsi_display_enabled ? (void *)vkGetPhysicalDeviceDisplayPlanePropertiesKHR : NULL; |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 2384 | return true; |
| 2385 | } |
| 2386 | if (!strcmp("vkGetDisplayPlaneSupportedDisplaysKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2387 | *addr = ptr_instance->wsi_display_enabled ? (void *)vkGetDisplayPlaneSupportedDisplaysKHR : NULL; |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 2388 | return true; |
| 2389 | } |
| 2390 | if (!strcmp("vkGetDisplayModePropertiesKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2391 | *addr = ptr_instance->wsi_display_enabled ? (void *)vkGetDisplayModePropertiesKHR : NULL; |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 2392 | return true; |
| 2393 | } |
| 2394 | if (!strcmp("vkCreateDisplayModeKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2395 | *addr = ptr_instance->wsi_display_enabled ? (void *)vkCreateDisplayModeKHR : NULL; |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 2396 | return true; |
| 2397 | } |
| 2398 | if (!strcmp("vkGetDisplayPlaneCapabilitiesKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2399 | *addr = ptr_instance->wsi_display_enabled ? (void *)vkGetDisplayPlaneCapabilitiesKHR : NULL; |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 2400 | return true; |
| 2401 | } |
| 2402 | if (!strcmp("vkCreateDisplayPlaneSurfaceKHR", name)) { |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 2403 | *addr = ptr_instance->wsi_display_enabled ? (void *)vkCreateDisplayPlaneSurfaceKHR : NULL; |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 2404 | return true; |
| 2405 | } |
Mark Young | f2eabea | 2016-07-01 15:18:27 -0600 | [diff] [blame] | 2406 | |
| 2407 | // Functions for KHR_display_swapchain extension: |
| 2408 | if (!strcmp("vkCreateSharedSwapchainsKHR", name)) { |
Lenny Komow | f1872d8 | 2018-02-23 11:28:38 -0700 | [diff] [blame] | 2409 | *addr = (void *)vkCreateSharedSwapchainsKHR; |
Mark Young | f2eabea | 2016-07-01 15:18:27 -0600 | [diff] [blame] | 2410 | return true; |
| 2411 | } |
| 2412 | |
Lenny Komow | 6113978 | 2018-05-31 11:32:31 -0600 | [diff] [blame] | 2413 | // Functions for KHR_get_display_properties2 |
| 2414 | if (!strcmp("vkGetPhysicalDeviceDisplayProperties2KHR", name)) { |
| 2415 | *addr = ptr_instance->wsi_display_props2_enabled ? (void *)vkGetPhysicalDeviceDisplayProperties2KHR : NULL; |
| 2416 | return true; |
| 2417 | } |
| 2418 | if (!strcmp("vkGetPhysicalDeviceDisplayPlaneProperties2KHR", name)) { |
| 2419 | *addr = ptr_instance->wsi_display_props2_enabled ? (void *)vkGetPhysicalDeviceDisplayPlaneProperties2KHR : NULL; |
| 2420 | return true; |
| 2421 | } |
| 2422 | if (!strcmp("vkGetDisplayModeProperties2KHR", name)) { |
| 2423 | *addr = ptr_instance->wsi_display_props2_enabled ? (void *)vkGetDisplayModeProperties2KHR : NULL; |
| 2424 | return true; |
| 2425 | } |
| 2426 | if (!strcmp("vkGetDisplayPlaneCapabilities2KHR", name)) { |
| 2427 | *addr = ptr_instance->wsi_display_props2_enabled ? (void *)vkGetDisplayPlaneCapabilities2KHR : NULL; |
| 2428 | return true; |
| 2429 | } |
| 2430 | |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 2431 | return false; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 2432 | } |