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