Chia-I Wu | 468e3c3 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 1 | /* |
Chia-I Wu | 468e3c3 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 2 | * |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014-2016 The Khronos Group Inc. |
| 4 | * Copyright (c) 2014-2016 Valve Corporation |
| 5 | * Copyright (c) 2014-2016 LunarG, Inc. |
Courtney Goeltzenleuchter | ebbb96d | 2015-12-02 14:53:22 -0700 | [diff] [blame] | 6 | * Copyright (C) 2015 Google Inc. |
Chia-I Wu | 468e3c3 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 7 | * |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | * of this software and/or associated documentation files (the "Materials"), to |
| 10 | * deal in the Materials without restriction, including without limitation the |
| 11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 12 | * sell copies of the Materials, and to permit persons to whom the Materials are |
| 13 | * furnished to do so, subject to the following conditions: |
Chia-I Wu | 468e3c3 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 14 | * |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 15 | * The above copyright notice(s) and this permission notice shall be included in |
| 16 | * all copies or substantial portions of the Materials. |
Chia-I Wu | 468e3c3 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 17 | * |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 18 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Chia-I Wu | 468e3c3 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
Chia-I Wu | 44e4236 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 21 | * |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 23 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 24 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE |
| 25 | * USE OR OTHER DEALINGS IN THE MATERIALS. |
| 26 | * |
| 27 | * Author: Jon Ashburn <jon@lunarg.com> |
| 28 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
Courtney Goeltzenleuchter | 96cd795 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 29 | * Author: Chia-I Wu <olvaffe@gmail.com> |
| 30 | * Author: Chia-I Wu <olv@lunarg.com> |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 31 | * Author: Mark Lobodzinski <mark@LunarG.com> |
Courtney Goeltzenleuchter | 96cd795 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 32 | * |
Chia-I Wu | 468e3c3 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 33 | */ |
| 34 | |
| 35 | #ifndef LOADER_H |
| 36 | #define LOADER_H |
| 37 | |
David Pinedo | 329ca9e | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 38 | #include <vulkan/vulkan.h> |
Aaron Karp | 074e0d5 | 2016-03-13 16:41:59 -0400 | [diff] [blame] | 39 | #include "vk_loader_platform.h" |
Ian Elliott | 64070a8 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 40 | |
David Pinedo | 329ca9e | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 41 | #include <vulkan/vk_layer.h> |
| 42 | #include <vulkan/vk_icd.h> |
Chia-I Wu | 1d6731b | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 43 | #include <assert.h> |
| 44 | |
Chia-I Wu | 468e3c3 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 45 | #if defined(__GNUC__) && __GNUC__ >= 4 |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 46 | #define LOADER_EXPORT __attribute__((visibility("default"))) |
Chia-I Wu | 468e3c3 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 47 | #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 48 | #define LOADER_EXPORT __attribute__((visibility("default"))) |
Chia-I Wu | 468e3c3 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 49 | #else |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 50 | #define LOADER_EXPORT |
Chia-I Wu | 468e3c3 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 51 | #endif |
| 52 | |
Jon Ashburn | 0b72805 | 2015-08-04 10:22:33 -0600 | [diff] [blame] | 53 | #define MAX_STRING_SIZE 1024 |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 54 | #define VK_MAJOR(version) (version >> 22) |
| 55 | #define VK_MINOR(version) ((version >> 12) & 0x3ff) |
| 56 | #define VK_PATCH(version) (version & 0xfff) |
Jon Ashburn | fce93d9 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 57 | |
Jon Ashburn | 68a6392 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 58 | enum layer_type { |
Jon Ashburn | 535bd00 | 2015-07-02 16:10:32 -0600 | [diff] [blame] | 59 | VK_LAYER_TYPE_DEVICE_EXPLICIT = 0x1, |
| 60 | VK_LAYER_TYPE_INSTANCE_EXPLICIT = 0x2, |
Jon Ashburn | 715de58 | 2016-02-10 20:59:26 -0700 | [diff] [blame] | 61 | VK_LAYER_TYPE_GLOBAL_EXPLICIT = 0x3, // instance and device layer, bitwise |
Jon Ashburn | 535bd00 | 2015-07-02 16:10:32 -0600 | [diff] [blame] | 62 | VK_LAYER_TYPE_DEVICE_IMPLICIT = 0x4, |
| 63 | VK_LAYER_TYPE_INSTANCE_IMPLICIT = 0x8, |
Jon Ashburn | 715de58 | 2016-02-10 20:59:26 -0700 | [diff] [blame] | 64 | VK_LAYER_TYPE_GLOBAL_IMPLICIT = 0xc, // instance and device layer, bitwise |
| 65 | VK_LAYER_TYPE_META_EXPLICT = 0x10, |
Jon Ashburn | 68a6392 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 66 | }; |
| 67 | |
Mark Lobodzinski | c882eee | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 68 | typedef enum VkStringErrorFlagBits { |
Jon Ashburn | 7ec85cd | 2016-02-10 20:50:19 -0700 | [diff] [blame] | 69 | VK_STRING_ERROR_NONE = 0x00000000, |
| 70 | VK_STRING_ERROR_LENGTH = 0x00000001, |
| 71 | VK_STRING_ERROR_BAD_DATA = 0x00000002, |
Mark Lobodzinski | c882eee | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 72 | } VkStringErrorFlagBits; |
| 73 | typedef VkFlags VkStringErrorFlags; |
| 74 | |
Jon Ashburn | 7ec85cd | 2016-02-10 20:50:19 -0700 | [diff] [blame] | 75 | static const int MaxLoaderStringLength = 256; |
| 76 | static const char UTF8_ONE_BYTE_CODE = 0xC0; |
| 77 | static const char UTF8_ONE_BYTE_MASK = 0xE0; |
| 78 | static const char UTF8_TWO_BYTE_CODE = 0xE0; |
| 79 | static const char UTF8_TWO_BYTE_MASK = 0xF0; |
| 80 | static const char UTF8_THREE_BYTE_CODE = 0xF0; |
| 81 | static const char UTF8_THREE_BYTE_MASK = 0xF8; |
| 82 | static const char UTF8_DATA_BYTE_CODE = 0x80; |
| 83 | static const char UTF8_DATA_BYTE_MASK = 0xC0; |
Mark Lobodzinski | c882eee | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 84 | |
Mark Lobodzinski | 0411f59 | 2016-03-15 17:23:12 -0600 | [diff] [blame] | 85 | static const char std_validation_names[8][VK_MAX_EXTENSION_NAME_SIZE] = { |
Jon Ashburn | 9b2a8c9 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 86 | "VK_LAYER_GOOGLE_threading", "VK_LAYER_LUNARG_parameter_validation", |
Jon Ashburn | 715de58 | 2016-02-10 20:59:26 -0700 | [diff] [blame] | 87 | "VK_LAYER_LUNARG_device_limits", "VK_LAYER_LUNARG_object_tracker", |
Jon Ashburn | 9b2a8c9 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 88 | "VK_LAYER_LUNARG_image", "VK_LAYER_LUNARG_core_validation", |
| 89 | "VK_LAYER_LUNARG_swapchain", "VK_LAYER_GOOGLE_unique_objects"}; |
Jon Ashburn | 715de58 | 2016-02-10 20:59:26 -0700 | [diff] [blame] | 90 | |
Jon Ashburn | 8f6be30 | 2015-12-10 08:51:10 -0700 | [diff] [blame] | 91 | // form of all dynamic lists/arrays |
| 92 | // only the list element should be changed |
| 93 | struct loader_generic_list { |
| 94 | size_t capacity; |
| 95 | uint32_t count; |
| 96 | void *list; |
| 97 | }; |
| 98 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 99 | struct loader_extension_list { |
| 100 | size_t capacity; |
| 101 | uint32_t count; |
Jon Ashburn | c4748dc | 2015-08-04 11:14:18 -0600 | [diff] [blame] | 102 | VkExtensionProperties *list; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 103 | }; |
| 104 | |
Jon Ashburn | 738136f | 2015-12-10 18:17:34 -0700 | [diff] [blame] | 105 | struct loader_dev_ext_props { |
| 106 | VkExtensionProperties props; |
| 107 | uint32_t entrypoint_count; |
| 108 | char **entrypoints; |
| 109 | }; |
| 110 | |
| 111 | struct loader_device_extension_list { |
| 112 | size_t capacity; |
| 113 | uint32_t count; |
| 114 | struct loader_dev_ext_props *list; |
| 115 | }; |
| 116 | |
Jon Ashburn | 68a6392 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 117 | struct loader_name_value { |
Jon Ashburn | 0b72805 | 2015-08-04 10:22:33 -0600 | [diff] [blame] | 118 | char name[MAX_STRING_SIZE]; |
| 119 | char value[MAX_STRING_SIZE]; |
Jon Ashburn | 68a6392 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 120 | }; |
| 121 | |
| 122 | struct loader_lib_info { |
Jon Ashburn | e9ca8fa | 2015-08-20 16:35:30 -0600 | [diff] [blame] | 123 | char lib_name[MAX_STRING_SIZE]; |
Jon Ashburn | 68a6392 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 124 | uint32_t ref_count; |
| 125 | loader_platform_dl_handle lib_handle; |
| 126 | }; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 127 | |
Jon Ashburn | 68a6392 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 128 | struct loader_layer_functions { |
Jon Ashburn | 0b72805 | 2015-08-04 10:22:33 -0600 | [diff] [blame] | 129 | char str_gipa[MAX_STRING_SIZE]; |
| 130 | char str_gdpa[MAX_STRING_SIZE]; |
Jon Ashburn | 68a6392 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 131 | PFN_vkGetInstanceProcAddr get_instance_proc_addr; |
| 132 | PFN_vkGetDeviceProcAddr get_device_proc_addr; |
| 133 | }; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 134 | |
Jon Ashburn | 68a6392 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 135 | struct loader_layer_properties { |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 136 | VkLayerProperties info; |
Jon Ashburn | 68a6392 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 137 | enum layer_type type; |
Jon Ashburn | e9ca8fa | 2015-08-20 16:35:30 -0600 | [diff] [blame] | 138 | char lib_name[MAX_STRING_SIZE]; |
Jon Ashburn | 68a6392 | 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 | 738136f | 2015-12-10 18:17:34 -0700 | [diff] [blame] | 141 | struct loader_device_extension_list device_extension_list; |
Jon Ashburn | 68a6392 | 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; |
| 144 | }; |
| 145 | |
| 146 | struct loader_layer_list { |
| 147 | size_t capacity; |
| 148 | uint32_t count; |
| 149 | struct loader_layer_properties *list; |
Jon Ashburn | fce93d9 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 150 | }; |
| 151 | |
Courtney Goeltzenleuchter | c5cf7d7 | 2015-07-05 12:53:31 -0600 | [diff] [blame] | 152 | struct loader_layer_library_list { |
| 153 | size_t capacity; |
| 154 | uint32_t count; |
| 155 | struct loader_lib_info *list; |
| 156 | }; |
| 157 | |
Jon Ashburn | 429e19f | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 158 | struct loader_dispatch_hash_list { |
| 159 | size_t capacity; |
| 160 | uint32_t count; |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 161 | uint32_t *index; // index into the dev_ext dispatch table |
Jon Ashburn | 429e19f | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 162 | }; |
| 163 | |
| 164 | #define MAX_NUM_DEV_EXTS 250 |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 165 | // loader_dispatch_hash_entry and loader_dev_ext_dispatch_table.DevExt have one |
| 166 | // to one |
Jon Ashburn | 429e19f | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 167 | // correspondence; one loader_dispatch_hash_entry for one DevExt dispatch entry. |
| 168 | // Also have a one to one correspondence with functions in dev_ext_trampoline.c |
| 169 | struct loader_dispatch_hash_entry { |
| 170 | char *func_name; |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 171 | struct loader_dispatch_hash_list list; // to handle hashing collisions |
Jon Ashburn | 429e19f | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 172 | }; |
| 173 | |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 174 | typedef void(VKAPI_PTR *PFN_vkDevExt)(VkDevice device); |
Jon Ashburn | 429e19f | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 175 | struct loader_dev_ext_dispatch_table { |
| 176 | PFN_vkDevExt DevExt[MAX_NUM_DEV_EXTS]; |
| 177 | }; |
| 178 | |
| 179 | struct loader_dev_dispatch_table { |
| 180 | VkLayerDispatchTable core_dispatch; |
| 181 | struct loader_dev_ext_dispatch_table ext_dispatch; |
| 182 | }; |
| 183 | |
Jon Ashburn | cb5a5ac | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 184 | /* per CreateDevice structure */ |
| 185 | struct loader_device { |
Jon Ashburn | 429e19f | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 186 | struct loader_dev_dispatch_table loader_dispatch; |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 187 | VkDevice device; // device object from the icd |
Jon Ashburn | cb5a5ac | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 188 | |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 189 | uint32_t app_extension_count; |
Jon Ashburn | cb5a5ac | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 190 | VkExtensionProperties *app_extension_props; |
| 191 | |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 192 | struct loader_layer_list activated_layer_list; |
Jon Ashburn | cb5a5ac | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 193 | |
| 194 | struct loader_device *next; |
| 195 | }; |
| 196 | |
Jon Ashburn | 6069926 | 2015-06-10 16:11:42 -0600 | [diff] [blame] | 197 | /* per ICD structure */ |
Jon Ashburn | 2666e2f | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 198 | struct loader_icd { |
Jon Ashburn | e9ca8fa | 2015-08-20 16:35:30 -0600 | [diff] [blame] | 199 | // pointers to find other structs |
| 200 | const struct loader_scanned_icds *this_icd_lib; |
| 201 | const struct loader_instance *this_instance; |
Jon Ashburn | cb5a5ac | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 202 | struct loader_device *logical_device_list; |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 203 | VkInstance instance; // instance object from the icd |
Jon Ashburn | 1245cec | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 204 | PFN_vkGetDeviceProcAddr GetDeviceProcAddr; |
Jon Ashburn | 2666e2f | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 205 | PFN_vkDestroyInstance DestroyInstance; |
| 206 | PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices; |
Chris Forbes | d757630 | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 207 | PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures; |
Courtney Goeltzenleuchter | 4da96aa | 2015-07-12 12:52:09 -0600 | [diff] [blame] | 208 | PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties; |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 209 | PFN_vkGetPhysicalDeviceImageFormatProperties |
| 210 | GetPhysicalDeviceImageFormatProperties; |
Jon Ashburn | 2666e2f | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 211 | PFN_vkCreateDevice CreateDevice; |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 212 | PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties; |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 213 | PFN_vkGetPhysicalDeviceQueueFamilyProperties |
| 214 | GetPhysicalDeviceQueueFamilyProperties; |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 215 | PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties; |
Courtney Goeltzenleuchter | 74c4ce9 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 216 | PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties; |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 217 | PFN_vkGetPhysicalDeviceSparseImageFormatProperties |
| 218 | GetPhysicalDeviceSparseImageFormatProperties; |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 219 | PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallbackEXT; |
| 220 | PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallbackEXT; |
| 221 | PFN_vkDebugReportMessageEXT DebugReportMessageEXT; |
Ian Elliott | 338dedb | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 222 | PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR; |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 223 | PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR |
| 224 | GetPhysicalDeviceSurfaceCapabilitiesKHR; |
Ian Elliott | 8cda180 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 225 | PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR; |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 226 | PFN_vkGetPhysicalDeviceSurfacePresentModesKHR |
| 227 | GetPhysicalDeviceSurfacePresentModesKHR; |
Ian Elliott | 4e309e9 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 228 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 229 | PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR |
| 230 | GetPhysicalDeviceWin32PresentationSupportKHR; |
Ian Elliott | 4e309e9 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 231 | #endif |
| 232 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 233 | PFN_vkGetPhysicalDeviceMirPresentationSupportKHR |
| 234 | GetPhysicalDeviceMirPresentvationSupportKHR; |
Ian Elliott | 4e309e9 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 235 | #endif |
| 236 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 237 | PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR |
| 238 | GetPhysicalDeviceWaylandPresentationSupportKHR; |
Ian Elliott | 4e309e9 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 239 | #endif |
| 240 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 241 | PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR |
| 242 | GetPhysicalDeviceXcbPresentationSupportKHR; |
Ian Elliott | 4e309e9 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 243 | #endif |
| 244 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 245 | PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR |
| 246 | GetPhysicalDeviceXlibPresentationSupportKHR; |
Ian Elliott | 4e309e9 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 247 | #endif |
Jon Ashburn | 00df045 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 248 | PFN_vkGetPhysicalDeviceDisplayPropertiesKHR |
| 249 | GetPhysicalDeviceDisplayPropertiesKHR; |
| 250 | PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR |
| 251 | GetPhysicalDeviceDisplayPlanePropertiesKHR; |
| 252 | PFN_vkGetDisplayPlaneSupportedDisplaysKHR |
| 253 | GetDisplayPlaneSupportedDisplaysKHR; |
Jon Ashburn | 9b2a8c9 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 254 | PFN_vkGetDisplayModePropertiesKHR GetDisplayModePropertiesKHR; |
| 255 | PFN_vkCreateDisplayModeKHR CreateDisplayModeKHR; |
| 256 | PFN_vkGetDisplayPlaneCapabilitiesKHR GetDisplayPlaneCapabilitiesKHR; |
| 257 | PFN_vkCreateDisplayPlaneSurfaceKHR CreateDisplayPlaneSurfaceKHR; |
| 258 | PFN_vkDestroySurfaceKHR DestroySurfaceKHR; |
Jon Ashburn | cb5a5ac | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 259 | struct loader_icd *next; |
Jon Ashburn | 2666e2f | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 260 | }; |
| 261 | |
Jon Ashburn | 754f199 | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 262 | /* per ICD library structure */ |
| 263 | struct loader_icd_libs { |
| 264 | size_t capacity; |
| 265 | uint32_t count; |
| 266 | struct loader_scanned_icds *list; |
| 267 | }; |
| 268 | |
Jon Ashburn | 6069926 | 2015-06-10 16:11:42 -0600 | [diff] [blame] | 269 | /* per instance structure */ |
Jon Ashburn | fce93d9 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 270 | struct loader_instance { |
Jon Ashburn | 2666e2f | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 271 | VkLayerInstanceDispatchTable *disp; // must be first entry in structure |
| 272 | |
Jon Ashburn | 8766043 | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 273 | uint32_t total_gpu_count; // count of the next two arrays |
| 274 | struct loader_physical_device *phys_devs_term; |
Jon Ashburn | 9b2a8c9 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 275 | struct loader_physical_device_tramp * |
| 276 | phys_devs; // tramp wrapped physDev obj list |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 277 | uint32_t total_icd_count; |
Jon Ashburn | fce93d9 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 278 | struct loader_icd *icds; |
| 279 | struct loader_instance *next; |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 280 | struct loader_extension_list ext_list; // icds and loaders extensions |
Jon Ashburn | 754f199 | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 281 | struct loader_icd_libs icd_libs; |
Jon Ashburn | e9ca8fa | 2015-08-20 16:35:30 -0600 | [diff] [blame] | 282 | struct loader_layer_list instance_layer_list; |
| 283 | struct loader_layer_list device_layer_list; |
Jon Ashburn | 429e19f | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 284 | struct loader_dispatch_hash_entry disp_hash[MAX_NUM_DEV_EXTS]; |
Jon Ashburn | e9ca8fa | 2015-08-20 16:35:30 -0600 | [diff] [blame] | 285 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 286 | struct loader_msg_callback_map_entry *icd_msg_callback_map; |
| 287 | |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 288 | struct loader_layer_list activated_layer_list; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 289 | |
Jon Ashburn | 9b2a8c9 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 290 | VkInstance instance; // layers/ICD instance returned to trampoline |
Courtney Goeltzenleuchter | 2bdf6da | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 291 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 292 | bool debug_report_enabled; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 293 | VkLayerDbgFunctionNode *DbgFunctionHead; |
Ian Elliott | 01b7832 | 2016-03-31 10:48:19 -0600 | [diff] [blame] | 294 | uint32_t num_tmp_callbacks; |
| 295 | VkDebugReportCallbackCreateInfoEXT *tmp_dbg_create_infos; |
| 296 | VkDebugReportCallbackEXT *tmp_callbacks; |
Courtney Goeltzenleuchter | b620ace | 2015-07-05 11:28:29 -0600 | [diff] [blame] | 297 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 298 | VkAllocationCallbacks alloc_callbacks; |
Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 299 | |
Ian Elliott | a81e8ac | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 300 | bool wsi_surface_enabled; |
Mark Lobodzinski | b3e934d | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 301 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | a81e8ac | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 302 | bool wsi_win32_surface_enabled; |
Mark Lobodzinski | b3e934d | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 303 | #endif |
| 304 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Ian Elliott | a81e8ac | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 305 | bool wsi_mir_surface_enabled; |
Mark Lobodzinski | b3e934d | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 306 | #endif |
| 307 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | a81e8ac | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 308 | bool wsi_wayland_surface_enabled; |
Mark Lobodzinski | b3e934d | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 309 | #endif |
| 310 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Ian Elliott | a81e8ac | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 311 | bool wsi_xcb_surface_enabled; |
Mark Lobodzinski | b3e934d | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 312 | #endif |
| 313 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Ian Elliott | a81e8ac | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 314 | bool wsi_xlib_surface_enabled; |
Mark Lobodzinski | b3e934d | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 315 | #endif |
| 316 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 317 | bool wsi_android_surface_enabled; |
| 318 | #endif |
Jon Ashburn | 00df045 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 319 | bool wsi_display_enabled; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 320 | }; |
| 321 | |
Jon Ashburn | 8766043 | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 322 | /* VkPhysicalDevice requires special treatment by loader. Firstly, terminator |
| 323 | * code must be able to get the struct loader_icd to call into the proper |
| 324 | * driver (multiple ICD/gpu case). This can be accomplished by wrapping the |
| 325 | * created VkPhysicalDevice in loader terminate_EnumeratePhysicalDevices(). |
Piers Daniell | fc50041 | 2016-03-29 11:51:11 -0600 | [diff] [blame] | 326 | * Secondly, the loader must be able to handle wrapped by layer VkPhysicalDevice |
Jon Ashburn | 8766043 | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 327 | * in trampoline code. This implies, that the loader trampoline code must also |
| 328 | * wrap the VkPhysicalDevice object in trampoline code. Thus, loader has to |
| 329 | * wrap the VkPhysicalDevice created object twice. In trampoline code it can't |
| 330 | * rely on the terminator object wrapping since a layer may also wrap. Since |
| 331 | * trampoline code wraps the VkPhysicalDevice this means all loader trampoline |
| 332 | * code that passes a VkPhysicalDevice should unwrap it. */ |
| 333 | |
| 334 | /* per enumerated PhysicalDevice structure, used to wrap in trampoline code and |
| 335 | also same structure used to wrap in terminator code */ |
Jon Ashburn | 3c4a114 | 2016-03-24 15:49:57 -0600 | [diff] [blame] | 336 | struct loader_physical_device_tramp { |
| 337 | VkLayerInstanceDispatchTable *disp; // must be first entry in structure |
Piers Daniell | fc50041 | 2016-03-29 11:51:11 -0600 | [diff] [blame] | 338 | struct loader_instance *this_instance; |
Jon Ashburn | 9b2a8c9 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 339 | VkPhysicalDevice phys_dev; // object from layers/loader terminator |
Jon Ashburn | 3c4a114 | 2016-03-24 15:49:57 -0600 | [diff] [blame] | 340 | }; |
| 341 | |
| 342 | /* per enumerated PhysicalDevice structure, used to wrap in terminator code */ |
Jon Ashburn | 251258f | 2015-11-01 14:04:06 -0700 | [diff] [blame] | 343 | struct loader_physical_device { |
| 344 | VkLayerInstanceDispatchTable *disp; // must be first entry in structure |
Jon Ashburn | 251258f | 2015-11-01 14:04:06 -0700 | [diff] [blame] | 345 | struct loader_icd *this_icd; |
Jon Ashburn | 3c4a114 | 2016-03-24 15:49:57 -0600 | [diff] [blame] | 346 | VkPhysicalDevice phys_dev; // object from ICD |
Jon Ashburn | 251258f | 2015-11-01 14:04:06 -0700 | [diff] [blame] | 347 | }; |
| 348 | |
Jon Ashburn | fce93d9 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 349 | struct loader_struct { |
| 350 | struct loader_instance *instances; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 351 | |
| 352 | unsigned int loaded_layer_lib_count; |
Courtney Goeltzenleuchter | a2f21d0 | 2015-10-07 09:00:34 -0600 | [diff] [blame] | 353 | size_t loaded_layer_lib_capacity; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 354 | struct loader_lib_info *loaded_layer_lib_list; |
Jon Ashburn | 754f199 | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 355 | // TODO add ref counting of ICD libraries |
Jon Ashburn | 1b111de | 2015-07-06 15:40:35 -0600 | [diff] [blame] | 356 | // TODO use this struct loader_layer_library_list scanned_layer_libraries; |
Jon Ashburn | 754f199 | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 357 | // TODO add list of icd libraries for ref counting them for closure |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 358 | }; |
| 359 | |
| 360 | struct loader_scanned_icds { |
| 361 | char *lib_name; |
| 362 | loader_platform_dl_handle handle; |
Jon Ashburn | 0083b22 | 2015-11-17 17:35:40 -0700 | [diff] [blame] | 363 | uint32_t api_version; |
Jon Ashburn | ce7e3d9 | 2015-07-16 10:17:29 -0600 | [diff] [blame] | 364 | PFN_vkGetInstanceProcAddr GetInstanceProcAddr; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 365 | PFN_vkCreateInstance CreateInstance; |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 366 | PFN_vkEnumerateInstanceExtensionProperties |
| 367 | EnumerateInstanceExtensionProperties; |
Jon Ashburn | fce93d9 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 368 | }; |
| 369 | |
Jon Ashburn | 68a6392 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 370 | static inline struct loader_instance *loader_instance(VkInstance instance) { |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 371 | return (struct loader_instance *)instance; |
Jon Ashburn | 68a6392 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 372 | } |
| 373 | |
Jon Ashburn | 8766043 | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 374 | static inline VkPhysicalDevice |
| 375 | loader_unwrap_physical_device(VkPhysicalDevice physicalDevice) { |
Piers Daniell | 9c28c38 | 2016-03-31 14:47:57 -0600 | [diff] [blame] | 376 | struct loader_physical_device_tramp *phys_dev = |
| 377 | (struct loader_physical_device_tramp *)physicalDevice; |
Jon Ashburn | 8766043 | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 378 | return phys_dev->phys_dev; |
| 379 | } |
| 380 | |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 381 | static inline void loader_set_dispatch(void *obj, const void *data) { |
| 382 | *((const void **)obj) = data; |
Chia-I Wu | 1d6731b | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 383 | } |
| 384 | |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 385 | static inline VkLayerDispatchTable *loader_get_dispatch(const void *obj) { |
| 386 | return *((VkLayerDispatchTable **)obj); |
Chia-I Wu | 1d6731b | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 387 | } |
| 388 | |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 389 | static inline struct loader_dev_dispatch_table * |
| 390 | loader_get_dev_dispatch(const void *obj) { |
| 391 | return *((struct loader_dev_dispatch_table **)obj); |
Jon Ashburn | 429e19f | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 392 | } |
| 393 | |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 394 | static inline VkLayerInstanceDispatchTable * |
| 395 | loader_get_instance_dispatch(const void *obj) { |
| 396 | return *((VkLayerInstanceDispatchTable **)obj); |
Jon Ashburn | fce93d9 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 397 | } |
| 398 | |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 399 | static inline void loader_init_dispatch(void *obj, const void *data) { |
Jon Ashburn | 166641e | 2015-04-15 13:34:33 -0600 | [diff] [blame] | 400 | #ifdef DEBUG |
Chia-I Wu | 1d6731b | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 401 | assert(valid_loader_magic_value(obj) && |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 402 | "Incompatible ICD, first dword must be initialized to " |
| 403 | "ICD_LOADER_MAGIC. See loader/README.md for details."); |
Jon Ashburn | 166641e | 2015-04-15 13:34:33 -0600 | [diff] [blame] | 404 | #endif |
Chia-I Wu | 1d6731b | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 405 | |
Jon Ashburn | da7c20d | 2015-05-01 18:00:33 -0600 | [diff] [blame] | 406 | loader_set_dispatch(obj, data); |
Chia-I Wu | 1d6731b | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 407 | } |
| 408 | |
Jon Ashburn | fce93d9 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 409 | /* global variables used across files */ |
| 410 | extern struct loader_struct loader; |
Jon Ashburn | 413d658 | 2015-08-28 15:19:27 -0600 | [diff] [blame] | 411 | extern THREAD_LOCAL_DECL struct loader_instance *tls_instance; |
Jon Ashburn | 754f199 | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 412 | extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_init); |
Jon Ashburn | b40f256 | 2015-05-29 13:15:39 -0600 | [diff] [blame] | 413 | extern loader_platform_thread_mutex loader_lock; |
Jon Ashburn | d02fc2c | 2015-09-22 13:11:00 -0600 | [diff] [blame] | 414 | extern loader_platform_thread_mutex loader_json_lock; |
Jon Ashburn | b40f256 | 2015-05-29 13:15:39 -0600 | [diff] [blame] | 415 | extern const VkLayerInstanceDispatchTable instance_disp; |
Jon Ashburn | 715de58 | 2016-02-10 20:59:26 -0700 | [diff] [blame] | 416 | extern const char *std_validation_str; |
Jon Ashburn | 301c5f0 | 2015-04-06 10:58:22 -0600 | [diff] [blame] | 417 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 418 | struct loader_msg_callback_map_entry { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 419 | VkDebugReportCallbackEXT icd_obj; |
| 420 | VkDebugReportCallbackEXT loader_obj; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 421 | }; |
| 422 | |
Jon Ashburn | a9c4a57 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 423 | /* helper function definitions */ |
| 424 | void *loader_heap_alloc(const struct loader_instance *instance, size_t size, |
| 425 | VkSystemAllocationScope allocationScope); |
| 426 | |
| 427 | void loader_heap_free(const struct loader_instance *instance, void *pMemory); |
| 428 | |
| 429 | void *loader_tls_heap_alloc(size_t size); |
| 430 | |
| 431 | void loader_tls_heap_free(void *pMemory); |
| 432 | |
Jon Ashburn | 7d1a53d | 2016-02-12 08:20:06 -0700 | [diff] [blame] | 433 | void loader_log(const struct loader_instance *inst, VkFlags msg_type, |
Jon Ashburn | a9c4a57 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 434 | int32_t msg_code, const char *format, ...); |
Jon Ashburn | 7d1a53d | 2016-02-12 08:20:06 -0700 | [diff] [blame] | 435 | |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 436 | bool compare_vk_extension_properties(const VkExtensionProperties *op1, |
| 437 | const VkExtensionProperties *op2); |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 438 | |
Mark Lobodzinski | c882eee | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 439 | VkResult loader_validate_layers(const struct loader_instance *inst, |
| 440 | const uint32_t layer_count, |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 441 | const char *const *ppEnabledLayerNames, |
| 442 | const struct loader_layer_list *list); |
Courtney Goeltzenleuchter | 5d9f29b | 2015-07-06 17:45:08 -0600 | [diff] [blame] | 443 | |
| 444 | VkResult loader_validate_instance_extensions( |
Mark Lobodzinski | c882eee | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 445 | const struct loader_instance *inst, |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 446 | const struct loader_extension_list *icd_exts, |
| 447 | const struct loader_layer_list *instance_layer, |
| 448 | const VkInstanceCreateInfo *pCreateInfo); |
Courtney Goeltzenleuchter | 5d9f29b | 2015-07-06 17:45:08 -0600 | [diff] [blame] | 449 | |
Jon Ashburn | 754f199 | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 450 | void loader_initialize(void); |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 451 | bool has_vk_extension_property_array(const VkExtensionProperties *vk_ext_prop, |
| 452 | const uint32_t count, |
| 453 | const VkExtensionProperties *ext_array); |
| 454 | bool has_vk_extension_property(const VkExtensionProperties *vk_ext_prop, |
| 455 | const struct loader_extension_list *ext_list); |
Jon Ashburn | fce93d9 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 456 | |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 457 | VkResult loader_add_to_ext_list(const struct loader_instance *inst, |
| 458 | struct loader_extension_list *ext_list, |
| 459 | uint32_t prop_list_count, |
| 460 | const VkExtensionProperties *props); |
Jon Ashburn | 9b2a8c9 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 461 | VkResult |
| 462 | loader_add_to_dev_ext_list(const struct loader_instance *inst, |
| 463 | struct loader_device_extension_list *ext_list, |
| 464 | const VkExtensionProperties *props, |
| 465 | uint32_t entry_count, char **entrys); |
Jon Ashburn | a9c4a57 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 466 | VkResult loader_add_device_extensions(const struct loader_instance *inst, |
Jon Ashburn | 9b2a8c9 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 467 | PFN_vkEnumerateDeviceExtensionProperties |
| 468 | fpEnumerateDeviceExtensionProperties, |
Jon Ashburn | a9c4a57 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 469 | VkPhysicalDevice physical_device, |
| 470 | const char *lib_name, |
| 471 | struct loader_extension_list *ext_list); |
| 472 | bool loader_init_generic_list(const struct loader_instance *inst, |
| 473 | struct loader_generic_list *list_info, |
| 474 | size_t element_size); |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 475 | void loader_destroy_generic_list(const struct loader_instance *inst, |
| 476 | struct loader_generic_list *list); |
Jon Ashburn | a9c4a57 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 477 | void loader_destroy_layer_list(const struct loader_instance *inst, |
| 478 | struct loader_layer_list *layer_list); |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 479 | void loader_delete_layer_properties(const struct loader_instance *inst, |
| 480 | struct loader_layer_list *layer_list); |
Jon Ashburn | 715de58 | 2016-02-10 20:59:26 -0700 | [diff] [blame] | 481 | void loader_expand_layer_names( |
| 482 | const struct loader_instance *inst, const char *key_name, |
| 483 | uint32_t expand_count, |
| 484 | const char expand_names[][VK_MAX_EXTENSION_NAME_SIZE], |
Jon Ashburn | 9b2a8c9 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 485 | uint32_t *layer_count, char const *const **ppp_layer_names); |
Chris Forbes | eef20d0 | 2016-04-06 20:49:02 +1200 | [diff] [blame] | 486 | void loader_delete_shadow_dev_layer_names(const struct loader_instance *inst, |
| 487 | const VkDeviceCreateInfo *orig, |
| 488 | VkDeviceCreateInfo *ours); |
| 489 | void loader_delete_shadow_inst_layer_names(const struct loader_instance *inst, |
| 490 | const VkInstanceCreateInfo *orig, |
| 491 | VkInstanceCreateInfo *ours); |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 492 | void loader_add_to_layer_list(const struct loader_instance *inst, |
| 493 | struct loader_layer_list *list, |
| 494 | uint32_t prop_list_count, |
| 495 | const struct loader_layer_properties *props); |
Jon Ashburn | 9b2a8c9 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 496 | void loader_find_layer_name_add_list( |
| 497 | const struct loader_instance *inst, const char *name, |
| 498 | const enum layer_type type, const struct loader_layer_list *search_list, |
| 499 | struct loader_layer_list *found_list); |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 500 | void loader_scanned_icd_clear(const struct loader_instance *inst, |
| 501 | struct loader_icd_libs *icd_libs); |
| 502 | void loader_icd_scan(const struct loader_instance *inst, |
| 503 | struct loader_icd_libs *icds); |
| 504 | void loader_layer_scan(const struct loader_instance *inst, |
| 505 | struct loader_layer_list *instance_layers, |
| 506 | struct loader_layer_list *device_layers); |
Jeremy Hayes | 0005c0c | 2016-04-01 11:40:26 -0600 | [diff] [blame] | 507 | void loader_implicit_layer_scan(const struct loader_instance *inst, |
Jon Ashburn | 9b2a8c9 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 508 | struct loader_layer_list *instance_layers, |
| 509 | struct loader_layer_list *device_layers); |
Jon Ashburn | 754f199 | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 510 | void loader_get_icd_loader_instance_extensions( |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 511 | const struct loader_instance *inst, struct loader_icd_libs *icd_libs, |
| 512 | struct loader_extension_list *inst_exts); |
| 513 | struct loader_icd *loader_get_icd_and_device(const VkDevice device, |
| 514 | struct loader_device **found_dev); |
Jon Ashburn | a9c4a57 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 515 | void loader_init_dispatch_dev_ext(struct loader_instance *inst, |
| 516 | struct loader_device *dev); |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 517 | void *loader_dev_ext_gpa(struct loader_instance *inst, const char *funcName); |
| 518 | void *loader_get_dev_ext_trampoline(uint32_t index); |
| 519 | struct loader_instance *loader_get_instance(const VkInstance instance); |
Jon Ashburn | a9c4a57 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 520 | struct loader_device * |
Piers Daniell | fc50041 | 2016-03-29 11:51:11 -0600 | [diff] [blame] | 521 | loader_create_logical_device(const struct loader_instance *inst); |
| 522 | void loader_add_logical_device(const struct loader_instance *inst, |
| 523 | struct loader_icd *icd, |
| 524 | struct loader_device *found_dev); |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 525 | void loader_remove_logical_device(const struct loader_instance *inst, |
| 526 | struct loader_icd *icd, |
| 527 | struct loader_device *found_dev); |
| 528 | VkResult |
| 529 | loader_enable_instance_layers(struct loader_instance *inst, |
| 530 | const VkInstanceCreateInfo *pCreateInfo, |
| 531 | const struct loader_layer_list *instance_layers); |
Jon Ashburn | cb5a5ac | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 532 | void loader_deactivate_instance_layers(struct loader_instance *instance); |
Courtney Goeltzenleuchter | 2bdf6da | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 533 | |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 534 | VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, |
| 535 | const VkAllocationCallbacks *pAllocator, |
| 536 | struct loader_instance *inst, |
Jon Ashburn | a4b3494 | 2016-02-03 12:37:30 -0700 | [diff] [blame] | 537 | VkInstance *created_instance); |
Courtney Goeltzenleuchter | 2bdf6da | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 538 | |
Jon Ashburn | 44aed66 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 539 | void loader_activate_instance_layer_extensions(struct loader_instance *inst, |
| 540 | VkInstance created_inst); |
Jon Ashburn | a9c4a57 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 541 | VkResult |
| 542 | loader_enable_device_layers(const struct loader_instance *inst, |
Jon Ashburn | a9c4a57 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 543 | struct loader_layer_list *activated_layer_list, |
| 544 | const VkDeviceCreateInfo *pCreateInfo, |
| 545 | const struct loader_layer_list *device_layers); |
Courtney Goeltzenleuchter | b620ace | 2015-07-05 11:28:29 -0600 | [diff] [blame] | 546 | |
Jon Ashburn | 9b2a8c9 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 547 | VkResult |
| 548 | loader_create_device_chain(const struct loader_physical_device_tramp *pd, |
| 549 | const VkDeviceCreateInfo *pCreateInfo, |
| 550 | const VkAllocationCallbacks *pAllocator, |
| 551 | const struct loader_instance *inst, |
| 552 | struct loader_device *dev); |
Jon Ashburn | a9c4a57 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 553 | VkResult loader_validate_device_extensions( |
Jon Ashburn | 3c4a114 | 2016-03-24 15:49:57 -0600 | [diff] [blame] | 554 | struct loader_physical_device_tramp *phys_dev, |
Jon Ashburn | a9c4a57 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 555 | const struct loader_layer_list *activated_device_layers, |
Jon Ashburn | 8766043 | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 556 | const struct loader_extension_list *icd_exts, |
Jon Ashburn | a9c4a57 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 557 | const VkDeviceCreateInfo *pCreateInfo); |
Courtney Goeltzenleuchter | b620ace | 2015-07-05 11:28:29 -0600 | [diff] [blame] | 558 | |
Jon Ashburn | a9c4a57 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 559 | /* instance layer chain termination entrypoint definitions */ |
| 560 | VKAPI_ATTR VkResult VKAPI_CALL |
| 561 | terminator_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, |
| 562 | const VkAllocationCallbacks *pAllocator, |
| 563 | VkInstance *pInstance); |
Jon Ashburn | 413d658 | 2015-08-28 15:19:27 -0600 | [diff] [blame] | 564 | |
Jon Ashburn | a9c4a57 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 565 | VKAPI_ATTR void VKAPI_CALL |
| 566 | terminator_DestroyInstance(VkInstance instance, |
| 567 | const VkAllocationCallbacks *pAllocator); |
Jon Ashburn | 413d658 | 2015-08-28 15:19:27 -0600 | [diff] [blame] | 568 | |
Jon Ashburn | a9c4a57 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 569 | VKAPI_ATTR VkResult VKAPI_CALL |
| 570 | terminator_EnumeratePhysicalDevices(VkInstance instance, |
| 571 | uint32_t *pPhysicalDeviceCount, |
| 572 | VkPhysicalDevice *pPhysicalDevices); |
| 573 | |
| 574 | VKAPI_ATTR void VKAPI_CALL |
| 575 | terminator_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, |
| 576 | VkPhysicalDeviceFeatures *pFeatures); |
| 577 | |
| 578 | VKAPI_ATTR void VKAPI_CALL |
| 579 | terminator_GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, |
| 580 | VkFormat format, |
| 581 | VkFormatProperties *pFormatInfo); |
| 582 | |
| 583 | VKAPI_ATTR VkResult VKAPI_CALL |
| 584 | terminator_GetPhysicalDeviceImageFormatProperties( |
| 585 | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, |
| 586 | VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, |
| 587 | VkImageFormatProperties *pImageFormatProperties); |
| 588 | |
| 589 | VKAPI_ATTR void VKAPI_CALL |
| 590 | terminator_GetPhysicalDeviceSparseImageFormatProperties( |
| 591 | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, |
| 592 | VkSampleCountFlagBits samples, VkImageUsageFlags usage, |
| 593 | VkImageTiling tiling, uint32_t *pNumProperties, |
| 594 | VkSparseImageFormatProperties *pProperties); |
| 595 | |
| 596 | VKAPI_ATTR void VKAPI_CALL |
| 597 | terminator_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, |
| 598 | VkPhysicalDeviceProperties *pProperties); |
| 599 | |
| 600 | VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceExtensionProperties( |
| 601 | VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pCount, |
| 602 | VkExtensionProperties *pProperties); |
| 603 | |
| 604 | VKAPI_ATTR VkResult VKAPI_CALL |
| 605 | terminator_EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, |
| 606 | uint32_t *pCount, |
| 607 | VkLayerProperties *pProperties); |
| 608 | |
| 609 | VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceQueueFamilyProperties( |
| 610 | VkPhysicalDevice physicalDevice, uint32_t *pCount, |
| 611 | VkQueueFamilyProperties *pProperties); |
| 612 | |
| 613 | VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMemoryProperties( |
| 614 | VkPhysicalDevice physicalDevice, |
| 615 | VkPhysicalDeviceMemoryProperties *pProperties); |
| 616 | |
| 617 | VKAPI_ATTR VkResult VKAPI_CALL |
| 618 | terminator_CreateDevice(VkPhysicalDevice gpu, |
| 619 | const VkDeviceCreateInfo *pCreateInfo, |
| 620 | const VkAllocationCallbacks *pAllocator, |
| 621 | VkDevice *pDevice); |
Mark Lobodzinski | c882eee | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 622 | |
Jon Ashburn | 7ec85cd | 2016-02-10 20:50:19 -0700 | [diff] [blame] | 623 | VkStringErrorFlags vk_string_validate(const int max_length, |
| 624 | const char *char_array); |
Mark Lobodzinski | c882eee | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 625 | |
Chia-I Wu | 468e3c3 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 626 | #endif /* LOADER_H */ |