blob: 5eafb516402dcce8c043a4093edf37a02f756c40 [file] [log] [blame]
Chia-I Wuc1e0f962014-08-04 08:03:57 +08001/*
Chia-I Wuc1e0f962014-08-04 08:03:57 +08002 *
Courtney Goeltzenleuchter20f29b12015-10-29 13:50:34 -06003 * Copyright (C) 2015 Valve Corporation
Chia-I Wuc1e0f962014-08-04 08:03:57 +08004 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
Chia-I Wud8ab1e62014-09-02 08:32:09 +080022 *
23 * Authors:
24 * Chia-I Wu <olv@lunarg.com>
Chia-I Wuc1e0f962014-08-04 08:03:57 +080025 */
26
27#ifndef LOADER_H
28#define LOADER_H
29
Courtney Goeltzenleuchter0b018602015-04-08 15:36:08 -060030#include <vulkan.h>
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060031#include <vk_debug_report_lunarg.h>
Ian Elliottec736342015-08-21 15:09:33 -060032#include <vk_ext_khr_swapchain.h>
Tobin Ehlis7ad5aca2015-07-03 09:42:57 -060033#include <vk_layer.h>
34#include <vk_icd.h>
Chia-I Wufe333ed2015-04-11 15:34:07 +080035#include <assert.h>
36
Chia-I Wuc1e0f962014-08-04 08:03:57 +080037#if defined(__GNUC__) && __GNUC__ >= 4
38# define LOADER_EXPORT __attribute__((visibility("default")))
39#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
40# define LOADER_EXPORT __attribute__((visibility("default")))
41#else
42# define LOADER_EXPORT
43#endif
44
Jon Ashburnb2379c52015-08-04 10:22:33 -060045#define MAX_STRING_SIZE 1024
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -060046#define VK_MAJOR(version) (version >> 22)
47#define VK_MINOR(version) ((version >> 12) & 0x3ff)
48#define VK_PATCH(version) (version & 0xfff)
Jon Ashburn13482452015-05-12 17:26:48 -060049
Jon Ashburn399c9162015-07-02 09:40:15 -060050enum layer_type {
Jon Ashburn9464e772015-07-02 16:10:32 -060051 VK_LAYER_TYPE_DEVICE_EXPLICIT = 0x1,
52 VK_LAYER_TYPE_INSTANCE_EXPLICIT = 0x2,
53 VK_LAYER_TYPE_GLOBAL_EXPLICIT = 0x3, // both instance and device layer, bitwise
54 VK_LAYER_TYPE_DEVICE_IMPLICIT = 0x4,
55 VK_LAYER_TYPE_INSTANCE_IMPLICIT = 0x8,
56 VK_LAYER_TYPE_GLOBAL_IMPLICIT = 0xc, // both instance and device layer, bitwise
Jon Ashburn399c9162015-07-02 09:40:15 -060057};
58
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060059struct loader_extension_list {
60 size_t capacity;
61 uint32_t count;
Jon Ashburnb7d327c2015-08-04 11:14:18 -060062 VkExtensionProperties *list;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060063};
64
Jon Ashburn399c9162015-07-02 09:40:15 -060065struct loader_name_value {
Jon Ashburnb2379c52015-08-04 10:22:33 -060066 char name[MAX_STRING_SIZE];
67 char value[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -060068};
69
70struct loader_lib_info {
Jon Ashburnb4c24232015-08-20 16:35:30 -060071 char lib_name[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -060072 uint32_t ref_count;
73 loader_platform_dl_handle lib_handle;
74};
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060075
Jon Ashburn399c9162015-07-02 09:40:15 -060076struct loader_layer_functions {
Jon Ashburnb2379c52015-08-04 10:22:33 -060077 char str_gipa[MAX_STRING_SIZE];
78 char str_gdpa[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -060079 PFN_vkGetInstanceProcAddr get_instance_proc_addr;
80 PFN_vkGetDeviceProcAddr get_device_proc_addr;
81};
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060082
Jon Ashburn399c9162015-07-02 09:40:15 -060083struct loader_layer_properties {
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -060084 VkLayerProperties info;
Jon Ashburn399c9162015-07-02 09:40:15 -060085 enum layer_type type;
Jon Ashburnb4c24232015-08-20 16:35:30 -060086 char lib_name[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -060087 struct loader_layer_functions functions;
88 struct loader_extension_list instance_extension_list;
89 struct loader_extension_list device_extension_list;
90 struct loader_name_value disable_env_var;
91 struct loader_name_value enable_env_var;
92};
93
94struct loader_layer_list {
95 size_t capacity;
96 uint32_t count;
97 struct loader_layer_properties *list;
Jon Ashburn13482452015-05-12 17:26:48 -060098};
99
Courtney Goeltzenleuchter8aff3862015-07-05 12:53:31 -0600100struct loader_layer_library_list {
101 size_t capacity;
102 uint32_t count;
103 struct loader_lib_info *list;
104};
105
Jon Ashburn10f4e822015-06-10 10:06:06 -0600106/* per CreateDevice structure */
107struct loader_device {
108 VkLayerDispatchTable loader_dispatch;
109 VkDevice device; // device object from the icd
110
111 uint32_t app_extension_count;
112 VkExtensionProperties *app_extension_props;
113
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600114 struct loader_layer_list activated_layer_list;
Jon Ashburn10f4e822015-06-10 10:06:06 -0600115
116 struct loader_device *next;
117};
118
Jon Ashburn392c5622015-06-10 16:11:42 -0600119/* per ICD structure */
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600120struct loader_icd {
Jon Ashburnb4c24232015-08-20 16:35:30 -0600121 // pointers to find other structs
122 const struct loader_scanned_icds *this_icd_lib;
123 const struct loader_instance *this_instance;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600124
Jon Ashburn10f4e822015-06-10 10:06:06 -0600125 struct loader_device *logical_device_list;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600126 VkInstance instance; // instance object from the icd
Jon Ashburnc89dd4a2015-05-18 13:20:15 -0600127 PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600128 PFN_vkDestroyInstance DestroyInstance;
129 PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
Chris Forbes1c946ec2015-06-21 22:55:02 +1200130 PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures;
Courtney Goeltzenleuchter2b6559e2015-07-12 12:52:09 -0600131 PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties;
Jon Ashburn25c11452015-07-23 18:49:07 -0600132 PFN_vkGetPhysicalDeviceImageFormatProperties GetPhysicalDeviceImageFormatProperties;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600133 PFN_vkCreateDevice CreateDevice;
Tony Barbour4e657ba2015-06-24 16:06:58 -0600134 PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
Cody Northropfc4ad132015-08-03 17:04:53 -0600135 PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties;
Tony Barbour4e657ba2015-06-24 16:06:58 -0600136 PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
Courtney Goeltzenleuchtere25064c2015-09-14 17:22:16 -0600137 PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties;
Mark Lobodzinski0c708be2015-07-03 15:58:09 -0600138 PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600139 PFN_vkDbgCreateMsgCallback DbgCreateMsgCallback;
140 PFN_vkDbgDestroyMsgCallback DbgDestroyMsgCallback;
Ian Elliottec736342015-08-21 15:09:33 -0600141 PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600142
Jon Ashburn10f4e822015-06-10 10:06:06 -0600143 struct loader_icd *next;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600144};
145
Jon Ashburne0367472015-08-18 18:04:47 -0600146/* per ICD library structure */
147struct loader_icd_libs {
148 size_t capacity;
149 uint32_t count;
150 struct loader_scanned_icds *list;
151};
152
Jon Ashburn392c5622015-06-10 16:11:42 -0600153/* per instance structure */
Jon Ashburn13482452015-05-12 17:26:48 -0600154struct loader_instance {
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600155 VkLayerInstanceDispatchTable *disp; // must be first entry in structure
156
Jon Ashburn13482452015-05-12 17:26:48 -0600157 uint32_t total_gpu_count;
Jon Ashburn969caa42015-11-01 14:04:06 -0700158 struct loader_physical_device *phys_devs;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600159 uint32_t total_icd_count;
Jon Ashburn13482452015-05-12 17:26:48 -0600160 struct loader_icd *icds;
161 struct loader_instance *next;
Jon Ashburne503a7d2015-08-14 14:49:22 -0600162 struct loader_extension_list ext_list; // icds and loaders extensions
Jon Ashburne0367472015-08-18 18:04:47 -0600163 struct loader_icd_libs icd_libs;
Jon Ashburnb4c24232015-08-20 16:35:30 -0600164 struct loader_layer_list instance_layer_list;
165 struct loader_layer_list device_layer_list;
166
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600167 struct loader_msg_callback_map_entry *icd_msg_callback_map;
168
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600169 struct loader_layer_list activated_layer_list;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600170
171 bool debug_report_enabled;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600172 VkLayerDbgFunctionNode *DbgFunctionHead;
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600173
Chia-I Wu227c8b32015-10-27 18:04:07 +0800174 VkAllocationCallbacks alloc_callbacks;
Ian Elliotted33eb72015-07-06 14:36:13 -0600175
176 bool wsi_swapchain_enabled;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600177};
178
Jon Ashburn969caa42015-11-01 14:04:06 -0700179/* per enumerated PhysicalDevice structure */
180struct loader_physical_device {
181 VkLayerInstanceDispatchTable *disp; // must be first entry in structure
182 struct loader_instance *this_instance;
183 struct loader_icd *this_icd;
184 VkPhysicalDevice phys_dev; // object from ICD
185 /*
186 * Fill in the cache of available device extensions from
Jon Ashburna1981ff2015-11-02 17:40:01 -0700187 * this physical device. This cache can be used during CreateDevice
Jon Ashburn969caa42015-11-01 14:04:06 -0700188 */
189 struct loader_extension_list device_extension_cache;
190};
191
Jon Ashburn13482452015-05-12 17:26:48 -0600192struct loader_struct {
193 struct loader_instance *instances;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600194
195 unsigned int loaded_layer_lib_count;
Courtney Goeltzenleuchter452303a2015-10-07 09:00:34 -0600196 size_t loaded_layer_lib_capacity;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600197 struct loader_lib_info *loaded_layer_lib_list;
Jon Ashburne0367472015-08-18 18:04:47 -0600198 // TODO add ref counting of ICD libraries
Jon Ashburn269b5922015-07-06 15:40:35 -0600199 // TODO use this struct loader_layer_library_list scanned_layer_libraries;
Jon Ashburne0367472015-08-18 18:04:47 -0600200 // TODO add list of icd libraries for ref counting them for closure
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600201};
202
203struct loader_scanned_icds {
204 char *lib_name;
205 loader_platform_dl_handle handle;
206
Jon Ashburnc7ca48d2015-07-16 10:17:29 -0600207 PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600208 PFN_vkCreateInstance CreateInstance;
Courtney Goeltzenleuchtere25064c2015-09-14 17:22:16 -0600209 PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
Jon Ashburn13482452015-05-12 17:26:48 -0600210};
211
Jon Ashburn399c9162015-07-02 09:40:15 -0600212static inline struct loader_instance *loader_instance(VkInstance instance) {
213 return (struct loader_instance *) instance;
214}
215
Tony Barbour303615c2015-07-03 10:33:54 -0600216static inline void loader_set_dispatch(void* obj, const void *data)
Chia-I Wufe333ed2015-04-11 15:34:07 +0800217{
218 *((const void **) obj) = data;
219}
220
Tony Barbour303615c2015-07-03 10:33:54 -0600221static inline VkLayerDispatchTable *loader_get_dispatch(const void* obj)
Chia-I Wufe333ed2015-04-11 15:34:07 +0800222{
Jon Ashburn62a54d12015-05-01 18:00:33 -0600223 return *((VkLayerDispatchTable **) obj);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800224}
225
Tony Barbour303615c2015-07-03 10:33:54 -0600226static inline VkLayerInstanceDispatchTable *loader_get_instance_dispatch(const void* obj)
Jon Ashburn13482452015-05-12 17:26:48 -0600227{
228 return *((VkLayerInstanceDispatchTable **) obj);
229}
230
Tony Barbour303615c2015-07-03 10:33:54 -0600231static inline void loader_init_dispatch(void* obj, const void *data)
Chia-I Wufe333ed2015-04-11 15:34:07 +0800232{
Jon Ashburn167b2b12015-04-15 13:34:33 -0600233#ifdef DEBUG
Chia-I Wufe333ed2015-04-11 15:34:07 +0800234 assert(valid_loader_magic_value(obj) &&
235 "Incompatible ICD, first dword must be initialized to ICD_LOADER_MAGIC. See loader/README.md for details.");
Jon Ashburn167b2b12015-04-15 13:34:33 -0600236#endif
Chia-I Wufe333ed2015-04-11 15:34:07 +0800237
Jon Ashburn62a54d12015-05-01 18:00:33 -0600238 loader_set_dispatch(obj, data);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800239}
240
Jon Ashburn13482452015-05-12 17:26:48 -0600241/* global variables used across files */
242extern struct loader_struct loader;
Jon Ashburnb4dee9c2015-08-28 15:19:27 -0600243extern THREAD_LOCAL_DECL struct loader_instance *tls_instance;
Jon Ashburne0367472015-08-18 18:04:47 -0600244extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_init);
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600245extern loader_platform_thread_mutex loader_lock;
Jon Ashburn7d4d51c2015-09-22 13:11:00 -0600246extern loader_platform_thread_mutex loader_json_lock;
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600247extern const VkLayerInstanceDispatchTable instance_disp;
Jon Ashburn37e7f972015-04-06 10:58:22 -0600248
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600249struct loader_msg_callback_map_entry {
250 VkDbgMsgCallback icd_obj;
251 VkDbgMsgCallback loader_obj;
252};
253
254bool compare_vk_extension_properties(
255 const VkExtensionProperties* op1,
256 const VkExtensionProperties* op2);
257
Jon Ashburnb4c24232015-08-20 16:35:30 -0600258VkResult loader_validate_layers(
259 const uint32_t layer_count,
260 const char * const *ppEnabledLayerNames,
261 const struct loader_layer_list *list);
Courtney Goeltzenleuchter76ece702015-07-06 17:45:08 -0600262
263VkResult loader_validate_instance_extensions(
Jon Ashburn555d2ed2015-08-14 11:57:54 -0600264 const struct loader_extension_list *icd_exts,
Jon Ashburnf6a69702015-08-11 14:49:54 -0600265 const struct loader_layer_list *instance_layer,
Courtney Goeltzenleuchter76ece702015-07-06 17:45:08 -0600266 const VkInstanceCreateInfo* pCreateInfo);
267
Jon Ashburn13482452015-05-12 17:26:48 -0600268/* instance layer chain termination entrypoint definitions */
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400269VkResult VKAPI loader_CreateInstance(
Jon Ashburn13482452015-05-12 17:26:48 -0600270 const VkInstanceCreateInfo* pCreateInfo,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800271 const VkAllocationCallbacks* pAllocator,
Jon Ashburn13482452015-05-12 17:26:48 -0600272 VkInstance* pInstance);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800273
Mark Lobodzinski025eade2015-09-07 13:59:43 -0600274void VKAPI loader_DestroyInstance(
Chia-I Wu221ca472015-10-26 21:10:41 +0800275 VkInstance instance,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800276 const VkAllocationCallbacks* pAllocator);
Jon Ashburn13482452015-05-12 17:26:48 -0600277
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400278VkResult VKAPI loader_EnumeratePhysicalDevices(
Jon Ashburn13482452015-05-12 17:26:48 -0600279 VkInstance instance,
280 uint32_t* pPhysicalDeviceCount,
281 VkPhysicalDevice* pPhysicalDevices);
Chris Forbes1c946ec2015-06-21 22:55:02 +1200282
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600283void VKAPI loader_GetPhysicalDeviceFeatures(
Chris Forbes1c946ec2015-06-21 22:55:02 +1200284 VkPhysicalDevice physicalDevice,
285 VkPhysicalDeviceFeatures* pFeatures);
286
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600287void VKAPI loader_GetPhysicalDeviceFormatProperties(
Chris Forbes1c946ec2015-06-21 22:55:02 +1200288 VkPhysicalDevice physicalDevice,
289 VkFormat format,
290 VkFormatProperties* pFormatInfo);
291
Chia-I Wuef653f62015-10-31 00:31:16 +0800292VkResult VKAPI loader_GetPhysicalDeviceImageFormatProperties(
293 VkPhysicalDevice physicalDevice,
Jon Ashburn25c11452015-07-23 18:49:07 -0600294 VkFormat format,
295 VkImageType type,
296 VkImageTiling tiling,
297 VkImageUsageFlags usage,
Courtney Goeltzenleuchter4743d002015-09-10 13:44:12 -0600298 VkImageCreateFlags flags,
Jon Ashburn25c11452015-07-23 18:49:07 -0600299 VkImageFormatProperties* pImageFormatProperties);
300
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600301void VKAPI loader_GetPhysicalDeviceSparseImageFormatProperties(
Mark Lobodzinski0c708be2015-07-03 15:58:09 -0600302 VkPhysicalDevice physicalDevice,
303 VkFormat format,
304 VkImageType type,
Chia-I Wubb2b5b32015-10-31 00:31:16 +0800305 VkSampleCountFlagBits samples,
Mark Lobodzinski0c708be2015-07-03 15:58:09 -0600306 VkImageUsageFlags usage,
307 VkImageTiling tiling,
308 uint32_t* pNumProperties,
309 VkSparseImageFormatProperties* pProperties);
Tony Barbour4e657ba2015-06-24 16:06:58 -0600310
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600311void VKAPI loader_GetPhysicalDeviceProperties (
Tony Barbour4e657ba2015-06-24 16:06:58 -0600312 VkPhysicalDevice physicalDevice,
313 VkPhysicalDeviceProperties* pProperties);
314
Courtney Goeltzenleuchtere25064c2015-09-14 17:22:16 -0600315VkResult VKAPI loader_EnumerateDeviceExtensionProperties (VkPhysicalDevice physicalDevice,
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600316 const char *pLayerName, uint32_t *pCount,
Tony Barbour4e657ba2015-06-24 16:06:58 -0600317 VkExtensionProperties* pProperties);
318
Courtney Goeltzenleuchtere25064c2015-09-14 17:22:16 -0600319VkResult VKAPI loader_EnumerateDeviceLayerProperties (VkPhysicalDevice physicalDevice,
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600320 uint32_t *pCount,
321 VkLayerProperties* pProperties);
Tony Barbour4e657ba2015-06-24 16:06:58 -0600322
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600323void VKAPI loader_GetPhysicalDeviceQueueFamilyProperties (
Cody Northropfc4ad132015-08-03 17:04:53 -0600324 VkPhysicalDevice physicalDevice,
325 uint32_t* pCount,
326 VkQueueFamilyProperties* pProperties);
Tony Barbour4e657ba2015-06-24 16:06:58 -0600327
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600328void VKAPI loader_GetPhysicalDeviceMemoryProperties (
Tony Barbour4e657ba2015-06-24 16:06:58 -0600329 VkPhysicalDevice physicalDevice,
330 VkPhysicalDeviceMemoryProperties * pProperties);
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600331
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400332VkResult VKAPI loader_CreateDevice(
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600333 VkPhysicalDevice gpu,
334 const VkDeviceCreateInfo* pCreateInfo,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800335 const VkAllocationCallbacks* pAllocator,
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600336 VkDevice* pDevice);
Jon Ashburn13482452015-05-12 17:26:48 -0600337
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600338/* helper function definitions */
Jon Ashburne0367472015-08-18 18:04:47 -0600339void loader_initialize(void);
Jon Ashburn02a8d6e2015-07-02 12:59:25 -0600340bool has_vk_extension_property_array(
341 const VkExtensionProperties *vk_ext_prop,
342 const uint32_t count,
343 const VkExtensionProperties *ext_array);
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600344bool has_vk_extension_property(
345 const VkExtensionProperties *vk_ext_prop,
346 const struct loader_extension_list *ext_list);
Jon Ashburn13482452015-05-12 17:26:48 -0600347
Jon Ashburn969caa42015-11-01 14:04:06 -0700348VkResult loader_add_to_ext_list(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600349 const struct loader_instance *inst,
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600350 struct loader_extension_list *ext_list,
351 uint32_t prop_list_count,
Jon Ashburnb7d327c2015-08-04 11:14:18 -0600352 const VkExtensionProperties *props);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600353void loader_destroy_ext_list(
354 const struct loader_instance *inst,
355 struct loader_extension_list *ext_info);
356void loader_delete_layer_properties(
357 const struct loader_instance *inst,
358 struct loader_layer_list *layer_list);
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600359void loader_add_to_layer_list(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600360 const struct loader_instance *inst,
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600361 struct loader_layer_list *list,
362 uint32_t prop_list_count,
363 const struct loader_layer_properties *props);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600364void loader_scanned_icd_clear(
365 const struct loader_instance *inst,
366 struct loader_icd_libs *icd_libs);
367void loader_icd_scan(
368 const struct loader_instance *inst,
369 struct loader_icd_libs *icds);
Jon Ashburnf6a69702015-08-11 14:49:54 -0600370void loader_layer_scan(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600371 const struct loader_instance *inst,
Jon Ashburnf6a69702015-08-11 14:49:54 -0600372 struct loader_layer_list *instance_layers,
373 struct loader_layer_list *device_layers);
Jon Ashburne0367472015-08-18 18:04:47 -0600374void loader_get_icd_loader_instance_extensions(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600375 const struct loader_instance *inst,
Jon Ashburne0367472015-08-18 18:04:47 -0600376 struct loader_icd_libs *icd_libs,
377 struct loader_extension_list *inst_exts);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600378struct loader_icd *loader_get_icd_and_device(
379 const VkDevice device,
380 struct loader_device **found_dev);
Jon Ashburn8a7e5622015-09-30 12:56:42 -0600381struct loader_instance *loader_get_instance(
382 const VkInstance instance);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600383void loader_remove_logical_device(
384 const struct loader_instance *inst,
385 VkDevice device);
Jon Ashburnf6a69702015-08-11 14:49:54 -0600386VkResult loader_enable_instance_layers(
387 struct loader_instance *inst,
388 const VkInstanceCreateInfo *pCreateInfo,
389 const struct loader_layer_list *instance_layers);
Jon Ashburn10f4e822015-06-10 10:06:06 -0600390void loader_deactivate_instance_layers(struct loader_instance *instance);
Jon Ashburn13482452015-05-12 17:26:48 -0600391uint32_t loader_activate_instance_layers(struct loader_instance *inst);
Courtney Goeltzenleuchter1c512402015-06-17 20:51:59 -0600392void loader_activate_instance_layer_extensions(struct loader_instance *inst);
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600393
394void* loader_heap_alloc(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600395 const struct loader_instance *instance,
Jon Ashburnf6a69702015-08-11 14:49:54 -0600396 size_t size,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800397 VkSystemAllocationScope allocationScope);
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600398
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600399void loader_heap_free(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600400 const struct loader_instance *instance,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800401 void *pMemory);
Jon Ashburnb4dee9c2015-08-28 15:19:27 -0600402
403void *loader_tls_heap_alloc(size_t size);
404
Chia-I Wu227c8b32015-10-27 18:04:07 +0800405void loader_tls_heap_free(void *pMemory);
Chia-I Wuc1e0f962014-08-04 08:03:57 +0800406#endif /* LOADER_H */