blob: addfc01c31508280cb39f9b007d91fa6530d6676 [file] [log] [blame]
Chia-I Wuc1e0f962014-08-04 08:03:57 +08001/*
Courtney Goeltzenleuchter0b018602015-04-08 15:36:08 -06002 * Vulkan
Chia-I Wuc1e0f962014-08-04 08:03:57 +08003 *
4 * Copyright (C) 2014 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
Chia-I Wud8ab1e62014-09-02 08:32:09 +080023 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
Chia-I Wuc1e0f962014-08-04 08:03:57 +080026 */
27
28#ifndef LOADER_H
29#define LOADER_H
30
Courtney Goeltzenleuchter0b018602015-04-08 15:36:08 -060031#include <vulkan.h>
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060032#include <vk_debug_report_lunarg.h>
Ian Elliottec736342015-08-21 15:09:33 -060033#include <vk_ext_khr_swapchain.h>
Tobin Ehlis7ad5aca2015-07-03 09:42:57 -060034#include <vk_layer.h>
35#include <vk_icd.h>
Chia-I Wufe333ed2015-04-11 15:34:07 +080036#include <assert.h>
37
Chia-I Wuc1e0f962014-08-04 08:03:57 +080038#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
Jon Ashburnb2379c52015-08-04 10:22:33 -060046#define MAX_STRING_SIZE 1024
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -060047#define VK_MAJOR(version) (version >> 22)
48#define VK_MINOR(version) ((version >> 12) & 0x3ff)
49#define VK_PATCH(version) (version & 0xfff)
Jon Ashburn13482452015-05-12 17:26:48 -060050
Jon Ashburn399c9162015-07-02 09:40:15 -060051enum layer_type {
Jon Ashburn9464e772015-07-02 16:10:32 -060052 VK_LAYER_TYPE_DEVICE_EXPLICIT = 0x1,
53 VK_LAYER_TYPE_INSTANCE_EXPLICIT = 0x2,
54 VK_LAYER_TYPE_GLOBAL_EXPLICIT = 0x3, // both instance and device layer, bitwise
55 VK_LAYER_TYPE_DEVICE_IMPLICIT = 0x4,
56 VK_LAYER_TYPE_INSTANCE_IMPLICIT = 0x8,
57 VK_LAYER_TYPE_GLOBAL_IMPLICIT = 0xc, // both instance and device layer, bitwise
Jon Ashburn399c9162015-07-02 09:40:15 -060058};
59
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060060struct loader_extension_list {
61 size_t capacity;
62 uint32_t count;
Jon Ashburnb7d327c2015-08-04 11:14:18 -060063 VkExtensionProperties *list;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060064};
65
Jon Ashburn399c9162015-07-02 09:40:15 -060066struct loader_name_value {
Jon Ashburnb2379c52015-08-04 10:22:33 -060067 char name[MAX_STRING_SIZE];
68 char value[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -060069};
70
71struct loader_lib_info {
Jon Ashburnb4c24232015-08-20 16:35:30 -060072 char lib_name[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -060073 uint32_t ref_count;
74 loader_platform_dl_handle lib_handle;
75};
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060076
Jon Ashburn399c9162015-07-02 09:40:15 -060077struct loader_layer_functions {
Jon Ashburnb2379c52015-08-04 10:22:33 -060078 char str_gipa[MAX_STRING_SIZE];
79 char str_gdpa[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -060080 PFN_vkGetInstanceProcAddr get_instance_proc_addr;
81 PFN_vkGetDeviceProcAddr get_device_proc_addr;
82};
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060083
Jon Ashburn399c9162015-07-02 09:40:15 -060084struct loader_layer_properties {
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -060085 VkLayerProperties info;
Jon Ashburn399c9162015-07-02 09:40:15 -060086 enum layer_type type;
Jon Ashburnb4c24232015-08-20 16:35:30 -060087 char lib_name[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -060088 struct loader_layer_functions functions;
89 struct loader_extension_list instance_extension_list;
90 struct loader_extension_list device_extension_list;
91 struct loader_name_value disable_env_var;
92 struct loader_name_value enable_env_var;
93};
94
95struct loader_layer_list {
96 size_t capacity;
97 uint32_t count;
98 struct loader_layer_properties *list;
Jon Ashburn13482452015-05-12 17:26:48 -060099};
100
Courtney Goeltzenleuchter8aff3862015-07-05 12:53:31 -0600101struct loader_layer_library_list {
102 size_t capacity;
103 uint32_t count;
104 struct loader_lib_info *list;
105};
106
Jon Ashburn10f4e822015-06-10 10:06:06 -0600107/* per CreateDevice structure */
108struct loader_device {
109 VkLayerDispatchTable loader_dispatch;
110 VkDevice device; // device object from the icd
111
112 uint32_t app_extension_count;
113 VkExtensionProperties *app_extension_props;
114
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600115 struct loader_layer_list activated_layer_list;
Jon Ashburn10f4e822015-06-10 10:06:06 -0600116
117 struct loader_device *next;
118};
119
Jon Ashburn392c5622015-06-10 16:11:42 -0600120/* per ICD structure */
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600121struct loader_icd {
Jon Ashburnb4c24232015-08-20 16:35:30 -0600122 // pointers to find other structs
123 const struct loader_scanned_icds *this_icd_lib;
124 const struct loader_instance *this_instance;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600125
Jon Ashburn10f4e822015-06-10 10:06:06 -0600126 struct loader_device *logical_device_list;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600127 VkInstance instance; // instance object from the icd
Jon Ashburnc89dd4a2015-05-18 13:20:15 -0600128 PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600129 PFN_vkDestroyInstance DestroyInstance;
130 PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
Chris Forbes1c946ec2015-06-21 22:55:02 +1200131 PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures;
Courtney Goeltzenleuchter2b6559e2015-07-12 12:52:09 -0600132 PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties;
Jon Ashburn25c11452015-07-23 18:49:07 -0600133 PFN_vkGetPhysicalDeviceImageFormatProperties GetPhysicalDeviceImageFormatProperties;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600134 PFN_vkCreateDevice CreateDevice;
Tony Barbour4e657ba2015-06-24 16:06:58 -0600135 PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
Cody Northropfc4ad132015-08-03 17:04:53 -0600136 PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties;
Tony Barbour4e657ba2015-06-24 16:06:58 -0600137 PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
Courtney Goeltzenleuchtere25064c2015-09-14 17:22:16 -0600138 PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties;
Mark Lobodzinski0c708be2015-07-03 15:58:09 -0600139 PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600140 PFN_vkDbgCreateMsgCallback DbgCreateMsgCallback;
141 PFN_vkDbgDestroyMsgCallback DbgDestroyMsgCallback;
Ian Elliottec736342015-08-21 15:09:33 -0600142 PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600143
Jon Ashburn10f4e822015-06-10 10:06:06 -0600144 struct loader_icd *next;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600145};
146
Jon Ashburne0367472015-08-18 18:04:47 -0600147/* per ICD library structure */
148struct loader_icd_libs {
149 size_t capacity;
150 uint32_t count;
151 struct loader_scanned_icds *list;
152};
153
Jon Ashburn392c5622015-06-10 16:11:42 -0600154/* per instance structure */
Jon Ashburn13482452015-05-12 17:26:48 -0600155struct loader_instance {
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600156 VkLayerInstanceDispatchTable *disp; // must be first entry in structure
157
Jon Ashburn13482452015-05-12 17:26:48 -0600158 uint32_t total_gpu_count;
Jon Ashburn969caa42015-11-01 14:04:06 -0700159 struct loader_physical_device *phys_devs;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600160 uint32_t total_icd_count;
Jon Ashburn13482452015-05-12 17:26:48 -0600161 struct loader_icd *icds;
162 struct loader_instance *next;
Jon Ashburne503a7d2015-08-14 14:49:22 -0600163 struct loader_extension_list ext_list; // icds and loaders extensions
Jon Ashburne0367472015-08-18 18:04:47 -0600164 struct loader_icd_libs icd_libs;
Jon Ashburnb4c24232015-08-20 16:35:30 -0600165 struct loader_layer_list instance_layer_list;
166 struct loader_layer_list device_layer_list;
167
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600168 struct loader_msg_callback_map_entry *icd_msg_callback_map;
169
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600170 struct loader_layer_list activated_layer_list;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600171
172 bool debug_report_enabled;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600173 VkLayerDbgFunctionNode *DbgFunctionHead;
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600174
Chia-I Wu227c8b32015-10-27 18:04:07 +0800175 VkAllocationCallbacks alloc_callbacks;
Ian Elliotted33eb72015-07-06 14:36:13 -0600176
177 bool wsi_swapchain_enabled;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600178};
179
Jon Ashburn969caa42015-11-01 14:04:06 -0700180/* per enumerated PhysicalDevice structure */
181struct loader_physical_device {
182 VkLayerInstanceDispatchTable *disp; // must be first entry in structure
183 struct loader_instance *this_instance;
184 struct loader_icd *this_icd;
185 VkPhysicalDevice phys_dev; // object from ICD
186 /*
187 * Fill in the cache of available device extensions from
188 * this physical device. This cache will be used to satisfy
189 * calls to EnumerateDeviceExtensionProperties
190 */
191 struct loader_extension_list device_extension_cache;
192};
193
Jon Ashburn13482452015-05-12 17:26:48 -0600194struct loader_struct {
195 struct loader_instance *instances;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600196
197 unsigned int loaded_layer_lib_count;
Courtney Goeltzenleuchter452303a2015-10-07 09:00:34 -0600198 size_t loaded_layer_lib_capacity;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600199 struct loader_lib_info *loaded_layer_lib_list;
Jon Ashburne0367472015-08-18 18:04:47 -0600200 // TODO add ref counting of ICD libraries
Jon Ashburn269b5922015-07-06 15:40:35 -0600201 // TODO use this struct loader_layer_library_list scanned_layer_libraries;
Jon Ashburne0367472015-08-18 18:04:47 -0600202 // TODO add list of icd libraries for ref counting them for closure
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600203};
204
205struct loader_scanned_icds {
206 char *lib_name;
207 loader_platform_dl_handle handle;
208
Jon Ashburnc7ca48d2015-07-16 10:17:29 -0600209 PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600210 PFN_vkCreateInstance CreateInstance;
Courtney Goeltzenleuchtere25064c2015-09-14 17:22:16 -0600211 PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
Jon Ashburn13482452015-05-12 17:26:48 -0600212};
213
Jon Ashburn399c9162015-07-02 09:40:15 -0600214static inline struct loader_instance *loader_instance(VkInstance instance) {
215 return (struct loader_instance *) instance;
216}
217
Tony Barbour303615c2015-07-03 10:33:54 -0600218static inline void loader_set_dispatch(void* obj, const void *data)
Chia-I Wufe333ed2015-04-11 15:34:07 +0800219{
220 *((const void **) obj) = data;
221}
222
Tony Barbour303615c2015-07-03 10:33:54 -0600223static inline VkLayerDispatchTable *loader_get_dispatch(const void* obj)
Chia-I Wufe333ed2015-04-11 15:34:07 +0800224{
Jon Ashburn62a54d12015-05-01 18:00:33 -0600225 return *((VkLayerDispatchTable **) obj);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800226}
227
Tony Barbour303615c2015-07-03 10:33:54 -0600228static inline VkLayerInstanceDispatchTable *loader_get_instance_dispatch(const void* obj)
Jon Ashburn13482452015-05-12 17:26:48 -0600229{
230 return *((VkLayerInstanceDispatchTable **) obj);
231}
232
Tony Barbour303615c2015-07-03 10:33:54 -0600233static inline void loader_init_dispatch(void* obj, const void *data)
Chia-I Wufe333ed2015-04-11 15:34:07 +0800234{
Jon Ashburn167b2b12015-04-15 13:34:33 -0600235#ifdef DEBUG
Chia-I Wufe333ed2015-04-11 15:34:07 +0800236 assert(valid_loader_magic_value(obj) &&
237 "Incompatible ICD, first dword must be initialized to ICD_LOADER_MAGIC. See loader/README.md for details.");
Jon Ashburn167b2b12015-04-15 13:34:33 -0600238#endif
Chia-I Wufe333ed2015-04-11 15:34:07 +0800239
Jon Ashburn62a54d12015-05-01 18:00:33 -0600240 loader_set_dispatch(obj, data);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800241}
242
Jon Ashburn13482452015-05-12 17:26:48 -0600243/* global variables used across files */
244extern struct loader_struct loader;
Jon Ashburnb4dee9c2015-08-28 15:19:27 -0600245extern THREAD_LOCAL_DECL struct loader_instance *tls_instance;
Jon Ashburne0367472015-08-18 18:04:47 -0600246extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_init);
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600247extern loader_platform_thread_mutex loader_lock;
Jon Ashburn7d4d51c2015-09-22 13:11:00 -0600248extern loader_platform_thread_mutex loader_json_lock;
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600249extern const VkLayerInstanceDispatchTable instance_disp;
Jon Ashburn37e7f972015-04-06 10:58:22 -0600250
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600251struct loader_msg_callback_map_entry {
252 VkDbgMsgCallback icd_obj;
253 VkDbgMsgCallback loader_obj;
254};
255
256bool compare_vk_extension_properties(
257 const VkExtensionProperties* op1,
258 const VkExtensionProperties* op2);
259
Jon Ashburnb4c24232015-08-20 16:35:30 -0600260VkResult loader_validate_layers(
261 const uint32_t layer_count,
262 const char * const *ppEnabledLayerNames,
263 const struct loader_layer_list *list);
Courtney Goeltzenleuchter76ece702015-07-06 17:45:08 -0600264
265VkResult loader_validate_instance_extensions(
Jon Ashburn555d2ed2015-08-14 11:57:54 -0600266 const struct loader_extension_list *icd_exts,
Jon Ashburnf6a69702015-08-11 14:49:54 -0600267 const struct loader_layer_list *instance_layer,
Courtney Goeltzenleuchter76ece702015-07-06 17:45:08 -0600268 const VkInstanceCreateInfo* pCreateInfo);
269
Jon Ashburn13482452015-05-12 17:26:48 -0600270/* instance layer chain termination entrypoint definitions */
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400271VkResult VKAPI loader_CreateInstance(
Jon Ashburn13482452015-05-12 17:26:48 -0600272 const VkInstanceCreateInfo* pCreateInfo,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800273 const VkAllocationCallbacks* pAllocator,
Jon Ashburn13482452015-05-12 17:26:48 -0600274 VkInstance* pInstance);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800275
Mark Lobodzinski025eade2015-09-07 13:59:43 -0600276void VKAPI loader_DestroyInstance(
Chia-I Wu221ca472015-10-26 21:10:41 +0800277 VkInstance instance,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800278 const VkAllocationCallbacks* pAllocator);
Jon Ashburn13482452015-05-12 17:26:48 -0600279
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400280VkResult VKAPI loader_EnumeratePhysicalDevices(
Jon Ashburn13482452015-05-12 17:26:48 -0600281 VkInstance instance,
282 uint32_t* pPhysicalDeviceCount,
283 VkPhysicalDevice* pPhysicalDevices);
Chris Forbes1c946ec2015-06-21 22:55:02 +1200284
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600285void VKAPI loader_GetPhysicalDeviceFeatures(
Chris Forbes1c946ec2015-06-21 22:55:02 +1200286 VkPhysicalDevice physicalDevice,
287 VkPhysicalDeviceFeatures* pFeatures);
288
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600289void VKAPI loader_GetPhysicalDeviceFormatProperties(
Chris Forbes1c946ec2015-06-21 22:55:02 +1200290 VkPhysicalDevice physicalDevice,
291 VkFormat format,
292 VkFormatProperties* pFormatInfo);
293
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600294void VKAPI loader_GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice,
Jon Ashburn25c11452015-07-23 18:49:07 -0600295 VkFormat format,
296 VkImageType type,
297 VkImageTiling tiling,
298 VkImageUsageFlags usage,
Courtney Goeltzenleuchter4743d002015-09-10 13:44:12 -0600299 VkImageCreateFlags flags,
Jon Ashburn25c11452015-07-23 18:49:07 -0600300 VkImageFormatProperties* pImageFormatProperties);
301
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600302void VKAPI loader_GetPhysicalDeviceSparseImageFormatProperties(
Mark Lobodzinski0c708be2015-07-03 15:58:09 -0600303 VkPhysicalDevice physicalDevice,
304 VkFormat format,
305 VkImageType type,
306 uint32_t samples,
307 VkImageUsageFlags usage,
308 VkImageTiling tiling,
309 uint32_t* pNumProperties,
310 VkSparseImageFormatProperties* pProperties);
Tony Barbour4e657ba2015-06-24 16:06:58 -0600311
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600312void VKAPI loader_GetPhysicalDeviceProperties (
Tony Barbour4e657ba2015-06-24 16:06:58 -0600313 VkPhysicalDevice physicalDevice,
314 VkPhysicalDeviceProperties* pProperties);
315
Courtney Goeltzenleuchtere25064c2015-09-14 17:22:16 -0600316VkResult VKAPI loader_EnumerateDeviceExtensionProperties (VkPhysicalDevice physicalDevice,
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600317 const char *pLayerName, uint32_t *pCount,
Tony Barbour4e657ba2015-06-24 16:06:58 -0600318 VkExtensionProperties* pProperties);
319
Courtney Goeltzenleuchtere25064c2015-09-14 17:22:16 -0600320VkResult VKAPI loader_EnumerateDeviceLayerProperties (VkPhysicalDevice physicalDevice,
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600321 uint32_t *pCount,
322 VkLayerProperties* pProperties);
Tony Barbour4e657ba2015-06-24 16:06:58 -0600323
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600324void VKAPI loader_GetPhysicalDeviceQueueFamilyProperties (
Cody Northropfc4ad132015-08-03 17:04:53 -0600325 VkPhysicalDevice physicalDevice,
326 uint32_t* pCount,
327 VkQueueFamilyProperties* pProperties);
Tony Barbour4e657ba2015-06-24 16:06:58 -0600328
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600329void VKAPI loader_GetPhysicalDeviceMemoryProperties (
Tony Barbour4e657ba2015-06-24 16:06:58 -0600330 VkPhysicalDevice physicalDevice,
331 VkPhysicalDeviceMemoryProperties * pProperties);
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600332
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400333VkResult VKAPI loader_CreateDevice(
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600334 VkPhysicalDevice gpu,
335 const VkDeviceCreateInfo* pCreateInfo,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800336 const VkAllocationCallbacks* pAllocator,
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600337 VkDevice* pDevice);
Jon Ashburn13482452015-05-12 17:26:48 -0600338
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600339/* helper function definitions */
Jon Ashburne0367472015-08-18 18:04:47 -0600340void loader_initialize(void);
Jon Ashburn02a8d6e2015-07-02 12:59:25 -0600341bool has_vk_extension_property_array(
342 const VkExtensionProperties *vk_ext_prop,
343 const uint32_t count,
344 const VkExtensionProperties *ext_array);
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600345bool has_vk_extension_property(
346 const VkExtensionProperties *vk_ext_prop,
347 const struct loader_extension_list *ext_list);
Jon Ashburn13482452015-05-12 17:26:48 -0600348
Jon Ashburn969caa42015-11-01 14:04:06 -0700349VkResult loader_add_to_ext_list(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600350 const struct loader_instance *inst,
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600351 struct loader_extension_list *ext_list,
352 uint32_t prop_list_count,
Jon Ashburnb7d327c2015-08-04 11:14:18 -0600353 const VkExtensionProperties *props);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600354void loader_destroy_ext_list(
355 const struct loader_instance *inst,
356 struct loader_extension_list *ext_info);
357void loader_delete_layer_properties(
358 const struct loader_instance *inst,
359 struct loader_layer_list *layer_list);
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600360void loader_add_to_layer_list(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600361 const struct loader_instance *inst,
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600362 struct loader_layer_list *list,
363 uint32_t prop_list_count,
364 const struct loader_layer_properties *props);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600365void loader_scanned_icd_clear(
366 const struct loader_instance *inst,
367 struct loader_icd_libs *icd_libs);
368void loader_icd_scan(
369 const struct loader_instance *inst,
370 struct loader_icd_libs *icds);
Jon Ashburnf6a69702015-08-11 14:49:54 -0600371void loader_layer_scan(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600372 const struct loader_instance *inst,
Jon Ashburnf6a69702015-08-11 14:49:54 -0600373 struct loader_layer_list *instance_layers,
374 struct loader_layer_list *device_layers);
Jon Ashburne0367472015-08-18 18:04:47 -0600375void loader_get_icd_loader_instance_extensions(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600376 const struct loader_instance *inst,
Jon Ashburne0367472015-08-18 18:04:47 -0600377 struct loader_icd_libs *icd_libs,
378 struct loader_extension_list *inst_exts);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600379struct loader_icd *loader_get_icd_and_device(
380 const VkDevice device,
381 struct loader_device **found_dev);
Jon Ashburn8a7e5622015-09-30 12:56:42 -0600382struct loader_instance *loader_get_instance(
383 const VkInstance instance);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600384void loader_remove_logical_device(
385 const struct loader_instance *inst,
386 VkDevice device);
Jon Ashburnf6a69702015-08-11 14:49:54 -0600387VkResult loader_enable_instance_layers(
388 struct loader_instance *inst,
389 const VkInstanceCreateInfo *pCreateInfo,
390 const struct loader_layer_list *instance_layers);
Jon Ashburn10f4e822015-06-10 10:06:06 -0600391void loader_deactivate_instance_layers(struct loader_instance *instance);
Jon Ashburn13482452015-05-12 17:26:48 -0600392uint32_t loader_activate_instance_layers(struct loader_instance *inst);
Courtney Goeltzenleuchter1c512402015-06-17 20:51:59 -0600393void loader_activate_instance_layer_extensions(struct loader_instance *inst);
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600394
395void* loader_heap_alloc(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600396 const struct loader_instance *instance,
Jon Ashburnf6a69702015-08-11 14:49:54 -0600397 size_t size,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800398 VkSystemAllocationScope allocationScope);
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600399
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600400void loader_heap_free(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600401 const struct loader_instance *instance,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800402 void *pMemory);
Jon Ashburnb4dee9c2015-08-28 15:19:27 -0600403
404void *loader_tls_heap_alloc(size_t size);
405
Chia-I Wu227c8b32015-10-27 18:04:07 +0800406void loader_tls_heap_free(void *pMemory);
Chia-I Wuc1e0f962014-08-04 08:03:57 +0800407#endif /* LOADER_H */