2
0

loader.h 23 KB

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