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