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