Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 1 | /* |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 2 | * |
Lenny Komow | 2a680fb | 2019-02-25 21:37:33 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014-2019 The Khronos Group Inc. |
| 4 | * Copyright (c) 2014-2019 Valve Corporation |
| 5 | * Copyright (c) 2014-2019 LunarG, Inc. |
Courtney Goeltzenleuchter | 8e1b8d9 | 2015-12-02 14:53:22 -0700 | [diff] [blame] | 6 | * Copyright (C) 2015 Google Inc. |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 7 | * |
Jon Ashburn | 4f80d67 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | * you may not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 11 | * |
Jon Ashburn | 4f80d67 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 12 | * http://www.apache.org/licenses/LICENSE-2.0 |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 13 | * |
Jon Ashburn | 4f80d67 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 14 | * Unless required by applicable law or agreed to in writing, software |
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | * See the License for the specific language governing permissions and |
| 18 | * limitations under the License. |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 19 | * |
| 20 | * Author: Jon Ashburn <jon@lunarg.com> |
| 21 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
Courtney Goeltzenleuchter | b9ce395 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 22 | * Author: Chia-I Wu <olvaffe@gmail.com> |
| 23 | * Author: Chia-I Wu <olv@lunarg.com> |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 24 | * Author: Mark Lobodzinski <mark@LunarG.com> |
Lenny Komow | 2a680fb | 2019-02-25 21:37:33 -0700 | [diff] [blame] | 25 | * Author: Lenny Komow <lenny@lunarg.com> |
Courtney Goeltzenleuchter | b9ce395 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 26 | * |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 27 | */ |
| 28 | |
| 29 | #ifndef LOADER_H |
| 30 | #define LOADER_H |
| 31 | |
David Pinedo | a503662 | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 32 | #include <vulkan/vulkan.h> |
Aaron Karp | 95c5f95 | 2016-03-13 16:41:59 -0400 | [diff] [blame] | 33 | #include "vk_loader_platform.h" |
Mark Lobodzinski | 663818f | 2016-05-24 16:04:56 -0600 | [diff] [blame] | 34 | #include "vk_loader_layer.h" |
David Pinedo | a503662 | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 35 | #include <vulkan/vk_layer.h> |
| 36 | #include <vulkan/vk_icd.h> |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 37 | #include <assert.h> |
Lenny Komow | 700483f | 2018-06-25 14:09:51 -0600 | [diff] [blame] | 38 | #include "vk_layer_dispatch_table.h" |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 39 | #include "vk_loader_extensions.h" |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 40 | |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 41 | #if defined(__GNUC__) && __GNUC__ >= 4 |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 42 | #define LOADER_EXPORT __attribute__((visibility("default"))) |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 43 | #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 44 | #define LOADER_EXPORT __attribute__((visibility("default"))) |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 45 | #else |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 46 | #define LOADER_EXPORT |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 47 | #endif |
| 48 | |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 49 | // A debug option to disable allocators at compile time to investigate future issues. |
| 50 | #define DEBUG_DISABLE_APP_ALLOCATORS 0 |
| 51 | |
Jon Ashburn | b2379c5 | 2015-08-04 10:22:33 -0600 | [diff] [blame] | 52 | #define MAX_STRING_SIZE 1024 |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 53 | |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 54 | // This is defined in vk_layer.h, but if there's problems we need to create the define |
| 55 | // here. |
| 56 | #ifndef MAX_NUM_UNKNOWN_EXTS |
| 57 | #define MAX_NUM_UNKNOWN_EXTS 250 |
| 58 | #endif |
| 59 | |
Mark Young | 74268f7 | 2017-05-02 10:49:46 -0600 | [diff] [blame] | 60 | enum layer_type_flags { |
| 61 | VK_LAYER_TYPE_FLAG_INSTANCE_LAYER = 0x1, // If not set, indicates Device layer |
| 62 | VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER = 0x2, // If not set, indicates Implicit layer |
| 63 | VK_LAYER_TYPE_FLAG_META_LAYER = 0x4, // If not set, indicates standard layer |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 64 | }; |
| 65 | |
Mark Lobodzinski | 8d32580 | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 66 | typedef enum VkStringErrorFlagBits { |
Jon Ashburn | b1cdf2e | 2016-02-10 20:50:19 -0700 | [diff] [blame] | 67 | VK_STRING_ERROR_NONE = 0x00000000, |
| 68 | VK_STRING_ERROR_LENGTH = 0x00000001, |
| 69 | VK_STRING_ERROR_BAD_DATA = 0x00000002, |
Charles Giessen | e8d7d88 | 2020-02-03 10:28:04 -0700 | [diff] [blame] | 70 | VK_STRING_ERROR_NULL_PTR = 0x00000004, |
Mark Lobodzinski | 8d32580 | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 71 | } VkStringErrorFlagBits; |
| 72 | typedef VkFlags VkStringErrorFlags; |
| 73 | |
Jon Ashburn | b1cdf2e | 2016-02-10 20:50:19 -0700 | [diff] [blame] | 74 | static const int MaxLoaderStringLength = 256; |
| 75 | static const char UTF8_ONE_BYTE_CODE = 0xC0; |
| 76 | static const char UTF8_ONE_BYTE_MASK = 0xE0; |
| 77 | static const char UTF8_TWO_BYTE_CODE = 0xE0; |
| 78 | static const char UTF8_TWO_BYTE_MASK = 0xF0; |
| 79 | static const char UTF8_THREE_BYTE_CODE = 0xF0; |
| 80 | static const char UTF8_THREE_BYTE_MASK = 0xF8; |
| 81 | static const char UTF8_DATA_BYTE_CODE = 0x80; |
| 82 | static const char UTF8_DATA_BYTE_MASK = 0xC0; |
Mark Lobodzinski | 8d32580 | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 83 | |
Jon Ashburn | 6b00b47 | 2015-12-10 08:51:10 -0700 | [diff] [blame] | 84 | // form of all dynamic lists/arrays |
| 85 | // only the list element should be changed |
| 86 | struct loader_generic_list { |
| 87 | size_t capacity; |
| 88 | uint32_t count; |
| 89 | void *list; |
| 90 | }; |
| 91 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 92 | struct loader_extension_list { |
| 93 | size_t capacity; |
| 94 | uint32_t count; |
Jon Ashburn | b7d327c | 2015-08-04 11:14:18 -0600 | [diff] [blame] | 95 | VkExtensionProperties *list; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 96 | }; |
| 97 | |
Jon Ashburn | 92cdb01 | 2015-12-10 18:17:34 -0700 | [diff] [blame] | 98 | struct loader_dev_ext_props { |
| 99 | VkExtensionProperties props; |
| 100 | uint32_t entrypoint_count; |
| 101 | char **entrypoints; |
| 102 | }; |
| 103 | |
| 104 | struct loader_device_extension_list { |
| 105 | size_t capacity; |
| 106 | uint32_t count; |
| 107 | struct loader_dev_ext_props *list; |
| 108 | }; |
| 109 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 110 | struct loader_name_value { |
Jon Ashburn | b2379c5 | 2015-08-04 10:22:33 -0600 | [diff] [blame] | 111 | char name[MAX_STRING_SIZE]; |
| 112 | char value[MAX_STRING_SIZE]; |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 113 | }; |
| 114 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 115 | struct loader_layer_functions { |
Jon Ashburn | b2379c5 | 2015-08-04 10:22:33 -0600 | [diff] [blame] | 116 | char str_gipa[MAX_STRING_SIZE]; |
| 117 | char str_gdpa[MAX_STRING_SIZE]; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 118 | char str_negotiate_interface[MAX_STRING_SIZE]; |
| 119 | PFN_vkNegotiateLoaderLayerInterfaceVersion negotiate_layer_interface; |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 120 | PFN_vkGetInstanceProcAddr get_instance_proc_addr; |
| 121 | PFN_vkGetDeviceProcAddr get_device_proc_addr; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 122 | PFN_GetPhysicalDeviceProcAddr get_physical_device_proc_addr; |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 123 | }; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 124 | |
Lenny Komow | 40761b0 | 2018-10-03 17:44:02 -0600 | [diff] [blame] | 125 | struct loader_override_expiration { |
| 126 | uint16_t year; |
| 127 | uint8_t month; |
| 128 | uint8_t day; |
| 129 | uint8_t hour; |
| 130 | uint8_t minute; |
| 131 | }; |
| 132 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 133 | struct loader_layer_properties { |
Courtney Goeltzenleuchter | 44667cc | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 134 | VkLayerProperties info; |
Mark Young | 74268f7 | 2017-05-02 10:49:46 -0600 | [diff] [blame] | 135 | enum layer_type_flags type_flags; |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 136 | uint32_t interface_version; // PFN_vkNegotiateLoaderLayerInterfaceVersion |
Jon Ashburn | b4c2423 | 2015-08-20 16:35:30 -0600 | [diff] [blame] | 137 | char lib_name[MAX_STRING_SIZE]; |
Jon Ashburn | d3cf955 | 2016-04-20 13:21:17 -0600 | [diff] [blame] | 138 | loader_platform_dl_handle lib_handle; |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 139 | struct loader_layer_functions functions; |
| 140 | struct loader_extension_list instance_extension_list; |
Jon Ashburn | 92cdb01 | 2015-12-10 18:17:34 -0700 | [diff] [blame] | 141 | struct loader_device_extension_list device_extension_list; |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 142 | struct loader_name_value disable_env_var; |
| 143 | struct loader_name_value enable_env_var; |
Mark Young | 74268f7 | 2017-05-02 10:49:46 -0600 | [diff] [blame] | 144 | uint32_t num_component_layers; |
| 145 | char (*component_layer_names)[MAX_STRING_SIZE]; |
Lenny Komow | e6b5494 | 2017-12-19 16:38:37 -0700 | [diff] [blame] | 146 | struct { |
| 147 | char enumerate_instance_extension_properties[MAX_STRING_SIZE]; |
| 148 | char enumerate_instance_layer_properties[MAX_STRING_SIZE]; |
Lenny Komow | 3b7c7f2 | 2018-02-13 15:58:47 -0700 | [diff] [blame] | 149 | char enumerate_instance_version[MAX_STRING_SIZE]; |
Lenny Komow | e6b5494 | 2017-12-19 16:38:37 -0700 | [diff] [blame] | 150 | } pre_instance_functions; |
Lenny Komow | 40761b0 | 2018-10-03 17:44:02 -0600 | [diff] [blame] | 151 | uint32_t num_override_paths; |
| 152 | char (*override_paths)[MAX_STRING_SIZE]; |
| 153 | bool is_override; |
| 154 | bool has_expiration; |
| 155 | struct loader_override_expiration expiration; |
| 156 | bool keep; |
Lenny Komow | 2a680fb | 2019-02-25 21:37:33 -0700 | [diff] [blame] | 157 | uint32_t num_blacklist_layers; |
| 158 | char (*blacklist_layer_names)[MAX_STRING_SIZE]; |
Charles Giessen | ead2b57 | 2019-10-28 14:15:11 -0600 | [diff] [blame] | 159 | uint32_t num_app_key_paths; |
| 160 | char (*app_key_paths)[MAX_STRING_SIZE]; |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 161 | }; |
| 162 | |
| 163 | struct loader_layer_list { |
| 164 | size_t capacity; |
| 165 | uint32_t count; |
| 166 | struct loader_layer_properties *list; |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 167 | }; |
| 168 | |
Jon Ashburn | 6cb69f4 | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 169 | struct loader_dispatch_hash_list { |
| 170 | size_t capacity; |
| 171 | uint32_t count; |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 172 | uint32_t *index; // index into the dev_ext dispatch table |
Jon Ashburn | 6cb69f4 | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 173 | }; |
| 174 | |
Mark Young | dd904ae | 2016-09-02 11:41:28 -0600 | [diff] [blame] | 175 | // loader_dispatch_hash_entry and loader_dev_ext_dispatch_table.dev_ext have |
| 176 | // one to one correspondence; one loader_dispatch_hash_entry for one dev_ext |
| 177 | // dispatch entry. |
Jon Ashburn | 6cb69f4 | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 178 | // Also have a one to one correspondence with functions in dev_ext_trampoline.c |
| 179 | struct loader_dispatch_hash_entry { |
| 180 | char *func_name; |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 181 | struct loader_dispatch_hash_list list; // to handle hashing collisions |
Jon Ashburn | 6cb69f4 | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 182 | }; |
| 183 | |
Lenny Komow | 2a61425 | 2018-05-09 11:09:58 -0600 | [diff] [blame] | 184 | typedef VkResult(VKAPI_PTR *PFN_vkDevExt)(VkDevice device); |
Jon Ashburn | 6cb69f4 | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 185 | struct loader_dev_ext_dispatch_table { |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 186 | PFN_vkDevExt dev_ext[MAX_NUM_UNKNOWN_EXTS]; |
Jon Ashburn | 6cb69f4 | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 187 | }; |
| 188 | |
| 189 | struct loader_dev_dispatch_table { |
| 190 | VkLayerDispatchTable core_dispatch; |
| 191 | struct loader_dev_ext_dispatch_table ext_dispatch; |
| 192 | }; |
| 193 | |
Mark Young | 1d64526 | 2016-09-07 08:50:32 -0600 | [diff] [blame] | 194 | // per CreateDevice structure |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 195 | struct loader_device { |
Jon Ashburn | 6cb69f4 | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 196 | struct loader_dev_dispatch_table loader_dispatch; |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 197 | VkDevice chain_device; // device object from the dispatch chain |
| 198 | VkDevice icd_device; // device object from the icd |
Mark Young | 0f7adeb | 2016-11-07 13:27:02 -0700 | [diff] [blame] | 199 | struct loader_physical_device_term *phys_dev_term; |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 200 | |
Mark Young | 5c87506 | 2017-05-04 12:16:35 -0600 | [diff] [blame] | 201 | // List of activated layers. |
| 202 | // app_ is the version based on exactly what the application asked for. |
| 203 | // This is what must be returned to the application on Enumerate calls. |
| 204 | // expanded_ is the version based on expanding meta-layers into their |
| 205 | // individual component layers. This is what is used internally. |
| 206 | struct loader_layer_list app_activated_layer_list; |
| 207 | struct loader_layer_list expanded_activated_layer_list; |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 208 | |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 209 | VkAllocationCallbacks alloc_callbacks; |
| 210 | |
Lenny Komow | bc3d03f | 2018-03-29 13:25:38 -0600 | [diff] [blame] | 211 | // List of activated device extensions that have terminators implemented in the loader |
| 212 | struct { |
| 213 | bool khr_swapchain_enabled; |
| 214 | bool khr_display_swapchain_enabled; |
Mike Schuchardt | 1df2ebd | 2019-03-16 10:09:25 -0700 | [diff] [blame] | 215 | bool khr_device_group_enabled; |
Lenny Komow | bc3d03f | 2018-03-29 13:25:38 -0600 | [diff] [blame] | 216 | bool ext_debug_marker_enabled; |
| 217 | bool ext_debug_utils_enabled; |
Mike Schuchardt | 1df2ebd | 2019-03-16 10:09:25 -0700 | [diff] [blame] | 218 | bool ext_full_screen_exclusive_enabled; |
Lenny Komow | bc3d03f | 2018-03-29 13:25:38 -0600 | [diff] [blame] | 219 | } extensions; |
| 220 | |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 221 | struct loader_device *next; |
| 222 | }; |
| 223 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 224 | // Per ICD information |
| 225 | |
| 226 | // Per ICD structure |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 227 | struct loader_icd_term { |
Jon Ashburn | b4c2423 | 2015-08-20 16:35:30 -0600 | [diff] [blame] | 228 | // pointers to find other structs |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 229 | const struct loader_scanned_icd *scanned_icd; |
Jon Ashburn | b4c2423 | 2015-08-20 16:35:30 -0600 | [diff] [blame] | 230 | const struct loader_instance *this_instance; |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 231 | struct loader_device *logical_device_list; |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 232 | VkInstance instance; // instance object from the icd |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 233 | struct loader_icd_term_dispatch dispatch; |
Mark Young | 4ab55c4 | 2016-12-12 16:14:55 -0700 | [diff] [blame] | 234 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 235 | struct loader_icd_term *next; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 236 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 237 | PFN_PhysDevExt phys_dev_ext[MAX_NUM_UNKNOWN_EXTS]; |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 238 | }; |
| 239 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 240 | // Per ICD library structure |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 241 | struct loader_icd_tramp_list { |
Jon Ashburn | e036747 | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 242 | size_t capacity; |
| 243 | uint32_t count; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 244 | struct loader_scanned_icd *scanned_list; |
Jon Ashburn | e036747 | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 245 | }; |
| 246 | |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 247 | struct loader_instance_dispatch_table { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 248 | VkLayerInstanceDispatchTable layer_inst_disp; // must be first entry in structure |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 249 | |
| 250 | // Physical device functions unknown to the loader |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 251 | PFN_PhysDevExt phys_dev_ext[MAX_NUM_UNKNOWN_EXTS]; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 252 | }; |
| 253 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 254 | // Per instance structure |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 255 | struct loader_instance { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 256 | struct loader_instance_dispatch_table *disp; // must be first entry in structure |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 257 | |
Lenny Komow | de705cc | 2017-10-25 15:26:15 -0600 | [diff] [blame] | 258 | // Vulkan API version the app is intending to use. |
| 259 | uint16_t app_api_major_version; |
| 260 | uint16_t app_api_minor_version; |
| 261 | |
Mark Young | 0746fce | 2017-03-10 17:31:18 -0700 | [diff] [blame] | 262 | // We need to manually track physical devices over time. If the user |
| 263 | // re-queries the information, we don't want to delete old data or |
| 264 | // create new data unless necessary. |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 265 | uint32_t total_gpu_count; |
Lenny Komow | e93e87f | 2016-12-20 15:35:11 -0700 | [diff] [blame] | 266 | uint32_t phys_dev_count_term; |
| 267 | struct loader_physical_device_term **phys_devs_term; |
Lenny Komow | aaa115c | 2016-12-19 17:11:40 -0700 | [diff] [blame] | 268 | uint32_t phys_dev_count_tramp; |
| 269 | struct loader_physical_device_tramp **phys_devs_tramp; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 270 | |
Mark Young | 0746fce | 2017-03-10 17:31:18 -0700 | [diff] [blame] | 271 | // We also need to manually track physical device groups, but we don't need |
| 272 | // loader specific structures since we have that content in the physical |
| 273 | // device stored internal to the public structures. |
| 274 | uint32_t phys_dev_group_count_term; |
Lenny Komow | 3121743 | 2017-10-02 15:08:53 -0600 | [diff] [blame] | 275 | struct VkPhysicalDeviceGroupProperties **phys_dev_groups_term; |
Mark Young | 0746fce | 2017-03-10 17:31:18 -0700 | [diff] [blame] | 276 | uint32_t phys_dev_group_count_tramp; |
Lenny Komow | 3121743 | 2017-10-02 15:08:53 -0600 | [diff] [blame] | 277 | struct VkPhysicalDeviceGroupProperties **phys_dev_groups_tramp; |
Mark Young | 0746fce | 2017-03-10 17:31:18 -0700 | [diff] [blame] | 278 | |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 279 | struct loader_instance *next; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 280 | |
| 281 | uint32_t total_icd_count; |
| 282 | struct loader_icd_term *icd_terms; |
| 283 | struct loader_icd_tramp_list icd_tramp_list; |
| 284 | |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 285 | struct loader_dispatch_hash_entry dev_ext_disp_hash[MAX_NUM_UNKNOWN_EXTS]; |
| 286 | struct loader_dispatch_hash_entry phys_dev_ext_disp_hash[MAX_NUM_UNKNOWN_EXTS]; |
Jon Ashburn | b4c2423 | 2015-08-20 16:35:30 -0600 | [diff] [blame] | 287 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 288 | struct loader_msg_callback_map_entry *icd_msg_callback_map; |
| 289 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 290 | struct loader_layer_list instance_layer_list; |
Lenny Komow | 40761b0 | 2018-10-03 17:44:02 -0600 | [diff] [blame] | 291 | bool override_layer_present; |
Mark Young | 5c87506 | 2017-05-04 12:16:35 -0600 | [diff] [blame] | 292 | |
| 293 | // List of activated layers. |
| 294 | // app_ is the version based on exactly what the application asked for. |
| 295 | // This is what must be returned to the application on Enumerate calls. |
| 296 | // expanded_ is the version based on expanding meta-layers into their |
| 297 | // individual component layers. This is what is used internally. |
| 298 | struct loader_layer_list app_activated_layer_list; |
| 299 | struct loader_layer_list expanded_activated_layer_list; |
| 300 | |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 301 | VkInstance instance; // layers/ICD instance returned to trampoline |
Courtney Goeltzenleuchter | 0bd705c | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 302 | |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 303 | struct loader_extension_list ext_list; // icds and loaders extensions |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 304 | union loader_instance_extension_enables enabled_known_extensions; |
| 305 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 306 | VkLayerDbgFunctionNode *DbgFunctionHead; |
Mark Young | e3e9b56 | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 307 | uint32_t num_tmp_report_callbacks; |
| 308 | VkDebugReportCallbackCreateInfoEXT *tmp_report_create_infos; |
| 309 | VkDebugReportCallbackEXT *tmp_report_callbacks; |
| 310 | uint32_t num_tmp_messengers; |
| 311 | VkDebugUtilsMessengerCreateInfoEXT *tmp_messenger_create_infos; |
| 312 | VkDebugUtilsMessengerEXT *tmp_messengers; |
Courtney Goeltzenleuchter | 71b454b | 2015-07-05 11:28:29 -0600 | [diff] [blame] | 313 | |
Chia-I Wu | 227c8b3 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 314 | VkAllocationCallbacks alloc_callbacks; |
Ian Elliott | ed33eb7 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 315 | |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 316 | bool wsi_surface_enabled; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 317 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 318 | bool wsi_win32_surface_enabled; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 319 | #endif |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 320 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 321 | bool wsi_wayland_surface_enabled; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 322 | #endif |
| 323 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 324 | bool wsi_xcb_surface_enabled; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 325 | #endif |
| 326 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 327 | bool wsi_xlib_surface_enabled; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 328 | #endif |
Nicolas Caramelli | fa696ca | 2020-07-04 22:53:59 +0200 | [diff] [blame] | 329 | #ifdef VK_USE_PLATFORM_DIRECTFB_EXT |
| 330 | bool wsi_directfb_surface_enabled; |
| 331 | #endif |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 332 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 333 | bool wsi_android_surface_enabled; |
| 334 | #endif |
Karl Schultz | d81ebfb | 2017-12-12 10:33:01 -0500 | [diff] [blame] | 335 | #ifdef VK_USE_PLATFORM_MACOS_MVK |
| 336 | bool wsi_macos_surface_enabled; |
| 337 | #endif |
| 338 | #ifdef VK_USE_PLATFORM_IOS_MVK |
| 339 | bool wsi_ios_surface_enabled; |
| 340 | #endif |
J.D. Rouan | d7928a1 | 2020-11-16 15:36:42 -0800 | [diff] [blame^] | 341 | #ifdef VK_USE_PLATFORM_GGP |
| 342 | bool wsi_ggp_surface_enabled; |
| 343 | #endif |
Bryan Law-Smith | 5730569 | 2019-04-01 09:45:55 +0100 | [diff] [blame] | 344 | bool wsi_headless_surface_enabled; |
Lenny Komow | a1b5e44 | 2019-09-16 16:14:36 -0600 | [diff] [blame] | 345 | #if defined(VK_USE_PLATFORM_METAL_EXT) |
| 346 | bool wsi_metal_surface_enabled; |
| 347 | #endif |
Craig Stout | f3b74dc | 2020-10-26 12:05:15 -0700 | [diff] [blame] | 348 | #ifdef VK_USE_PLATFORM_FUCHSIA |
| 349 | bool wsi_imagepipe_surface_enabled; |
| 350 | #endif |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 351 | bool wsi_display_enabled; |
Lenny Komow | 6113978 | 2018-05-31 11:32:31 -0600 | [diff] [blame] | 352 | bool wsi_display_props2_enabled; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 353 | }; |
| 354 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 355 | // VkPhysicalDevice requires special treatment by loader. Firstly, terminator |
| 356 | // code must be able to get the struct loader_icd_term to call into the proper |
| 357 | // driver (multiple ICD/gpu case). This can be accomplished by wrapping the |
| 358 | // created VkPhysicalDevice in loader terminate_EnumeratePhysicalDevices(). |
| 359 | // Secondly, the loader must be able to handle wrapped by layer VkPhysicalDevice |
| 360 | // in trampoline code. This implies, that the loader trampoline code must also |
| 361 | // wrap the VkPhysicalDevice object in trampoline code. Thus, loader has to |
| 362 | // wrap the VkPhysicalDevice created object twice. In trampoline code it can't |
| 363 | // rely on the terminator object wrapping since a layer may also wrap. Since |
| 364 | // trampoline code wraps the VkPhysicalDevice this means all loader trampoline |
| 365 | // code that passes a VkPhysicalDevice should unwrap it. |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 366 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 367 | // Per enumerated PhysicalDevice structure, used to wrap in trampoline code and |
| 368 | // also same structure used to wrap in terminator code |
Jon Ashburn | c3519e4 | 2016-03-24 15:49:57 -0600 | [diff] [blame] | 369 | struct loader_physical_device_tramp { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 370 | struct loader_instance_dispatch_table *disp; // must be first entry in structure |
Piers Daniell | 82107a6 | 2016-03-29 11:51:11 -0600 | [diff] [blame] | 371 | struct loader_instance *this_instance; |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 372 | VkPhysicalDevice phys_dev; // object from layers/loader terminator |
Jon Ashburn | c3519e4 | 2016-03-24 15:49:57 -0600 | [diff] [blame] | 373 | }; |
| 374 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 375 | // Per enumerated PhysicalDevice structure, used to wrap in terminator code |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 376 | struct loader_physical_device_term { |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 377 | struct loader_instance_dispatch_table *disp; // must be first entry in structure |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 378 | struct loader_icd_term *this_icd_term; |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 379 | uint8_t icd_index; |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 380 | VkPhysicalDevice phys_dev; // object from ICD |
Jon Ashburn | 969caa4 | 2015-11-01 14:04:06 -0700 | [diff] [blame] | 381 | }; |
| 382 | |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 383 | struct loader_struct { |
| 384 | struct loader_instance *instances; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 385 | }; |
| 386 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 387 | struct loader_scanned_icd { |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 388 | char *lib_name; |
| 389 | loader_platform_dl_handle handle; |
Jon Ashburn | 27109e8 | 2015-11-17 17:35:40 -0700 | [diff] [blame] | 390 | uint32_t api_version; |
Jon Ashburn | 68b06d6 | 2016-04-25 11:09:37 -0600 | [diff] [blame] | 391 | uint32_t interface_version; |
Jon Ashburn | c7ca48d | 2015-07-16 10:17:29 -0600 | [diff] [blame] | 392 | PFN_vkGetInstanceProcAddr GetInstanceProcAddr; |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 393 | PFN_GetPhysicalDeviceProcAddr GetPhysicalDeviceProcAddr; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 394 | PFN_vkCreateInstance CreateInstance; |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 395 | PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties; |
Lenny Komow | 363a95a | 2020-07-27 11:33:45 -0600 | [diff] [blame] | 396 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
| 397 | PFN_vk_icdEnumerateAdapterPhysicalDevices EnumerateAdapterPhysicalDevices; |
| 398 | #endif |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 399 | }; |
| 400 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 401 | static inline struct loader_instance *loader_instance(VkInstance instance) { return (struct loader_instance *)instance; } |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 402 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 403 | static inline VkPhysicalDevice loader_unwrap_physical_device(VkPhysicalDevice physicalDevice) { |
| 404 | struct loader_physical_device_tramp *phys_dev = (struct loader_physical_device_tramp *)physicalDevice; |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 405 | return phys_dev->phys_dev; |
| 406 | } |
| 407 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 408 | static inline void loader_set_dispatch(void *obj, const void *data) { *((const void **)obj) = data; } |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 409 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 410 | static inline VkLayerDispatchTable *loader_get_dispatch(const void *obj) { return *((VkLayerDispatchTable **)obj); } |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 411 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 412 | static inline struct loader_dev_dispatch_table *loader_get_dev_dispatch(const void *obj) { |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 413 | return *((struct loader_dev_dispatch_table **)obj); |
Jon Ashburn | 6cb69f4 | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 414 | } |
| 415 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 416 | static inline VkLayerInstanceDispatchTable *loader_get_instance_layer_dispatch(const void *obj) { |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 417 | return *((VkLayerInstanceDispatchTable **)obj); |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 418 | } |
| 419 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 420 | static inline struct loader_instance_dispatch_table *loader_get_instance_dispatch(const void *obj) { |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 421 | return *((struct loader_instance_dispatch_table **)obj); |
| 422 | } |
| 423 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 424 | static inline void loader_init_dispatch(void *obj, const void *data) { |
Jon Ashburn | 167b2b1 | 2015-04-15 13:34:33 -0600 | [diff] [blame] | 425 | #ifdef DEBUG |
Mark Lobodzinski | e2859eb | 2017-01-26 13:34:13 -0700 | [diff] [blame] | 426 | assert(valid_loader_magic_value(obj) && |
| 427 | "Incompatible ICD, first dword must be initialized to " |
| 428 | "ICD_LOADER_MAGIC. See loader/README.md for details."); |
Jon Ashburn | 167b2b1 | 2015-04-15 13:34:33 -0600 | [diff] [blame] | 429 | #endif |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 430 | |
Jon Ashburn | 62a54d1 | 2015-05-01 18:00:33 -0600 | [diff] [blame] | 431 | loader_set_dispatch(obj, data); |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 432 | } |
| 433 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 434 | // Global variables used across files |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 435 | extern struct loader_struct loader; |
Jon Ashburn | b4dee9c | 2015-08-28 15:19:27 -0600 | [diff] [blame] | 436 | extern THREAD_LOCAL_DECL struct loader_instance *tls_instance; |
Jon Ashburn | 7e8d8b4 | 2015-05-29 13:15:39 -0600 | [diff] [blame] | 437 | extern loader_platform_thread_mutex loader_lock; |
Jon Ashburn | 7d4d51c | 2015-09-22 13:11:00 -0600 | [diff] [blame] | 438 | extern loader_platform_thread_mutex loader_json_lock; |
Charles Giessen | 3e390a1 | 2020-05-12 14:25:47 -0600 | [diff] [blame] | 439 | extern loader_platform_thread_mutex loader_preload_icd_lock; |
Jon Ashburn | 37e7f97 | 2015-04-06 10:58:22 -0600 | [diff] [blame] | 440 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 441 | struct loader_msg_callback_map_entry { |
Courtney Goeltzenleuchter | 725db94 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 442 | VkDebugReportCallbackEXT icd_obj; |
| 443 | VkDebugReportCallbackEXT loader_obj; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 444 | }; |
| 445 | |
Mark Young | d4e5ba4 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 446 | // Helper function definitions |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 447 | void *loader_instance_heap_alloc(const struct loader_instance *instance, size_t size, VkSystemAllocationScope allocationScope); |
| 448 | void loader_instance_heap_free(const struct loader_instance *instance, void *pMemory); |
| 449 | void *loader_instance_heap_realloc(const struct loader_instance *instance, void *pMemory, size_t orig_size, size_t size, |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 450 | VkSystemAllocationScope alloc_scope); |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 451 | void *loader_instance_tls_heap_alloc(size_t size); |
| 452 | void loader_instance_tls_heap_free(void *pMemory); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 453 | void *loader_device_heap_alloc(const struct loader_device *device, size_t size, VkSystemAllocationScope allocationScope); |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 454 | void loader_device_heap_free(const struct loader_device *device, void *pMemory); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 455 | void *loader_device_heap_realloc(const struct loader_device *device, void *pMemory, size_t orig_size, size_t size, |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 456 | VkSystemAllocationScope alloc_scope); |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 457 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 458 | void loader_log(const struct loader_instance *inst, VkFlags msg_type, int32_t msg_code, const char *format, ...); |
Jon Ashburn | 663f831 | 2016-02-12 08:20:06 -0700 | [diff] [blame] | 459 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 460 | bool compare_vk_extension_properties(const VkExtensionProperties *op1, const VkExtensionProperties *op2); |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 461 | |
Lenny Komow | 40761b0 | 2018-10-03 17:44:02 -0600 | [diff] [blame] | 462 | VkResult loaderValidateLayers(const struct loader_instance *inst, const uint32_t layer_count, |
| 463 | const char *const *ppEnabledLayerNames, const struct loader_layer_list *list); |
Courtney Goeltzenleuchter | 76ece70 | 2015-07-06 17:45:08 -0600 | [diff] [blame] | 464 | |
Lenny Komow | 40761b0 | 2018-10-03 17:44:02 -0600 | [diff] [blame] | 465 | VkResult loader_validate_instance_extensions(struct loader_instance *inst, const struct loader_extension_list *icd_exts, |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 466 | const struct loader_layer_list *instance_layer, |
| 467 | const VkInstanceCreateInfo *pCreateInfo); |
Courtney Goeltzenleuchter | 76ece70 | 2015-07-06 17:45:08 -0600 | [diff] [blame] | 468 | |
Jon Ashburn | e036747 | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 469 | void loader_initialize(void); |
Charles Giessen | 95a4ccd | 2020-03-02 15:04:30 -0700 | [diff] [blame] | 470 | void loader_preload_icds(void); |
| 471 | void loader_unload_preloaded_icds(void); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 472 | bool has_vk_extension_property_array(const VkExtensionProperties *vk_ext_prop, const uint32_t count, |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 473 | const VkExtensionProperties *ext_array); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 474 | bool has_vk_extension_property(const VkExtensionProperties *vk_ext_prop, const struct loader_extension_list *ext_list); |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 475 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 476 | VkResult loader_add_to_ext_list(const struct loader_instance *inst, struct loader_extension_list *ext_list, |
| 477 | uint32_t prop_list_count, const VkExtensionProperties *props); |
| 478 | VkResult loader_add_to_dev_ext_list(const struct loader_instance *inst, struct loader_device_extension_list *ext_list, |
| 479 | const VkExtensionProperties *props, uint32_t entry_count, char **entrys); |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 480 | VkResult loader_add_device_extensions(const struct loader_instance *inst, |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 481 | PFN_vkEnumerateDeviceExtensionProperties fpEnumerateDeviceExtensionProperties, |
| 482 | VkPhysicalDevice physical_device, const char *lib_name, |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 483 | struct loader_extension_list *ext_list); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 484 | VkResult loader_init_generic_list(const struct loader_instance *inst, struct loader_generic_list *list_info, size_t element_size); |
| 485 | void loader_destroy_generic_list(const struct loader_instance *inst, struct loader_generic_list *list); |
Lenny Komow | 40761b0 | 2018-10-03 17:44:02 -0600 | [diff] [blame] | 486 | void loaderDestroyLayerList(const struct loader_instance *inst, struct loader_device *device, struct loader_layer_list *layer_list); |
| 487 | void loaderDeleteLayerListAndProperties(const struct loader_instance *inst, struct loader_layer_list *layer_list); |
Lenny Komow | 61bf3be | 2020-08-06 17:00:25 -0600 | [diff] [blame] | 488 | VkResult loaderAddLayerNameToList(const struct loader_instance *inst, const char *name, const enum layer_type_flags type_flags, |
| 489 | const struct loader_layer_list *source_list, struct loader_layer_list *target_list, |
| 490 | struct loader_layer_list *expanded_target_list); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 491 | void loader_scanned_icd_clear(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list); |
| 492 | VkResult loader_icd_scan(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list); |
Lenny Komow | 40761b0 | 2018-10-03 17:44:02 -0600 | [diff] [blame] | 493 | void loaderScanForLayers(struct loader_instance *inst, struct loader_layer_list *instance_layers); |
| 494 | void loaderScanForImplicitLayers(struct loader_instance *inst, struct loader_layer_list *instance_layers); |
| 495 | bool loaderImplicitLayerIsEnabled(const struct loader_instance *inst, const struct loader_layer_properties *prop); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 496 | VkResult loader_get_icd_loader_instance_extensions(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list, |
| 497 | struct loader_extension_list *inst_exts); |
Lenny Komow | a4f41ae | 2020-01-31 15:25:46 -0700 | [diff] [blame] | 498 | struct loader_icd_term *loader_get_icd_and_device(const void *device, struct loader_device **found_dev, uint32_t *icd_index); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 499 | void loader_init_dispatch_dev_ext(struct loader_instance *inst, struct loader_device *dev); |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 500 | void *loader_dev_ext_gpa(struct loader_instance *inst, const char *funcName); |
| 501 | void *loader_get_dev_ext_trampoline(uint32_t index); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 502 | bool loader_phys_dev_ext_gpa(struct loader_instance *inst, const char *funcName, bool perform_checking, void **tramp_addr, |
| 503 | void **term_addr); |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 504 | void *loader_get_phys_dev_ext_tramp(uint32_t index); |
| 505 | void *loader_get_phys_dev_ext_termin(uint32_t index); |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 506 | struct loader_instance *loader_get_instance(const VkInstance instance); |
Lenny Komow | 40761b0 | 2018-10-03 17:44:02 -0600 | [diff] [blame] | 507 | void loaderDeactivateLayers(const struct loader_instance *instance, struct loader_device *device, struct loader_layer_list *list); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 508 | struct loader_device *loader_create_logical_device(const struct loader_instance *inst, const VkAllocationCallbacks *pAllocator); |
| 509 | void loader_add_logical_device(const struct loader_instance *inst, struct loader_icd_term *icd_term, |
Piers Daniell | 82107a6 | 2016-03-29 11:51:11 -0600 | [diff] [blame] | 510 | struct loader_device *found_dev); |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 511 | void loader_remove_logical_device(const struct loader_instance *inst, struct loader_icd_term *icd_term, |
| 512 | struct loader_device *found_dev, const VkAllocationCallbacks *pAllocator); |
Mark Young | 1509839 | 2017-03-08 13:38:35 -0700 | [diff] [blame] | 513 | // NOTE: Outside of loader, this entry-point is only provided for error |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 514 | // cleanup. |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 515 | void loader_destroy_logical_device(const struct loader_instance *inst, struct loader_device *dev, |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 516 | const VkAllocationCallbacks *pAllocator); |
| 517 | |
Lenny Komow | 40761b0 | 2018-10-03 17:44:02 -0600 | [diff] [blame] | 518 | VkResult loaderEnableInstanceLayers(struct loader_instance *inst, const VkInstanceCreateInfo *pCreateInfo, |
| 519 | const struct loader_layer_list *instance_layers); |
Courtney Goeltzenleuchter | 0bd705c | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 520 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 521 | VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 522 | struct loader_instance *inst, VkInstance *created_instance); |
Courtney Goeltzenleuchter | 0bd705c | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 523 | |
Lenny Komow | 40761b0 | 2018-10-03 17:44:02 -0600 | [diff] [blame] | 524 | void loaderActivateInstanceLayerExtensions(struct loader_instance *inst, VkInstance created_inst); |
Courtney Goeltzenleuchter | 71b454b | 2015-07-05 11:28:29 -0600 | [diff] [blame] | 525 | |
Felix Dörre | 0679472 | 2019-04-26 14:57:59 +0200 | [diff] [blame] | 526 | VKAPI_ATTR VkResult VKAPI_CALL loader_layer_create_device(VkInstance instance, VkPhysicalDevice physicalDevice, |
| 527 | const VkDeviceCreateInfo *pCreateInfo, |
| 528 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, |
| 529 | PFN_vkGetInstanceProcAddr layerGIPA, PFN_vkGetDeviceProcAddr *nextGDPA); |
| 530 | VKAPI_ATTR void VKAPI_CALL loader_layer_destroy_device(VkDevice device, const VkAllocationCallbacks *pAllocator, |
| 531 | PFN_vkDestroyDevice destroyFunction); |
Felix Dörre | b222384 | 2018-12-11 18:29:38 +0100 | [diff] [blame] | 532 | |
Felix Dörre | 34c3c5a | 2018-12-11 18:30:24 +0100 | [diff] [blame] | 533 | VkResult loader_create_device_chain(const VkPhysicalDevice pd, const VkDeviceCreateInfo *pCreateInfo, |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 534 | const VkAllocationCallbacks *pAllocator, const struct loader_instance *inst, |
Felix Dörre | 0679472 | 2019-04-26 14:57:59 +0200 | [diff] [blame] | 535 | struct loader_device *dev, PFN_vkGetInstanceProcAddr callingLayer, |
| 536 | PFN_vkGetDeviceProcAddr *layerNextGDPA); |
Mark Young | 274e4bc | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 537 | |
Felix Dörre | 34c3c5a | 2018-12-11 18:30:24 +0100 | [diff] [blame] | 538 | VkResult loader_validate_device_extensions(struct loader_instance *this_instance, |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 539 | const struct loader_layer_list *activated_device_layers, |
| 540 | const struct loader_extension_list *icd_exts, const VkDeviceCreateInfo *pCreateInfo); |
Courtney Goeltzenleuchter | 71b454b | 2015-07-05 11:28:29 -0600 | [diff] [blame] | 541 | |
Mark Young | d4ff03b | 2017-01-12 12:27:19 -0700 | [diff] [blame] | 542 | VkResult setupLoaderTrampPhysDevs(VkInstance instance); |
| 543 | VkResult setupLoaderTermPhysDevs(struct loader_instance *inst); |
| 544 | |
Mark Lobodzinski | 91c1075 | 2017-01-26 12:16:30 -0700 | [diff] [blame] | 545 | VkStringErrorFlags vk_string_validate(const int max_length, const char *char_array); |
Mark Lobodzinski | 8d32580 | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 546 | |
Mark Young | 74268f7 | 2017-05-02 10:49:46 -0600 | [diff] [blame] | 547 | #endif // LOADER_H |