Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright (C) 2015 Valve Corporation |
| 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | * copy of this software and associated documentation files (the "Software"), |
| 7 | * to deal in the Software without restriction, including without limitation |
| 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | * and/or sell copies of the Software, and to permit persons to whom the |
| 10 | * Software is furnished to do so, subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice shall be included |
| 13 | * in all copies or substantial portions of the Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 21 | * DEALINGS IN THE SOFTWARE. |
| 22 | * |
| 23 | * Author: Ian Elliott <ian@lunarg.com> |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 24 | * Author: Ian Elliott <ianelliott@google.com> |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 25 | */ |
| 26 | |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 27 | // FIXME/TODO: DEVELOP A BETTER APPROACH FOR SETTING THE DEFAULT VALUES FOR |
| 28 | // THESE PLATFORM-SPECIFIC MACROS APPROPRIATELY: |
| 29 | #ifdef _WIN32 |
| 30 | // The Win32 default is to support the WIN32 platform: |
| 31 | #ifndef VK_USE_PLATFORM_WIN32_KHR |
| 32 | #define VK_USE_PLATFORM_WIN32_KHR |
| 33 | #endif |
| 34 | #else // _WIN32 (i.e. Linux) |
| 35 | // The Linux default is to support the XCB platform: |
| 36 | #if (!defined(VK_USE_PLATFORM_MIR_KHR) && \ |
| 37 | !defined(VK_USE_PLATFORM_WAYLAND_KHR) && \ |
| 38 | !defined(VK_USE_PLATFORM_XCB_KHR) && \ |
| 39 | !defined(VK_USE_PLATFORM_XLIB_KHR)) |
| 40 | #define VK_USE_PLATFORM_XCB_KHR |
| 41 | #endif |
| 42 | #endif // _WIN32 |
| 43 | |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 44 | //#define _ISOC11_SOURCE /* for aligned_alloc() */ |
| 45 | #define _GNU_SOURCE |
| 46 | #include <stdlib.h> |
| 47 | #include <string.h> |
| 48 | #include "vk_loader_platform.h" |
| 49 | #include "loader.h" |
| 50 | #include "wsi.h" |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 51 | #include <vulkan/vk_icd.h> |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 52 | |
| 53 | static const VkExtensionProperties wsi_surface_extension_info = { |
| 54 | .extensionName = VK_KHR_SURFACE_EXTENSION_NAME, |
| 55 | .specVersion = VK_KHR_SURFACE_REVISION, |
| 56 | }; |
| 57 | |
| 58 | #ifdef _WIN32 |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 59 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 60 | static const VkExtensionProperties wsi_win32_surface_extension_info = { |
| 61 | .extensionName = VK_KHR_WIN32_SURFACE_EXTENSION_NAME, |
| 62 | .specVersion = VK_KHR_WIN32_SURFACE_REVISION, |
| 63 | }; |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 64 | #endif/ VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 65 | #else // _WIN32 |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 66 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 67 | static const VkExtensionProperties wsi_mir_surface_extension_info = { |
| 68 | .extensionName = VK_KHR_MIR_SURFACE_EXTENSION_NAME, |
| 69 | .specVersion = VK_KHR_MIR_SURFACE_REVISION, |
| 70 | }; |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 71 | #endif // VK_USE_PLATFORM_MIR_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 72 | |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 73 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 74 | static const VkExtensionProperties wsi_wayland_surface_extension_info = { |
| 75 | .extensionName = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, |
| 76 | .specVersion = VK_KHR_WAYLAND_SURFACE_REVISION, |
| 77 | }; |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 78 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 79 | |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 80 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 81 | static const VkExtensionProperties wsi_xcb_surface_extension_info = { |
| 82 | .extensionName = VK_KHR_XCB_SURFACE_EXTENSION_NAME, |
| 83 | .specVersion = VK_KHR_XCB_SURFACE_REVISION, |
| 84 | }; |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 85 | #endif // VK_USE_PLATFORM_XCB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 86 | |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 87 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 88 | static const VkExtensionProperties wsi_xlib_surface_extension_info = { |
| 89 | .extensionName = VK_KHR_XLIB_SURFACE_EXTENSION_NAME, |
| 90 | .specVersion = VK_KHR_XLIB_SURFACE_REVISION, |
| 91 | }; |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 92 | #endif // VK_USE_PLATFORM_XLIB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 93 | #endif // _WIN32 |
| 94 | |
| 95 | void wsi_add_instance_extensions( |
| 96 | const struct loader_instance *inst, |
| 97 | struct loader_extension_list *ext_list) |
| 98 | { |
| 99 | loader_add_to_ext_list(inst, ext_list, 1, &wsi_surface_extension_info); |
| 100 | #ifdef _WIN32 |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 101 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 102 | loader_add_to_ext_list(inst, ext_list, 1, &wsi_win32_surface_extension_info); |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 103 | #endif/ VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 104 | #else // _WIN32 |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 105 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 106 | loader_add_to_ext_list(inst, ext_list, 1, &wsi_mir_surface_extension_info); |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 107 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 108 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 109 | loader_add_to_ext_list(inst, ext_list, 1, &wsi_wayland_surface_extension_info); |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 110 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 111 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 112 | loader_add_to_ext_list(inst, ext_list, 1, &wsi_xcb_surface_extension_info); |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 113 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 114 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 115 | loader_add_to_ext_list(inst, ext_list, 1, &wsi_xlib_surface_extension_info); |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 116 | #endif // VK_USE_PLATFORM_XLIB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 117 | #endif // _WIN32 |
| 118 | } |
| 119 | |
| 120 | void wsi_create_instance( |
| 121 | struct loader_instance *ptr_instance, |
| 122 | const VkInstanceCreateInfo *pCreateInfo) |
| 123 | { |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 124 | ptr_instance->wsi_surface_enabled = false; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 125 | #ifdef _WIN32 |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 126 | ptr_instance->wsi_win32_surface_enabled = true; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 127 | #else // _WIN32 |
| 128 | ptr_instance->wsi_mir_surface_enabled = false; |
| 129 | ptr_instance->wsi_wayland_surface_enabled = false; |
| 130 | ptr_instance->wsi_xcb_surface_enabled = false; |
| 131 | ptr_instance->wsi_xlib_surface_enabled = false; |
| 132 | #endif // _WIN32 |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 133 | |
| 134 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) { |
| 135 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0) { |
| 136 | ptr_instance->wsi_surface_enabled = true; |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 137 | continue; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 138 | } |
| 139 | #ifdef _WIN32 |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 140 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 141 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) { |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 142 | ptr_instance->wsi_win32_surface_enabled = true; |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 143 | continue; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 144 | } |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 145 | #endif/ VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 146 | #else // _WIN32 |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 147 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 148 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) { |
| 149 | ptr_instance->wsi_mir_surface_enabled = true; |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 150 | continue; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 151 | } |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 152 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 153 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 154 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) { |
| 155 | ptr_instance->wsi_wayland_surface_enabled = true; |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 156 | continue; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 157 | } |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 158 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 159 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 160 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) { |
| 161 | ptr_instance->wsi_xcb_surface_enabled = true; |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 162 | continue; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 163 | } |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 164 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 165 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 166 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) { |
| 167 | ptr_instance->wsi_xlib_surface_enabled = true; |
Ian Elliott | b184974 | 2015-11-19 11:58:08 -0700 | [diff] [blame] | 168 | continue; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 169 | } |
Ian Elliott | 5fb891a | 2015-10-30 17:45:05 -0600 | [diff] [blame] | 170 | #endif // VK_USE_PLATFORM_XLIB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 171 | #endif // _WIN32 |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | /* |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 176 | * Functions for the VK_KHR_surface extension: |
| 177 | */ |
| 178 | |
| 179 | /* |
| 180 | * This is the trampoline entrypoint |
| 181 | * for DestroySurfaceKHR |
| 182 | * |
| 183 | * Note: There is no terminator for this function. |
| 184 | */ |
| 185 | LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR( |
| 186 | VkInstance instance, |
| 187 | VkSurfaceKHR surface, |
| 188 | const VkAllocationCallbacks* pAllocator) |
| 189 | { |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 190 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
| 191 | |
| 192 | loader_heap_free(ptr_instance, surface); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | /* |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 196 | * This is the trampoline entrypoint |
| 197 | * for GetPhysicalDeviceSurfaceSupportKHR |
| 198 | */ |
Ian Elliott | f3be00f | 2015-11-19 12:37:51 -0700 | [diff] [blame] | 199 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR( |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 200 | VkPhysicalDevice physicalDevice, |
| 201 | uint32_t queueFamilyIndex, |
| 202 | VkSurfaceKHR surface, |
| 203 | VkBool32* pSupported) |
| 204 | { |
| 205 | const VkLayerInstanceDispatchTable *disp; |
| 206 | disp = loader_get_instance_dispatch(physicalDevice); |
| 207 | VkResult res = disp->GetPhysicalDeviceSurfaceSupportKHR( |
| 208 | physicalDevice, |
| 209 | queueFamilyIndex, |
| 210 | surface, |
| 211 | pSupported); |
| 212 | return res; |
| 213 | } |
| 214 | |
| 215 | /* |
| 216 | * This is the instance chain terminator function |
| 217 | * for GetPhysicalDeviceSurfaceSupportKHR |
| 218 | */ |
| 219 | VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceSurfaceSupportKHR( |
| 220 | VkPhysicalDevice physicalDevice, |
| 221 | uint32_t queueFamilyIndex, |
| 222 | VkSurfaceKHR surface, |
| 223 | VkBool32* pSupported) |
| 224 | { |
| 225 | struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice; |
| 226 | struct loader_icd *icd = phys_dev->this_icd; |
| 227 | |
| 228 | assert(pSupported && "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported"); |
| 229 | *pSupported = false; |
| 230 | |
| 231 | assert(icd->GetPhysicalDeviceSurfaceSupportKHR && "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer"); |
| 232 | |
| 233 | return icd->GetPhysicalDeviceSurfaceSupportKHR(phys_dev->phys_dev, |
| 234 | queueFamilyIndex, |
| 235 | surface, |
| 236 | pSupported); |
| 237 | } |
| 238 | |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 239 | /* |
| 240 | * This is the trampoline entrypoint |
| 241 | * for GetPhysicalDeviceSurfaceCapabilitiesKHR |
| 242 | */ |
| 243 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR( |
| 244 | VkPhysicalDevice physicalDevice, |
| 245 | VkSurfaceKHR surface, |
| 246 | VkSurfaceCapabilitiesKHR* pSurfaceCapabilities) |
| 247 | { |
| 248 | const VkLayerInstanceDispatchTable *disp; |
| 249 | disp = loader_get_instance_dispatch(physicalDevice); |
| 250 | VkResult res = disp->GetPhysicalDeviceSurfaceCapabilitiesKHR( |
| 251 | physicalDevice, |
| 252 | surface, |
| 253 | pSurfaceCapabilities); |
| 254 | return res; |
| 255 | } |
| 256 | |
| 257 | /* |
| 258 | * This is the instance chain terminator function |
| 259 | * for GetPhysicalDeviceSurfaceCapabilitiesKHR |
| 260 | */ |
| 261 | VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceSurfaceCapabilitiesKHR( |
| 262 | VkPhysicalDevice physicalDevice, |
| 263 | VkSurfaceKHR surface, |
| 264 | VkSurfaceCapabilitiesKHR* pSurfaceCapabilities) |
| 265 | { |
| 266 | struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice; |
| 267 | struct loader_icd *icd = phys_dev->this_icd; |
| 268 | |
| 269 | assert(pSurfaceCapabilities && "GetPhysicalDeviceSurfaceCapabilitiesKHR: Error, null pSurfaceCapabilities"); |
| 270 | |
| 271 | assert(icd->GetPhysicalDeviceSurfaceCapabilitiesKHR && "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer"); |
| 272 | |
| 273 | return icd->GetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev->phys_dev, |
| 274 | surface, |
| 275 | pSurfaceCapabilities); |
| 276 | } |
| 277 | |
| 278 | /* |
| 279 | * This is the trampoline entrypoint |
| 280 | * for GetPhysicalDeviceSurfaceFormatsKHR |
| 281 | */ |
| 282 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR( |
| 283 | VkPhysicalDevice physicalDevice, |
| 284 | VkSurfaceKHR surface, |
| 285 | uint32_t* pSurfaceFormatCount, |
| 286 | VkSurfaceFormatKHR* pSurfaceFormats) |
| 287 | { |
| 288 | const VkLayerInstanceDispatchTable *disp; |
| 289 | disp = loader_get_instance_dispatch(physicalDevice); |
| 290 | VkResult res = disp->GetPhysicalDeviceSurfaceFormatsKHR( |
| 291 | physicalDevice, |
| 292 | surface, |
| 293 | pSurfaceFormatCount, |
| 294 | pSurfaceFormats); |
| 295 | return res; |
| 296 | } |
| 297 | |
| 298 | /* |
| 299 | * This is the instance chain terminator function |
| 300 | * for GetPhysicalDeviceSurfaceFormatsKHR |
| 301 | */ |
| 302 | VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceSurfaceFormatsKHR( |
| 303 | VkPhysicalDevice physicalDevice, |
| 304 | VkSurfaceKHR surface, |
| 305 | uint32_t* pSurfaceFormatCount, |
| 306 | VkSurfaceFormatKHR* pSurfaceFormats) |
| 307 | { |
| 308 | struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice; |
| 309 | struct loader_icd *icd = phys_dev->this_icd; |
| 310 | |
| 311 | assert(pSurfaceFormatCount && "GetPhysicalDeviceSurfaceFormatsKHR: Error, null pSurfaceFormatCount"); |
| 312 | |
| 313 | assert(icd->GetPhysicalDeviceSurfaceFormatsKHR && "loader: null GetPhysicalDeviceSurfaceFormatsKHR ICD pointer"); |
| 314 | |
| 315 | return icd->GetPhysicalDeviceSurfaceFormatsKHR(phys_dev->phys_dev, |
| 316 | surface, |
| 317 | pSurfaceFormatCount, |
| 318 | pSurfaceFormats); |
| 319 | } |
| 320 | |
| 321 | /* |
| 322 | * This is the trampoline entrypoint |
| 323 | * for GetPhysicalDeviceSurfacePresentModesKHR |
| 324 | */ |
| 325 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 326 | VkPhysicalDevice physicalDevice, |
| 327 | VkSurfaceKHR surface, |
| 328 | uint32_t* pPresentModeCount, |
| 329 | VkPresentModeKHR* pPresentModes) |
| 330 | { |
| 331 | const VkLayerInstanceDispatchTable *disp; |
| 332 | disp = loader_get_instance_dispatch(physicalDevice); |
| 333 | VkResult res = disp->GetPhysicalDeviceSurfacePresentModesKHR( |
| 334 | physicalDevice, |
| 335 | surface, |
| 336 | pPresentModeCount, |
| 337 | pPresentModes); |
| 338 | return res; |
| 339 | } |
| 340 | |
| 341 | /* |
| 342 | * This is the instance chain terminator function |
| 343 | * for GetPhysicalDeviceSurfacePresentModesKHR |
| 344 | */ |
| 345 | VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceSurfacePresentModesKHR( |
| 346 | VkPhysicalDevice physicalDevice, |
| 347 | VkSurfaceKHR surface, |
| 348 | uint32_t* pPresentModeCount, |
| 349 | VkPresentModeKHR* pPresentModes) |
| 350 | { |
| 351 | struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice; |
| 352 | struct loader_icd *icd = phys_dev->this_icd; |
| 353 | |
| 354 | assert(pPresentModeCount && "GetPhysicalDeviceSurfacePresentModesKHR: Error, null pPresentModeCount"); |
| 355 | |
| 356 | assert(icd->GetPhysicalDeviceSurfacePresentModesKHR && "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer"); |
| 357 | |
| 358 | return icd->GetPhysicalDeviceSurfacePresentModesKHR(phys_dev->phys_dev, |
| 359 | surface, |
| 360 | pPresentModeCount, |
| 361 | pPresentModes); |
| 362 | } |
| 363 | |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 364 | |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 365 | /* |
| 366 | * Functions for the VK_KHR_swapchain extension: |
| 367 | */ |
| 368 | |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 369 | /* |
| 370 | * This is the trampoline entrypoint |
| 371 | * for CreateSwapchainKHR |
| 372 | */ |
| 373 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR( |
| 374 | VkDevice device, |
| 375 | const VkSwapchainCreateInfoKHR* pCreateInfo, |
| 376 | const VkAllocationCallbacks* pAllocator, |
| 377 | VkSwapchainKHR* pSwapchain) |
| 378 | { |
| 379 | const VkLayerDispatchTable *disp; |
| 380 | disp = loader_get_dispatch(device); |
| 381 | VkResult res = disp->CreateSwapchainKHR( |
| 382 | device, |
| 383 | pCreateInfo, |
| 384 | pAllocator, |
| 385 | pSwapchain); |
| 386 | return res; |
| 387 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 388 | |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 389 | /* |
| 390 | * This is the trampoline entrypoint |
| 391 | * for DestroySwapchainKHR |
| 392 | */ |
| 393 | LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR( |
| 394 | VkDevice device, |
| 395 | VkSwapchainKHR swapchain, |
| 396 | const VkAllocationCallbacks* pAllocator) |
| 397 | { |
| 398 | const VkLayerDispatchTable *disp; |
| 399 | disp = loader_get_dispatch(device); |
| 400 | disp->DestroySwapchainKHR(device, swapchain, pAllocator); |
| 401 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 402 | |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 403 | /* |
| 404 | * This is the trampoline entrypoint |
| 405 | * for GetSwapchainImagesKHR |
| 406 | */ |
| 407 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR( |
| 408 | VkDevice device, |
| 409 | VkSwapchainKHR swapchain, |
| 410 | uint32_t* pSwapchainImageCount, |
| 411 | VkImage* pSwapchainImages) |
| 412 | { |
| 413 | const VkLayerDispatchTable *disp; |
| 414 | disp = loader_get_dispatch(device); |
| 415 | VkResult res = disp->GetSwapchainImagesKHR( |
| 416 | device, |
| 417 | swapchain, |
| 418 | pSwapchainImageCount, |
| 419 | pSwapchainImages); |
| 420 | return res; |
| 421 | } |
| 422 | |
| 423 | /* |
| 424 | * This is the trampoline entrypoint |
| 425 | * for AcquireNextImageKHR |
| 426 | */ |
| 427 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR( |
| 428 | VkDevice device, |
| 429 | VkSwapchainKHR swapchain, |
| 430 | uint64_t timeout, |
| 431 | VkSemaphore semaphore, |
| 432 | VkFence fence, |
| 433 | uint32_t* pImageIndex) |
| 434 | { |
| 435 | const VkLayerDispatchTable *disp; |
| 436 | disp = loader_get_dispatch(device); |
| 437 | VkResult res = disp->AcquireNextImageKHR( |
| 438 | device, |
| 439 | swapchain, |
| 440 | timeout, |
| 441 | semaphore, |
| 442 | fence, |
| 443 | pImageIndex); |
| 444 | return res; |
| 445 | } |
| 446 | |
| 447 | /* |
| 448 | * This is the trampoline entrypoint |
| 449 | * for QueuePresentKHR |
| 450 | */ |
| 451 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR( |
| 452 | VkQueue queue, |
| 453 | const VkPresentInfoKHR* pPresentInfo) |
| 454 | { |
| 455 | const VkLayerDispatchTable *disp; |
| 456 | disp = loader_get_dispatch(queue); |
| 457 | VkResult res = disp->QueuePresentKHR(queue, pPresentInfo); |
| 458 | return res; |
| 459 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 460 | |
| 461 | |
| 462 | #ifdef _WIN32 |
| 463 | |
| 464 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 465 | |
| 466 | /* |
| 467 | * Functions for the VK_KHR_win32_surface extension: |
| 468 | */ |
| 469 | |
| 470 | /* |
| 471 | * This is the trampoline entrypoint |
| 472 | * for CreateWin32SurfaceKHR |
| 473 | */ |
| 474 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR( |
| 475 | VkInstance instance, |
| 476 | HINSTANCE hinstance, |
| 477 | HWND hwnd, |
| 478 | const VkAllocationCallbacks* pAllocator, |
| 479 | VkSurfaceKHR* pSurface) |
| 480 | { |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 481 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 482 | VkIcdSurfaceWin32 *pIcdSurface = NULL; |
| 483 | |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 484 | pIcdSurface = loader_heap_alloc(ptr_instance, |
| 485 | sizeof(VkIcdSurfaceWin32), |
| 486 | VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 487 | if (pIcdSurface == NULL) { |
| 488 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 489 | } |
| 490 | |
| 491 | pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WIN32; |
| 492 | pIcdSurface->hinstance = hinstance; |
| 493 | pIcdSurface->hwnd = hwnd; |
| 494 | |
| 495 | *pSurface = (VkSurfaceKHR) pIcdSurface; |
| 496 | |
| 497 | return VK_SUCCESS; |
| 498 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 499 | |
| 500 | /* |
| 501 | * This is the trampoline entrypoint |
| 502 | * for GetPhysicalDeviceWin32PresentationSupportKHR |
| 503 | */ |
| 504 | LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR( |
| 505 | VkPhysicalDevice physicalDevice, |
| 506 | uint32_t queueFamilyIndex) |
| 507 | { |
| 508 | const VkLayerInstanceDispatchTable *disp; |
| 509 | disp = loader_get_instance_dispatch(physicalDevice); |
| 510 | VkBool32 res = disp->GetPhysicalDeviceWin32PresentationSupportKHR( |
| 511 | physicalDevice, |
| 512 | queueFamilyIndex); |
| 513 | return res; |
| 514 | } |
| 515 | |
| 516 | |
| 517 | /* |
| 518 | * This is the instance chain terminator function |
| 519 | * for GetPhysicalDeviceWin32PresentationSupportKHR |
| 520 | */ |
| 521 | VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceWin32PresentationSupportKHR( |
| 522 | VkPhysicalDevice physicalDevice, |
| 523 | uint32_t queueFamilyIndex) |
| 524 | { |
| 525 | struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice; |
| 526 | struct loader_icd *icd = phys_dev->this_icd; |
| 527 | |
Mark Lobodzinski | 3b8c149 | 2015-11-24 15:49:46 -0700 | [diff] [blame^] | 528 | assert(icd->GetPhysicalDeviceWin32PresentationSupportKHR && "loader: null GetPhysicalDeviceWin32PresentationSupportKHR ICD pointer"); |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 529 | |
| 530 | return icd->GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev->phys_dev, |
| 531 | queueFamilyIndex); |
| 532 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 533 | #endif/ VK_USE_PLATFORM_WIN32_KHR |
| 534 | |
| 535 | #else // _WIN32 (i.e. Linux) |
| 536 | |
| 537 | #ifdef VK_USE_PLATFORM_MIR_KHR |
| 538 | |
| 539 | /* |
| 540 | * Functions for the VK_KHR_mir_surface extension: |
| 541 | */ |
| 542 | |
| 543 | /* |
| 544 | * This is the trampoline entrypoint |
| 545 | * for CreateMirSurfaceKHR |
| 546 | */ |
| 547 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR( |
| 548 | VkInstance instance, |
| 549 | MirConnection* connection, |
| 550 | MirSurface* mirSurface, |
| 551 | const VkAllocationCallbacks* pAllocator, |
| 552 | VkSurfaceKHR* pSurface) |
| 553 | { |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 554 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 555 | VkIcdSurfaceMir *pIcdSurface = NULL; |
| 556 | |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 557 | pIcdSurface = loader_heap_alloc(ptr_instance, |
| 558 | sizeof(VkIcdSurfaceMir), |
| 559 | VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 560 | if (pIcdSurface == NULL) { |
| 561 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 562 | } |
| 563 | |
| 564 | pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_MIR; |
| 565 | pIcdSurface->connection = connection; |
| 566 | pIcdSurface->mirSurface = mirSurface; |
| 567 | |
| 568 | *pSurface = (VkSurfaceKHR) pIcdSurface; |
| 569 | |
| 570 | return VK_SUCCESS; |
| 571 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 572 | |
| 573 | /* |
| 574 | * This is the trampoline entrypoint |
| 575 | * for GetPhysicalDeviceMirPresentationSupportKHR |
| 576 | */ |
| 577 | LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceMirPresentationSupportKHR( |
| 578 | VkPhysicalDevice physicalDevice, |
| 579 | uint32_t queueFamilyIndex, |
| 580 | MirConnection* connection) |
| 581 | { |
| 582 | const VkLayerInstanceDispatchTable *disp; |
| 583 | disp = loader_get_instance_dispatch(physicalDevice); |
| 584 | VkBool32 res = disp->GetPhysicalDeviceMirPresentationSupportKHR( |
| 585 | physicalDevice, |
| 586 | queueFamilyIndex, |
| 587 | connection); |
| 588 | return res; |
| 589 | } |
| 590 | |
| 591 | |
| 592 | /* |
| 593 | * This is the instance chain terminator function |
| 594 | * for GetPhysicalDeviceMirPresentationSupportKHR |
| 595 | */ |
| 596 | VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceMirPresentationSupportKHR( |
| 597 | VkPhysicalDevice physicalDevice, |
| 598 | uint32_t queueFamilyIndex, |
| 599 | MirConnection* connection) |
| 600 | { |
| 601 | struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice; |
| 602 | struct loader_icd *icd = phys_dev->this_icd; |
| 603 | |
| 604 | assert(icd->GetPhysicalDeviceMirPresentationSupportKHR && "loader: null GetPhysicalDeviceMirPresentationSupportKHR ICD pointer"); |
| 605 | |
| 606 | return icd->GetPhysicalDeviceMirPresentationSupportKHR(phys_dev->phys_dev, |
| 607 | queueFamilyIndex, |
| 608 | connection); |
| 609 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 610 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 611 | |
| 612 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
| 613 | |
| 614 | /* |
| 615 | * Functions for the VK_KHR_wayland_surface extension: |
| 616 | */ |
| 617 | |
| 618 | /* |
| 619 | * This is the trampoline entrypoint |
| 620 | * for CreateWaylandSurfaceKHR |
| 621 | */ |
| 622 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR( |
| 623 | VkInstance instance, |
| 624 | struct wl_display* display, |
| 625 | struct wl_surface* surface, |
| 626 | const VkAllocationCallbacks* pAllocator, |
| 627 | VkSurfaceKHR* pSurface) |
| 628 | { |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 629 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 630 | VkIcdSurfaceWayland *pIcdSurface = NULL; |
| 631 | |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 632 | pIcdSurface = loader_heap_alloc(ptr_instance, |
| 633 | sizeof(VkIcdSurfaceWayland), |
| 634 | VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 635 | if (pIcdSurface == NULL) { |
| 636 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 637 | } |
| 638 | |
| 639 | pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WAYLAND; |
| 640 | pIcdSurface->display = display; |
| 641 | pIcdSurface->surface = surface; |
| 642 | |
| 643 | *pSurface = (VkSurfaceKHR) pIcdSurface; |
| 644 | |
| 645 | return VK_SUCCESS; |
| 646 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 647 | |
| 648 | /* |
| 649 | * This is the trampoline entrypoint |
| 650 | * for GetPhysicalDeviceWaylandPresentationSupportKHR |
| 651 | */ |
| 652 | LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR( |
| 653 | VkPhysicalDevice physicalDevice, |
| 654 | uint32_t queueFamilyIndex, |
| 655 | struct wl_display* display) |
| 656 | { |
| 657 | const VkLayerInstanceDispatchTable *disp; |
| 658 | disp = loader_get_instance_dispatch(physicalDevice); |
| 659 | VkBool32 res = disp->GetPhysicalDeviceWaylandPresentationSupportKHR( |
| 660 | physicalDevice, |
| 661 | queueFamilyIndex, |
| 662 | display); |
| 663 | return res; |
| 664 | } |
| 665 | |
| 666 | |
| 667 | /* |
| 668 | * This is the instance chain terminator function |
| 669 | * for GetPhysicalDeviceWaylandPresentationSupportKHR |
| 670 | */ |
| 671 | VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceWaylandPresentationSupportKHR( |
| 672 | VkPhysicalDevice physicalDevice, |
| 673 | uint32_t queueFamilyIndex, |
| 674 | struct wl_display* display) |
| 675 | { |
| 676 | struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice; |
| 677 | struct loader_icd *icd = phys_dev->this_icd; |
| 678 | |
| 679 | assert(icd->GetPhysicalDeviceWaylandPresentationSupportKHR && "loader: null GetPhysicalDeviceWaylandPresentationSupportKHR ICD pointer"); |
| 680 | |
| 681 | return icd->GetPhysicalDeviceWaylandPresentationSupportKHR(phys_dev->phys_dev, |
| 682 | queueFamilyIndex, |
| 683 | display); |
| 684 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 685 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 686 | |
| 687 | #ifdef VK_USE_PLATFORM_XCB_KHR |
| 688 | |
| 689 | /* |
| 690 | * Functions for the VK_KHR_xcb_surface extension: |
| 691 | */ |
| 692 | |
| 693 | /* |
| 694 | * This is the trampoline entrypoint |
| 695 | * for CreateXcbSurfaceKHR |
| 696 | */ |
| 697 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR( |
| 698 | VkInstance instance, |
| 699 | xcb_connection_t* connection, |
| 700 | xcb_window_t window, |
| 701 | const VkAllocationCallbacks* pAllocator, |
| 702 | VkSurfaceKHR* pSurface) |
| 703 | { |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 704 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 705 | VkIcdSurfaceXcb *pIcdSurface = NULL; |
| 706 | |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 707 | pIcdSurface = loader_heap_alloc(ptr_instance, |
| 708 | sizeof(VkIcdSurfaceXcb), |
| 709 | VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 710 | if (pIcdSurface == NULL) { |
| 711 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 712 | } |
| 713 | |
| 714 | pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XCB; |
| 715 | pIcdSurface->connection = connection; |
| 716 | pIcdSurface->window = window; |
| 717 | |
| 718 | *pSurface = (VkSurfaceKHR) pIcdSurface; |
| 719 | |
| 720 | return VK_SUCCESS; |
| 721 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 722 | |
| 723 | /* |
| 724 | * This is the trampoline entrypoint |
| 725 | * for GetPhysicalDeviceXcbPresentationSupportKHR |
| 726 | */ |
| 727 | LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR( |
| 728 | VkPhysicalDevice physicalDevice, |
| 729 | uint32_t queueFamilyIndex, |
| 730 | xcb_connection_t* connection, |
| 731 | xcb_visualid_t visual_id) |
| 732 | { |
| 733 | const VkLayerInstanceDispatchTable *disp; |
| 734 | disp = loader_get_instance_dispatch(physicalDevice); |
| 735 | VkBool32 res = disp->GetPhysicalDeviceXcbPresentationSupportKHR( |
| 736 | physicalDevice, |
| 737 | queueFamilyIndex, |
| 738 | connection, |
| 739 | visual_id); |
| 740 | return res; |
| 741 | } |
| 742 | |
| 743 | |
| 744 | /* |
| 745 | * This is the instance chain terminator function |
| 746 | * for GetPhysicalDeviceXcbPresentationSupportKHR |
| 747 | */ |
| 748 | VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceXcbPresentationSupportKHR( |
| 749 | VkPhysicalDevice physicalDevice, |
| 750 | uint32_t queueFamilyIndex, |
| 751 | xcb_connection_t* connection, |
| 752 | xcb_visualid_t visual_id) |
| 753 | { |
| 754 | struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice; |
| 755 | struct loader_icd *icd = phys_dev->this_icd; |
| 756 | |
| 757 | assert(icd->GetPhysicalDeviceXcbPresentationSupportKHR && "loader: null GetPhysicalDeviceXcbPresentationSupportKHR ICD pointer"); |
| 758 | |
| 759 | return icd->GetPhysicalDeviceXcbPresentationSupportKHR(phys_dev->phys_dev, |
| 760 | queueFamilyIndex, |
| 761 | connection, |
| 762 | visual_id); |
| 763 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 764 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 765 | |
| 766 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
| 767 | |
| 768 | /* |
| 769 | * Functions for the VK_KHR_xlib_surface extension: |
| 770 | */ |
| 771 | |
| 772 | /* |
| 773 | * This is the trampoline entrypoint |
| 774 | * for CreateXlibSurfaceKHR |
| 775 | */ |
| 776 | LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR( |
| 777 | VkInstance instance, |
| 778 | Display* dpy, |
| 779 | Window window, |
| 780 | const VkAllocationCallbacks* pAllocator, |
| 781 | VkSurfaceKHR* pSurface) |
| 782 | { |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 783 | struct loader_instance *ptr_instance = loader_get_instance(instance); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 784 | VkIcdSurfaceXlib *pIcdSurface = NULL; |
| 785 | |
Ian Elliott | 1693f59 | 2015-11-23 10:17:23 -0700 | [diff] [blame] | 786 | pIcdSurface = loader_heap_alloc(ptr_instance, |
| 787 | sizeof(VkIcdSurfaceXlib), |
| 788 | VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 789 | if (pIcdSurface == NULL) { |
| 790 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
| 791 | } |
| 792 | |
| 793 | pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XLIB; |
| 794 | pIcdSurface->dpy = dpy; |
| 795 | pIcdSurface->window = window; |
| 796 | |
| 797 | *pSurface = (VkSurfaceKHR) pIcdSurface; |
| 798 | |
| 799 | return VK_SUCCESS; |
| 800 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 801 | |
| 802 | /* |
| 803 | * This is the trampoline entrypoint |
| 804 | * for GetPhysicalDeviceXlibPresentationSupportKHR |
| 805 | */ |
| 806 | LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR( |
| 807 | VkPhysicalDevice physicalDevice, |
| 808 | uint32_t queueFamilyIndex, |
| 809 | Display* dpy, |
| 810 | VisualID visualID) |
| 811 | { |
| 812 | const VkLayerInstanceDispatchTable *disp; |
| 813 | disp = loader_get_instance_dispatch(physicalDevice); |
| 814 | VkBool32 res = disp->GetPhysicalDeviceXlibPresentationSupportKHR( |
| 815 | physicalDevice, |
| 816 | queueFamilyIndex, |
| 817 | dpy, |
| 818 | visualID); |
| 819 | return res; |
| 820 | } |
| 821 | |
| 822 | |
| 823 | /* |
| 824 | * This is the instance chain terminator function |
| 825 | * for GetPhysicalDeviceXlibPresentationSupportKHR |
| 826 | */ |
| 827 | VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceXlibPresentationSupportKHR( |
| 828 | VkPhysicalDevice physicalDevice, |
| 829 | uint32_t queueFamilyIndex, |
| 830 | Display* dpy, |
| 831 | VisualID visualID) |
| 832 | { |
| 833 | struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice; |
| 834 | struct loader_icd *icd = phys_dev->this_icd; |
| 835 | |
| 836 | assert(icd->GetPhysicalDeviceXlibPresentationSupportKHR && "loader: null GetPhysicalDeviceXlibPresentationSupportKHR ICD pointer"); |
| 837 | |
| 838 | return icd->GetPhysicalDeviceXlibPresentationSupportKHR(phys_dev->phys_dev, |
| 839 | queueFamilyIndex, |
| 840 | dpy, |
| 841 | visualID); |
| 842 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 843 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 844 | |
| 845 | #endif // _WIN32 |
| 846 | |
| 847 | |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 848 | bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, |
| 849 | const char* name, void **addr) |
| 850 | { |
| 851 | *addr = NULL; |
| 852 | |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 853 | /* |
| 854 | * Functions for the VK_KHR_surface extension: |
| 855 | */ |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 856 | if (!strcmp("vkDestroySurfaceKHR", name)) { |
| 857 | *addr = ptr_instance->wsi_surface_enabled ? (void *) vkDestroySurfaceKHR : NULL; |
| 858 | return true; |
| 859 | } |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 860 | if (!strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", name)) { |
Ian Elliott | f3be00f | 2015-11-19 12:37:51 -0700 | [diff] [blame] | 861 | *addr = ptr_instance->wsi_surface_enabled ? (void *) vkGetPhysicalDeviceSurfaceSupportKHR : NULL; |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 862 | return true; |
| 863 | } |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 864 | if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", name)) { |
| 865 | *addr = ptr_instance->wsi_surface_enabled ? (void *) vkGetPhysicalDeviceSurfaceCapabilitiesKHR : NULL; |
| 866 | return true; |
| 867 | } |
| 868 | if (!strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", name)) { |
| 869 | *addr = ptr_instance->wsi_surface_enabled ? (void *) vkGetPhysicalDeviceSurfaceFormatsKHR : NULL; |
| 870 | return true; |
| 871 | } |
| 872 | if (!strcmp("vkGetPhysicalDeviceSurfacePresentModesKHR", name)) { |
| 873 | *addr = ptr_instance->wsi_surface_enabled ? (void *) vkGetPhysicalDeviceSurfacePresentModesKHR : NULL; |
| 874 | return true; |
| 875 | } |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 876 | |
| 877 | /* |
| 878 | * Functions for the VK_KHR_swapchain extension: |
| 879 | * |
| 880 | * Note: This is a device extension, and its functions are statically |
| 881 | * exported from the loader. Per Khronos decisions, the the loader's GIPA |
| 882 | * function will return the trampoline function for such device-extension |
| 883 | * functions, regardless of whether the extension has been enabled. |
| 884 | */ |
| 885 | if (!strcmp("vkCreateSwapchainKHR", name)) { |
| 886 | *addr = (void *) vkCreateSwapchainKHR; |
| 887 | return true; |
| 888 | } |
| 889 | if (!strcmp("vkDestroySwapchainKHR", name)) { |
| 890 | *addr = (void *) vkDestroySwapchainKHR; |
| 891 | return true; |
| 892 | } |
| 893 | if (!strcmp("vkGetSwapchainImagesKHR", name)) { |
| 894 | *addr = (void *) vkGetSwapchainImagesKHR; |
| 895 | return true; |
| 896 | } |
| 897 | if (!strcmp("vkAcquireNextImageKHR", name)) { |
| 898 | *addr = (void *) vkAcquireNextImageKHR; |
| 899 | return true; |
| 900 | } |
| 901 | if (!strcmp("vkQueuePresentKHR", name)) { |
| 902 | *addr = (void *) vkQueuePresentKHR; |
| 903 | return true; |
| 904 | } |
| 905 | |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 906 | #ifdef _WIN32 |
| 907 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 908 | /* |
| 909 | * Functions for the VK_KHR_win32_surface extension: |
| 910 | */ |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 911 | if (!strcmp("vkCreateWin32SurfaceKHR", name)) { |
| 912 | *addr = ptr_instance->wsi_win32_surface_enabled ? (void *) vkCreateWin32SurfaceKHR : NULL; |
| 913 | return true; |
| 914 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 915 | if (!strcmp("vkGetPhysicalDeviceWin32PresentationSupportKHR", name)) { |
| 916 | *addr = ptr_instance->wsi_win32_surface_enabled ? (void *) vkGetPhysicalDeviceWin32PresentationSupportKHR : NULL; |
| 917 | return true; |
| 918 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 919 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 920 | #else // _WIN32 (i.e. Linux) |
| 921 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 922 | /* |
| 923 | * Functions for the VK_KHR_mir_surface extension: |
| 924 | */ |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 925 | if (!strcmp("vkCreateMirSurfaceKHR", name)) { |
| 926 | *addr = ptr_instance->wsi_mir_surface_enabled ? (void *) vkCreateMirSurfaceKHR : NULL; |
| 927 | return true; |
| 928 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 929 | if (!strcmp("vkGetPhysicalDeviceMirPresentationSupportKHR", name)) { |
| 930 | *addr = ptr_instance->wsi_mir_surface_enabled ? (void *) vkGetPhysicalDeviceMirPresentationSupportKHR : NULL; |
| 931 | return true; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 932 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 933 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 934 | /* |
| 935 | * Functions for the VK_KHR_wayland_surface extension: |
| 936 | */ |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 937 | if (!strcmp("vkCreateWaylandSurfaceKHR", name)) { |
| 938 | *addr = ptr_instance->wsi_wayland_surface_enabled ? (void *) vkCreateWaylandSurfaceKHR : NULL; |
| 939 | return true; |
| 940 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 941 | if (!strcmp("vkGetPhysicalDeviceWaylandPresentationSupportKHR", name)) { |
| 942 | *addr = ptr_instance->wsi_wayland_surface_enabled ? (void *) vkGetPhysicalDeviceWaylandPresentationSupportKHR : NULL; |
| 943 | return true; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 944 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 945 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 946 | /* |
| 947 | * Functions for the VK_KHR_xcb_surface extension: |
| 948 | */ |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 949 | if (!strcmp("vkCreateXcbSurfaceKHR", name)) { |
| 950 | *addr = ptr_instance->wsi_xcb_surface_enabled ? (void *) vkCreateXcbSurfaceKHR : NULL; |
| 951 | return true; |
| 952 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 953 | if (!strcmp("vkGetPhysicalDeviceXcbPresentationSupportKHR", name)) { |
| 954 | *addr = ptr_instance->wsi_xcb_surface_enabled ? (void *) vkGetPhysicalDeviceXcbPresentationSupportKHR : NULL; |
| 955 | return true; |
| 956 | } |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 957 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 958 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Ian Elliott | 9b89a47 | 2015-11-19 16:39:21 -0700 | [diff] [blame] | 959 | /* |
| 960 | * Functions for the VK_KHR_xlib_surface extension: |
| 961 | */ |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 962 | if (!strcmp("vkCreateXlibSurfaceKHR", name)) { |
| 963 | *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *) vkCreateXlibSurfaceKHR : NULL; |
| 964 | return true; |
| 965 | } |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 966 | if (!strcmp("vkGetPhysicalDeviceXlibPresentationSupportKHR", name)) { |
| 967 | *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *) vkGetPhysicalDeviceXlibPresentationSupportKHR : NULL; |
| 968 | return true; |
Ian Elliott | 7c35255 | 2015-11-19 13:14:05 -0700 | [diff] [blame] | 969 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 970 | #endif // _WIN32 |
| 971 | |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 972 | return false; |
| 973 | } |