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