Uh oh!
There was an error while loading. Please reload this page.
forked from KhronosGroup/Vulkan-Loader
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloader.h
More file actions
Latest commit
273 lines (238 loc) · 17.7 KB
/
Copy pathloader.h
File metadata and controls
273 lines (238 loc) · 17.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
/*
*
* Copyright (c) 2014-2023 The Khronos Group Inc.
* Copyright (c) 2014-2023 Valve Corporation
* Copyright (c) 2014-2023 LunarG, Inc.
* Copyright (C) 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author: Jon Ashburn <jon@lunarg.com>
* Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
* Author: Chia-I Wu <olvaffe@gmail.com>
* Author: Chia-I Wu <olv@lunarg.com>
* Author: Mark Lobodzinski <mark@LunarG.com>
* Author: Lenny Komow <lenny@lunarg.com>
* Author: Charles Giessen <charles@lunarg.com>
*
*/
#pragma once
#include"loader_common.h"
#include"cJSON.h"
// Declare the once_init variable
LOADER_PLATFORM_THREAD_ONCE_EXTERN_DEFINITION(once_init)
staticinlineVkPhysicalDeviceloader_unwrap_physical_device(VkPhysicalDevicephysicalDevice) {
if (VK_NULL_HANDLE==physicalDevice) {
returnVK_NULL_HANDLE;
}
structloader_physical_device_tramp*phys_dev= (structloader_physical_device_tramp*)physicalDevice;
if (PHYS_TRAMP_MAGIC_NUMBER!=phys_dev->magic) {
returnVK_NULL_HANDLE;
}
returnphys_dev->phys_dev;
}
staticinlinevoidloader_set_dispatch(void*obj, constvoid*data) { *((constvoid**)obj) =data; }
staticinlineVkLayerDispatchTable*loader_get_dispatch(constvoid*obj) {
if (VK_NULL_HANDLE==obj) {
returnNULL;
}
VkLayerDispatchTable*disp=*((VkLayerDispatchTable**)obj);
if (VK_NULL_HANDLE==disp||DEVICE_DISP_TABLE_MAGIC_NUMBER!=disp->magic) {
returnNULL;
}
returndisp;
}
staticinlinestructloader_dev_dispatch_table*loader_get_dev_dispatch(constvoid*obj) {
return*((structloader_dev_dispatch_table**)obj);
}
staticinlineVkLayerInstanceDispatchTable*loader_get_instance_layer_dispatch(constvoid*obj) {
return*((VkLayerInstanceDispatchTable**)obj);
}
staticinlinevoidloader_init_dispatch(void*obj, constvoid*data) {
#if defined(DEBUG)
assert(valid_loader_magic_value(obj) &&
"Incompatible ICD, first dword must be initialized to "
"ICD_LOADER_MAGIC. See loader/README.md for details.");
#endif
loader_set_dispatch(obj, data);
}
// Global variables used across files
externstructloader_structloader;
externloader_platform_thread_mutexloader_lock;
externloader_platform_thread_mutexloader_preload_icd_lock;
boolcompare_vk_extension_properties(constVkExtensionProperties*op1, constVkExtensionProperties*op2);
VkResultloader_validate_layers(conststructloader_instance*inst, constuint32_tlayer_count,
constchar*const*ppEnabledLayerNames, conststructloader_layer_list*list);
VkResultloader_validate_instance_extensions(structloader_instance*inst, conststructloader_extension_list*icd_exts,
conststructloader_layer_list*instance_layer,
conststructloader_envvar_all_filters*layer_filters,
constVkInstanceCreateInfo*pCreateInfo);
#if defined(_WIN32)
BOOL __stdcall loader_initialize(PINIT_ONCEInitOnce, PVOIDParameter, PVOID*Context);
#else
voidloader_initialize(void);
#endif
voidloader_release(void);
voidloader_preload_icds(void);
voidloader_unload_preloaded_icds(void);
VkResultloader_init_library_list(structloader_layer_list*instance_layers, loader_platform_dl_handle**libs);
// Allocate a new string able to hold source_str and place it in dest_str
VkResultloader_copy_to_new_str(conststructloader_instance*inst, constchar*source_str, char**dest_str);
// Allocate a loader_string_list with enough space for allocated_count strings inside of it
VkResultcreate_string_list(conststructloader_instance*inst, uint32_tallocated_count, structloader_string_list*string_list);
// Resize if there isn't enough space, then add the string str to the end of the loader_string_list
// This function takes ownership of the str passed in
VkResultappend_str_to_string_list(conststructloader_instance*inst, structloader_string_list*string_list, char*str);
// Checks that the string doesn't already exist in the list, resizes if there isn't enough space, adds the string str to the end of
// the loader_string_list.
// This function takes ownership of the str passed in
VkResultappend_str_to_string_list_if_unique(conststructloader_instance*inst, structloader_string_list*string_list, char*str);
// Resize if there isn't enough space, then add the string str to the start of the loader_string_list
// This function takes ownership of the str passed in
VkResultprepend_str_to_string_list(conststructloader_instance*inst, structloader_string_list*string_list, char*str);
// Copy the string str to a new string and append it to string_list, resizing string_list if there isn't enough space.
// This function does not take ownership of the string, it merely copies it.
// This function automatically appends a null terminator to the string being copied
// The str_len parameter does not include the null terminator
VkResultcopy_str_to_string_list(conststructloader_instance*inst, structloader_string_list*string_list, constchar*str,
size_tstr_len);
// Checks that the string doesn't already exist in the list, then copies the string str to a new string and append it to
// string_list, resizing string_list if there isn't enough space.
// This function does not take ownership of the string, it merely copies it.
// This function automatically appends a null terminator to the string being copied The str_len parameter does not
// include the null terminator
VkResultcopy_str_to_string_list_if_unique(conststructloader_instance*inst, structloader_string_list*string_list,
constchar*str, size_tstr_len);
// Copy the string str to a new string and prepend it to string_list, resizing string_list if there isn't enough space.
// This function does not take ownership of the string, it merely copies it.
// This function automatically appends a null terminator to the string being copied
// The str_len parameter does not include the null terminator
VkResultcopy_str_to_start_of_string_list(conststructloader_instance*inst, structloader_string_list*string_list,
constchar*str, size_tstr_len);
// Free any string inside of loader_string_list and then free the list itself
voidfree_string_list(conststructloader_instance*inst, structloader_string_list*string_list);
VkResultloader_init_generic_list(conststructloader_instance*inst, structloader_generic_list*list_info, size_telement_size);
VkResultloader_resize_generic_list(conststructloader_instance*inst, structloader_generic_list*list_info);
VkResultloader_get_next_available_entry(conststructloader_instance*inst, structloader_used_object_list*list_info,
uint32_t*free_index, constVkAllocationCallbacks*pAllocator);
voidloader_release_object_from_list(structloader_used_object_list*list_info, uint32_tindex_to_free);
boolhas_vk_extension_property_array(constVkExtensionProperties*vk_ext_prop, constuint32_tcount,
constVkExtensionProperties*ext_array);
boolhas_vk_extension_property(constVkExtensionProperties*vk_ext_prop, conststructloader_extension_list*ext_list);
// This function takes ownership of layer_property in the case that allocation fails
VkResultloader_append_layer_property(conststructloader_instance*inst, structloader_layer_list*layer_list,
structloader_layer_properties*layer_property);
VkResultloader_add_layer_properties(conststructloader_instance*inst, structloader_layer_list*layer_instance_list, cJSON*json,
boolis_implicit, char*filename);
boolloader_find_layer_name_in_list(constchar*name, conststructloader_pointer_layer_list*layer_list);
VkResultloader_add_layer_properties_to_list(conststructloader_instance*inst, structloader_pointer_layer_list*list,
structloader_layer_properties*props);
voidloader_free_layer_properties(conststructloader_instance*inst, structloader_layer_properties*layer_properties);
boolloader_implicit_layer_is_enabled(conststructloader_instance*inst, conststructloader_envvar_all_filters*filters,
conststructloader_layer_properties*prop);
VkResultloader_add_meta_layer(conststructloader_instance*inst, conststructloader_envvar_all_filters*filters,
structloader_layer_properties*prop, structloader_pointer_layer_list*target_list,
structloader_pointer_layer_list*expanded_target_list, conststructloader_layer_list*source_list,
bool*out_found_all_component_layers);
VkResultloader_add_to_ext_list(conststructloader_instance*inst, structloader_extension_list*ext_list,
uint32_tprop_list_count, constVkExtensionProperties*props);
VkResultloader_add_device_extensions(conststructloader_instance*inst,
PFN_vkEnumerateDeviceExtensionPropertiesfpEnumerateDeviceExtensionProperties,
VkPhysicalDevicephysical_device, constchar*lib_name,
structloader_extension_list*ext_list);
VkResultloader_init_generic_list(conststructloader_instance*inst, structloader_generic_list*list_info, size_telement_size);
voidloader_destroy_generic_list(conststructloader_instance*inst, structloader_generic_list*list);
voidloader_destroy_pointer_layer_list(conststructloader_instance*inst, structloader_pointer_layer_list*layer_list);
TEST_FUNCTION_EXPORTvoidloader_delete_layer_list_and_properties(conststructloader_instance*inst,
structloader_layer_list*layer_list);
voidloader_remove_layer_in_list(conststructloader_instance*inst, structloader_layer_list*layer_list,
uint32_tlayer_to_remove);
VkResultloader_init_scanned_icd_list(conststructloader_instance*inst, structloader_icd_tramp_list*icd_tramp_list);
voidloader_clear_scanned_icd_list(conststructloader_instance*inst, structloader_icd_tramp_list*icd_tramp_list);
VkResultloader_icd_scan(conststructloader_instance*inst, structloader_icd_tramp_list*icd_tramp_list,
constVkInstanceCreateInfo*pCreateInfo, bool*skipped_portability_drivers);
voidloader_icd_close_objects(structloader_instance*ptr_inst, structloader_icd_term*icd_term);
voidloader_icd_destroy(structloader_instance*ptr_inst, structloader_icd_term*icd_term,
constVkAllocationCallbacks*pAllocator);
VkResultloader_scan_for_layers(structloader_instance*inst, structloader_layer_list*instance_layers,
conststructloader_envvar_all_filters*layer_filters);
VkResultloader_scan_for_implicit_layers(structloader_instance*inst, structloader_layer_list*instance_layers,
conststructloader_envvar_all_filters*layer_filters);
VkResultloader_get_icd_loader_instance_extensions(conststructloader_instance*inst, structloader_icd_tramp_list*icd_tramp_list,
structloader_extension_list*inst_exts);
structloader_icd_term*loader_get_icd_and_device(constvoid*device, structloader_device**found_dev);
structloader_instance*loader_get_instance(constVkInstanceinstance);
loader_platform_dl_handleloader_open_layer_file(conststructloader_instance*inst, structloader_layer_properties*prop);
structloader_device*loader_create_logical_device(conststructloader_instance*inst, constVkAllocationCallbacks*pAllocator);
voidloader_add_logical_device(structloader_icd_term*icd_term, structloader_device*found_dev);
voidloader_remove_logical_device(structloader_icd_term*icd_term, structloader_device*found_dev,
constVkAllocationCallbacks*pAllocator);
// NOTE: Outside of loader, this entry-point is only provided for error
// cleanup.
voidloader_destroy_logical_device(structloader_device*dev, constVkAllocationCallbacks*pAllocator);
VkResultloader_enable_instance_layers(structloader_instance*inst, constVkInstanceCreateInfo*pCreateInfo,
conststructloader_layer_list*instance_layers,
conststructloader_envvar_all_filters*layer_filters);
VkResultloader_create_instance_chain(constVkInstanceCreateInfo*pCreateInfo, constVkAllocationCallbacks*pAllocator,
structloader_instance*inst, VkInstance*created_instance);
voidloader_activate_instance_layer_extensions(structloader_instance*inst, VkInstancecreated_inst);
VKAPI_ATTRVkResultVKAPI_CALLloader_layer_create_device(VkInstanceinstance, VkPhysicalDevicephysicalDevice,
constVkDeviceCreateInfo*pCreateInfo,
constVkAllocationCallbacks*pAllocator, VkDevice*pDevice,
PFN_vkGetInstanceProcAddrlayerGIPA, PFN_vkGetDeviceProcAddr*nextGDPA);
VKAPI_ATTRvoidVKAPI_CALLloader_layer_destroy_device(VkDevicedevice, constVkAllocationCallbacks*pAllocator,
PFN_vkDestroyDevicedestroyFunction);
VkResultloader_create_device_chain(constVkPhysicalDevicepd, constVkDeviceCreateInfo*pCreateInfo,
constVkAllocationCallbacks*pAllocator, conststructloader_instance*inst,
structloader_device*dev, PFN_vkGetInstanceProcAddrcallingLayer,
PFN_vkGetDeviceProcAddr*layerNextGDPA);
VkResultloader_validate_device_extensions(structloader_instance*this_instance,
conststructloader_pointer_layer_list*activated_device_layers,
conststructloader_extension_list*icd_exts, constVkDeviceCreateInfo*pCreateInfo);
VkResultsetup_loader_tramp_phys_devs(structloader_instance*inst, uint32_tphys_dev_count, VkPhysicalDevice*phys_devs);
VkResultsetup_loader_tramp_phys_dev_groups(structloader_instance*inst, uint32_tgroup_count,
VkPhysicalDeviceGroupProperties*groups);
voidunload_drivers_without_physical_devices(structloader_instance*inst);
VkResultloader_apply_settings_device_configurations(structloader_instance*inst, uint32_t*pPhysicalDeviceCount,
VkPhysicalDevice*pPhysicalDevices);
TEST_FUNCTION_EXPORTVkStringErrorFlagsvk_string_validate(constintmax_length, constchar*char_array);
char*loader_get_next_path(char*path);
VkResultadd_if_manifest_file(conststructloader_instance*inst, constchar*file_name, structloader_string_list*out_files);
VkResultprepend_if_manifest_file(conststructloader_instance*inst, constchar*file_name, structloader_string_list*out_files);
VkResultadd_data_files(conststructloader_instance*inst, structloader_string_list*search_paths,
structloader_string_list*out_files);
loader_api_versionloader_make_version(uint32_tversion);
loader_api_versionloader_combine_version(uint32_tmajor, uint32_tminor, uint32_tpatch);
// Helper macros for determining if a version is valid or not
boolloader_check_version_meets_required(loader_api_versionrequired, loader_api_versionversion);
// Helper that returns true if the string passed in path ends in .json
boolis_json(constchar*path, size_tlen);
VkResultloader_filter_enumerated_physical_device(conststructloader_instance*inst,
conststructloader_envvar_id_filter*device_id_filter,
conststructloader_envvar_id_filter*vendor_id_filter,
conststructloader_envvar_id_filter*driver_id_filter,
constuint32_tin_PhysicalDeviceCount,
constVkPhysicalDevice*in_pPhysicalDevices, uint32_t*out_pPhysicalDeviceCount,
VkPhysicalDevice*out_pPhysicalDevices);
VkResultloader_filter_enumerated_physical_device_groups(
conststructloader_instance*inst, conststructloader_envvar_id_filter*device_id_filter,
conststructloader_envvar_id_filter*vendor_id_filter, conststructloader_envvar_id_filter*driver_id_filter,
constuint32_tin_PhysicalDeviceGroupCount, constVkPhysicalDeviceGroupProperties*in_pPhysicalDeviceGroupProperties,
uint32_t*out_PhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties*out_pPhysicalDeviceGroupProperties);
// Convenience macros for common versions
#if !defined(LOADER_VERSION_1_0_0)
#defineLOADER_VERSION_1_0_0 loader_combine_version(1, 0, 0)
#endif
#if !defined(LOADER_VERSION_1_1_0)
#defineLOADER_VERSION_1_1_0 loader_combine_version(1, 1, 0)
#endif