Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 1 | /* |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 2 | * Copyright (c) 2015-2016 The Khronos Group Inc. |
| 3 | * Copyright (c) 2015-2016 Valve Corporation |
| 4 | * Copyright (c) 2015-2016 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> |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 22 | */ |
| 23 | |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 24 | #define _GNU_SOURCE |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 25 | #include <stdio.h> |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 26 | #include <stdlib.h> |
| 27 | #include <string.h> |
| 28 | #include "vk_loader_platform.h" |
| 29 | #include "loader.h" |
| 30 | #include "wsi.h" |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 31 | #include <vulkan/vk_icd.h> |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 32 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 33 | // The first ICD/Loader interface that support querying the SurfaceKHR from |
| 34 | // the ICDs. |
| 35 | #define ICD_VER_SUPPORTS_ICD_SURFACE_KHR 3 |
| 36 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 37 | void wsi_create_instance(struct loader_instance *ptr_instance, |
| 38 | const VkInstanceCreateInfo *pCreateInfo) { |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 39 | ptr_instance->wsi_surface_enabled = false; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 40 | |
| 41 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 42 | ptr_instance->wsi_win32_surface_enabled = false; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 43 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 44 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 45 | ptr_instance->wsi_mir_surface_enabled = false; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 46 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 47 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 48 | ptr_instance->wsi_wayland_surface_enabled = false; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 49 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 50 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 51 | ptr_instance->wsi_xcb_surface_enabled = false; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 52 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 53 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 54 | ptr_instance->wsi_xlib_surface_enabled = false; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 55 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 56 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 57 | ptr_instance->wsi_android_surface_enabled = false; |
| 58 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 59 | |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 60 | ptr_instance->wsi_display_enabled = false; |
| 61 | |
Jon Ashburn | a0673ab | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 62 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 63 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], |
| 64 | VK_KHR_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 65 | ptr_instance->wsi_surface_enabled = true; |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 66 | continue; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 67 | } |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 68 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 69 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], |
| 70 | VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 71 | ptr_instance->wsi_win32_surface_enabled = true; |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 72 | continue; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 73 | } |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 74 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 75 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 76 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], |
| 77 | VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 78 | ptr_instance->wsi_mir_surface_enabled = true; |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 79 | continue; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 80 | } |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 81 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 82 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 83 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], |
| 84 | VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 85 | ptr_instance->wsi_wayland_surface_enabled = true; |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 86 | continue; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 87 | } |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 88 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 89 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 90 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], |
| 91 | VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 92 | ptr_instance->wsi_xcb_surface_enabled = true; |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 93 | continue; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 94 | } |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 95 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 96 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 97 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], |
| 98 | VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 99 | ptr_instance->wsi_xlib_surface_enabled = true; |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 100 | continue; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 101 | } |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 102 | #endif // VK_USE_PLATFORM_XLIB_KHR |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 103 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 104 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], |
| 105 | VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0) { |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 106 | ptr_instance->wsi_android_surface_enabled = true; |
| 107 | continue; |
| 108 | } |
| 109 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 110 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], |
| 111 | VK_KHR_DISPLAY_EXTENSION_NAME) == 0) { |
| 112 | ptr_instance->wsi_display_enabled = true; |
| 113 | continue; |
| 114 | } |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 115 | } |
| 116 | } |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 117 | |
| 118 | // Linux WSI surface extensions are not always compiled into the loader. (Assume |
| 119 | // for Windows the KHR_win32_surface is always compiled into loader). A given |
| 120 | // Linux build environment might not have the headers required for building one |
| 121 | // of the four extensions (Xlib, Xcb, Mir, Wayland). Thus, need to check if |
| 122 | // the built loader actually supports the particular Linux surface extension. |
| 123 | // If not supported by the built loader it will not be included in the list of |
| 124 | // enumerated instance extensions. This solves the issue where an ICD or layer |
| 125 | // advertises support for a given Linux surface extension but the loader was not |
| 126 | // built to support the extension. |
Jon Ashburn | ae8f1e8 | 2016-03-25 12:49:35 -0600 | [diff] [blame] | 127 | bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop) { |
| 128 | #ifndef VK_USE_PLATFORM_MIR_KHR |
| 129 | if (!strcmp(ext_prop->extensionName, "VK_KHR_mir_surface")) |
| 130 | return true; |
| 131 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 132 | #ifndef VK_USE_PLATFORM_WAYLAND_KHR |
| 133 | if (!strcmp(ext_prop->extensionName, "VK_KHR_wayland_surface")) |
| 134 | return true; |
| 135 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 136 | #ifndef VK_USE_PLATFORM_XCB_KHR |
| 137 | if (!strcmp(ext_prop->extensionName, "VK_KHR_xcb_surface")) |
| 138 | return true; |
| 139 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 140 | #ifndef VK_USE_PLATFORM_XLIB_KHR |
| 141 | if (!strcmp(ext_prop->extensionName, "VK_KHR_xlib_surface")) |
| 142 | return true; |
| 143 | #endif // VK_USE_PLATFORM_XLIB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 144 | |
Jon Ashburn | ae8f1e8 | 2016-03-25 12:49:35 -0600 | [diff] [blame] | 145 | return false; |
| 146 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 147 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 148 | // Functions for the VK_KHR_surface extension: |
| 149 | |
| 150 | // This is the trampoline entrypoint for DestroySurfaceKHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 151 | LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 152 | vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, |
| 153 | const VkAllocationCallbacks *pAllocator) { |
Ian Elliott | abf5066 | 2015-11-25 14:43:02 -0700 | [diff] [blame] | 154 | const VkLayerInstanceDispatchTable *disp; |
| 155 | disp = loader_get_instance_dispatch(instance); |
| 156 | disp->DestroySurfaceKHR(instance, surface, pAllocator); |
| 157 | } |
| 158 | |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 159 | // TODO probably need to lock around all the loader_get_instance() calls. |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 160 | |
| 161 | // This is the instance chain terminator function for DestroySurfaceKHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 162 | VKAPI_ATTR void VKAPI_CALL |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 163 | terminator_DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, |
| 164 | const VkAllocationCallbacks *pAllocator) { |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 165 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
| 166 | |
Karl Schultz | a9e989f | 2016-11-19 09:02:27 -0700 | [diff] [blame] | 167 | VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; |
Mark Young | 11e9d47 | 2016-10-17 12:27:36 -0600 | [diff] [blame] | 168 | if (NULL != icd_surface) { |
| 169 | if (NULL != icd_surface->real_icd_surfaces) { |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 170 | uint32_t i = 0; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 171 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; |
| 172 | icd_term != NULL; icd_term = icd_term->next, i++) { |
| 173 | if (icd_term->scanned_icd->interface_version >= |
Mark Young | 11e9d47 | 2016-10-17 12:27:36 -0600 | [diff] [blame] | 174 | ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 175 | if (NULL != icd_term->DestroySurfaceKHR && |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 176 | (VkSurfaceKHR)NULL != |
| 177 | icd_surface->real_icd_surfaces[i]) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 178 | icd_term->DestroySurfaceKHR( |
| 179 | icd_term->instance, |
| 180 | icd_surface->real_icd_surfaces[i], pAllocator); |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 181 | icd_surface->real_icd_surfaces[i] = (VkSurfaceKHR)NULL; |
Mark Young | 11e9d47 | 2016-10-17 12:27:36 -0600 | [diff] [blame] | 182 | } |
| 183 | } else { |
| 184 | // The real_icd_surface for any ICD not supporting the |
| 185 | // proper interface version should be NULL. If not, then |
| 186 | // we have a problem. |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 187 | assert((VkSurfaceKHR)NULL == |
| 188 | icd_surface->real_icd_surfaces[i]); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 189 | } |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 190 | } |
Mark Young | 11e9d47 | 2016-10-17 12:27:36 -0600 | [diff] [blame] | 191 | loader_instance_heap_free(ptr_instance, |
| 192 | icd_surface->real_icd_surfaces); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 193 | } |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 194 | |
Karl Schultz | a9e989f | 2016-11-19 09:02:27 -0700 | [diff] [blame] | 195 | loader_instance_heap_free(ptr_instance, (void *)(uintptr_t)surface); |
Mark Young | 11e9d47 | 2016-10-17 12:27:36 -0600 | [diff] [blame] | 196 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 197 | } |
| 198 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 199 | // This is the trampoline entrypoint for GetPhysicalDeviceSurfaceSupportKHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 200 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 201 | vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, |
| 202 | uint32_t queueFamilyIndex, |
| 203 | VkSurfaceKHR surface, |
| 204 | VkBool32 *pSupported) { |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 205 | const VkLayerInstanceDispatchTable *disp; |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 206 | VkPhysicalDevice unwrapped_phys_dev = |
| 207 | loader_unwrap_physical_device(physicalDevice); |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 208 | disp = loader_get_instance_dispatch(physicalDevice); |
| 209 | VkResult res = disp->GetPhysicalDeviceSurfaceSupportKHR( |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 210 | unwrapped_phys_dev, queueFamilyIndex, surface, pSupported); |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 211 | return res; |
| 212 | } |
| 213 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 214 | // This is the instance chain terminator function for |
| 215 | // GetPhysicalDeviceSurfaceSupportKHR |
| 216 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceSupportKHR( |
| 217 | VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, |
| 218 | VkSurfaceKHR surface, VkBool32 *pSupported) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 219 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 220 | // First, check to ensure the appropriate extension was enabled: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 221 | struct loader_physical_device_term *phys_dev_term = |
| 222 | (struct loader_physical_device_term *)physicalDevice; |
| 223 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 224 | struct loader_instance *ptr_instance = |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 225 | (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 226 | if (!ptr_instance->wsi_surface_enabled) { |
Ian Elliott | 469ea4a | 2016-03-24 15:49:02 -0600 | [diff] [blame] | 227 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 228 | "VK_KHR_VK_KHR_surface extension not enabled. " |
| 229 | "vkGetPhysicalDeviceSurfaceSupportKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 230 | return VK_SUCCESS; |
| 231 | } |
| 232 | |
| 233 | // Next, if so, proceed with the implementation of this function: |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 234 | assert(pSupported && |
| 235 | "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported"); |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 236 | *pSupported = false; |
| 237 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 238 | assert(icd_term->GetPhysicalDeviceSurfaceSupportKHR && |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 239 | "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer"); |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 240 | |
Karl Schultz | a9e989f | 2016-11-19 09:02:27 -0700 | [diff] [blame] | 241 | VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 242 | if (NULL != icd_surface->real_icd_surfaces && |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 243 | (VkSurfaceKHR)NULL != |
| 244 | icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 245 | return icd_term->GetPhysicalDeviceSurfaceSupportKHR( |
| 246 | phys_dev_term->phys_dev, queueFamilyIndex, |
| 247 | icd_surface->real_icd_surfaces[phys_dev_term->icd_index], |
| 248 | pSupported); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 249 | } |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 250 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 251 | return icd_term->GetPhysicalDeviceSurfaceSupportKHR( |
| 252 | phys_dev_term->phys_dev, queueFamilyIndex, surface, pSupported); |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 253 | } |
| 254 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 255 | // This is the trampoline entrypoint for GetPhysicalDeviceSurfaceCapabilitiesKHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 256 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 257 | vkGetPhysicalDeviceSurfaceCapabilitiesKHR( |
| 258 | VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, |
| 259 | VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) { |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 260 | |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 261 | const VkLayerInstanceDispatchTable *disp; |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 262 | VkPhysicalDevice unwrapped_phys_dev = |
| 263 | loader_unwrap_physical_device(physicalDevice); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 264 | disp = loader_get_instance_dispatch(physicalDevice); |
| 265 | VkResult res = disp->GetPhysicalDeviceSurfaceCapabilitiesKHR( |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 266 | unwrapped_phys_dev, surface, pSurfaceCapabilities); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 267 | return res; |
| 268 | } |
| 269 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 270 | // This is the instance chain terminator function for |
| 271 | // GetPhysicalDeviceSurfaceCapabilitiesKHR |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 272 | VKAPI_ATTR VkResult VKAPI_CALL |
| 273 | terminator_GetPhysicalDeviceSurfaceCapabilitiesKHR( |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 274 | VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, |
| 275 | VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 276 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 277 | // First, check to ensure the appropriate extension was enabled: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 278 | struct loader_physical_device_term *phys_dev_term = |
| 279 | (struct loader_physical_device_term *)physicalDevice; |
| 280 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 281 | struct loader_instance *ptr_instance = |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 282 | (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 283 | if (!ptr_instance->wsi_surface_enabled) { |
Ian Elliott | 469ea4a | 2016-03-24 15:49:02 -0600 | [diff] [blame] | 284 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 285 | "VK_KHR_surface extension not enabled. " |
| 286 | "vkGetPhysicalDeviceSurfaceCapabilitiesKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 287 | return VK_SUCCESS; |
| 288 | } |
| 289 | |
| 290 | // Next, if so, proceed with the implementation of this function: |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 291 | assert(pSurfaceCapabilities && "GetPhysicalDeviceSurfaceCapabilitiesKHR: " |
| 292 | "Error, null pSurfaceCapabilities"); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 293 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 294 | assert(icd_term->GetPhysicalDeviceSurfaceCapabilitiesKHR && |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 295 | "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer"); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 296 | |
Karl Schultz | a9e989f | 2016-11-19 09:02:27 -0700 | [diff] [blame] | 297 | VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 298 | if (NULL != icd_surface->real_icd_surfaces && |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 299 | (VkSurfaceKHR)NULL != |
| 300 | icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 301 | return icd_term->GetPhysicalDeviceSurfaceCapabilitiesKHR( |
| 302 | phys_dev_term->phys_dev, |
| 303 | icd_surface->real_icd_surfaces[phys_dev_term->icd_index], |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 304 | pSurfaceCapabilities); |
| 305 | } |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 306 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 307 | return icd_term->GetPhysicalDeviceSurfaceCapabilitiesKHR( |
| 308 | phys_dev_term->phys_dev, surface, pSurfaceCapabilities); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 309 | } |
| 310 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 311 | // This is the trampoline entrypoint for GetPhysicalDeviceSurfaceFormatsKHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 312 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 313 | vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, |
| 314 | VkSurfaceKHR surface, |
| 315 | uint32_t *pSurfaceFormatCount, |
| 316 | VkSurfaceFormatKHR *pSurfaceFormats) { |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 317 | VkPhysicalDevice unwrapped_phys_dev = |
| 318 | loader_unwrap_physical_device(physicalDevice); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 319 | const VkLayerInstanceDispatchTable *disp; |
| 320 | disp = loader_get_instance_dispatch(physicalDevice); |
| 321 | VkResult res = disp->GetPhysicalDeviceSurfaceFormatsKHR( |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 322 | unwrapped_phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 323 | return res; |
| 324 | } |
| 325 | |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 326 | // This is the instance chain terminator function for |
| 327 | // GetPhysicalDeviceSurfaceFormatsKHR |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 328 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormatsKHR( |
| 329 | VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, |
| 330 | uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 331 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 332 | // First, check to ensure the appropriate extension was enabled: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 333 | struct loader_physical_device_term *phys_dev_term = |
| 334 | (struct loader_physical_device_term *)physicalDevice; |
| 335 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 336 | struct loader_instance *ptr_instance = |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 337 | (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 338 | if (!ptr_instance->wsi_surface_enabled) { |
Ian Elliott | 469ea4a | 2016-03-24 15:49:02 -0600 | [diff] [blame] | 339 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 340 | "VK_KHR_surface extension not enabled. " |
| 341 | "vkGetPhysicalDeviceSurfaceFormatsKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 342 | return VK_SUCCESS; |
| 343 | } |
| 344 | |
| 345 | // Next, if so, proceed with the implementation of this function: |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 346 | assert( |
| 347 | pSurfaceFormatCount && |
| 348 | "GetPhysicalDeviceSurfaceFormatsKHR: Error, null pSurfaceFormatCount"); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 349 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 350 | assert(icd_term->GetPhysicalDeviceSurfaceFormatsKHR && |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 351 | "loader: null GetPhysicalDeviceSurfaceFormatsKHR ICD pointer"); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 352 | |
Karl Schultz | a9e989f | 2016-11-19 09:02:27 -0700 | [diff] [blame] | 353 | VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 354 | if (NULL != icd_surface->real_icd_surfaces && |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 355 | (VkSurfaceKHR)NULL != |
| 356 | icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 357 | return icd_term->GetPhysicalDeviceSurfaceFormatsKHR( |
| 358 | phys_dev_term->phys_dev, |
| 359 | icd_surface->real_icd_surfaces[phys_dev_term->icd_index], |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 360 | pSurfaceFormatCount, pSurfaceFormats); |
| 361 | } |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 362 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 363 | return icd_term->GetPhysicalDeviceSurfaceFormatsKHR( |
| 364 | phys_dev_term->phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 365 | } |
| 366 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 367 | // This is the trampoline entrypoint for GetPhysicalDeviceSurfacePresentModesKHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 368 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 369 | vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, |
| 370 | VkSurfaceKHR surface, |
| 371 | uint32_t *pPresentModeCount, |
| 372 | VkPresentModeKHR *pPresentModes) { |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 373 | VkPhysicalDevice unwrapped_phys_dev = |
| 374 | loader_unwrap_physical_device(physicalDevice); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 375 | const VkLayerInstanceDispatchTable *disp; |
| 376 | disp = loader_get_instance_dispatch(physicalDevice); |
| 377 | VkResult res = disp->GetPhysicalDeviceSurfacePresentModesKHR( |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 378 | unwrapped_phys_dev, surface, pPresentModeCount, pPresentModes); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 379 | return res; |
| 380 | } |
| 381 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 382 | // This is the instance chain terminator function for |
| 383 | // GetPhysicalDeviceSurfacePresentModesKHR |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 384 | VKAPI_ATTR VkResult VKAPI_CALL |
| 385 | terminator_GetPhysicalDeviceSurfacePresentModesKHR( |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 386 | VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, |
| 387 | uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 388 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 389 | // First, check to ensure the appropriate extension was enabled: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 390 | struct loader_physical_device_term *phys_dev_term = |
| 391 | (struct loader_physical_device_term *)physicalDevice; |
| 392 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 393 | struct loader_instance *ptr_instance = |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 394 | (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 395 | if (!ptr_instance->wsi_surface_enabled) { |
Ian Elliott | 469ea4a | 2016-03-24 15:49:02 -0600 | [diff] [blame] | 396 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 397 | "VK_KHR_surface extension not enabled. " |
| 398 | "vkGetPhysicalDeviceSurfacePresentModesKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 399 | return VK_SUCCESS; |
| 400 | } |
| 401 | |
| 402 | // Next, if so, proceed with the implementation of this function: |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 403 | assert(pPresentModeCount && "GetPhysicalDeviceSurfacePresentModesKHR: " |
| 404 | "Error, null pPresentModeCount"); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 405 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 406 | assert(icd_term->GetPhysicalDeviceSurfacePresentModesKHR && |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 407 | "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer"); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 408 | |
Karl Schultz | a9e989f | 2016-11-19 09:02:27 -0700 | [diff] [blame] | 409 | VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 410 | if (NULL != icd_surface->real_icd_surfaces && |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 411 | (VkSurfaceKHR)NULL != |
| 412 | icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 413 | return icd_term->GetPhysicalDeviceSurfacePresentModesKHR( |
| 414 | phys_dev_term->phys_dev, |
| 415 | icd_surface->real_icd_surfaces[phys_dev_term->icd_index], |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 416 | pPresentModeCount, pPresentModes); |
| 417 | } |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 418 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 419 | return icd_term->GetPhysicalDeviceSurfacePresentModesKHR( |
| 420 | phys_dev_term->phys_dev, surface, pPresentModeCount, pPresentModes); |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 421 | } |
| 422 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 423 | // Functions for the VK_KHR_swapchain extension: |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 424 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 425 | // This is the trampoline entrypoint for CreateSwapchainKHR |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 426 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR( |
| 427 | VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, |
| 428 | const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) { |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 429 | const VkLayerDispatchTable *disp; |
| 430 | disp = loader_get_dispatch(device); |
Mark Young | 76b3fe0 | 2016-09-08 12:28:38 -0600 | [diff] [blame] | 431 | return disp->CreateSwapchainKHR(device, pCreateInfo, pAllocator, |
| 432 | pSwapchain); |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 433 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 434 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 435 | VKAPI_ATTR VkResult VKAPI_CALL terminator_vkCreateSwapchainKHR( |
| 436 | VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, |
| 437 | const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) { |
| 438 | uint32_t icd_index = 0; |
| 439 | struct loader_device *dev; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 440 | struct loader_icd_term *icd_term = |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 441 | loader_get_icd_and_device(device, &dev, &icd_index); |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 442 | if (NULL != icd_term && NULL != icd_term->CreateSwapchainKHR) { |
Karl Schultz | a9e989f | 2016-11-19 09:02:27 -0700 | [diff] [blame] | 443 | VkIcdSurface *icd_surface = |
| 444 | (VkIcdSurface *)(uintptr_t)pCreateInfo->surface; |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 445 | if (NULL != icd_surface->real_icd_surfaces) { |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 446 | if ((VkSurfaceKHR)NULL != |
| 447 | icd_surface->real_icd_surfaces[icd_index]) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 448 | // We found the ICD, and there is an ICD KHR surface |
| 449 | // associated with it, so copy the CreateInfo struct |
| 450 | // and point it at the ICD's surface. |
| 451 | VkSwapchainCreateInfoKHR *pCreateCopy = |
| 452 | loader_stack_alloc(sizeof(VkSwapchainCreateInfoKHR)); |
| 453 | if (NULL == pCreateCopy) { |
| 454 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 455 | } |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 456 | memcpy(pCreateCopy, pCreateInfo, |
| 457 | sizeof(VkSwapchainCreateInfoKHR)); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 458 | pCreateCopy->surface = |
| 459 | icd_surface->real_icd_surfaces[icd_index]; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 460 | return icd_term->CreateSwapchainKHR(device, pCreateCopy, |
| 461 | pAllocator, pSwapchain); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 462 | } |
| 463 | } |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 464 | return icd_term->CreateSwapchainKHR(device, pCreateInfo, pAllocator, |
| 465 | pSwapchain); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 466 | } |
| 467 | return VK_SUCCESS; |
| 468 | } |
| 469 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 470 | // This is the trampoline entrypoint for DestroySwapchainKHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 471 | LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL |
| 472 | vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, |
| 473 | const VkAllocationCallbacks *pAllocator) { |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 474 | const VkLayerDispatchTable *disp; |
| 475 | disp = loader_get_dispatch(device); |
| 476 | disp->DestroySwapchainKHR(device, swapchain, pAllocator); |
| 477 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 478 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 479 | /* |
| 480 | * This is the trampoline entrypoint |
| 481 | * for GetSwapchainImagesKHR |
| 482 | */ |
| 483 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR( |
| 484 | VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, |
| 485 | VkImage *pSwapchainImages) { |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 486 | const VkLayerDispatchTable *disp; |
| 487 | disp = loader_get_dispatch(device); |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 488 | return disp->GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, |
| 489 | pSwapchainImages); |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 490 | } |
| 491 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 492 | /* |
| 493 | * This is the trampoline entrypoint |
| 494 | * for AcquireNextImageKHR |
| 495 | */ |
| 496 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR( |
| 497 | VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, |
| 498 | VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex) { |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 499 | const VkLayerDispatchTable *disp; |
| 500 | disp = loader_get_dispatch(device); |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 501 | return disp->AcquireNextImageKHR(device, swapchain, timeout, semaphore, |
| 502 | fence, pImageIndex); |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 503 | } |
| 504 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 505 | // This is the trampoline entrypoint for QueuePresentKHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 506 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 507 | vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) { |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 508 | const VkLayerDispatchTable *disp; |
| 509 | disp = loader_get_dispatch(queue); |
Mark Young | 76b3fe0 | 2016-09-08 12:28:38 -0600 | [diff] [blame] | 510 | return disp->QueuePresentKHR(queue, pPresentInfo); |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 511 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 512 | |
Mark Young | f27962c | 2016-09-16 10:18:42 -0600 | [diff] [blame] | 513 | static VkIcdSurface *AllocateIcdSurfaceStruct(struct loader_instance *instance, |
| 514 | size_t base_size, |
| 515 | size_t platform_size, |
| 516 | bool create_icd_surfs) { |
| 517 | // Next, if so, proceed with the implementation of this function: |
| 518 | VkIcdSurface *pIcdSurface = loader_instance_heap_alloc( |
| 519 | instance, sizeof(VkIcdSurface), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); |
| 520 | if (pIcdSurface != NULL) { |
| 521 | // Setup the new sizes and offsets so we can grow the structures in the |
| 522 | // future without having problems |
| 523 | pIcdSurface->base_size = (uint32_t)base_size; |
| 524 | pIcdSurface->platform_size = (uint32_t)platform_size; |
| 525 | pIcdSurface->non_platform_offset = (uint32_t)( |
| 526 | (uint8_t *)(&pIcdSurface->base_size) - (uint8_t *)pIcdSurface); |
| 527 | pIcdSurface->entire_size = sizeof(VkIcdSurface); |
| 528 | |
| 529 | if (create_icd_surfs) { |
| 530 | pIcdSurface->real_icd_surfaces = loader_instance_heap_alloc( |
| 531 | instance, sizeof(VkSurfaceKHR) * instance->total_icd_count, |
| 532 | VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); |
| 533 | if (pIcdSurface->real_icd_surfaces == NULL) { |
| 534 | loader_instance_heap_free(instance, pIcdSurface); |
| 535 | pIcdSurface = NULL; |
| 536 | } else { |
| 537 | memset(pIcdSurface->real_icd_surfaces, 0, |
| 538 | sizeof(VkSurfaceKHR) * instance->total_icd_count); |
| 539 | } |
| 540 | } else { |
| 541 | pIcdSurface->real_icd_surfaces = NULL; |
| 542 | } |
| 543 | } |
| 544 | return pIcdSurface; |
| 545 | } |
| 546 | |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 547 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 548 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 549 | // Functions for the VK_KHR_win32_surface extension: |
| 550 | |
| 551 | // This is the trampoline entrypoint for CreateWin32SurfaceKHR |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 552 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR( |
| 553 | VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, |
| 554 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 555 | const VkLayerInstanceDispatchTable *disp; |
| 556 | disp = loader_get_instance_dispatch(instance); |
| 557 | VkResult res; |
| 558 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 559 | res = disp->CreateWin32SurfaceKHR(instance, pCreateInfo, pAllocator, |
| 560 | pSurface); |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 561 | return res; |
| 562 | } |
| 563 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 564 | // This is the instance chain terminator function for CreateWin32SurfaceKHR |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 565 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWin32SurfaceKHR( |
| 566 | VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, |
| 567 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 568 | VkResult vkRes = VK_SUCCESS; |
Mark Young | d7fb159 | 2016-10-12 14:18:44 -0600 | [diff] [blame] | 569 | VkIcdSurface *pIcdSurface = NULL; |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 570 | uint32_t i = 0; |
| 571 | |
Mark Young | f27962c | 2016-09-16 10:18:42 -0600 | [diff] [blame] | 572 | // Initialize pSurface to NULL just to be safe. |
| 573 | *pSurface = VK_NULL_HANDLE; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 574 | // First, check to ensure the appropriate extension was enabled: |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 575 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 576 | if (!ptr_instance->wsi_win32_surface_enabled) { |
Ian Elliott | 469ea4a | 2016-03-24 15:49:02 -0600 | [diff] [blame] | 577 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 578 | "VK_KHR_win32_surface extension not enabled. " |
| 579 | "vkCreateWin32SurfaceKHR not executed!\n"); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 580 | vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; |
| 581 | goto out; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 582 | } |
| 583 | |
| 584 | // Next, if so, proceed with the implementation of this function: |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 585 | pIcdSurface = AllocateIcdSurfaceStruct(ptr_instance, |
| 586 | sizeof(pIcdSurface->win_surf.base), |
| 587 | sizeof(pIcdSurface->win_surf), true); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 588 | if (pIcdSurface == NULL) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 589 | vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; |
| 590 | goto out; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 591 | } |
| 592 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 593 | pIcdSurface->win_surf.base.platform = VK_ICD_WSI_PLATFORM_WIN32; |
| 594 | pIcdSurface->win_surf.hinstance = pCreateInfo->hinstance; |
| 595 | pIcdSurface->win_surf.hwnd = pCreateInfo->hwnd; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 596 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 597 | // Loop through each ICD and determine if they need to create a surface |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 598 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; |
| 599 | icd_term != NULL; icd_term = icd_term->next, i++) { |
| 600 | if (icd_term->scanned_icd->interface_version >= |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 601 | ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 602 | if (NULL != icd_term->CreateWin32SurfaceKHR) { |
| 603 | vkRes = icd_term->CreateWin32SurfaceKHR( |
| 604 | icd_term->instance, pCreateInfo, pAllocator, |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 605 | &pIcdSurface->real_icd_surfaces[i]); |
| 606 | if (VK_SUCCESS != vkRes) { |
| 607 | goto out; |
| 608 | } |
| 609 | } |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | *pSurface = (VkSurfaceKHR)(pIcdSurface); |
| 614 | |
| 615 | out: |
| 616 | |
| 617 | if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { |
| 618 | if (NULL != pIcdSurface->real_icd_surfaces) { |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 619 | i = 0; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 620 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; |
| 621 | icd_term != NULL; icd_term = icd_term->next, i++) { |
Jamie Madill | e416fcc | 2016-11-30 12:47:45 -0500 | [diff] [blame] | 622 | if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 623 | NULL != icd_term->DestroySurfaceKHR) { |
| 624 | icd_term->DestroySurfaceKHR( |
| 625 | icd_term->instance, pIcdSurface->real_icd_surfaces[i], |
| 626 | pAllocator); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 627 | } |
| 628 | } |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 629 | loader_instance_heap_free(ptr_instance, |
| 630 | pIcdSurface->real_icd_surfaces); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 631 | } |
| 632 | loader_instance_heap_free(ptr_instance, pIcdSurface); |
| 633 | } |
| 634 | |
| 635 | return vkRes; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 636 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 637 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 638 | // This is the trampoline entrypoint for |
| 639 | // GetPhysicalDeviceWin32PresentationSupportKHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 640 | LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL |
| 641 | vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice, |
| 642 | uint32_t queueFamilyIndex) { |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 643 | VkPhysicalDevice unwrapped_phys_dev = |
| 644 | loader_unwrap_physical_device(physicalDevice); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 645 | const VkLayerInstanceDispatchTable *disp; |
| 646 | disp = loader_get_instance_dispatch(physicalDevice); |
| 647 | VkBool32 res = disp->GetPhysicalDeviceWin32PresentationSupportKHR( |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 648 | unwrapped_phys_dev, queueFamilyIndex); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 649 | return res; |
| 650 | } |
| 651 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 652 | // This is the instance chain terminator function for |
| 653 | // GetPhysicalDeviceWin32PresentationSupportKHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 654 | VKAPI_ATTR VkBool32 VKAPI_CALL |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 655 | terminator_GetPhysicalDeviceWin32PresentationSupportKHR( |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 656 | VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex) { |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 657 | // First, check to ensure the appropriate extension was enabled: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 658 | struct loader_physical_device_term *phys_dev_term = |
| 659 | (struct loader_physical_device_term *)physicalDevice; |
| 660 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 661 | struct loader_instance *ptr_instance = |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 662 | (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 663 | if (!ptr_instance->wsi_win32_surface_enabled) { |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 664 | loader_log( |
| 665 | ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 666 | "VK_KHR_win32_surface extension not enabled. " |
| 667 | "vkGetPhysicalDeviceWin32PresentationSupportKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 668 | return VK_SUCCESS; |
| 669 | } |
| 670 | |
| 671 | // Next, if so, proceed with the implementation of this function: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 672 | assert(icd_term->GetPhysicalDeviceWin32PresentationSupportKHR && |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 673 | "loader: null GetPhysicalDeviceWin32PresentationSupportKHR ICD " |
| 674 | "pointer"); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 675 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 676 | return icd_term->GetPhysicalDeviceWin32PresentationSupportKHR( |
| 677 | phys_dev_term->phys_dev, queueFamilyIndex); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 678 | } |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 679 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 680 | |
| 681 | #ifdef VK_USE_PLATFORM_MIR_KHR |
| 682 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 683 | // Functions for the VK_KHR_mir_surface extension: |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 684 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 685 | // This is the trampoline entrypoint for CreateMirSurfaceKHR |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 686 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR( |
| 687 | VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo, |
| 688 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 689 | const VkLayerInstanceDispatchTable *disp; |
| 690 | disp = loader_get_instance_dispatch(instance); |
| 691 | VkResult res; |
| 692 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 693 | res = |
| 694 | disp->CreateMirSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 695 | return res; |
| 696 | } |
| 697 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 698 | // This is the instance chain terminator function for CreateMirSurfaceKHR |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 699 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMirSurfaceKHR( |
| 700 | VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo, |
| 701 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 702 | VkResult vkRes = VK_SUCCESS; |
Mark Young | d7fb159 | 2016-10-12 14:18:44 -0600 | [diff] [blame] | 703 | VkIcdSurface *pIcdSurface = NULL; |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 704 | uint32_t i = 0; |
| 705 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 706 | // First, check to ensure the appropriate extension was enabled: |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 707 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 708 | if (!ptr_instance->wsi_mir_surface_enabled) { |
Ian Elliott | 469ea4a | 2016-03-24 15:49:02 -0600 | [diff] [blame] | 709 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 710 | "VK_KHR_mir_surface extension not enabled. " |
| 711 | "vkCreateMirSurfaceKHR not executed!\n"); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 712 | vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; |
| 713 | goto out; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | // Next, if so, proceed with the implementation of this function: |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 717 | pIcdSurface = AllocateIcdSurfaceStruct(ptr_instance, |
| 718 | sizeof(pIcdSurface->mir_surf.base), |
| 719 | sizeof(pIcdSurface->mir_surf), true); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 720 | if (pIcdSurface == NULL) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 721 | vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; |
| 722 | goto out; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 723 | } |
| 724 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 725 | pIcdSurface->mir_surf.base.platform = VK_ICD_WSI_PLATFORM_MIR; |
| 726 | pIcdSurface->mir_surf.connection = pCreateInfo->connection; |
| 727 | pIcdSurface->mir_surf.mirSurface = pCreateInfo->mirSurface; |
| 728 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 729 | // Loop through each ICD and determine if they need to create a surface |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 730 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; |
| 731 | icd_term != NULL; icd_term = icd_term->next, i++) { |
| 732 | if (icd_term->scanned_icd->interface_version >= |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 733 | ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 734 | if (NULL != icd_term->CreateMirSurfaceKHR) { |
| 735 | vkRes = icd_term->CreateMirSurfaceKHR( |
| 736 | icd_term->instance, pCreateInfo, pAllocator, |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 737 | &pIcdSurface->real_icd_surfaces[i]); |
| 738 | if (VK_SUCCESS != vkRes) { |
| 739 | goto out; |
| 740 | } |
| 741 | } |
| 742 | } |
| 743 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 744 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 745 | *pSurface = (VkSurfaceKHR)pIcdSurface; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 746 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 747 | out: |
| 748 | |
| 749 | if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { |
| 750 | if (NULL != pIcdSurface->real_icd_surfaces) { |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 751 | i = 0; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 752 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; |
| 753 | icd_term != NULL; icd_term = icd_term->next, i++) { |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 754 | if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 755 | NULL != icd_term->DestroySurfaceKHR) { |
| 756 | icd_term->DestroySurfaceKHR( |
| 757 | icd_term->instance, pIcdSurface->real_icd_surfaces[i], |
| 758 | pAllocator); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 759 | } |
| 760 | } |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 761 | loader_instance_heap_free(ptr_instance, |
| 762 | pIcdSurface->real_icd_surfaces); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 763 | } |
| 764 | loader_instance_heap_free(ptr_instance, pIcdSurface); |
| 765 | } |
| 766 | |
| 767 | return vkRes; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 768 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 769 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 770 | // This is the trampoline entrypoint for |
| 771 | // GetPhysicalDeviceMirPresentationSupportKHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 772 | LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL |
| 773 | vkGetPhysicalDeviceMirPresentationSupportKHR(VkPhysicalDevice physicalDevice, |
| 774 | uint32_t queueFamilyIndex, |
| 775 | MirConnection *connection) { |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 776 | VkPhysicalDevice unwrapped_phys_dev = |
| 777 | loader_unwrap_physical_device(physicalDevice); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 778 | const VkLayerInstanceDispatchTable *disp; |
| 779 | disp = loader_get_instance_dispatch(physicalDevice); |
| 780 | VkBool32 res = disp->GetPhysicalDeviceMirPresentationSupportKHR( |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 781 | unwrapped_phys_dev, queueFamilyIndex, connection); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 782 | return res; |
| 783 | } |
| 784 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 785 | // This is the instance chain terminator function for |
| 786 | // GetPhysicalDeviceMirPresentationSupportKHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 787 | VKAPI_ATTR VkBool32 VKAPI_CALL |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 788 | terminator_GetPhysicalDeviceMirPresentationSupportKHR( |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 789 | VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, |
| 790 | MirConnection *connection) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 791 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 792 | // First, check to ensure the appropriate extension was enabled: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 793 | struct loader_physical_device_term *phys_dev_term = |
| 794 | (struct loader_physical_device_term *)physicalDevice; |
| 795 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 796 | struct loader_instance *ptr_instance = |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 797 | (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 798 | if (!ptr_instance->wsi_mir_surface_enabled) { |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 799 | loader_log( |
| 800 | ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 801 | "VK_KHR_mir_surface extension not enabled. " |
| 802 | "vkGetPhysicalDeviceMirPresentationSupportKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 803 | return VK_SUCCESS; |
| 804 | } |
| 805 | |
| 806 | // Next, if so, proceed with the implementation of this function: |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 807 | assert( |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 808 | icd_term->GetPhysicalDeviceMirPresentationSupportKHR && |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 809 | "loader: null GetPhysicalDeviceMirPresentationSupportKHR ICD pointer"); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 810 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 811 | return icd_term->GetPhysicalDeviceMirPresentationSupportKHR( |
| 812 | phys_dev_term->phys_dev, queueFamilyIndex, connection); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 813 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 814 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 815 | |
| 816 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
| 817 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 818 | /* |
| 819 | * This is the trampoline entrypoint |
| 820 | * for CreateWaylandSurfaceKHR |
| 821 | */ |
| 822 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR( |
| 823 | VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, |
| 824 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 825 | const VkLayerInstanceDispatchTable *disp; |
| 826 | disp = loader_get_instance_dispatch(instance); |
| 827 | VkResult res; |
| 828 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 829 | res = disp->CreateWaylandSurfaceKHR(instance, pCreateInfo, pAllocator, |
| 830 | pSurface); |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 831 | return res; |
| 832 | } |
| 833 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 834 | // This is the instance chain terminator function for CreateWaylandSurfaceKHR |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 835 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR( |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 836 | VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, |
| 837 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 838 | VkResult vkRes = VK_SUCCESS; |
Mark Young | d7fb159 | 2016-10-12 14:18:44 -0600 | [diff] [blame] | 839 | VkIcdSurface *pIcdSurface = NULL; |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 840 | uint32_t i = 0; |
| 841 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 842 | // First, check to ensure the appropriate extension was enabled: |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 843 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
Jon Ashburn | 436d6a3 | 2016-03-24 17:26:59 -0600 | [diff] [blame] | 844 | if (!ptr_instance->wsi_wayland_surface_enabled) { |
Ian Elliott | 469ea4a | 2016-03-24 15:49:02 -0600 | [diff] [blame] | 845 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 846 | "VK_KHR_wayland_surface extension not enabled. " |
| 847 | "vkCreateWaylandSurfaceKHR not executed!\n"); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 848 | vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; |
| 849 | goto out; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 850 | } |
| 851 | |
| 852 | // Next, if so, proceed with the implementation of this function: |
Mark Young | d7fb159 | 2016-10-12 14:18:44 -0600 | [diff] [blame] | 853 | pIcdSurface = AllocateIcdSurfaceStruct( |
Mark Young | f27962c | 2016-09-16 10:18:42 -0600 | [diff] [blame] | 854 | ptr_instance, sizeof(pIcdSurface->wayland_surf.base), |
| 855 | sizeof(pIcdSurface->wayland_surf), true); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 856 | if (pIcdSurface == NULL) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 857 | vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; |
| 858 | goto out; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 859 | } |
| 860 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 861 | pIcdSurface->wayland_surf.base.platform = VK_ICD_WSI_PLATFORM_WAYLAND; |
| 862 | pIcdSurface->wayland_surf.display = pCreateInfo->display; |
| 863 | pIcdSurface->wayland_surf.surface = pCreateInfo->surface; |
| 864 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 865 | // Loop through each ICD and determine if they need to create a surface |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 866 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; |
| 867 | icd_term != NULL; icd_term = icd_term->next, i++) { |
| 868 | if (icd_term->scanned_icd->interface_version >= |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 869 | ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 870 | if (NULL != icd_term->CreateWaylandSurfaceKHR) { |
| 871 | vkRes = icd_term->CreateWaylandSurfaceKHR( |
| 872 | icd_term->instance, pCreateInfo, pAllocator, |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 873 | &pIcdSurface->real_icd_surfaces[i]); |
| 874 | if (VK_SUCCESS != vkRes) { |
| 875 | goto out; |
| 876 | } |
| 877 | } |
| 878 | } |
| 879 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 880 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 881 | *pSurface = (VkSurfaceKHR)pIcdSurface; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 882 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 883 | out: |
| 884 | |
| 885 | if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { |
| 886 | if (NULL != pIcdSurface->real_icd_surfaces) { |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 887 | i = 0; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 888 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; |
| 889 | icd_term != NULL; icd_term = icd_term->next, i++) { |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 890 | if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 891 | NULL != icd_term->DestroySurfaceKHR) { |
| 892 | icd_term->DestroySurfaceKHR( |
| 893 | icd_term->instance, pIcdSurface->real_icd_surfaces[i], |
| 894 | pAllocator); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 895 | } |
| 896 | } |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 897 | loader_instance_heap_free(ptr_instance, |
| 898 | pIcdSurface->real_icd_surfaces); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 899 | } |
| 900 | loader_instance_heap_free(ptr_instance, pIcdSurface); |
| 901 | } |
| 902 | |
| 903 | return vkRes; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 904 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 905 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 906 | // This is the trampoline entrypoint for |
| 907 | // GetPhysicalDeviceWaylandPresentationSupportKHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 908 | LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL |
| 909 | vkGetPhysicalDeviceWaylandPresentationSupportKHR( |
| 910 | VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, |
| 911 | struct wl_display *display) { |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 912 | VkPhysicalDevice unwrapped_phys_dev = |
| 913 | loader_unwrap_physical_device(physicalDevice); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 914 | const VkLayerInstanceDispatchTable *disp; |
| 915 | disp = loader_get_instance_dispatch(physicalDevice); |
| 916 | VkBool32 res = disp->GetPhysicalDeviceWaylandPresentationSupportKHR( |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 917 | unwrapped_phys_dev, queueFamilyIndex, display); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 918 | return res; |
| 919 | } |
| 920 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 921 | // This is the instance chain terminator function for |
| 922 | // GetPhysicalDeviceWaylandPresentationSupportKHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 923 | VKAPI_ATTR VkBool32 VKAPI_CALL |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 924 | terminator_GetPhysicalDeviceWaylandPresentationSupportKHR( |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 925 | VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, |
| 926 | struct wl_display *display) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 927 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 928 | // First, check to ensure the appropriate extension was enabled: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 929 | struct loader_physical_device_term *phys_dev_term = |
| 930 | (struct loader_physical_device_term *)physicalDevice; |
| 931 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 932 | struct loader_instance *ptr_instance = |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 933 | (struct loader_instance *)icd_term->this_instance; |
Jon Ashburn | 436d6a3 | 2016-03-24 17:26:59 -0600 | [diff] [blame] | 934 | if (!ptr_instance->wsi_wayland_surface_enabled) { |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 935 | loader_log( |
| 936 | ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 937 | "VK_KHR_wayland_surface extension not enabled. " |
| 938 | "vkGetPhysicalDeviceWaylandPresentationSupportKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 939 | return VK_SUCCESS; |
| 940 | } |
| 941 | |
| 942 | // Next, if so, proceed with the implementation of this function: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 943 | assert(icd_term->GetPhysicalDeviceWaylandPresentationSupportKHR && |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 944 | "loader: null GetPhysicalDeviceWaylandPresentationSupportKHR ICD " |
| 945 | "pointer"); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 946 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 947 | return icd_term->GetPhysicalDeviceWaylandPresentationSupportKHR( |
| 948 | phys_dev_term->phys_dev, queueFamilyIndex, display); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 949 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 950 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 951 | |
| 952 | #ifdef VK_USE_PLATFORM_XCB_KHR |
| 953 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 954 | // Functions for the VK_KHR_xcb_surface extension: |
| 955 | |
| 956 | // This is the trampoline entrypoint for CreateXcbSurfaceKHR |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 957 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR( |
| 958 | VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo, |
| 959 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 960 | const VkLayerInstanceDispatchTable *disp; |
| 961 | disp = loader_get_instance_dispatch(instance); |
| 962 | VkResult res; |
| 963 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 964 | res = |
| 965 | disp->CreateXcbSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 966 | return res; |
| 967 | } |
| 968 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 969 | // This is the instance chain terminator function for CreateXcbSurfaceKHR |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 970 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXcbSurfaceKHR( |
| 971 | VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo, |
| 972 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 973 | VkResult vkRes = VK_SUCCESS; |
Mark Young | d7fb159 | 2016-10-12 14:18:44 -0600 | [diff] [blame] | 974 | VkIcdSurface *pIcdSurface = NULL; |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 975 | uint32_t i = 0; |
| 976 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 977 | // First, check to ensure the appropriate extension was enabled: |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 978 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 979 | if (!ptr_instance->wsi_xcb_surface_enabled) { |
Ian Elliott | 469ea4a | 2016-03-24 15:49:02 -0600 | [diff] [blame] | 980 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 981 | "VK_KHR_xcb_surface extension not enabled. " |
| 982 | "vkCreateXcbSurfaceKHR not executed!\n"); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 983 | vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; |
| 984 | goto out; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 985 | } |
| 986 | |
| 987 | // Next, if so, proceed with the implementation of this function: |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 988 | pIcdSurface = AllocateIcdSurfaceStruct(ptr_instance, |
| 989 | sizeof(pIcdSurface->xcb_surf.base), |
| 990 | sizeof(pIcdSurface->xcb_surf), true); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 991 | if (pIcdSurface == NULL) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 992 | vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; |
| 993 | goto out; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 994 | } |
| 995 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 996 | pIcdSurface->xcb_surf.base.platform = VK_ICD_WSI_PLATFORM_XCB; |
| 997 | pIcdSurface->xcb_surf.connection = pCreateInfo->connection; |
| 998 | pIcdSurface->xcb_surf.window = pCreateInfo->window; |
| 999 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1000 | // Loop through each ICD and determine if they need to create a surface |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1001 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; |
| 1002 | icd_term != NULL; icd_term = icd_term->next, i++) { |
| 1003 | if (icd_term->scanned_icd->interface_version >= |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1004 | ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1005 | if (NULL != icd_term->CreateXcbSurfaceKHR) { |
| 1006 | vkRes = icd_term->CreateXcbSurfaceKHR( |
| 1007 | icd_term->instance, pCreateInfo, pAllocator, |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1008 | &pIcdSurface->real_icd_surfaces[i]); |
| 1009 | if (VK_SUCCESS != vkRes) { |
| 1010 | goto out; |
| 1011 | } |
| 1012 | } |
| 1013 | } |
| 1014 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1015 | |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 1016 | *pSurface = (VkSurfaceKHR)pIcdSurface; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1017 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1018 | out: |
| 1019 | |
| 1020 | if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { |
| 1021 | if (NULL != pIcdSurface->real_icd_surfaces) { |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 1022 | i = 0; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1023 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; |
| 1024 | icd_term != NULL; icd_term = icd_term->next, i++) { |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 1025 | if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1026 | NULL != icd_term->DestroySurfaceKHR) { |
| 1027 | icd_term->DestroySurfaceKHR( |
| 1028 | icd_term->instance, pIcdSurface->real_icd_surfaces[i], |
| 1029 | pAllocator); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1030 | } |
| 1031 | } |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 1032 | loader_instance_heap_free(ptr_instance, |
| 1033 | pIcdSurface->real_icd_surfaces); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1034 | } |
| 1035 | loader_instance_heap_free(ptr_instance, pIcdSurface); |
| 1036 | } |
| 1037 | |
| 1038 | return vkRes; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1039 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 1040 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1041 | // This is the trampoline entrypoint for |
| 1042 | // GetPhysicalDeviceXcbPresentationSupportKHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1043 | LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL |
| 1044 | vkGetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice, |
| 1045 | uint32_t queueFamilyIndex, |
| 1046 | xcb_connection_t *connection, |
| 1047 | xcb_visualid_t visual_id) { |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 1048 | VkPhysicalDevice unwrapped_phys_dev = |
| 1049 | loader_unwrap_physical_device(physicalDevice); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 1050 | const VkLayerInstanceDispatchTable *disp; |
| 1051 | disp = loader_get_instance_dispatch(physicalDevice); |
| 1052 | VkBool32 res = disp->GetPhysicalDeviceXcbPresentationSupportKHR( |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 1053 | unwrapped_phys_dev, queueFamilyIndex, connection, visual_id); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 1054 | return res; |
| 1055 | } |
| 1056 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1057 | // This is the instance chain terminator function for |
| 1058 | // GetPhysicalDeviceXcbPresentationSupportKHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1059 | VKAPI_ATTR VkBool32 VKAPI_CALL |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 1060 | terminator_GetPhysicalDeviceXcbPresentationSupportKHR( |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1061 | VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, |
| 1062 | xcb_connection_t *connection, xcb_visualid_t visual_id) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1063 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1064 | // First, check to ensure the appropriate extension was enabled: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1065 | struct loader_physical_device_term *phys_dev_term = |
| 1066 | (struct loader_physical_device_term *)physicalDevice; |
| 1067 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1068 | struct loader_instance *ptr_instance = |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1069 | (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1070 | if (!ptr_instance->wsi_xcb_surface_enabled) { |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 1071 | loader_log( |
| 1072 | ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1073 | "VK_KHR_xcb_surface extension not enabled. " |
| 1074 | "vkGetPhysicalDeviceXcbPresentationSupportKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1075 | return VK_SUCCESS; |
| 1076 | } |
| 1077 | |
| 1078 | // Next, if so, proceed with the implementation of this function: |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1079 | assert( |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1080 | icd_term->GetPhysicalDeviceXcbPresentationSupportKHR && |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1081 | "loader: null GetPhysicalDeviceXcbPresentationSupportKHR ICD pointer"); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 1082 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1083 | return icd_term->GetPhysicalDeviceXcbPresentationSupportKHR( |
| 1084 | phys_dev_term->phys_dev, queueFamilyIndex, connection, visual_id); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 1085 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1086 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 1087 | |
| 1088 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
| 1089 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1090 | // Functions for the VK_KHR_xlib_surface extension: |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1091 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1092 | // This is the trampoline entrypoint for CreateXlibSurfaceKHR |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 1093 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR( |
| 1094 | VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo, |
| 1095 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 1096 | const VkLayerInstanceDispatchTable *disp; |
| 1097 | disp = loader_get_instance_dispatch(instance); |
| 1098 | VkResult res; |
| 1099 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1100 | res = |
| 1101 | disp->CreateXlibSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); |
Jon Ashburn | 16edfa6 | 2015-11-25 17:55:49 -0700 | [diff] [blame] | 1102 | return res; |
| 1103 | } |
| 1104 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1105 | // This is the instance chain terminator function for CreateXlibSurfaceKHR |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 1106 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXlibSurfaceKHR( |
| 1107 | VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo, |
| 1108 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1109 | VkResult vkRes = VK_SUCCESS; |
Mark Young | d7fb159 | 2016-10-12 14:18:44 -0600 | [diff] [blame] | 1110 | VkIcdSurface *pIcdSurface = NULL; |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 1111 | uint32_t i = 0; |
| 1112 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1113 | // First, check to ensure the appropriate extension was enabled: |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 1114 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1115 | if (!ptr_instance->wsi_xlib_surface_enabled) { |
Ian Elliott | 469ea4a | 2016-03-24 15:49:02 -0600 | [diff] [blame] | 1116 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1117 | "VK_KHR_xlib_surface extension not enabled. " |
| 1118 | "vkCreateXlibSurfaceKHR not executed!\n"); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1119 | vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; |
| 1120 | goto out; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1121 | } |
| 1122 | |
| 1123 | // Next, if so, proceed with the implementation of this function: |
Mark Young | d7fb159 | 2016-10-12 14:18:44 -0600 | [diff] [blame] | 1124 | pIcdSurface = AllocateIcdSurfaceStruct( |
Mark Young | f27962c | 2016-09-16 10:18:42 -0600 | [diff] [blame] | 1125 | ptr_instance, sizeof(pIcdSurface->xlib_surf.base), |
| 1126 | sizeof(pIcdSurface->xlib_surf), true); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1127 | if (pIcdSurface == NULL) { |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1128 | vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; |
| 1129 | goto out; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1130 | } |
| 1131 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1132 | pIcdSurface->xlib_surf.base.platform = VK_ICD_WSI_PLATFORM_XLIB; |
| 1133 | pIcdSurface->xlib_surf.dpy = pCreateInfo->dpy; |
| 1134 | pIcdSurface->xlib_surf.window = pCreateInfo->window; |
| 1135 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1136 | // Loop through each ICD and determine if they need to create a surface |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1137 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; |
| 1138 | icd_term != NULL; icd_term = icd_term->next, i++) { |
| 1139 | if (icd_term->scanned_icd->interface_version >= |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1140 | ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1141 | if (NULL != icd_term->CreateXlibSurfaceKHR) { |
| 1142 | vkRes = icd_term->CreateXlibSurfaceKHR( |
| 1143 | icd_term->instance, pCreateInfo, pAllocator, |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1144 | &pIcdSurface->real_icd_surfaces[i]); |
| 1145 | if (VK_SUCCESS != vkRes) { |
| 1146 | goto out; |
| 1147 | } |
| 1148 | } |
| 1149 | } |
| 1150 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1151 | |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 1152 | *pSurface = (VkSurfaceKHR)pIcdSurface; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1153 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1154 | out: |
| 1155 | |
| 1156 | if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { |
| 1157 | if (NULL != pIcdSurface->real_icd_surfaces) { |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 1158 | i = 0; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1159 | for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; |
| 1160 | icd_term != NULL; icd_term = icd_term->next, i++) { |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 1161 | if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1162 | NULL != icd_term->DestroySurfaceKHR) { |
| 1163 | icd_term->DestroySurfaceKHR( |
| 1164 | icd_term->instance, pIcdSurface->real_icd_surfaces[i], |
| 1165 | pAllocator); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1166 | } |
| 1167 | } |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 1168 | loader_instance_heap_free(ptr_instance, |
| 1169 | pIcdSurface->real_icd_surfaces); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1170 | } |
| 1171 | loader_instance_heap_free(ptr_instance, pIcdSurface); |
| 1172 | } |
| 1173 | |
| 1174 | return vkRes; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1175 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 1176 | |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 1177 | // This is the trampoline entrypoint for |
| 1178 | // GetPhysicalDeviceXlibPresentationSupportKHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1179 | LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL |
| 1180 | vkGetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice, |
| 1181 | uint32_t queueFamilyIndex, |
| 1182 | Display *dpy, VisualID visualID) { |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 1183 | VkPhysicalDevice unwrapped_phys_dev = |
| 1184 | loader_unwrap_physical_device(physicalDevice); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 1185 | const VkLayerInstanceDispatchTable *disp; |
| 1186 | disp = loader_get_instance_dispatch(physicalDevice); |
| 1187 | VkBool32 res = disp->GetPhysicalDeviceXlibPresentationSupportKHR( |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 1188 | unwrapped_phys_dev, queueFamilyIndex, dpy, visualID); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 1189 | return res; |
| 1190 | } |
| 1191 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1192 | // This is the instance chain terminator function for |
| 1193 | // GetPhysicalDeviceXlibPresentationSupportKHR |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1194 | VKAPI_ATTR VkBool32 VKAPI_CALL |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 1195 | terminator_GetPhysicalDeviceXlibPresentationSupportKHR( |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1196 | VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display *dpy, |
| 1197 | VisualID visualID) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1198 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1199 | // First, check to ensure the appropriate extension was enabled: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1200 | struct loader_physical_device_term *phys_dev_term = |
| 1201 | (struct loader_physical_device_term *)physicalDevice; |
| 1202 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1203 | struct loader_instance *ptr_instance = |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1204 | (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1205 | if (!ptr_instance->wsi_xlib_surface_enabled) { |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 1206 | loader_log( |
| 1207 | ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1208 | "VK_KHR_xlib_surface extension not enabled. " |
| 1209 | "vkGetPhysicalDeviceXlibPresentationSupportKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1210 | return VK_SUCCESS; |
| 1211 | } |
| 1212 | |
| 1213 | // Next, if so, proceed with the implementation of this function: |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1214 | assert( |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1215 | icd_term->GetPhysicalDeviceXlibPresentationSupportKHR && |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1216 | "loader: null GetPhysicalDeviceXlibPresentationSupportKHR ICD pointer"); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 1217 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1218 | return icd_term->GetPhysicalDeviceXlibPresentationSupportKHR( |
| 1219 | phys_dev_term->phys_dev, queueFamilyIndex, dpy, visualID); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 1220 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1221 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 1222 | |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 1223 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1224 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1225 | // Functions for the VK_KHR_android_surface extension: |
| 1226 | |
| 1227 | // This is the trampoline entrypoint for CreateAndroidSurfaceKHR |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 1228 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR( |
| 1229 | VkInstance instance, ANativeWindow *window, |
| 1230 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 1231 | const VkLayerInstanceDispatchTable *disp; |
| 1232 | disp = loader_get_instance_dispatch(instance); |
| 1233 | VkResult res; |
| 1234 | |
| 1235 | res = disp->CreateAndroidSurfaceKHR(instance, window, pAllocator, pSurface); |
| 1236 | return res; |
| 1237 | } |
| 1238 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1239 | // This is the instance chain terminator function for CreateAndroidSurfaceKHR |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 1240 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateAndroidSurfaceKHR( |
| 1241 | VkInstance instance, Window window, const VkAllocationCallbacks *pAllocator, |
| 1242 | VkSurfaceKHR *pSurface) { |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1243 | // First, check to ensure the appropriate extension was enabled: |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 1244 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1245 | if (!ptr_instance->wsi_display_enabled) { |
Ian Elliott | 469ea4a | 2016-03-24 15:49:02 -0600 | [diff] [blame] | 1246 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1247 | "VK_KHR_display extension not enabled. " |
| 1248 | "vkCreateAndroidSurfaceKHR not executed!\n"); |
Jeremy Hayes | 0231e1c | 2016-06-14 11:50:02 -0600 | [diff] [blame] | 1249 | return VK_ERROR_EXTENSION_NOT_PRESENT; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1250 | } |
| 1251 | |
| 1252 | // Next, if so, proceed with the implementation of this function: |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1253 | VkIcdSurfaceAndroid *pIcdSurface = |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 1254 | loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceAndroid), |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1255 | VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 1256 | if (pIcdSurface == NULL) { |
| 1257 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 1258 | } |
| 1259 | |
| 1260 | pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_ANDROID; |
| 1261 | pIcdSurface->dpy = dpy; |
| 1262 | pIcdSurface->window = window; |
| 1263 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1264 | *pSurface = (VkSurfaceKHR)pIcdSurface; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 1265 | |
| 1266 | return VK_SUCCESS; |
| 1267 | } |
| 1268 | |
| 1269 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1270 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1271 | // Functions for the VK_KHR_display instance extension: |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1272 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 1273 | vkGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, |
| 1274 | uint32_t *pPropertyCount, |
| 1275 | VkDisplayPropertiesKHR *pProperties) { |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1276 | VkPhysicalDevice unwrapped_phys_dev = |
| 1277 | loader_unwrap_physical_device(physicalDevice); |
| 1278 | const VkLayerInstanceDispatchTable *disp; |
| 1279 | disp = loader_get_instance_dispatch(physicalDevice); |
| 1280 | VkResult res = disp->GetPhysicalDeviceDisplayPropertiesKHR( |
| 1281 | unwrapped_phys_dev, pPropertyCount, pProperties); |
| 1282 | return res; |
| 1283 | } |
| 1284 | |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 1285 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPropertiesKHR( |
| 1286 | VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, |
| 1287 | VkDisplayPropertiesKHR *pProperties) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1288 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1289 | // First, check to ensure the appropriate extension was enabled: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1290 | struct loader_physical_device_term *phys_dev_term = |
| 1291 | (struct loader_physical_device_term *)physicalDevice; |
| 1292 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1293 | struct loader_instance *ptr_instance = |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1294 | (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1295 | if (!ptr_instance->wsi_display_enabled) { |
Ian Elliott | 469ea4a | 2016-03-24 15:49:02 -0600 | [diff] [blame] | 1296 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1297 | "VK_KHR_display extension not enabled. " |
| 1298 | "vkGetPhysicalDeviceDisplayPropertiesKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1299 | return VK_SUCCESS; |
| 1300 | } |
| 1301 | |
| 1302 | // Next, if so, proceed with the implementation of this function: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1303 | assert(icd_term->GetPhysicalDeviceDisplayPropertiesKHR && |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 1304 | "loader: null GetPhysicalDeviceDisplayPropertiesKHR ICD pointer"); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1305 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1306 | return icd_term->GetPhysicalDeviceDisplayPropertiesKHR( |
| 1307 | phys_dev_term->phys_dev, pPropertyCount, pProperties); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1308 | } |
| 1309 | |
| 1310 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
| 1311 | vkGetPhysicalDeviceDisplayPlanePropertiesKHR( |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 1312 | VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, |
| 1313 | VkDisplayPlanePropertiesKHR *pProperties) { |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1314 | VkPhysicalDevice unwrapped_phys_dev = |
| 1315 | loader_unwrap_physical_device(physicalDevice); |
| 1316 | const VkLayerInstanceDispatchTable *disp; |
| 1317 | disp = loader_get_instance_dispatch(physicalDevice); |
| 1318 | VkResult res = disp->GetPhysicalDeviceDisplayPlanePropertiesKHR( |
| 1319 | unwrapped_phys_dev, pPropertyCount, pProperties); |
| 1320 | return res; |
| 1321 | } |
| 1322 | |
| 1323 | VKAPI_ATTR VkResult VKAPI_CALL |
| 1324 | terminator_GetPhysicalDeviceDisplayPlanePropertiesKHR( |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 1325 | VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, |
| 1326 | VkDisplayPlanePropertiesKHR *pProperties) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1327 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1328 | // First, check to ensure the appropriate extension was enabled: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1329 | struct loader_physical_device_term *phys_dev_term = |
| 1330 | (struct loader_physical_device_term *)physicalDevice; |
| 1331 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1332 | struct loader_instance *ptr_instance = |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1333 | (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1334 | if (!ptr_instance->wsi_display_enabled) { |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 1335 | loader_log( |
| 1336 | ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1337 | "VK_KHR_display extension not enabled. " |
| 1338 | "vkGetPhysicalDeviceDisplayPlanePropertiesKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1339 | return VK_SUCCESS; |
| 1340 | } |
| 1341 | |
| 1342 | // Next, if so, proceed with the implementation of this function: |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1343 | assert( |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1344 | icd_term->GetPhysicalDeviceDisplayPlanePropertiesKHR && |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1345 | "loader: null GetPhysicalDeviceDisplayPlanePropertiesKHR ICD pointer"); |
| 1346 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1347 | return icd_term->GetPhysicalDeviceDisplayPlanePropertiesKHR( |
| 1348 | phys_dev_term->phys_dev, pPropertyCount, pProperties); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1349 | } |
| 1350 | |
| 1351 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 1352 | vkGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, |
| 1353 | uint32_t planeIndex, |
| 1354 | uint32_t *pDisplayCount, |
| 1355 | VkDisplayKHR *pDisplays) { |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1356 | VkPhysicalDevice unwrapped_phys_dev = |
| 1357 | loader_unwrap_physical_device(physicalDevice); |
| 1358 | const VkLayerInstanceDispatchTable *disp; |
| 1359 | disp = loader_get_instance_dispatch(physicalDevice); |
| 1360 | VkResult res = disp->GetDisplayPlaneSupportedDisplaysKHR( |
| 1361 | unwrapped_phys_dev, planeIndex, pDisplayCount, pDisplays); |
| 1362 | return res; |
| 1363 | } |
| 1364 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1365 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneSupportedDisplaysKHR( |
| 1366 | VkPhysicalDevice physicalDevice, uint32_t planeIndex, |
| 1367 | uint32_t *pDisplayCount, VkDisplayKHR *pDisplays) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1368 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1369 | // First, check to ensure the appropriate extension was enabled: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1370 | struct loader_physical_device_term *phys_dev_term = |
| 1371 | (struct loader_physical_device_term *)physicalDevice; |
| 1372 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1373 | struct loader_instance *ptr_instance = |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1374 | (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1375 | if (!ptr_instance->wsi_display_enabled) { |
Ian Elliott | 469ea4a | 2016-03-24 15:49:02 -0600 | [diff] [blame] | 1376 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1377 | "VK_KHR_display extension not enabled. " |
| 1378 | "vkGetDisplayPlaneSupportedDisplaysKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1379 | return VK_SUCCESS; |
| 1380 | } |
| 1381 | |
| 1382 | // Next, if so, proceed with the implementation of this function: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1383 | assert(icd_term->GetDisplayPlaneSupportedDisplaysKHR && |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 1384 | "loader: null GetDisplayPlaneSupportedDisplaysKHR ICD pointer"); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1385 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1386 | return icd_term->GetDisplayPlaneSupportedDisplaysKHR( |
| 1387 | phys_dev_term->phys_dev, planeIndex, pDisplayCount, pDisplays); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1388 | } |
| 1389 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1390 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayModePropertiesKHR( |
| 1391 | VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 1392 | uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) { |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1393 | VkPhysicalDevice unwrapped_phys_dev = |
| 1394 | loader_unwrap_physical_device(physicalDevice); |
| 1395 | const VkLayerInstanceDispatchTable *disp; |
| 1396 | disp = loader_get_instance_dispatch(physicalDevice); |
| 1397 | VkResult res = disp->GetDisplayModePropertiesKHR( |
| 1398 | unwrapped_phys_dev, display, pPropertyCount, pProperties); |
| 1399 | return res; |
| 1400 | } |
| 1401 | |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 1402 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayModePropertiesKHR( |
| 1403 | VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 1404 | uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1405 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1406 | // First, check to ensure the appropriate extension was enabled: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1407 | struct loader_physical_device_term *phys_dev_term = |
| 1408 | (struct loader_physical_device_term *)physicalDevice; |
| 1409 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1410 | struct loader_instance *ptr_instance = |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1411 | (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1412 | if (!ptr_instance->wsi_display_enabled) { |
Ian Elliott | 469ea4a | 2016-03-24 15:49:02 -0600 | [diff] [blame] | 1413 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1414 | "VK_KHR_display extension not enabled. " |
| 1415 | "vkGetDisplayModePropertiesKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1416 | return VK_SUCCESS; |
| 1417 | } |
| 1418 | |
| 1419 | // Next, if so, proceed with the implementation of this function: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1420 | assert(icd_term->GetDisplayModePropertiesKHR && |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 1421 | "loader: null GetDisplayModePropertiesKHR ICD pointer"); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1422 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1423 | return icd_term->GetDisplayModePropertiesKHR( |
| 1424 | phys_dev_term->phys_dev, display, pPropertyCount, pProperties); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1425 | } |
| 1426 | |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 1427 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayModeKHR( |
| 1428 | VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 1429 | const VkDisplayModeCreateInfoKHR *pCreateInfo, |
| 1430 | const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) { |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1431 | VkPhysicalDevice unwrapped_phys_dev = |
| 1432 | loader_unwrap_physical_device(physicalDevice); |
| 1433 | const VkLayerInstanceDispatchTable *disp; |
| 1434 | disp = loader_get_instance_dispatch(physicalDevice); |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 1435 | VkResult res = disp->CreateDisplayModeKHR(unwrapped_phys_dev, display, |
| 1436 | pCreateInfo, pAllocator, pMode); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1437 | return res; |
| 1438 | } |
| 1439 | |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 1440 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayModeKHR( |
| 1441 | VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 1442 | const VkDisplayModeCreateInfoKHR *pCreateInfo, |
| 1443 | const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1444 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1445 | // First, check to ensure the appropriate extension was enabled: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1446 | struct loader_physical_device_term *phys_dev_term = |
| 1447 | (struct loader_physical_device_term *)physicalDevice; |
| 1448 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1449 | struct loader_instance *ptr_instance = |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1450 | (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1451 | if (!ptr_instance->wsi_display_enabled) { |
Ian Elliott | 469ea4a | 2016-03-24 15:49:02 -0600 | [diff] [blame] | 1452 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1453 | "VK_KHR_display extension not enabled. " |
| 1454 | "vkCreateDisplayModeKHR not executed!\n"); |
Jeremy Hayes | 0231e1c | 2016-06-14 11:50:02 -0600 | [diff] [blame] | 1455 | return VK_ERROR_EXTENSION_NOT_PRESENT; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1456 | } |
| 1457 | |
| 1458 | // Next, if so, proceed with the implementation of this function: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1459 | assert(icd_term->CreateDisplayModeKHR && |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 1460 | "loader: null CreateDisplayModeKHR ICD pointer"); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1461 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1462 | return icd_term->CreateDisplayModeKHR(phys_dev_term->phys_dev, display, |
| 1463 | pCreateInfo, pAllocator, pMode); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1464 | } |
| 1465 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1466 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneCapabilitiesKHR( |
| 1467 | VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex, |
| 1468 | VkDisplayPlaneCapabilitiesKHR *pCapabilities) { |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1469 | VkPhysicalDevice unwrapped_phys_dev = |
| 1470 | loader_unwrap_physical_device(physicalDevice); |
| 1471 | const VkLayerInstanceDispatchTable *disp; |
| 1472 | disp = loader_get_instance_dispatch(physicalDevice); |
| 1473 | VkResult res = disp->GetDisplayPlaneCapabilitiesKHR( |
| 1474 | unwrapped_phys_dev, mode, planeIndex, pCapabilities); |
| 1475 | return res; |
| 1476 | } |
| 1477 | |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 1478 | VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneCapabilitiesKHR( |
| 1479 | VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex, |
| 1480 | VkDisplayPlaneCapabilitiesKHR *pCapabilities) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1481 | |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1482 | // First, check to ensure the appropriate extension was enabled: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1483 | struct loader_physical_device_term *phys_dev_term = |
| 1484 | (struct loader_physical_device_term *)physicalDevice; |
| 1485 | struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1486 | struct loader_instance *ptr_instance = |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1487 | (struct loader_instance *)icd_term->this_instance; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1488 | if (!ptr_instance->wsi_display_enabled) { |
Ian Elliott | 469ea4a | 2016-03-24 15:49:02 -0600 | [diff] [blame] | 1489 | loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1490 | "VK_KHR_display extension not enabled. " |
| 1491 | "vkGetDisplayPlaneCapabilitiesKHR not executed!\n"); |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1492 | return VK_SUCCESS; |
| 1493 | } |
| 1494 | |
| 1495 | // Next, if so, proceed with the implementation of this function: |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1496 | assert(icd_term->GetDisplayPlaneCapabilitiesKHR && |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 1497 | "loader: null GetDisplayPlaneCapabilitiesKHR ICD pointer"); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1498 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1499 | return icd_term->GetDisplayPlaneCapabilitiesKHR( |
| 1500 | phys_dev_term->phys_dev, mode, planeIndex, pCapabilities); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1501 | } |
| 1502 | |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 1503 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayPlaneSurfaceKHR( |
| 1504 | VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, |
| 1505 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1506 | const VkLayerInstanceDispatchTable *disp; |
| 1507 | disp = loader_get_instance_dispatch(instance); |
| 1508 | VkResult res; |
| 1509 | |
| 1510 | res = disp->CreateDisplayPlaneSurfaceKHR(instance, pCreateInfo, pAllocator, |
| 1511 | pSurface); |
| 1512 | return res; |
| 1513 | } |
| 1514 | |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 1515 | VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR( |
| 1516 | VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, |
| 1517 | const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1518 | struct loader_instance *inst = loader_get_instance(instance); |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1519 | VkIcdSurface *pIcdSurface = NULL; |
Mark Young | f06def9 | 2016-11-01 19:20:41 -0600 | [diff] [blame] | 1520 | VkResult vkRes = VK_SUCCESS; |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 1521 | uint32_t i = 0; |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1522 | |
Mark Young | f06def9 | 2016-11-01 19:20:41 -0600 | [diff] [blame] | 1523 | if (!inst->wsi_display_enabled) { |
Petros Bantolas | f309586 | 2016-04-14 12:50:42 +0100 | [diff] [blame] | 1524 | loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, |
| 1525 | "VK_KHR_surface extension not enabled. " |
| 1526 | "vkCreateDisplayPlaneSurfaceKHR not executed!\n"); |
Mark Young | f06def9 | 2016-11-01 19:20:41 -0600 | [diff] [blame] | 1527 | vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; |
| 1528 | goto out; |
Petros Bantolas | f309586 | 2016-04-14 12:50:42 +0100 | [diff] [blame] | 1529 | } |
| 1530 | |
Mark Young | f27962c | 2016-09-16 10:18:42 -0600 | [diff] [blame] | 1531 | // The VK_KHR_display path will continue to use the old path (hence the |
| 1532 | // false as the last parameter). |
| 1533 | pIcdSurface = |
| 1534 | AllocateIcdSurfaceStruct(inst, sizeof(pIcdSurface->display_surf.base), |
| 1535 | sizeof(pIcdSurface->display_surf), false); |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1536 | if (pIcdSurface == NULL) { |
Mark Young | f06def9 | 2016-11-01 19:20:41 -0600 | [diff] [blame] | 1537 | vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; |
| 1538 | goto out; |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1539 | } |
| 1540 | |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 1541 | pIcdSurface->display_surf.base.platform = VK_ICD_WSI_PLATFORM_DISPLAY; |
| 1542 | pIcdSurface->display_surf.displayMode = pCreateInfo->displayMode; |
| 1543 | pIcdSurface->display_surf.planeIndex = pCreateInfo->planeIndex; |
| 1544 | pIcdSurface->display_surf.planeStackIndex = pCreateInfo->planeStackIndex; |
| 1545 | pIcdSurface->display_surf.transform = pCreateInfo->transform; |
| 1546 | pIcdSurface->display_surf.globalAlpha = pCreateInfo->globalAlpha; |
| 1547 | pIcdSurface->display_surf.alphaMode = pCreateInfo->alphaMode; |
| 1548 | pIcdSurface->display_surf.imageExtent = pCreateInfo->imageExtent; |
| 1549 | |
Mark Young | f06def9 | 2016-11-01 19:20:41 -0600 | [diff] [blame] | 1550 | // Loop through each ICD and determine if they need to create a surface |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1551 | for (struct loader_icd_term *icd_term = inst->icd_terms; icd_term != NULL; |
| 1552 | icd_term = icd_term->next, i++) { |
| 1553 | if (icd_term->scanned_icd->interface_version >= |
Mark Young | f06def9 | 2016-11-01 19:20:41 -0600 | [diff] [blame] | 1554 | ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1555 | if (NULL != icd_term->CreateDisplayPlaneSurfaceKHR) { |
| 1556 | vkRes = icd_term->CreateDisplayPlaneSurfaceKHR( |
| 1557 | icd_term->instance, pCreateInfo, pAllocator, |
Mark Young | f06def9 | 2016-11-01 19:20:41 -0600 | [diff] [blame] | 1558 | &pIcdSurface->real_icd_surfaces[i]); |
| 1559 | if (VK_SUCCESS != vkRes) { |
| 1560 | goto out; |
| 1561 | } |
| 1562 | } |
| 1563 | } |
| 1564 | } |
| 1565 | |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 1566 | *pSurface = (VkSurfaceKHR)pIcdSurface; |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1567 | |
Mark Young | f06def9 | 2016-11-01 19:20:41 -0600 | [diff] [blame] | 1568 | out: |
| 1569 | |
| 1570 | if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { |
| 1571 | if (NULL != pIcdSurface->real_icd_surfaces) { |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 1572 | i = 0; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1573 | for (struct loader_icd_term *icd_term = inst->icd_terms; |
| 1574 | icd_term != NULL; icd_term = icd_term->next, i++) { |
Mark Young | 3eda588 | 2016-12-01 10:42:21 -0700 | [diff] [blame] | 1575 | if ((VkSurfaceKHR)NULL != pIcdSurface->real_icd_surfaces[i] && |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 1576 | NULL != icd_term->DestroySurfaceKHR) { |
| 1577 | icd_term->DestroySurfaceKHR( |
| 1578 | icd_term->instance, pIcdSurface->real_icd_surfaces[i], |
| 1579 | pAllocator); |
Mark Young | f06def9 | 2016-11-01 19:20:41 -0600 | [diff] [blame] | 1580 | } |
| 1581 | } |
| 1582 | loader_instance_heap_free(inst, pIcdSurface->real_icd_surfaces); |
| 1583 | } |
| 1584 | loader_instance_heap_free(inst, pIcdSurface); |
| 1585 | } |
| 1586 | |
| 1587 | return vkRes; |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1588 | } |
| 1589 | |
Mark Young | f2eabea | 2016-07-01 15:18:27 -0600 | [diff] [blame] | 1590 | // This is the trampoline entrypoint |
| 1591 | // for CreateSharedSwapchainsKHR |
| 1592 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR( |
| 1593 | VkDevice device, uint32_t swapchainCount, |
| 1594 | const VkSwapchainCreateInfoKHR *pCreateInfos, |
| 1595 | const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchains) { |
Mark Young | 2a2122f | 2016-09-08 18:36:32 -0600 | [diff] [blame] | 1596 | const VkLayerDispatchTable *disp; |
| 1597 | disp = loader_get_dispatch(device); |
Mark Young | 573a7a1 | 2016-11-02 09:37:08 -0600 | [diff] [blame] | 1598 | return disp->CreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, |
| 1599 | pAllocator, pSwapchains); |
Mark Young | f2eabea | 2016-07-01 15:18:27 -0600 | [diff] [blame] | 1600 | } |
| 1601 | |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 1602 | bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1603 | const char *name, void **addr) { |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 1604 | *addr = NULL; |
| 1605 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1606 | // Functions for the VK_KHR_surface extension: |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1607 | if (!strcmp("vkDestroySurfaceKHR", name)) { |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1608 | *addr = ptr_instance->wsi_surface_enabled ? (void *)vkDestroySurfaceKHR |
| 1609 | : NULL; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1610 | return true; |
| 1611 | } |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 1612 | if (!strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", name)) { |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1613 | *addr = ptr_instance->wsi_surface_enabled |
| 1614 | ? (void *)vkGetPhysicalDeviceSurfaceSupportKHR |
| 1615 | : NULL; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 1616 | return true; |
| 1617 | } |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 1618 | if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", name)) { |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1619 | *addr = ptr_instance->wsi_surface_enabled |
| 1620 | ? (void *)vkGetPhysicalDeviceSurfaceCapabilitiesKHR |
| 1621 | : NULL; |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 1622 | return true; |
| 1623 | } |
| 1624 | if (!strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", name)) { |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1625 | *addr = ptr_instance->wsi_surface_enabled |
| 1626 | ? (void *)vkGetPhysicalDeviceSurfaceFormatsKHR |
| 1627 | : NULL; |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 1628 | return true; |
| 1629 | } |
| 1630 | if (!strcmp("vkGetPhysicalDeviceSurfacePresentModesKHR", name)) { |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1631 | *addr = ptr_instance->wsi_surface_enabled |
| 1632 | ? (void *)vkGetPhysicalDeviceSurfacePresentModesKHR |
| 1633 | : NULL; |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 1634 | return true; |
| 1635 | } |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 1636 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1637 | // Functions for the VK_KHR_swapchain extension: |
| 1638 | |
| 1639 | // Note: This is a device extension, and its functions are statically |
| 1640 | // exported from the loader. Per Khronos decisions, the loader's GIPA |
| 1641 | // function will return the trampoline function for such device-extension |
| 1642 | // functions, regardless of whether the extension has been enabled. |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 1643 | if (!strcmp("vkCreateSwapchainKHR", name)) { |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1644 | *addr = (void *)vkCreateSwapchainKHR; |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 1645 | return true; |
| 1646 | } |
| 1647 | if (!strcmp("vkDestroySwapchainKHR", name)) { |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1648 | *addr = (void *)vkDestroySwapchainKHR; |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 1649 | return true; |
| 1650 | } |
| 1651 | if (!strcmp("vkGetSwapchainImagesKHR", name)) { |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1652 | *addr = (void *)vkGetSwapchainImagesKHR; |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 1653 | return true; |
| 1654 | } |
| 1655 | if (!strcmp("vkAcquireNextImageKHR", name)) { |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1656 | *addr = (void *)vkAcquireNextImageKHR; |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 1657 | return true; |
| 1658 | } |
| 1659 | if (!strcmp("vkQueuePresentKHR", name)) { |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1660 | *addr = (void *)vkQueuePresentKHR; |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 1661 | return true; |
| 1662 | } |
| 1663 | |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1664 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1665 | |
| 1666 | // Functions for the VK_KHR_win32_surface extension: |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1667 | if (!strcmp("vkCreateWin32SurfaceKHR", name)) { |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1668 | *addr = ptr_instance->wsi_win32_surface_enabled |
| 1669 | ? (void *)vkCreateWin32SurfaceKHR |
| 1670 | : NULL; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1671 | return true; |
| 1672 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 1673 | if (!strcmp("vkGetPhysicalDeviceWin32PresentationSupportKHR", name)) { |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1674 | *addr = ptr_instance->wsi_win32_surface_enabled |
| 1675 | ? (void *)vkGetPhysicalDeviceWin32PresentationSupportKHR |
| 1676 | : NULL; |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 1677 | return true; |
| 1678 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1679 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1680 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1681 | |
| 1682 | // Functions for the VK_KHR_mir_surface extension: |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1683 | if (!strcmp("vkCreateMirSurfaceKHR", name)) { |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1684 | *addr = ptr_instance->wsi_mir_surface_enabled |
| 1685 | ? (void *)vkCreateMirSurfaceKHR |
| 1686 | : NULL; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1687 | return true; |
| 1688 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 1689 | if (!strcmp("vkGetPhysicalDeviceMirPresentationSupportKHR", name)) { |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1690 | *addr = ptr_instance->wsi_mir_surface_enabled |
| 1691 | ? (void *)vkGetPhysicalDeviceMirPresentationSupportKHR |
| 1692 | : NULL; |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 1693 | return true; |
Jason Ekstrand | 3bfebc9 | 2016-02-12 17:25:03 -0800 | [diff] [blame] | 1694 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1695 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 1696 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1697 | |
| 1698 | // Functions for the VK_KHR_wayland_surface extension: |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 1699 | if (!strcmp("vkCreateWaylandSurfaceKHR", name)) { |
| 1700 | *addr = ptr_instance->wsi_wayland_surface_enabled |
| 1701 | ? (void *)vkCreateWaylandSurfaceKHR |
| 1702 | : NULL; |
| 1703 | return true; |
| 1704 | } |
| 1705 | if (!strcmp("vkGetPhysicalDeviceWaylandPresentationSupportKHR", name)) { |
| 1706 | *addr = ptr_instance->wsi_wayland_surface_enabled |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 1707 | ? (void *)vkGetPhysicalDeviceWaylandPresentationSupportKHR |
| 1708 | : NULL; |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 1709 | return true; |
| 1710 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1711 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 1712 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1713 | |
| 1714 | // Functions for the VK_KHR_xcb_surface extension: |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 1715 | if (!strcmp("vkCreateXcbSurfaceKHR", name)) { |
| 1716 | *addr = ptr_instance->wsi_xcb_surface_enabled |
| 1717 | ? (void *)vkCreateXcbSurfaceKHR |
| 1718 | : NULL; |
| 1719 | return true; |
| 1720 | } |
| 1721 | if (!strcmp("vkGetPhysicalDeviceXcbPresentationSupportKHR", name)) { |
| 1722 | *addr = ptr_instance->wsi_xcb_surface_enabled |
| 1723 | ? (void *)vkGetPhysicalDeviceXcbPresentationSupportKHR |
| 1724 | : NULL; |
| 1725 | return true; |
| 1726 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1727 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 1728 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1729 | |
| 1730 | // Functions for the VK_KHR_xlib_surface extension: |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 1731 | if (!strcmp("vkCreateXlibSurfaceKHR", name)) { |
| 1732 | *addr = ptr_instance->wsi_xlib_surface_enabled |
| 1733 | ? (void *)vkCreateXlibSurfaceKHR |
| 1734 | : NULL; |
| 1735 | return true; |
| 1736 | } |
| 1737 | if (!strcmp("vkGetPhysicalDeviceXlibPresentationSupportKHR", name)) { |
| 1738 | *addr = ptr_instance->wsi_xlib_surface_enabled |
| 1739 | ? (void *)vkGetPhysicalDeviceXlibPresentationSupportKHR |
| 1740 | : NULL; |
| 1741 | return true; |
| 1742 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1743 | #endif // VK_USE_PLATFORM_XLIB_KHR |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 1744 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1745 | |
| 1746 | // Functions for the VK_KHR_android_surface extension: |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 1747 | if (!strcmp("vkCreateAndroidSurfaceKHR", name)) { |
| 1748 | *addr = ptr_instance->wsi_xlib_surface_enabled |
| 1749 | ? (void *)vkCreateAndroidSurfaceKHR |
| 1750 | : NULL; |
| 1751 | return true; |
| 1752 | } |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 1753 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 1754 | |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 1755 | // Functions for VK_KHR_display extension: |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 1756 | if (!strcmp("vkGetPhysicalDeviceDisplayPropertiesKHR", name)) { |
| 1757 | *addr = ptr_instance->wsi_display_enabled |
| 1758 | ? (void *)vkGetPhysicalDeviceDisplayPropertiesKHR |
| 1759 | : NULL; |
| 1760 | return true; |
| 1761 | } |
| 1762 | if (!strcmp("vkGetPhysicalDeviceDisplayPlanePropertiesKHR", name)) { |
| 1763 | *addr = ptr_instance->wsi_display_enabled |
| 1764 | ? (void *)vkGetPhysicalDeviceDisplayPlanePropertiesKHR |
| 1765 | : NULL; |
| 1766 | return true; |
| 1767 | } |
| 1768 | if (!strcmp("vkGetDisplayPlaneSupportedDisplaysKHR", name)) { |
| 1769 | *addr = ptr_instance->wsi_display_enabled |
| 1770 | ? (void *)vkGetDisplayPlaneSupportedDisplaysKHR |
| 1771 | : NULL; |
| 1772 | return true; |
| 1773 | } |
| 1774 | if (!strcmp("vkGetDisplayModePropertiesKHR", name)) { |
| 1775 | *addr = ptr_instance->wsi_display_enabled |
| 1776 | ? (void *)vkGetDisplayModePropertiesKHR |
| 1777 | : NULL; |
| 1778 | return true; |
| 1779 | } |
| 1780 | if (!strcmp("vkCreateDisplayModeKHR", name)) { |
| 1781 | *addr = ptr_instance->wsi_display_enabled |
| 1782 | ? (void *)vkCreateDisplayModeKHR |
| 1783 | : NULL; |
| 1784 | return true; |
| 1785 | } |
| 1786 | if (!strcmp("vkGetDisplayPlaneCapabilitiesKHR", name)) { |
| 1787 | *addr = ptr_instance->wsi_display_enabled |
| 1788 | ? (void *)vkGetDisplayPlaneCapabilitiesKHR |
| 1789 | : NULL; |
| 1790 | return true; |
| 1791 | } |
| 1792 | if (!strcmp("vkCreateDisplayPlaneSurfaceKHR", name)) { |
| 1793 | *addr = ptr_instance->wsi_display_enabled |
| 1794 | ? (void *)vkCreateDisplayPlaneSurfaceKHR |
| 1795 | : NULL; |
| 1796 | return true; |
| 1797 | } |
Mark Young | f2eabea | 2016-07-01 15:18:27 -0600 | [diff] [blame] | 1798 | |
| 1799 | // Functions for KHR_display_swapchain extension: |
| 1800 | if (!strcmp("vkCreateSharedSwapchainsKHR", name)) { |
| 1801 | *addr = (void *)vkCreateSharedSwapchainsKHR; |
| 1802 | return true; |
| 1803 | } |
| 1804 | |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 1805 | return false; |
Ian Elliott | 0d4ffa3 | 2016-03-24 13:59:22 -0600 | [diff] [blame] | 1806 | } |