/src/vulkan-loader/loader/loader_common.h
Line | Count | Source |
1 | | /* |
2 | | * |
3 | | * Copyright (c) 2014-2022 The Khronos Group Inc. |
4 | | * Copyright (c) 2014-2022 Valve Corporation |
5 | | * Copyright (c) 2014-2022 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 | | * Author: Charles Giessen <charles@lunarg.com> |
27 | | * |
28 | | */ |
29 | | |
30 | | #pragma once |
31 | | |
32 | | #include "vulkan/vk_platform.h" |
33 | | #include <vulkan/vulkan.h> |
34 | | #include <vulkan/vk_layer.h> |
35 | | #include <vulkan/vk_icd.h> |
36 | | |
37 | | #include "vk_loader_platform.h" |
38 | | #include "vk_loader_layer.h" |
39 | | #include "vk_layer_dispatch_table.h" |
40 | | #include "vk_loader_extensions.h" |
41 | | |
42 | | #include "settings.h" |
43 | | |
44 | | typedef enum VkStringErrorFlagBits { |
45 | | VK_STRING_ERROR_NONE = 0x00000000, |
46 | | VK_STRING_ERROR_LENGTH = 0x00000001, |
47 | | VK_STRING_ERROR_BAD_DATA = 0x00000002, |
48 | | VK_STRING_ERROR_NULL_PTR = 0x00000004, |
49 | | } VkStringErrorFlagBits; |
50 | | typedef VkFlags VkStringErrorFlags; |
51 | | |
52 | | static const int MaxLoaderStringLength = 256; // 0xFF; |
53 | | static const unsigned char UTF8_ONE_BYTE_CODE = 192; // 0xC0; |
54 | | static const unsigned char UTF8_ONE_BYTE_MASK = 224; // 0xE0; |
55 | | static const unsigned char UTF8_TWO_BYTE_CODE = 224; // 0xE0; |
56 | | static const unsigned char UTF8_TWO_BYTE_MASK = 240; // 0xF0; |
57 | | static const unsigned char UTF8_THREE_BYTE_CODE = 240; // 0xF0; |
58 | | static const unsigned char UTF8_THREE_BYTE_MASK = 248; // 0xF8; |
59 | | static const unsigned char UTF8_DATA_BYTE_CODE = 128; // 0x80; |
60 | | static const unsigned char UTF8_DATA_BYTE_MASK = 192; // 0xC0; |
61 | | |
62 | | // 32-bit FNV-1a (https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function). Mirrored |
63 | | // byte-for-byte in Python as loader_hash_string() in scripts/generators/loader_extension_generator.py, |
64 | | // which precomputes the hash constants embedded in loader/generated/vk_loader_extensions.c - keep both in |
65 | | // sync or those constants stop matching this function (see HashString.MatchesGeneratorEmbeddedConstants in |
66 | | // tests/loader_hash_string_tests.cpp). |
67 | | // |
68 | | // Used as a cheap pre-filter before the strcmp confirmation when resolving entry point names |
69 | | // (vkGet{Instance,Device}ProcAddr): a hash match still falls through to a switch/case-guarded strcmp before |
70 | | // anything is returned, so a collision can never produce a wrong lookup - at worst it costs one extra |
71 | | // strcmp. Bounded by MaxLoaderStringLength so a non-NUL-terminated or adversarially long input can't make |
72 | | // this scan past a bounded byte count the way an unbounded `while (*str)` would. MaxLoaderStringLength is |
73 | | // an unrelated pre-existing constant reused here for convenience, not a bound derived from entry point |
74 | | // name lengths; every real entry point name is far shorter than the cap, so this never changes the hash |
75 | | // of a valid name. |
76 | 0 | static inline uint32_t loader_hash_string(const char *str) { |
77 | 0 | uint32_t hash = 2166136261u; |
78 | 0 | for (uint32_t i = 0; i < (uint32_t)MaxLoaderStringLength && str[i]; ++i) { |
79 | 0 | hash ^= (uint8_t)str[i]; |
80 | 0 | hash *= 16777619u; |
81 | 0 | } |
82 | 0 | return hash; |
83 | 0 | } Unexecuted instantiation: instance_enumerate_fuzzer.c:loader_hash_string Unexecuted instantiation: trampoline.c:loader_hash_string Unexecuted instantiation: allocation.c:loader_hash_string Unexecuted instantiation: debug_utils.c:loader_hash_string Unexecuted instantiation: gpa_helper.c:loader_hash_string Unexecuted instantiation: loader.c:loader_hash_string Unexecuted instantiation: loader_environment.c:loader_hash_string Unexecuted instantiation: loader_json.c:loader_hash_string Unexecuted instantiation: loader_linux.c:loader_hash_string Unexecuted instantiation: log.c:loader_hash_string Unexecuted instantiation: settings.c:loader_hash_string Unexecuted instantiation: terminator.c:loader_hash_string Unexecuted instantiation: unknown_function_handling.c:loader_hash_string Unexecuted instantiation: wsi.c:loader_hash_string Unexecuted instantiation: cJSON.c:loader_hash_string Unexecuted instantiation: extension_manual.c:loader_hash_string |
84 | | |
85 | | // form of all dynamic lists/arrays |
86 | | // only the list element should be changed |
87 | | struct loader_generic_list { |
88 | | size_t capacity; |
89 | | uint32_t count; |
90 | | void *list; |
91 | | }; |
92 | | |
93 | | struct loader_string_list { |
94 | | uint32_t allocated_count; |
95 | | uint32_t count; |
96 | | char **list; |
97 | | }; |
98 | | |
99 | | struct loader_extension_list { |
100 | | size_t capacity; |
101 | | uint32_t count; |
102 | | VkExtensionProperties *list; |
103 | | }; |
104 | | |
105 | | struct loader_dev_ext_props { |
106 | | VkExtensionProperties props; |
107 | | struct loader_string_list entrypoints; |
108 | | }; |
109 | | |
110 | | struct loader_device_extension_list { |
111 | | size_t capacity; |
112 | | uint32_t count; |
113 | | struct loader_dev_ext_props *list; |
114 | | }; |
115 | | |
116 | | struct loader_used_object_status { |
117 | | VkBool32 status; |
118 | | VkAllocationCallbacks allocation_callbacks; |
119 | | }; |
120 | | |
121 | | struct loader_used_object_list { |
122 | | size_t capacity; |
123 | | uint32_t padding; // count variable isn't used |
124 | | struct loader_used_object_status *list; |
125 | | }; |
126 | | |
127 | | struct loader_surface_allocation { |
128 | | VkSurfaceKHR surface; |
129 | | VkAllocationCallbacks allocation_callbacks; |
130 | | }; |
131 | | |
132 | | struct loader_surface_list { |
133 | | size_t capacity; |
134 | | uint32_t padding; // count variable isn't used |
135 | | VkSurfaceKHR *list; |
136 | | }; |
137 | | |
138 | | struct loader_debug_utils_messenger_list { |
139 | | size_t capacity; |
140 | | uint32_t padding; // count variable isn't used |
141 | | VkDebugUtilsMessengerEXT *list; |
142 | | }; |
143 | | |
144 | | struct loader_debug_report_callback_list { |
145 | | size_t capacity; |
146 | | uint32_t padding; // count variable isn't used |
147 | | VkDebugReportCallbackEXT *list; |
148 | | }; |
149 | | |
150 | | struct loader_name_value { |
151 | | char *name; |
152 | | char *value; |
153 | | }; |
154 | | |
155 | | struct loader_layer_functions { |
156 | | char *str_gipa; |
157 | | char *str_gdpa; |
158 | | char *str_negotiate_interface; |
159 | | PFN_vkNegotiateLoaderLayerInterfaceVersion negotiate_layer_interface; |
160 | | PFN_vkGetInstanceProcAddr get_instance_proc_addr; |
161 | | PFN_vkGetDeviceProcAddr get_device_proc_addr; |
162 | | PFN_GetPhysicalDeviceProcAddr get_physical_device_proc_addr; |
163 | | }; |
164 | | |
165 | | // This structure is used to store the json file version in a more manageable way. |
166 | | typedef struct { |
167 | | uint16_t major; |
168 | | uint16_t minor; |
169 | | uint16_t patch; |
170 | | } loader_api_version; |
171 | | |
172 | | // Enumeration used to clearly identify reason for library load failure. |
173 | | enum loader_layer_library_status { |
174 | | LOADER_LAYER_LIB_NOT_LOADED = 0, |
175 | | |
176 | | LOADER_LAYER_LIB_SUCCESS_LOADED = 1, |
177 | | |
178 | | LOADER_LAYER_LIB_ERROR_WRONG_BIT_TYPE = 20, |
179 | | LOADER_LAYER_LIB_ERROR_FAILED_TO_LOAD = 21, |
180 | | LOADER_LAYER_LIB_ERROR_OUT_OF_MEMORY = 22, |
181 | | }; |
182 | | |
183 | | enum layer_type_flags { |
184 | | VK_LAYER_TYPE_FLAG_INSTANCE_LAYER = 0x1, // If not set, indicates Device layer |
185 | | VK_LAYER_TYPE_FLAG_EXPLICIT_LAYER = 0x2, // If not set, indicates Implicit layer |
186 | | VK_LAYER_TYPE_FLAG_META_LAYER = 0x4, // If not set, indicates standard layer |
187 | | }; |
188 | | |
189 | | enum loader_layer_enabled_by_what { |
190 | | ENABLED_BY_WHAT_UNSET, // default value indicates this field hasn't been filled in |
191 | | ENABLED_BY_WHAT_LOADER_SETTINGS_FILE, |
192 | | ENABLED_BY_WHAT_IMPLICIT_LAYER, |
193 | | ENABLED_BY_WHAT_VK_INSTANCE_LAYERS, |
194 | | ENABLED_BY_WHAT_VK_LOADER_LAYERS_ENABLE, |
195 | | ENABLED_BY_WHAT_IN_APPLICATION_API, |
196 | | ENABLED_BY_WHAT_META_LAYER, |
197 | | }; |
198 | | |
199 | | struct loader_layer_properties { |
200 | | VkLayerProperties info; |
201 | | enum layer_type_flags type_flags; |
202 | | enum loader_settings_layer_control settings_control_value; |
203 | | |
204 | | uint32_t interface_version; // PFN_vkNegotiateLoaderLayerInterfaceVersion |
205 | | char *manifest_file_name; |
206 | | char *lib_name; |
207 | | enum loader_layer_library_status lib_status; |
208 | | enum loader_layer_enabled_by_what enabled_by_what; |
209 | | loader_platform_dl_handle lib_handle; |
210 | | struct loader_layer_functions functions; |
211 | | struct loader_extension_list instance_extension_list; |
212 | | struct loader_device_extension_list device_extension_list; |
213 | | struct loader_name_value disable_env_var; |
214 | | struct loader_name_value enable_env_var; |
215 | | struct loader_string_list component_layer_names; |
216 | | struct { |
217 | | char *enumerate_instance_extension_properties; |
218 | | char *enumerate_instance_layer_properties; |
219 | | char *enumerate_instance_version; |
220 | | } pre_instance_functions; |
221 | | struct loader_string_list override_paths; |
222 | | bool is_override; |
223 | | bool keep; |
224 | | // Set while this meta-layer is being expanded, used to break cyclic component references. |
225 | | bool is_being_expanded; |
226 | | struct loader_string_list blacklist_layer_names; |
227 | | struct loader_string_list app_key_paths; |
228 | | }; |
229 | | |
230 | | // Stores a list of loader_layer_properties |
231 | | struct loader_layer_list { |
232 | | size_t capacity; |
233 | | uint32_t count; |
234 | | struct loader_layer_properties *list; |
235 | | }; |
236 | | |
237 | | // Stores a list of pointers to loader_layer_properties |
238 | | // Used for app_activated_layer_list and expanded_activated_layer_list |
239 | | struct loader_pointer_layer_list { |
240 | | size_t capacity; |
241 | | uint32_t count; |
242 | | struct loader_layer_properties **list; |
243 | | }; |
244 | | |
245 | | typedef VkResult(VKAPI_PTR *PFN_vkDevExt)(VkDevice device); |
246 | | |
247 | | struct loader_dev_dispatch_table { |
248 | | VkLayerDispatchTable core_dispatch; |
249 | | PFN_vkDevExt ext_dispatch[MAX_NUM_UNKNOWN_EXTS]; |
250 | | struct loader_device_terminator_dispatch extension_terminator_dispatch; |
251 | | }; |
252 | | |
253 | | // per CreateDevice structure |
254 | | struct loader_device { |
255 | | struct loader_dev_dispatch_table loader_dispatch; |
256 | | VkDevice chain_device; // device object from the dispatch chain |
257 | | VkDevice icd_device; // device object from the icd |
258 | | struct loader_physical_device_term *phys_dev_term; |
259 | | |
260 | | VkAllocationCallbacks alloc_callbacks; |
261 | | |
262 | | // List of activated device extensions that layers support (but not necessarily the driver which have functions that require |
263 | | // trampolines to work correctly. EX - vkDebugMarkerSetObjectNameEXT can name wrapped handles like instance, physical device, |
264 | | // or surface |
265 | | struct { |
266 | | bool ext_debug_marker_enabled; |
267 | | bool ext_debug_utils_enabled; |
268 | | } layer_extensions; |
269 | | |
270 | | // List of activated device extensions that have terminators implemented in the loader |
271 | | struct { |
272 | | bool khr_swapchain_enabled; |
273 | | bool khr_display_swapchain_enabled; |
274 | | bool khr_device_group_enabled; |
275 | | bool ext_debug_marker_enabled; |
276 | | bool ext_debug_utils_enabled; |
277 | | bool ext_full_screen_exclusive_enabled; |
278 | | } driver_extensions; |
279 | | |
280 | | struct loader_device *next; |
281 | | |
282 | | // Makes vkGetDeviceProcAddr check if core functions are supported by the current app_api_version. |
283 | | // Only set to true if VK_KHR_maintenance5 is enabled. |
284 | | bool should_ignore_device_commands_from_newer_version; |
285 | | }; |
286 | | |
287 | | // Per ICD information |
288 | | |
289 | | // Per ICD structure |
290 | | struct loader_icd_term { |
291 | | // pointers to find other structs |
292 | | const struct loader_scanned_icd *scanned_icd; |
293 | | const struct loader_instance *this_instance; |
294 | | struct loader_device *logical_device_list; |
295 | | VkInstance instance; // instance object from the icd |
296 | | struct loader_icd_term_dispatch dispatch; |
297 | | |
298 | | struct loader_icd_term *next; |
299 | | |
300 | | PFN_PhysDevExt phys_dev_ext[MAX_NUM_UNKNOWN_EXTS]; |
301 | | |
302 | | struct loader_instance_extension_enable_list enabled_instance_extensions; |
303 | | |
304 | | uint32_t physical_device_count; |
305 | | |
306 | | struct loader_surface_list surface_list; |
307 | | struct loader_debug_utils_messenger_list debug_utils_messenger_list; |
308 | | struct loader_debug_report_callback_list debug_report_callback_list; |
309 | | }; |
310 | | |
311 | | // Per ICD library structure |
312 | | struct loader_icd_tramp_list { |
313 | | size_t capacity; |
314 | | uint32_t count; |
315 | | struct loader_scanned_icd *scanned_list; |
316 | | }; |
317 | | |
318 | | struct loader_instance_dispatch_table { |
319 | | VkLayerInstanceDispatchTable layer_inst_disp; // must be first entry in structure |
320 | | |
321 | | // Physical device functions unknown to the loader |
322 | | PFN_PhysDevExt phys_dev_ext[MAX_NUM_UNKNOWN_EXTS]; |
323 | | }; |
324 | | |
325 | | // Unique magic number identifier for the loader. |
326 | 0 | #define LOADER_MAGIC_NUMBER 0x10ADED010110ADEDUL |
327 | | |
328 | | // Per instance structure |
329 | | struct loader_instance { |
330 | | struct loader_instance_dispatch_table *disp; // must be first entry in structure |
331 | | uint64_t magic; // Should be LOADER_MAGIC_NUMBER |
332 | | |
333 | | // Store all the terminators for instance functions in case a layer queries one *after* vkCreateInstance |
334 | | VkLayerInstanceDispatchTable terminator_dispatch; |
335 | | |
336 | | // Vulkan API version the app is intending to use. |
337 | | loader_api_version app_api_version; |
338 | | |
339 | | // We need to manually track physical devices over time. If the user |
340 | | // re-queries the information, we don't want to delete old data or |
341 | | // create new data unless necessary. |
342 | | uint32_t total_gpu_count; |
343 | | uint32_t phys_dev_count_term; |
344 | | struct loader_physical_device_term **phys_devs_term; |
345 | | uint32_t phys_dev_count_tramp; |
346 | | struct loader_physical_device_tramp **phys_devs_tramp; |
347 | | |
348 | | // We also need to manually track physical device groups, but we don't need |
349 | | // loader specific structures since we have that content in the physical |
350 | | // device stored internal to the public structures. |
351 | | uint32_t phys_dev_group_count_term; |
352 | | struct VkPhysicalDeviceGroupProperties **phys_dev_groups_term; |
353 | | |
354 | | struct loader_instance *next; |
355 | | |
356 | | uint32_t icd_terms_count; |
357 | | struct loader_icd_term *icd_terms; |
358 | | struct loader_icd_tramp_list icd_tramp_list; |
359 | | |
360 | | // Must store the strings inside loader_instance directly - since the asm code will offset into |
361 | | // loader_instance to get the function name |
362 | | uint32_t dev_ext_disp_function_count; |
363 | | char *dev_ext_disp_functions[MAX_NUM_UNKNOWN_EXTS]; |
364 | | uint32_t phys_dev_ext_disp_function_count; |
365 | | char *phys_dev_ext_disp_functions[MAX_NUM_UNKNOWN_EXTS]; |
366 | | |
367 | | struct loader_msg_callback_map_entry *icd_msg_callback_map; |
368 | | |
369 | | struct loader_string_list enabled_layer_names; |
370 | | |
371 | | struct loader_layer_list instance_layer_list; |
372 | | bool override_layer_present; |
373 | | |
374 | | // List of activated layers. |
375 | | // app_ is the version based on exactly what the application asked for. |
376 | | // This is what must be returned to the application on Enumerate calls. |
377 | | // expanded_ is the version based on expanding meta-layers into their |
378 | | // individual component layers. This is what is used internally. |
379 | | struct loader_pointer_layer_list app_activated_layer_list; |
380 | | struct loader_pointer_layer_list expanded_activated_layer_list; |
381 | | |
382 | | VkInstance instance; // layers/ICD instance returned to trampoline |
383 | | |
384 | | struct loader_extension_list ext_list; // icds and loaders extensions |
385 | | struct loader_instance_extension_enable_list enabled_extensions; |
386 | | |
387 | | // Indicates which indices in the array are in-use and which are free to be reused |
388 | | struct loader_used_object_list surfaces_list; |
389 | | struct loader_used_object_list debug_utils_messengers_list; |
390 | | struct loader_used_object_list debug_report_callbacks_list; |
391 | | |
392 | | // Stores debug callbacks - used in the log. |
393 | | VkLayerDbgFunctionNode *current_dbg_function_head; // Current head |
394 | | VkLayerDbgFunctionNode *instance_only_dbg_function_head; // Only used for instance create/destroy |
395 | | |
396 | | VkAllocationCallbacks alloc_callbacks; |
397 | | |
398 | | // Set to true after vkCreateInstance has returned - necessary for loader_gpa_instance_terminator() |
399 | | bool instance_finished_creation; |
400 | | |
401 | | loader_settings settings; |
402 | | |
403 | | bool portability_enumeration_enabled; |
404 | | |
405 | | bool create_terminator_invalid_extension; |
406 | | bool supports_get_dev_prop_2; |
407 | | }; |
408 | | |
409 | | // VkPhysicalDevice requires special treatment by loader. Firstly, terminator |
410 | | // code must be able to get the struct loader_icd_term to call into the proper |
411 | | // driver (multiple ICD/gpu case). This can be accomplished by wrapping the |
412 | | // created VkPhysicalDevice in loader terminate_EnumeratePhysicalDevices(). |
413 | | // Secondly, the loader must be able to handle wrapped by layer VkPhysicalDevice |
414 | | // in trampoline code. This implies, that the loader trampoline code must also |
415 | | // wrap the VkPhysicalDevice object in trampoline code. Thus, loader has to |
416 | | // wrap the VkPhysicalDevice created object twice. In trampoline code it can't |
417 | | // rely on the terminator object wrapping since a layer may also wrap. Since |
418 | | // trampoline code wraps the VkPhysicalDevice this means all loader trampoline |
419 | | // code that passes a VkPhysicalDevice should unwrap it. |
420 | | |
421 | | // Unique identifier for physical devices |
422 | 0 | #define PHYS_TRAMP_MAGIC_NUMBER 0x10ADED020210ADEDUL |
423 | | |
424 | | // Per enumerated PhysicalDevice structure, used to wrap in trampoline code and |
425 | | // also same structure used to wrap in terminator code |
426 | | struct loader_physical_device_tramp { |
427 | | struct loader_instance_dispatch_table *disp; // must be first entry in structure |
428 | | struct loader_instance *this_instance; |
429 | | uint64_t magic; // Should be PHYS_TRAMP_MAGIC_NUMBER |
430 | | VkPhysicalDevice phys_dev; // object from layers/loader terminator |
431 | | }; |
432 | | |
433 | | // Per enumerated PhysicalDevice structure, used to wrap in terminator code |
434 | | struct loader_physical_device_term { |
435 | | struct loader_instance_dispatch_table *disp; // must be first entry in structure |
436 | | struct loader_icd_term *this_icd_term; |
437 | | VkPhysicalDevice phys_dev; // object from ICD |
438 | | }; |
439 | | |
440 | | #if defined(LOADER_ENABLE_LINUX_SORT) |
441 | | // Structure for storing the relevant device information for selecting a device. |
442 | | // NOTE: Needs to be defined here so we can store this content in the term structure |
443 | | // for quicker sorting. |
444 | | struct LinuxSortedDeviceInfo { |
445 | | // Associated Vulkan Physical Device |
446 | | VkPhysicalDevice physical_device; |
447 | | bool default_device; |
448 | | |
449 | | // Loader specific items about the driver providing support for this physical device |
450 | | struct loader_icd_term *icd_term; |
451 | | |
452 | | // Some generic device properties |
453 | | VkPhysicalDeviceType device_type; |
454 | | char device_name[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE]; |
455 | | uint32_t vendor_id; |
456 | | uint32_t device_id; |
457 | | |
458 | | // PCI information on this device |
459 | | bool has_pci_bus_info; |
460 | | uint32_t pci_domain; |
461 | | uint32_t pci_bus; |
462 | | uint32_t pci_device; |
463 | | uint32_t pci_function; |
464 | | }; |
465 | | #endif // LOADER_ENABLE_LINUX_SORT |
466 | | |
467 | | // Per enumerated PhysicalDeviceGroup structure, used to wrap in terminator code |
468 | | struct loader_physical_device_group_term { |
469 | | struct loader_icd_term *this_icd_term; |
470 | | VkPhysicalDeviceGroupProperties group_props; |
471 | | #if defined(LOADER_ENABLE_LINUX_SORT) |
472 | | struct LinuxSortedDeviceInfo internal_device_info[VK_MAX_DEVICE_GROUP_SIZE]; |
473 | | #endif // LOADER_ENABLE_LINUX_SORT |
474 | | }; |
475 | | |
476 | | struct loader_struct { |
477 | | struct loader_instance *instances; |
478 | | }; |
479 | | |
480 | | struct loader_scanned_icd { |
481 | | char *lib_name; |
482 | | loader_platform_dl_handle handle; |
483 | | uint32_t api_version; |
484 | | uint32_t interface_version; |
485 | | PFN_vkGetInstanceProcAddr GetInstanceProcAddr; |
486 | | PFN_GetPhysicalDeviceProcAddr GetPhysicalDeviceProcAddr; |
487 | | PFN_vkCreateInstance CreateInstance; |
488 | | PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties; |
489 | | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
490 | | PFN_vk_icdEnumerateAdapterPhysicalDevices EnumerateAdapterPhysicalDevices; |
491 | | #endif |
492 | | }; |
493 | | |
494 | | enum loader_data_files_type { |
495 | | LOADER_DATA_FILE_MANIFEST_DRIVER = 0, |
496 | | LOADER_DATA_FILE_MANIFEST_EXPLICIT_LAYER, |
497 | | LOADER_DATA_FILE_MANIFEST_IMPLICIT_LAYER, |
498 | | LOADER_DATA_FILE_NUM_TYPES // Not a real field, used for possible loop terminator |
499 | | }; |
500 | | |
501 | | struct loader_icd_physical_devices { |
502 | | uint32_t device_count; |
503 | | VkPhysicalDevice *physical_devices; |
504 | | struct loader_icd_term *icd_term; |
505 | | #if defined(WIN32) |
506 | | LUID windows_adapter_luid; |
507 | | #endif |
508 | | }; |
509 | | |
510 | | struct loader_msg_callback_map_entry { |
511 | | VkDebugReportCallbackEXT icd_obj; |
512 | | VkDebugReportCallbackEXT loader_obj; |
513 | | }; |
514 | | |
515 | | typedef enum loader_filter_string_type { |
516 | | FILTER_STRING_FULLNAME = 0, |
517 | | FILTER_STRING_SUBSTRING, |
518 | | FILTER_STRING_PREFIX, |
519 | | FILTER_STRING_SUFFIX, |
520 | | FILTER_STRING_SPECIAL, |
521 | | } loader_filter_string_type; |
522 | | |
523 | | struct loader_envvar_filter_value { |
524 | | char value[VK_MAX_EXTENSION_NAME_SIZE]; |
525 | | size_t length; |
526 | | loader_filter_string_type type; |
527 | | }; |
528 | | |
529 | 11.7k | #define MAX_ADDITIONAL_FILTERS 16 |
530 | | struct loader_envvar_filter { |
531 | | uint32_t count; |
532 | | struct loader_envvar_filter_value filters[MAX_ADDITIONAL_FILTERS]; |
533 | | }; |
534 | | struct loader_envvar_disable_layers_filter { |
535 | | struct loader_envvar_filter additional_filters; |
536 | | bool disable_all; |
537 | | bool disable_all_implicit; |
538 | | bool disable_all_explicit; |
539 | | }; |
540 | | |
541 | | struct loader_envvar_all_filters { |
542 | | struct loader_envvar_filter enable_filter; |
543 | | struct loader_envvar_disable_layers_filter disable_filter; |
544 | | struct loader_envvar_filter allow_filter; |
545 | | }; |
546 | | |
547 | | struct loader_envvar_id_filter_value { |
548 | | uint32_t begin; |
549 | | uint32_t end; |
550 | | }; |
551 | | |
552 | | struct loader_envvar_id_filter { |
553 | | uint32_t count; |
554 | | struct loader_envvar_id_filter_value filters[MAX_ADDITIONAL_FILTERS]; |
555 | | }; |