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