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> |
Ian Elliott | ed33eb7 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 33 | #include <vk_wsi_swapchain.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 | 44667cc | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 46 | #define MAX_EXTENSION_NAME_SIZE (VK_MAX_EXTENSION_NAME-1) |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 47 | #define MAX_GPUS_PER_ICD 16 |
Jon Ashburn | b2379c5 | 2015-08-04 10:22:33 -0600 | [diff] [blame] | 48 | #define MAX_STRING_SIZE 1024 |
Courtney Goeltzenleuchter | 44667cc | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 49 | #define VK_MAJOR(version) (version >> 22) |
| 50 | #define VK_MINOR(version) ((version >> 12) & 0x3ff) |
| 51 | #define VK_PATCH(version) (version & 0xfff) |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 52 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 53 | enum layer_type { |
Jon Ashburn | 9464e77 | 2015-07-02 16:10:32 -0600 | [diff] [blame] | 54 | VK_LAYER_TYPE_DEVICE_EXPLICIT = 0x1, |
| 55 | VK_LAYER_TYPE_INSTANCE_EXPLICIT = 0x2, |
| 56 | VK_LAYER_TYPE_GLOBAL_EXPLICIT = 0x3, // both instance and device layer, bitwise |
| 57 | VK_LAYER_TYPE_DEVICE_IMPLICIT = 0x4, |
| 58 | VK_LAYER_TYPE_INSTANCE_IMPLICIT = 0x8, |
| 59 | VK_LAYER_TYPE_GLOBAL_IMPLICIT = 0xc, // both instance and device layer, bitwise |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 60 | }; |
| 61 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 62 | struct loader_extension_list { |
| 63 | size_t capacity; |
| 64 | uint32_t count; |
Jon Ashburn | b7d327c | 2015-08-04 11:14:18 -0600 | [diff] [blame] | 65 | VkExtensionProperties *list; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 66 | }; |
| 67 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 68 | struct loader_name_value { |
Jon Ashburn | b2379c5 | 2015-08-04 10:22:33 -0600 | [diff] [blame] | 69 | char name[MAX_STRING_SIZE]; |
| 70 | char value[MAX_STRING_SIZE]; |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | struct loader_lib_info { |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 74 | char *lib_name; |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 75 | uint32_t ref_count; |
| 76 | loader_platform_dl_handle lib_handle; |
| 77 | }; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 78 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 79 | struct loader_layer_functions { |
Jon Ashburn | b2379c5 | 2015-08-04 10:22:33 -0600 | [diff] [blame] | 80 | char str_gipa[MAX_STRING_SIZE]; |
| 81 | char str_gdpa[MAX_STRING_SIZE]; |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 82 | PFN_vkGetInstanceProcAddr get_instance_proc_addr; |
| 83 | PFN_vkGetDeviceProcAddr get_device_proc_addr; |
| 84 | }; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 85 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 86 | struct loader_layer_properties { |
Courtney Goeltzenleuchter | 44667cc | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 87 | VkLayerProperties info; |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 88 | enum layer_type type; |
| 89 | struct loader_lib_info lib_info; |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 90 | struct loader_layer_functions functions; |
| 91 | struct loader_extension_list instance_extension_list; |
| 92 | struct loader_extension_list device_extension_list; |
| 93 | struct loader_name_value disable_env_var; |
| 94 | struct loader_name_value enable_env_var; |
| 95 | }; |
| 96 | |
| 97 | struct loader_layer_list { |
| 98 | size_t capacity; |
| 99 | uint32_t count; |
| 100 | struct loader_layer_properties *list; |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 101 | }; |
| 102 | |
Courtney Goeltzenleuchter | 8aff386 | 2015-07-05 12:53:31 -0600 | [diff] [blame] | 103 | struct loader_layer_library_list { |
| 104 | size_t capacity; |
| 105 | uint32_t count; |
| 106 | struct loader_lib_info *list; |
| 107 | }; |
| 108 | |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 109 | /* per CreateDevice structure */ |
| 110 | struct loader_device { |
| 111 | VkLayerDispatchTable loader_dispatch; |
| 112 | VkDevice device; // device object from the icd |
| 113 | |
| 114 | uint32_t app_extension_count; |
| 115 | VkExtensionProperties *app_extension_props; |
| 116 | |
Courtney Goeltzenleuchter | 44667cc | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 117 | struct loader_layer_list activated_layer_list; |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 118 | |
| 119 | struct loader_device *next; |
| 120 | }; |
| 121 | |
Jon Ashburn | 392c562 | 2015-06-10 16:11:42 -0600 | [diff] [blame] | 122 | /* per ICD structure */ |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 123 | struct loader_icd { |
| 124 | const struct loader_scanned_icds *scanned_icds; |
| 125 | |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 126 | struct loader_device *logical_device_list; |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 127 | uint32_t gpu_count; |
Jon Ashburn | 392c562 | 2015-06-10 16:11:42 -0600 | [diff] [blame] | 128 | VkPhysicalDevice *gpus; // enumerated PhysicalDevices |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 129 | VkInstance instance; // instance object from the icd |
Jon Ashburn | c89dd4a | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 130 | PFN_vkGetDeviceProcAddr GetDeviceProcAddr; |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 131 | PFN_vkDestroyInstance DestroyInstance; |
| 132 | PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices; |
Chris Forbes | 1c946ec | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 133 | PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures; |
Courtney Goeltzenleuchter | 2b6559e | 2015-07-12 12:52:09 -0600 | [diff] [blame] | 134 | PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties; |
Jon Ashburn | 25c1145 | 2015-07-23 18:49:07 -0600 | [diff] [blame] | 135 | PFN_vkGetPhysicalDeviceImageFormatProperties GetPhysicalDeviceImageFormatProperties; |
Chris Forbes | 1c946ec | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 136 | PFN_vkGetPhysicalDeviceLimits GetPhysicalDeviceLimits; |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 137 | PFN_vkCreateDevice CreateDevice; |
Tony Barbour | 4e657ba | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 138 | PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties; |
Cody Northrop | fc4ad13 | 2015-08-03 17:04:53 -0600 | [diff] [blame] | 139 | PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties; |
Tony Barbour | 4e657ba | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 140 | PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties; |
Tony Barbour | 4e657ba | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 141 | PFN_vkGetPhysicalDeviceExtensionProperties GetPhysicalDeviceExtensionProperties; |
Mark Lobodzinski | 0c708be | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 142 | PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 143 | PFN_vkDbgCreateMsgCallback DbgCreateMsgCallback; |
| 144 | PFN_vkDbgDestroyMsgCallback DbgDestroyMsgCallback; |
Jon Ashburn | c7ca48d | 2015-07-16 10:17:29 -0600 | [diff] [blame] | 145 | PFN_vkGetPhysicalDeviceSurfaceSupportWSI GetPhysicalDeviceSurfaceSupportWSI; |
Courtney Goeltzenleuchter | 44667cc | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 146 | |
Courtney Goeltzenleuchter | 1c51240 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 147 | /* |
Courtney Goeltzenleuchter | 44667cc | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 148 | * Fill in the cache of available global extensions that operate |
| 149 | * with this physical device. This cache will be used to satisfy |
| 150 | * calls to GetPhysicalDeviceExtensionProperties |
Courtney Goeltzenleuchter | 1c51240 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 151 | */ |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 152 | struct loader_extension_list device_extension_cache[MAX_GPUS_PER_ICD]; |
| 153 | struct loader_icd *next; |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 154 | }; |
| 155 | |
Jon Ashburn | 392c562 | 2015-06-10 16:11:42 -0600 | [diff] [blame] | 156 | /* per instance structure */ |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 157 | struct loader_instance { |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 158 | VkLayerInstanceDispatchTable *disp; // must be first entry in structure |
| 159 | |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 160 | uint32_t total_gpu_count; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 161 | uint32_t total_icd_count; |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 162 | struct loader_icd *icds; |
| 163 | struct loader_instance *next; |
Jon Ashburn | e503a7d | 2015-08-14 14:49:22 -0600 | [diff] [blame^] | 164 | struct loader_extension_list ext_list; // icds and loaders extensions |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 165 | /* TODO: Should keep track of application provided allocation functions */ |
| 166 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 167 | struct loader_msg_callback_map_entry *icd_msg_callback_map; |
| 168 | |
Courtney Goeltzenleuchter | 44667cc | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 169 | struct loader_layer_list activated_layer_list; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 170 | |
| 171 | bool debug_report_enabled; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 172 | VkLayerDbgFunctionNode *DbgFunctionHead; |
Courtney Goeltzenleuchter | 71b454b | 2015-07-05 11:28:29 -0600 | [diff] [blame] | 173 | |
| 174 | VkAllocCallbacks alloc_callbacks; |
Ian Elliott | ed33eb7 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 175 | |
| 176 | bool wsi_swapchain_enabled; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 177 | }; |
| 178 | |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 179 | struct loader_struct { |
| 180 | struct loader_instance *instances; |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 181 | struct loader_scanned_icds *scanned_icd_list; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 182 | |
| 183 | unsigned int loaded_layer_lib_count; |
| 184 | struct loader_lib_info *loaded_layer_lib_list; |
| 185 | |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 186 | char *layer_dirs; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 187 | |
Jon Ashburn | 269b592 | 2015-07-06 15:40:35 -0600 | [diff] [blame] | 188 | // TODO use this struct loader_layer_library_list scanned_layer_libraries; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 189 | }; |
| 190 | |
| 191 | struct loader_scanned_icds { |
| 192 | char *lib_name; |
| 193 | loader_platform_dl_handle handle; |
| 194 | |
Jon Ashburn | c7ca48d | 2015-07-16 10:17:29 -0600 | [diff] [blame] | 195 | PFN_vkGetInstanceProcAddr GetInstanceProcAddr; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 196 | PFN_vkCreateInstance CreateInstance; |
Tony Barbour | 4e657ba | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 197 | PFN_vkGetGlobalExtensionProperties GetGlobalExtensionProperties; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 198 | struct loader_scanned_icds *next; |
| 199 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 200 | /* |
| 201 | * cache of device extensions for specific ICD, |
| 202 | * filled in at CreateInstance time |
| 203 | */ |
Courtney Goeltzenleuchter | 1c51240 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 204 | struct loader_extension_list device_extension_list; |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 205 | }; |
| 206 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 207 | static inline struct loader_instance *loader_instance(VkInstance instance) { |
| 208 | return (struct loader_instance *) instance; |
| 209 | } |
| 210 | |
Tony Barbour | 303615c | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 211 | static inline void loader_set_dispatch(void* obj, const void *data) |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 212 | { |
| 213 | *((const void **) obj) = data; |
| 214 | } |
| 215 | |
Tony Barbour | 303615c | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 216 | static inline VkLayerDispatchTable *loader_get_dispatch(const void* obj) |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 217 | { |
Jon Ashburn | 62a54d1 | 2015-05-01 18:00:33 -0600 | [diff] [blame] | 218 | return *((VkLayerDispatchTable **) obj); |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 219 | } |
| 220 | |
Tony Barbour | 303615c | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 221 | static inline VkLayerInstanceDispatchTable *loader_get_instance_dispatch(const void* obj) |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 222 | { |
| 223 | return *((VkLayerInstanceDispatchTable **) obj); |
| 224 | } |
| 225 | |
Tony Barbour | 303615c | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 226 | static inline void loader_init_dispatch(void* obj, const void *data) |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 227 | { |
Jon Ashburn | 167b2b1 | 2015-04-15 13:34:33 -0600 | [diff] [blame] | 228 | #ifdef DEBUG |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 229 | assert(valid_loader_magic_value(obj) && |
| 230 | "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] | 231 | #endif |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 232 | |
Jon Ashburn | 62a54d1 | 2015-05-01 18:00:33 -0600 | [diff] [blame] | 233 | loader_set_dispatch(obj, data); |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 234 | } |
| 235 | |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 236 | /* global variables used across files */ |
| 237 | extern struct loader_struct loader; |
| 238 | extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_icd); |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 239 | extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_exts); |
Jon Ashburn | 7e8d8b4 | 2015-05-29 13:15:39 -0600 | [diff] [blame] | 240 | extern loader_platform_thread_mutex loader_lock; |
| 241 | extern const VkLayerInstanceDispatchTable instance_disp; |
Jon Ashburn | 37e7f97 | 2015-04-06 10:58:22 -0600 | [diff] [blame] | 242 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 243 | struct loader_msg_callback_map_entry { |
| 244 | VkDbgMsgCallback icd_obj; |
| 245 | VkDbgMsgCallback loader_obj; |
| 246 | }; |
| 247 | |
| 248 | bool compare_vk_extension_properties( |
| 249 | const VkExtensionProperties* op1, |
| 250 | const VkExtensionProperties* op2); |
| 251 | |
Courtney Goeltzenleuchter | 7acb967 | 2015-07-06 20:14:18 -0600 | [diff] [blame] | 252 | VkResult loader_validate_layers(const uint32_t layer_count, const char * const *ppEnabledLayerNames, struct loader_layer_list *list); |
Courtney Goeltzenleuchter | 76ece70 | 2015-07-06 17:45:08 -0600 | [diff] [blame] | 253 | |
| 254 | VkResult loader_validate_instance_extensions( |
Jon Ashburn | 555d2ed | 2015-08-14 11:57:54 -0600 | [diff] [blame] | 255 | const struct loader_extension_list *icd_exts, |
Jon Ashburn | f6a6970 | 2015-08-11 14:49:54 -0600 | [diff] [blame] | 256 | const struct loader_layer_list *instance_layer, |
Courtney Goeltzenleuchter | 76ece70 | 2015-07-06 17:45:08 -0600 | [diff] [blame] | 257 | const VkInstanceCreateInfo* pCreateInfo); |
| 258 | |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 259 | /* instance layer chain termination entrypoint definitions */ |
Dan Ginsburg | a2d864e | 2015-07-23 13:15:00 -0400 | [diff] [blame] | 260 | VkResult VKAPI loader_CreateInstance( |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 261 | const VkInstanceCreateInfo* pCreateInfo, |
| 262 | VkInstance* pInstance); |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 263 | |
Dan Ginsburg | a2d864e | 2015-07-23 13:15:00 -0400 | [diff] [blame] | 264 | VkResult VKAPI loader_DestroyInstance( |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 265 | VkInstance instance); |
| 266 | |
Dan Ginsburg | a2d864e | 2015-07-23 13:15:00 -0400 | [diff] [blame] | 267 | VkResult VKAPI loader_EnumeratePhysicalDevices( |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 268 | VkInstance instance, |
| 269 | uint32_t* pPhysicalDeviceCount, |
| 270 | VkPhysicalDevice* pPhysicalDevices); |
Chris Forbes | 1c946ec | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 271 | |
Dan Ginsburg | a2d864e | 2015-07-23 13:15:00 -0400 | [diff] [blame] | 272 | VkResult VKAPI loader_GetPhysicalDeviceFeatures( |
Chris Forbes | 1c946ec | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 273 | VkPhysicalDevice physicalDevice, |
| 274 | VkPhysicalDeviceFeatures* pFeatures); |
| 275 | |
Dan Ginsburg | a2d864e | 2015-07-23 13:15:00 -0400 | [diff] [blame] | 276 | VkResult VKAPI loader_GetPhysicalDeviceFormatProperties( |
Chris Forbes | 1c946ec | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 277 | VkPhysicalDevice physicalDevice, |
| 278 | VkFormat format, |
| 279 | VkFormatProperties* pFormatInfo); |
| 280 | |
Jon Ashburn | 25c1145 | 2015-07-23 18:49:07 -0600 | [diff] [blame] | 281 | VkResult VKAPI loader_GetPhysicalDeviceImageFormatProperties( |
| 282 | VkPhysicalDevice physicalDevice, |
| 283 | VkFormat format, |
| 284 | VkImageType type, |
| 285 | VkImageTiling tiling, |
| 286 | VkImageUsageFlags usage, |
| 287 | VkImageFormatProperties* pImageFormatProperties); |
| 288 | |
Dan Ginsburg | a2d864e | 2015-07-23 13:15:00 -0400 | [diff] [blame] | 289 | VkResult VKAPI loader_GetPhysicalDeviceLimits( |
Chris Forbes | 1c946ec | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 290 | VkPhysicalDevice physicalDevice, |
| 291 | VkPhysicalDeviceLimits* pLimits); |
| 292 | |
Dan Ginsburg | a2d864e | 2015-07-23 13:15:00 -0400 | [diff] [blame] | 293 | VkResult VKAPI loader_GetPhysicalDeviceSparseImageFormatProperties( |
Mark Lobodzinski | 0c708be | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 294 | VkPhysicalDevice physicalDevice, |
| 295 | VkFormat format, |
| 296 | VkImageType type, |
| 297 | uint32_t samples, |
| 298 | VkImageUsageFlags usage, |
| 299 | VkImageTiling tiling, |
| 300 | uint32_t* pNumProperties, |
| 301 | VkSparseImageFormatProperties* pProperties); |
Tony Barbour | 4e657ba | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 302 | |
Dan Ginsburg | a2d864e | 2015-07-23 13:15:00 -0400 | [diff] [blame] | 303 | VkResult VKAPI loader_GetPhysicalDeviceProperties ( |
Tony Barbour | 4e657ba | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 304 | VkPhysicalDevice physicalDevice, |
| 305 | VkPhysicalDeviceProperties* pProperties); |
| 306 | |
Dan Ginsburg | a2d864e | 2015-07-23 13:15:00 -0400 | [diff] [blame] | 307 | VkResult VKAPI loader_GetPhysicalDeviceExtensionProperties (VkPhysicalDevice physicalDevice, |
Courtney Goeltzenleuchter | 44667cc | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 308 | const char *pLayerName, uint32_t *pCount, |
Tony Barbour | 4e657ba | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 309 | VkExtensionProperties* pProperties); |
| 310 | |
Dan Ginsburg | a2d864e | 2015-07-23 13:15:00 -0400 | [diff] [blame] | 311 | VkResult VKAPI loader_GetPhysicalDeviceLayerProperties (VkPhysicalDevice physicalDevice, |
Courtney Goeltzenleuchter | 44667cc | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 312 | uint32_t *pCount, |
| 313 | VkLayerProperties* pProperties); |
Tony Barbour | 4e657ba | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 314 | |
Cody Northrop | fc4ad13 | 2015-08-03 17:04:53 -0600 | [diff] [blame] | 315 | VkResult VKAPI loader_GetPhysicalDeviceQueueFamilyProperties ( |
| 316 | VkPhysicalDevice physicalDevice, |
| 317 | uint32_t* pCount, |
| 318 | VkQueueFamilyProperties* pProperties); |
Tony Barbour | 4e657ba | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 319 | |
Dan Ginsburg | a2d864e | 2015-07-23 13:15:00 -0400 | [diff] [blame] | 320 | VkResult VKAPI loader_GetPhysicalDeviceMemoryProperties ( |
Tony Barbour | 4e657ba | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 321 | VkPhysicalDevice physicalDevice, |
| 322 | VkPhysicalDeviceMemoryProperties * pProperties); |
Jon Ashburn | 7e8d8b4 | 2015-05-29 13:15:39 -0600 | [diff] [blame] | 323 | |
Dan Ginsburg | a2d864e | 2015-07-23 13:15:00 -0400 | [diff] [blame] | 324 | VkResult VKAPI loader_CreateDevice( |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 325 | VkPhysicalDevice gpu, |
| 326 | const VkDeviceCreateInfo* pCreateInfo, |
| 327 | VkDevice* pDevice); |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 328 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 329 | /* helper function definitions */ |
Jon Ashburn | 02a8d6e | 2015-07-02 12:59:25 -0600 | [diff] [blame] | 330 | bool has_vk_extension_property_array( |
| 331 | const VkExtensionProperties *vk_ext_prop, |
| 332 | const uint32_t count, |
| 333 | const VkExtensionProperties *ext_array); |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 334 | bool has_vk_extension_property( |
| 335 | const VkExtensionProperties *vk_ext_prop, |
| 336 | const struct loader_extension_list *ext_list); |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 337 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 338 | void loader_add_to_ext_list( |
| 339 | struct loader_extension_list *ext_list, |
| 340 | uint32_t prop_list_count, |
Jon Ashburn | b7d327c | 2015-08-04 11:14:18 -0600 | [diff] [blame] | 341 | const VkExtensionProperties *props); |
Courtney Goeltzenleuchter | 54fcee1 | 2015-06-08 15:09:22 -0600 | [diff] [blame] | 342 | void loader_destroy_ext_list(struct loader_extension_list *ext_info); |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 343 | |
Courtney Goeltzenleuchter | 44667cc | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 344 | void loader_add_to_layer_list( |
| 345 | struct loader_layer_list *list, |
| 346 | uint32_t prop_list_count, |
| 347 | const struct loader_layer_properties *props); |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 348 | void loader_icd_scan(void); |
Jon Ashburn | f6a6970 | 2015-08-11 14:49:54 -0600 | [diff] [blame] | 349 | void loader_layer_scan( |
| 350 | struct loader_layer_list *instance_layers, |
| 351 | struct loader_layer_list *device_layers); |
Jon Ashburn | 555d2ed | 2015-08-14 11:57:54 -0600 | [diff] [blame] | 352 | void loader_get_icd_loader_instance_extensions(struct loader_extension_list *inst_exts); |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 353 | |
Jon Ashburn | f6a6970 | 2015-08-11 14:49:54 -0600 | [diff] [blame] | 354 | struct loader_icd * loader_get_icd( |
| 355 | const VkPhysicalDevice gpu, |
| 356 | uint32_t *gpu_index); |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 357 | void loader_remove_logical_device(VkDevice device); |
Jon Ashburn | f6a6970 | 2015-08-11 14:49:54 -0600 | [diff] [blame] | 358 | VkResult loader_enable_instance_layers( |
| 359 | struct loader_instance *inst, |
| 360 | const VkInstanceCreateInfo *pCreateInfo, |
| 361 | const struct loader_layer_list *instance_layers); |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 362 | void loader_deactivate_instance_layers(struct loader_instance *instance); |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 363 | uint32_t loader_activate_instance_layers(struct loader_instance *inst); |
Courtney Goeltzenleuchter | 1c51240 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 364 | void loader_activate_instance_layer_extensions(struct loader_instance *inst); |
Courtney Goeltzenleuchter | 71b454b | 2015-07-05 11:28:29 -0600 | [diff] [blame] | 365 | |
| 366 | void* loader_heap_alloc( |
Jon Ashburn | f6a6970 | 2015-08-11 14:49:54 -0600 | [diff] [blame] | 367 | struct loader_instance *instance, |
| 368 | size_t size, |
| 369 | VkSystemAllocType allocType); |
Courtney Goeltzenleuchter | 71b454b | 2015-07-05 11:28:29 -0600 | [diff] [blame] | 370 | |
| 371 | void* loader_aligned_heap_alloc( |
Jon Ashburn | f6a6970 | 2015-08-11 14:49:54 -0600 | [diff] [blame] | 372 | struct loader_instance *instance, |
| 373 | size_t size, |
| 374 | size_t alignment, |
| 375 | VkSystemAllocType allocType); |
Courtney Goeltzenleuchter | 71b454b | 2015-07-05 11:28:29 -0600 | [diff] [blame] | 376 | |
| 377 | void loader_heap_free( |
Jon Ashburn | f6a6970 | 2015-08-11 14:49:54 -0600 | [diff] [blame] | 378 | struct loader_instance *instance, |
| 379 | void *pMem); |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 380 | #endif /* LOADER_H */ |