Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 1 | /* |
Courtney Goeltzenleuchter | 0b01860 | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2 | * Vulkan |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2014 LunarG, Inc. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
Chia-I Wu | d8ab1e6 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 23 | * |
| 24 | * Authors: |
| 25 | * Chia-I Wu <olv@lunarg.com> |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #ifndef LOADER_H |
| 29 | #define LOADER_H |
| 30 | |
Courtney Goeltzenleuchter | 0b01860 | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 31 | #include <vulkan.h> |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 32 | #include <vk_debug_report_lunarg.h> |
Chia-I Wu | 73e9db3 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 33 | #include <vk_wsi_lunarg.h> |
Tobin Ehlis | 7ad5aca | 2015-07-03 09:42:57 -0600 | [diff] [blame] | 34 | #include <vk_layer.h> |
| 35 | #include <vk_icd.h> |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 36 | #include <assert.h> |
| 37 | |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 38 | #if defined(__GNUC__) && __GNUC__ >= 4 |
| 39 | # define LOADER_EXPORT __attribute__((visibility("default"))) |
| 40 | #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) |
| 41 | # define LOADER_EXPORT __attribute__((visibility("default"))) |
| 42 | #else |
| 43 | # define LOADER_EXPORT |
| 44 | #endif |
| 45 | |
Courtney Goeltzenleuchter | 48403a9 | 2015-06-07 18:24:30 -0600 | [diff] [blame] | 46 | #define MAX_EXTENSION_NAME_SIZE 255 |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 47 | #define MAX_GPUS_PER_ICD 16 |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 48 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 49 | enum extension_origin { |
| 50 | VK_EXTENSION_ORIGIN_ICD, |
| 51 | VK_EXTENSION_ORIGIN_LAYER, |
| 52 | VK_EXTENSION_ORIGIN_LOADER |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 53 | }; |
| 54 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 55 | enum layer_type { |
| 56 | VK_LAYER_TYPE_DEVICE_EXPLICIT, |
| 57 | VK_LAYER_TYPE_INSTANCE_EXPLICIT, |
| 58 | VK_LAYER_TYPE_GLOBAL_EXPLICIT, // both instance and device layer |
| 59 | VK_LAYER_TYPE_DEVICE_IMPLICIT, |
| 60 | VK_LAYER_TYPE_INSTANCE_IMPLICIT, |
| 61 | VK_LAYER_TYPE_GLOBAL_IMPLICIT, // both instance and device layer |
| 62 | }; |
| 63 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 64 | struct loader_extension_property { |
| 65 | VkExtensionProperties info; |
| 66 | const char *lib_name; |
| 67 | enum extension_origin origin; |
Courtney Goeltzenleuchter | 99ad448 | 2015-06-07 17:28:17 -0600 | [diff] [blame] | 68 | // An extension library can export the same extension |
| 69 | // under different names. Handy to provide a "grouping" |
| 70 | // such as Validation. However, the loader requires |
| 71 | // that a layer be included only once in a chain. |
| 72 | // During layer scanning the loader will check if |
Jon Ashburn | 392c562 | 2015-06-10 16:11:42 -0600 | [diff] [blame] | 73 | // the vkGetInstanceProcAddr is the same as an existing extension |
Courtney Goeltzenleuchter | 99ad448 | 2015-06-07 17:28:17 -0600 | [diff] [blame] | 74 | // If so, it will link them together via the alias pointer. |
| 75 | // At initialization time we'll follow the alias pointer |
| 76 | // to the "base" extension and then use that extension |
| 77 | // internally to ensure we reject duplicates |
Jon Ashburn | 392c562 | 2015-06-10 16:11:42 -0600 | [diff] [blame] | 78 | PFN_vkGPA get_proc_addr; |
Courtney Goeltzenleuchter | 99ad448 | 2015-06-07 17:28:17 -0600 | [diff] [blame] | 79 | struct loader_extension_property *alias; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | struct loader_extension_list { |
| 83 | size_t capacity; |
| 84 | uint32_t count; |
| 85 | struct loader_extension_property *list; |
| 86 | }; |
| 87 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 88 | struct loader_name_value { |
| 89 | char *name; |
| 90 | char *value; |
| 91 | }; |
| 92 | |
| 93 | struct loader_lib_info { |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 94 | char *lib_name; |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 95 | uint32_t ref_count; |
| 96 | loader_platform_dl_handle lib_handle; |
| 97 | }; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 98 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 99 | struct loader_layer_functions { |
| 100 | PFN_vkGetInstanceProcAddr get_instance_proc_addr; |
| 101 | PFN_vkGetDeviceProcAddr get_device_proc_addr; |
| 102 | }; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 103 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 104 | struct loader_layer_properties { |
| 105 | char *name; |
| 106 | enum layer_type type; |
| 107 | struct loader_lib_info lib_info; |
| 108 | char *abi_versions; |
| 109 | char *impl_version; |
| 110 | char *description; |
| 111 | struct loader_layer_functions functions; |
| 112 | struct loader_extension_list instance_extension_list; |
| 113 | struct loader_extension_list device_extension_list; |
| 114 | struct loader_name_value disable_env_var; |
| 115 | struct loader_name_value enable_env_var; |
| 116 | }; |
| 117 | |
| 118 | struct loader_layer_list { |
| 119 | size_t capacity; |
| 120 | uint32_t count; |
| 121 | struct loader_layer_properties *list; |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 122 | }; |
| 123 | |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 124 | /* per CreateDevice structure */ |
| 125 | struct loader_device { |
| 126 | VkLayerDispatchTable loader_dispatch; |
| 127 | VkDevice device; // device object from the icd |
| 128 | |
| 129 | uint32_t app_extension_count; |
| 130 | VkExtensionProperties *app_extension_props; |
| 131 | |
| 132 | struct loader_extension_list enabled_device_extensions; |
| 133 | struct loader_extension_list activated_layer_list; |
| 134 | |
| 135 | struct loader_device *next; |
| 136 | }; |
| 137 | |
Jon Ashburn | 392c562 | 2015-06-10 16:11:42 -0600 | [diff] [blame] | 138 | /* per ICD structure */ |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 139 | struct loader_icd { |
| 140 | const struct loader_scanned_icds *scanned_icds; |
| 141 | |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 142 | struct loader_device *logical_device_list; |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 143 | uint32_t gpu_count; |
Jon Ashburn | 392c562 | 2015-06-10 16:11:42 -0600 | [diff] [blame] | 144 | VkPhysicalDevice *gpus; // enumerated PhysicalDevices |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 145 | VkInstance instance; // instance object from the icd |
Jon Ashburn | c89dd4a | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 146 | PFN_vkGetDeviceProcAddr GetDeviceProcAddr; |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 147 | PFN_vkDestroyInstance DestroyInstance; |
| 148 | PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices; |
Chris Forbes | 1c946ec | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 149 | PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures; |
| 150 | PFN_vkGetPhysicalDeviceFormatInfo GetPhysicalDeviceFormatInfo; |
| 151 | PFN_vkGetPhysicalDeviceLimits GetPhysicalDeviceLimits; |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 152 | PFN_vkCreateDevice CreateDevice; |
Tony Barbour | 4e657ba | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 153 | PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties; |
| 154 | PFN_vkGetPhysicalDevicePerformance GetPhysicalDevicePerformance; |
| 155 | PFN_vkGetPhysicalDeviceQueueCount GetPhysicalDeviceQueueCount; |
| 156 | PFN_vkGetPhysicalDeviceQueueProperties GetPhysicalDeviceQueueProperties; |
| 157 | PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties; |
| 158 | PFN_vkGetPhysicalDeviceExtensionCount GetPhysicalDeviceExtensionCount; |
| 159 | PFN_vkGetPhysicalDeviceExtensionProperties GetPhysicalDeviceExtensionProperties; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 160 | PFN_vkDbgCreateMsgCallback DbgCreateMsgCallback; |
| 161 | PFN_vkDbgDestroyMsgCallback DbgDestroyMsgCallback; |
Courtney Goeltzenleuchter | 1c51240 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 162 | /* |
| 163 | * Fill in the cache of available extensions from all layers that |
| 164 | * operate with this physical device. |
Tony Barbour | 4e657ba | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 165 | * This cache will be used to satisfy calls to GetPhysicalDeviceExtensionProperties |
Courtney Goeltzenleuchter | 1c51240 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 166 | */ |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 167 | struct loader_extension_list device_extension_cache[MAX_GPUS_PER_ICD]; |
| 168 | struct loader_icd *next; |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 169 | }; |
| 170 | |
Jon Ashburn | 392c562 | 2015-06-10 16:11:42 -0600 | [diff] [blame] | 171 | /* per instance structure */ |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 172 | struct loader_instance { |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 173 | VkLayerInstanceDispatchTable *disp; // must be first entry in structure |
| 174 | |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 175 | uint32_t layer_count; |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 176 | uint32_t total_gpu_count; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 177 | uint32_t total_icd_count; |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 178 | struct loader_icd *icds; |
| 179 | struct loader_instance *next; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 180 | |
| 181 | /* TODO: Should keep track of application provided allocation functions */ |
| 182 | |
| 183 | /* |
| 184 | * CreateMsgCallback is global and needs to be |
| 185 | * applied to all layers and ICDs. |
| 186 | * What happens if a layer is enabled on both the instance chain |
| 187 | * as well as the device chain and a call to CreateMsgCallback is made? |
| 188 | * Do we need to make sure that each layer / driver only gets called once? |
| 189 | * Should a layer implementing support for CreateMsgCallback only be allowed (?) |
| 190 | * to live on one chain? Or maybe make it the application's responsibility. |
| 191 | * If the app enables DRAW_STATE on at both CreateInstance time and CreateDevice |
| 192 | * time, CreateMsgCallback will call the DRAW_STATE layer twice. Once via |
| 193 | * the instance chain and once via the device chain. |
| 194 | * The loader should only return the DEBUG_REPORT extension as supported |
| 195 | * for the GetGlobalExtensionSupport call. That should help eliminate one |
| 196 | * duplication. |
| 197 | * Since the instance chain requires us iterating over the available ICDs |
| 198 | * and each ICD will have it's own unique MsgCallback object we need to |
| 199 | * track those objects to give back the right one. |
| 200 | * This also implies that the loader has to intercept vkDestroyObject and |
| 201 | * if the extension is enabled and the object type is a MsgCallback then |
| 202 | * we must translate the object into the proper ICD specific ones. |
| 203 | * DestroyObject works on a device chain. Should not be what's destroying |
| 204 | * the MsgCallback object. That needs to be an instance thing. So, since |
| 205 | * we used an instance to create it, we need a custom Destroy that also |
| 206 | * takes an instance. That way we can iterate over the ICDs properly. |
| 207 | * Example use: |
| 208 | * CreateInstance: DEBUG_REPORT |
| 209 | * Loader will create instance chain with enabled extensions. |
| 210 | * TODO: Should validation layers be enabled here? If not, they will not be in the instance chain. |
| 211 | * fn = GetProcAddr(INSTANCE, "vkCreateMsgCallback") -> point to loader's vkCreateMsgCallback |
| 212 | * App creates a callback object: fn(..., &MsgCallbackObject1) |
| 213 | * Have only established the instance chain so far. Loader will call the instance chain. |
| 214 | * Each layer in the instance chain will call down to the next layer, terminating with |
| 215 | * the CreateMsgCallback loader terminator function that creates the actual MsgCallbackObject1 object. |
| 216 | * The loader CreateMsgCallback terminator will iterate over the ICDs. |
| 217 | * Calling each ICD that supports vkCreateMsgCallback and collect answers in icd_msg_callback_map here. |
| 218 | * As result is sent back up the chain each layer has opportunity to record the callback operation and |
| 219 | * appropriate MsgCallback object. |
| 220 | * ... |
| 221 | * Any reports matching the flags set in MsgCallbackObject1 will generate the defined callback behavior |
| 222 | * in the layer / ICD that initiated that report. |
| 223 | * ... |
| 224 | * CreateDevice: MemTracker:... |
| 225 | * App does not include DEBUG_REPORT as that is a global extension. |
| 226 | * TODO: GetExtensionSupport must not report DEBUG_REPORT when using instance. |
| 227 | * App MUST include any desired validation layers or they will not participate in the device call chain. |
| 228 | * App creates a callback object: fn(..., &MsgCallbackObject2) |
| 229 | * Loader's vkCreateMsgCallback is called. |
| 230 | * Loader sends call down instance chain - this is a global extension - any validation layer that was |
| 231 | * enabled at CreateInstance will be able to register the callback. Loader will iterate over the ICDs and |
| 232 | * will record the ICD's version of the MsgCallback2 object here. |
| 233 | * ... |
| 234 | * Any report will go to the layer's report function and it will check the flags for MsgCallbackObject1 |
| 235 | * and MsgCallbackObject2 and take the appropriate action as indicated by the app. |
| 236 | * ... |
| 237 | * App calls vkDestroyMsgCallback( MsgCallbackObject1 ) |
| 238 | * Loader's DestroyMsgCallback is where call starts. DestroyMsgCallback will be sent down instance chain |
| 239 | * ending in the loader's DestroyMsgCallback terminator which will iterate over the ICD's destroying each |
| 240 | * ICD version of that MsgCallback object and then destroy the loader's version of the object. |
| 241 | * Any reports generated after this will only have MsgCallbackObject2 available. |
| 242 | */ |
| 243 | struct loader_msg_callback_map_entry *icd_msg_callback_map; |
| 244 | |
| 245 | struct loader_extension_list enabled_instance_extensions; |
Courtney Goeltzenleuchter | 99ad448 | 2015-06-07 17:28:17 -0600 | [diff] [blame] | 246 | struct loader_extension_list activated_layer_list; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 247 | |
| 248 | uint32_t app_extension_count; |
| 249 | VkExtensionProperties *app_extension_props; |
| 250 | |
| 251 | bool debug_report_enabled; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 252 | VkLayerDbgFunctionNode *DbgFunctionHead; |
| 253 | }; |
| 254 | |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 255 | struct loader_struct { |
| 256 | struct loader_instance *instances; |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 257 | struct loader_scanned_icds *scanned_icd_list; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 258 | |
| 259 | unsigned int loaded_layer_lib_count; |
| 260 | struct loader_lib_info *loaded_layer_lib_list; |
| 261 | |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 262 | char *layer_dirs; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 263 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 264 | struct loader_layer_list scanned_layers; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 265 | |
Tony Barbour | 4e657ba | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 266 | /* Keep track of all the extensions available via GetGlobalExtensionProperties */ |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 267 | struct loader_extension_list global_extensions; |
| 268 | }; |
| 269 | |
| 270 | struct loader_scanned_icds { |
| 271 | char *lib_name; |
| 272 | loader_platform_dl_handle handle; |
| 273 | |
| 274 | PFN_vkCreateInstance CreateInstance; |
| 275 | PFN_vkDestroyInstance DestroyInstance; |
| 276 | PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices; |
Tony Barbour | 4e657ba | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 277 | PFN_vkGetGlobalExtensionCount GetGlobalExtensionCount; |
| 278 | PFN_vkGetGlobalExtensionProperties GetGlobalExtensionProperties; |
| 279 | PFN_vkGetPhysicalDeviceExtensionCount GetPhysicalDeviceExtensionCount; |
| 280 | PFN_vkGetPhysicalDeviceExtensionProperties GetPhysicalDeviceExtensionProperties; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 281 | VkInstance instance; |
| 282 | struct loader_scanned_icds *next; |
| 283 | |
| 284 | /* cache of global extensions for specific ICD */ |
| 285 | struct loader_extension_list global_extension_list; |
| 286 | |
| 287 | /* |
| 288 | * cache of device extensions for specific ICD, |
| 289 | * filled in at CreateInstance time |
| 290 | */ |
Courtney Goeltzenleuchter | 1c51240 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 291 | struct loader_extension_list device_extension_list; |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 292 | }; |
| 293 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 294 | static inline struct loader_instance *loader_instance(VkInstance instance) { |
| 295 | return (struct loader_instance *) instance; |
| 296 | } |
| 297 | |
Jon Ashburn | 62a54d1 | 2015-05-01 18:00:33 -0600 | [diff] [blame] | 298 | static inline void loader_set_dispatch(VkObject obj, const void *data) |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 299 | { |
| 300 | *((const void **) obj) = data; |
| 301 | } |
| 302 | |
Jon Ashburn | 62a54d1 | 2015-05-01 18:00:33 -0600 | [diff] [blame] | 303 | static inline VkLayerDispatchTable *loader_get_dispatch(const VkObject obj) |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 304 | { |
Jon Ashburn | 62a54d1 | 2015-05-01 18:00:33 -0600 | [diff] [blame] | 305 | return *((VkLayerDispatchTable **) obj); |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 306 | } |
| 307 | |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 308 | static inline VkLayerInstanceDispatchTable *loader_get_instance_dispatch(const VkObject obj) |
| 309 | { |
| 310 | return *((VkLayerInstanceDispatchTable **) obj); |
| 311 | } |
| 312 | |
Jon Ashburn | 62a54d1 | 2015-05-01 18:00:33 -0600 | [diff] [blame] | 313 | static inline void loader_init_dispatch(VkObject obj, const void *data) |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 314 | { |
Jon Ashburn | 167b2b1 | 2015-04-15 13:34:33 -0600 | [diff] [blame] | 315 | #ifdef DEBUG |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 316 | assert(valid_loader_magic_value(obj) && |
| 317 | "Incompatible ICD, first dword must be initialized to ICD_LOADER_MAGIC. See loader/README.md for details."); |
Jon Ashburn | 167b2b1 | 2015-04-15 13:34:33 -0600 | [diff] [blame] | 318 | #endif |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 319 | |
Jon Ashburn | 62a54d1 | 2015-05-01 18:00:33 -0600 | [diff] [blame] | 320 | loader_set_dispatch(obj, data); |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 321 | } |
| 322 | |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 323 | /* global variables used across files */ |
| 324 | extern struct loader_struct loader; |
| 325 | extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_icd); |
| 326 | extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_layer); |
| 327 | extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_exts); |
Jon Ashburn | 7e8d8b4 | 2015-05-29 13:15:39 -0600 | [diff] [blame] | 328 | extern loader_platform_thread_mutex loader_lock; |
| 329 | extern const VkLayerInstanceDispatchTable instance_disp; |
Jon Ashburn | 37e7f97 | 2015-04-06 10:58:22 -0600 | [diff] [blame] | 330 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 331 | struct loader_msg_callback_map_entry { |
| 332 | VkDbgMsgCallback icd_obj; |
| 333 | VkDbgMsgCallback loader_obj; |
| 334 | }; |
| 335 | |
| 336 | bool compare_vk_extension_properties( |
| 337 | const VkExtensionProperties* op1, |
| 338 | const VkExtensionProperties* op2); |
| 339 | |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 340 | /* instance layer chain termination entrypoint definitions */ |
| 341 | VkResult loader_CreateInstance( |
| 342 | const VkInstanceCreateInfo* pCreateInfo, |
| 343 | VkInstance* pInstance); |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 344 | |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 345 | VkResult loader_DestroyInstance( |
| 346 | VkInstance instance); |
| 347 | |
| 348 | VkResult loader_EnumeratePhysicalDevices( |
| 349 | VkInstance instance, |
| 350 | uint32_t* pPhysicalDeviceCount, |
| 351 | VkPhysicalDevice* pPhysicalDevices); |
Chris Forbes | 1c946ec | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 352 | |
Chris Forbes | 1c946ec | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 353 | VkResult loader_GetPhysicalDeviceFeatures( |
| 354 | VkPhysicalDevice physicalDevice, |
| 355 | VkPhysicalDeviceFeatures* pFeatures); |
| 356 | |
| 357 | VkResult loader_GetPhysicalDeviceFormatInfo( |
| 358 | VkPhysicalDevice physicalDevice, |
| 359 | VkFormat format, |
| 360 | VkFormatProperties* pFormatInfo); |
| 361 | |
| 362 | VkResult loader_GetPhysicalDeviceLimits( |
| 363 | VkPhysicalDevice physicalDevice, |
| 364 | VkPhysicalDeviceLimits* pLimits); |
| 365 | |
Tony Barbour | 4e657ba | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 366 | |
| 367 | VkResult loader_GetPhysicalDeviceProperties ( |
| 368 | VkPhysicalDevice physicalDevice, |
| 369 | VkPhysicalDeviceProperties* pProperties); |
| 370 | |
| 371 | VkResult loader_GetPhysicalDevicePerformance ( |
| 372 | VkPhysicalDevice physicalDevice, |
| 373 | VkPhysicalDevicePerformance* pPerformance); |
| 374 | |
| 375 | VkResult loader_GetPhysicalDeviceExtensionProperties ( |
| 376 | VkPhysicalDevice physicalDevice, |
| 377 | uint32_t extensionIndex, |
| 378 | VkExtensionProperties* pProperties); |
| 379 | |
| 380 | VkResult loader_GetPhysicalDeviceExtensionCount ( |
| 381 | VkPhysicalDevice physicalDevice, |
| 382 | uint32_t* pCount); |
| 383 | |
| 384 | VkResult loader_GetPhysicalDeviceQueueCount ( |
| 385 | VkPhysicalDevice physicalDevice, |
| 386 | uint32_t* pCount); |
| 387 | |
| 388 | VkResult loader_GetPhysicalDeviceQueueProperties ( |
| 389 | VkPhysicalDevice physicalDevice, |
| 390 | uint32_t count, |
| 391 | VkPhysicalDeviceQueueProperties * pProperties); |
| 392 | |
| 393 | VkResult loader_GetPhysicalDeviceMemoryProperties ( |
| 394 | VkPhysicalDevice physicalDevice, |
| 395 | VkPhysicalDeviceMemoryProperties * pProperties); |
Jon Ashburn | 7e8d8b4 | 2015-05-29 13:15:39 -0600 | [diff] [blame] | 396 | |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 397 | VkResult loader_CreateDevice( |
| 398 | VkPhysicalDevice gpu, |
| 399 | const VkDeviceCreateInfo* pCreateInfo, |
| 400 | VkDevice* pDevice); |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 401 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 402 | /* helper function definitions */ |
| 403 | bool has_vk_extension_property( |
| 404 | const VkExtensionProperties *vk_ext_prop, |
| 405 | const struct loader_extension_list *ext_list); |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 406 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 407 | void loader_add_to_ext_list( |
| 408 | struct loader_extension_list *ext_list, |
| 409 | uint32_t prop_list_count, |
| 410 | const struct loader_extension_property *props); |
Courtney Goeltzenleuchter | 54fcee1 | 2015-06-08 15:09:22 -0600 | [diff] [blame] | 411 | void loader_destroy_ext_list(struct loader_extension_list *ext_info); |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 412 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 413 | bool loader_is_extension_scanned(const VkExtensionProperties *ext_prop); |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 414 | void loader_icd_scan(void); |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 415 | void loader_layer_scan(void); |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 416 | void loader_coalesce_extensions(void); |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 417 | |
Jon Ashburn | 540a90d | 2015-05-28 19:16:58 -0600 | [diff] [blame] | 418 | struct loader_icd * loader_get_icd(const VkPhysicalDevice gpu, |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 419 | uint32_t *gpu_index); |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 420 | void loader_remove_logical_device(VkDevice device); |
| 421 | void loader_enable_instance_layers(struct loader_instance *inst); |
| 422 | void loader_deactivate_instance_layers(struct loader_instance *instance); |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 423 | uint32_t loader_activate_instance_layers(struct loader_instance *inst); |
Courtney Goeltzenleuchter | 1c51240 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 424 | void loader_activate_instance_layer_extensions(struct loader_instance *inst); |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 425 | #endif /* LOADER_H */ |