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