2014-08-04 00:03:57 +00:00
|
|
|
/*
|
|
|
|
*
|
2021-12-02 23:55:13 +00:00
|
|
|
* Copyright (c) 2014-2022 The Khronos Group Inc.
|
|
|
|
* Copyright (c) 2014-2022 Valve Corporation
|
|
|
|
* Copyright (c) 2014-2022 LunarG, Inc.
|
2015-12-02 21:53:22 +00:00
|
|
|
* Copyright (C) 2015 Google Inc.
|
2014-08-04 00:03:57 +00:00
|
|
|
*
|
2016-04-19 17:30:31 +00:00
|
|
|
* 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
|
2014-08-04 00:03:57 +00:00
|
|
|
*
|
2016-04-19 17:30:31 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2014-08-04 00:03:57 +00:00
|
|
|
*
|
2016-04-19 17:30:31 +00:00
|
|
|
* 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.
|
2014-09-02 00:32:09 +00:00
|
|
|
*
|
2016-02-03 00:47:28 +00:00
|
|
|
* Author: Jon Ashburn <jon@lunarg.com>
|
|
|
|
* Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
|
2015-10-30 17:14:30 +00:00
|
|
|
* Author: Chia-I Wu <olvaffe@gmail.com>
|
|
|
|
* Author: Chia-I Wu <olv@lunarg.com>
|
2016-02-03 00:47:28 +00:00
|
|
|
* Author: Mark Lobodzinski <mark@LunarG.com>
|
2019-02-26 04:37:33 +00:00
|
|
|
* Author: Lenny Komow <lenny@lunarg.com>
|
2021-09-04 03:23:43 +00:00
|
|
|
* Author: Charles Giessen <charles@lunarg.com>
|
2015-10-30 17:14:30 +00:00
|
|
|
*
|
2014-08-04 00:03:57 +00:00
|
|
|
*/
|
|
|
|
|
2021-09-04 03:41:19 +00:00
|
|
|
#pragma once
|
2014-08-04 00:03:57 +00:00
|
|
|
|
2021-09-04 04:03:18 +00:00
|
|
|
#include "loader_common.h"
|
2015-05-12 23:26:48 +00:00
|
|
|
|
2022-07-07 19:25:22 +00:00
|
|
|
// Declare the once_init variable
|
|
|
|
LOADER_PLATFORM_THREAD_ONCE_EXTERN_DEFINITION(once_init)
|
|
|
|
|
2017-01-26 19:16:30 +00:00
|
|
|
static inline VkPhysicalDevice loader_unwrap_physical_device(VkPhysicalDevice physicalDevice) {
|
|
|
|
struct loader_physical_device_tramp *phys_dev = (struct loader_physical_device_tramp *)physicalDevice;
|
2021-07-29 14:42:44 +00:00
|
|
|
if (PHYS_TRAMP_MAGIC_NUMBER != phys_dev->magic) {
|
|
|
|
return VK_NULL_HANDLE;
|
|
|
|
}
|
2016-03-02 02:51:07 +00:00
|
|
|
return phys_dev->phys_dev;
|
|
|
|
}
|
|
|
|
|
2017-01-26 19:16:30 +00:00
|
|
|
static inline void loader_set_dispatch(void *obj, const void *data) { *((const void **)obj) = data; }
|
2015-04-11 07:34:07 +00:00
|
|
|
|
2021-07-29 14:42:44 +00:00
|
|
|
static inline VkLayerDispatchTable *loader_get_dispatch(const void *obj) {
|
2022-05-03 19:28:57 +00:00
|
|
|
if (VK_NULL_HANDLE == obj) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2021-07-29 14:42:44 +00:00
|
|
|
VkLayerDispatchTable *disp = *((VkLayerDispatchTable **)obj);
|
2022-05-03 19:28:57 +00:00
|
|
|
if (VK_NULL_HANDLE == disp || DEVICE_DISP_TABLE_MAGIC_NUMBER != disp->magic) {
|
2021-07-29 14:42:44 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return disp;
|
|
|
|
}
|
2015-04-11 07:34:07 +00:00
|
|
|
|
2017-01-26 19:16:30 +00:00
|
|
|
static inline struct loader_dev_dispatch_table *loader_get_dev_dispatch(const void *obj) {
|
2016-02-03 00:47:28 +00:00
|
|
|
return *((struct loader_dev_dispatch_table **)obj);
|
2015-11-17 22:31:02 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 19:16:30 +00:00
|
|
|
static inline VkLayerInstanceDispatchTable *loader_get_instance_layer_dispatch(const void *obj) {
|
2016-02-03 00:47:28 +00:00
|
|
|
return *((VkLayerInstanceDispatchTable **)obj);
|
2015-05-12 23:26:48 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 19:16:30 +00:00
|
|
|
static inline struct loader_instance_dispatch_table *loader_get_instance_dispatch(const void *obj) {
|
2017-01-20 04:10:49 +00:00
|
|
|
return *((struct loader_instance_dispatch_table **)obj);
|
|
|
|
}
|
|
|
|
|
2016-02-03 00:47:28 +00:00
|
|
|
static inline void loader_init_dispatch(void *obj, const void *data) {
|
2015-04-15 19:34:33 +00:00
|
|
|
#ifdef DEBUG
|
2017-01-26 20:34:13 +00:00
|
|
|
assert(valid_loader_magic_value(obj) &&
|
|
|
|
"Incompatible ICD, first dword must be initialized to "
|
|
|
|
"ICD_LOADER_MAGIC. See loader/README.md for details.");
|
2015-04-15 19:34:33 +00:00
|
|
|
#endif
|
2015-04-11 07:34:07 +00:00
|
|
|
|
2015-05-02 00:00:33 +00:00
|
|
|
loader_set_dispatch(obj, data);
|
2015-04-11 07:34:07 +00:00
|
|
|
}
|
|
|
|
|
2017-02-28 16:58:04 +00:00
|
|
|
// Global variables used across files
|
2015-05-12 23:26:48 +00:00
|
|
|
extern struct loader_struct loader;
|
2015-05-29 19:15:39 +00:00
|
|
|
extern loader_platform_thread_mutex loader_lock;
|
2015-09-22 19:11:00 +00:00
|
|
|
extern loader_platform_thread_mutex loader_json_lock;
|
2020-05-12 20:25:47 +00:00
|
|
|
extern loader_platform_thread_mutex loader_preload_icd_lock;
|
2022-05-20 18:18:41 +00:00
|
|
|
extern loader_platform_thread_mutex loader_global_instance_list_lock;
|
2015-04-06 16:58:22 +00:00
|
|
|
|
2017-01-26 19:16:30 +00:00
|
|
|
bool compare_vk_extension_properties(const VkExtensionProperties *op1, const VkExtensionProperties *op2);
|
2015-06-10 23:39:03 +00:00
|
|
|
|
2021-09-03 01:24:19 +00:00
|
|
|
VkResult loader_validate_layers(const struct loader_instance *inst, const uint32_t layer_count,
|
|
|
|
const char *const *ppEnabledLayerNames, const struct loader_layer_list *list);
|
2015-07-06 23:45:08 +00:00
|
|
|
|
2018-10-03 23:44:02 +00:00
|
|
|
VkResult loader_validate_instance_extensions(struct loader_instance *inst, const struct loader_extension_list *icd_exts,
|
2017-01-26 19:16:30 +00:00
|
|
|
const struct loader_layer_list *instance_layer,
|
|
|
|
const VkInstanceCreateInfo *pCreateInfo);
|
2015-07-06 23:45:08 +00:00
|
|
|
|
2015-08-19 00:04:47 +00:00
|
|
|
void loader_initialize(void);
|
2021-09-06 00:34:10 +00:00
|
|
|
void loader_release(void);
|
2020-03-02 22:04:30 +00:00
|
|
|
void loader_preload_icds(void);
|
|
|
|
void loader_unload_preloaded_icds(void);
|
2017-01-26 19:16:30 +00:00
|
|
|
bool has_vk_extension_property_array(const VkExtensionProperties *vk_ext_prop, const uint32_t count,
|
2016-02-03 00:47:28 +00:00
|
|
|
const VkExtensionProperties *ext_array);
|
2017-01-26 19:16:30 +00:00
|
|
|
bool has_vk_extension_property(const VkExtensionProperties *vk_ext_prop, const struct loader_extension_list *ext_list);
|
|
|
|
|
2021-09-08 21:23:22 +00:00
|
|
|
void loader_free_layer_properties(const struct loader_instance *inst, struct loader_layer_properties *layer_properties);
|
2017-01-26 19:16:30 +00:00
|
|
|
VkResult loader_add_to_ext_list(const struct loader_instance *inst, struct loader_extension_list *ext_list,
|
|
|
|
uint32_t prop_list_count, const VkExtensionProperties *props);
|
|
|
|
VkResult loader_add_to_dev_ext_list(const struct loader_instance *inst, struct loader_device_extension_list *ext_list,
|
|
|
|
const VkExtensionProperties *props, uint32_t entry_count, char **entrys);
|
2016-02-26 20:14:27 +00:00
|
|
|
VkResult loader_add_device_extensions(const struct loader_instance *inst,
|
2017-01-26 19:16:30 +00:00
|
|
|
PFN_vkEnumerateDeviceExtensionProperties fpEnumerateDeviceExtensionProperties,
|
|
|
|
VkPhysicalDevice physical_device, const char *lib_name,
|
2016-02-26 20:14:27 +00:00
|
|
|
struct loader_extension_list *ext_list);
|
2017-01-26 19:16:30 +00:00
|
|
|
VkResult loader_init_generic_list(const struct loader_instance *inst, struct loader_generic_list *list_info, size_t element_size);
|
|
|
|
void loader_destroy_generic_list(const struct loader_instance *inst, struct loader_generic_list *list);
|
2021-09-03 01:24:19 +00:00
|
|
|
void loader_destroy_layer_list(const struct loader_instance *inst, struct loader_device *device,
|
|
|
|
struct loader_layer_list *layer_list);
|
|
|
|
void loader_delete_layer_list_and_properties(const struct loader_instance *inst, struct loader_layer_list *layer_list);
|
|
|
|
VkResult loader_add_layer_name_to_list(const struct loader_instance *inst, const char *name, const enum layer_type_flags type_flags,
|
|
|
|
const struct loader_layer_list *source_list, struct loader_layer_list *target_list,
|
|
|
|
struct loader_layer_list *expanded_target_list);
|
2022-05-27 22:36:35 +00:00
|
|
|
void loader_icd_destroy(struct loader_instance *ptr_inst, struct loader_icd_term *icd_term,
|
|
|
|
const VkAllocationCallbacks *pAllocator);
|
2017-01-26 19:16:30 +00:00
|
|
|
void loader_scanned_icd_clear(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list);
|
2022-05-03 20:29:06 +00:00
|
|
|
VkResult loader_icd_scan(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list,
|
|
|
|
bool *skipped_portability_drivers);
|
2021-09-03 01:24:19 +00:00
|
|
|
void loader_scan_for_layers(struct loader_instance *inst, struct loader_layer_list *instance_layers);
|
|
|
|
void loader_scan_for_implicit_layers(struct loader_instance *inst, struct loader_layer_list *instance_layers);
|
|
|
|
bool loader_implicit_layer_is_enabled(const struct loader_instance *inst, const struct loader_layer_properties *prop);
|
2017-01-26 19:16:30 +00:00
|
|
|
VkResult loader_get_icd_loader_instance_extensions(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list,
|
|
|
|
struct loader_extension_list *inst_exts);
|
2020-01-31 22:25:46 +00:00
|
|
|
struct loader_icd_term *loader_get_icd_and_device(const void *device, struct loader_device **found_dev, uint32_t *icd_index);
|
2016-02-03 00:47:28 +00:00
|
|
|
struct loader_instance *loader_get_instance(const VkInstance instance);
|
2021-09-03 01:24:19 +00:00
|
|
|
void loader_deactivate_layers(const struct loader_instance *instance, struct loader_device *device, struct loader_layer_list *list);
|
2017-01-26 19:16:30 +00:00
|
|
|
struct loader_device *loader_create_logical_device(const struct loader_instance *inst, const VkAllocationCallbacks *pAllocator);
|
|
|
|
void loader_add_logical_device(const struct loader_instance *inst, struct loader_icd_term *icd_term,
|
2016-03-29 17:51:11 +00:00
|
|
|
struct loader_device *found_dev);
|
2017-01-26 19:16:30 +00:00
|
|
|
void loader_remove_logical_device(const struct loader_instance *inst, struct loader_icd_term *icd_term,
|
|
|
|
struct loader_device *found_dev, const VkAllocationCallbacks *pAllocator);
|
2017-03-08 20:38:35 +00:00
|
|
|
// NOTE: Outside of loader, this entry-point is only provided for error
|
2016-11-03 20:27:13 +00:00
|
|
|
// cleanup.
|
2017-01-26 19:16:30 +00:00
|
|
|
void loader_destroy_logical_device(const struct loader_instance *inst, struct loader_device *dev,
|
2016-06-30 19:02:42 +00:00
|
|
|
const VkAllocationCallbacks *pAllocator);
|
|
|
|
|
2021-09-03 01:24:19 +00:00
|
|
|
VkResult loader_enable_instance_layers(struct loader_instance *inst, const VkInstanceCreateInfo *pCreateInfo,
|
|
|
|
const struct loader_layer_list *instance_layers);
|
2016-01-08 19:18:43 +00:00
|
|
|
|
2017-01-26 19:16:30 +00:00
|
|
|
VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
|
|
|
|
struct loader_instance *inst, VkInstance *created_instance);
|
|
|
|
|
2021-09-03 01:24:19 +00:00
|
|
|
void loader_activate_instance_layer_extensions(struct loader_instance *inst, VkInstance created_inst);
|
2017-01-26 19:16:30 +00:00
|
|
|
|
2019-04-26 12:57:59 +00:00
|
|
|
VKAPI_ATTR VkResult VKAPI_CALL loader_layer_create_device(VkInstance instance, VkPhysicalDevice physicalDevice,
|
|
|
|
const VkDeviceCreateInfo *pCreateInfo,
|
|
|
|
const VkAllocationCallbacks *pAllocator, VkDevice *pDevice,
|
|
|
|
PFN_vkGetInstanceProcAddr layerGIPA, PFN_vkGetDeviceProcAddr *nextGDPA);
|
|
|
|
VKAPI_ATTR void VKAPI_CALL loader_layer_destroy_device(VkDevice device, const VkAllocationCallbacks *pAllocator,
|
|
|
|
PFN_vkDestroyDevice destroyFunction);
|
2018-12-11 17:29:38 +00:00
|
|
|
|
2018-12-11 17:30:24 +00:00
|
|
|
VkResult loader_create_device_chain(const VkPhysicalDevice pd, const VkDeviceCreateInfo *pCreateInfo,
|
2017-01-26 19:16:30 +00:00
|
|
|
const VkAllocationCallbacks *pAllocator, const struct loader_instance *inst,
|
2019-04-26 12:57:59 +00:00
|
|
|
struct loader_device *dev, PFN_vkGetInstanceProcAddr callingLayer,
|
|
|
|
PFN_vkGetDeviceProcAddr *layerNextGDPA);
|
2017-01-26 19:16:30 +00:00
|
|
|
|
2018-12-11 17:30:24 +00:00
|
|
|
VkResult loader_validate_device_extensions(struct loader_instance *this_instance,
|
2017-01-26 19:16:30 +00:00
|
|
|
const struct loader_layer_list *activated_device_layers,
|
|
|
|
const struct loader_extension_list *icd_exts, const VkDeviceCreateInfo *pCreateInfo);
|
2015-07-05 17:28:29 +00:00
|
|
|
|
2021-12-02 23:55:13 +00:00
|
|
|
VkResult setup_loader_tramp_phys_devs(struct loader_instance *inst, uint32_t phys_dev_count, VkPhysicalDevice *phys_devs);
|
2022-03-09 23:28:04 +00:00
|
|
|
VkResult setup_loader_tramp_phys_dev_groups(struct loader_instance *inst, uint32_t group_count,
|
|
|
|
VkPhysicalDeviceGroupProperties *groups);
|
2017-01-12 19:27:19 +00:00
|
|
|
|
2017-01-26 19:16:30 +00:00
|
|
|
VkStringErrorFlags vk_string_validate(const int max_length, const char *char_array);
|
2021-09-06 00:34:10 +00:00
|
|
|
char *loader_get_next_path(char *path);
|
2022-01-04 18:45:18 +00:00
|
|
|
VkResult add_data_files(const struct loader_instance *inst, char *search_path, struct loader_data_files *out_files,
|
|
|
|
bool use_first_found_manifest);
|
2022-03-25 23:08:57 +00:00
|
|
|
|
|
|
|
loader_api_version loader_make_version(uint32_t version);
|
|
|
|
loader_api_version loader_combine_version(uint32_t major, uint32_t minor, uint32_t patch);
|
|
|
|
|
|
|
|
// Helper macros for determining if a version is valid or not
|
|
|
|
bool loader_check_version_meets_required(loader_api_version required, loader_api_version version);
|
|
|
|
|
|
|
|
// Convenience macros for common versions
|
|
|
|
#ifndef LOADER_VERSION_1_0_0
|
|
|
|
#define LOADER_VERSION_1_0_0 loader_combine_version(1, 0, 0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef LOADER_VERSION_1_1_0
|
|
|
|
#define LOADER_VERSION_1_1_0 loader_combine_version(1, 1, 0)
|
2022-05-27 22:36:35 +00:00
|
|
|
#endif
|