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