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