blob: 62a8b5fc4edde5921bbb5db7a7f18ea5ee52b49e [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 *
Courtney Goeltzenleuchterb9ce3952015-10-30 11:14:30 -060023 * Author: Chia-I Wu <olvaffe@gmail.com>
24 * Author: Chia-I Wu <olv@lunarg.com>
25 * Author: Chris Forbes <chrisf@ijw.co.nz>
26 * Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
27 * Author: Jon Ashburn <jon@lunarg.com>
28 * Author: Tony Barbour <tony@LunarG.com>
29 *
Chia-I Wuc1e0f962014-08-04 08:03:57 +080030 */
31
32#ifndef LOADER_H
33#define LOADER_H
34
David Pinedoa5036622015-11-06 12:54:48 -070035#include <vulkan/vulkan.h>
Jon Ashburn3708e792015-11-06 11:02:40 -070036#include <vk_loader_platform.h>
David Pinedoa5036622015-11-06 12:54:48 -070037#include <vulkan/vk_debug_report_lunarg.h>
38#include <vulkan/vk_ext_khr_swapchain.h>
39#include <vulkan/vk_layer.h>
40#include <vulkan/vk_icd.h>
Chia-I Wufe333ed2015-04-11 15:34:07 +080041#include <assert.h>
42
Chia-I Wuc1e0f962014-08-04 08:03:57 +080043#if defined(__GNUC__) && __GNUC__ >= 4
44# define LOADER_EXPORT __attribute__((visibility("default")))
45#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
46# define LOADER_EXPORT __attribute__((visibility("default")))
47#else
48# define LOADER_EXPORT
49#endif
50
Jon Ashburnb2379c52015-08-04 10:22:33 -060051#define MAX_STRING_SIZE 1024
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -060052#define VK_MAJOR(version) (version >> 22)
53#define VK_MINOR(version) ((version >> 12) & 0x3ff)
54#define VK_PATCH(version) (version & 0xfff)
Jon Ashburn13482452015-05-12 17:26:48 -060055
Jon Ashburn399c9162015-07-02 09:40:15 -060056enum layer_type {
Jon Ashburn9464e772015-07-02 16:10:32 -060057 VK_LAYER_TYPE_DEVICE_EXPLICIT = 0x1,
58 VK_LAYER_TYPE_INSTANCE_EXPLICIT = 0x2,
59 VK_LAYER_TYPE_GLOBAL_EXPLICIT = 0x3, // both instance and device layer, bitwise
60 VK_LAYER_TYPE_DEVICE_IMPLICIT = 0x4,
61 VK_LAYER_TYPE_INSTANCE_IMPLICIT = 0x8,
62 VK_LAYER_TYPE_GLOBAL_IMPLICIT = 0xc, // both instance and device layer, bitwise
Jon Ashburn399c9162015-07-02 09:40:15 -060063};
64
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060065struct loader_extension_list {
66 size_t capacity;
67 uint32_t count;
Jon Ashburnb7d327c2015-08-04 11:14:18 -060068 VkExtensionProperties *list;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060069};
70
Jon Ashburn399c9162015-07-02 09:40:15 -060071struct loader_name_value {
Jon Ashburnb2379c52015-08-04 10:22:33 -060072 char name[MAX_STRING_SIZE];
73 char value[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -060074};
75
76struct loader_lib_info {
Jon Ashburnb4c24232015-08-20 16:35:30 -060077 char lib_name[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -060078 uint32_t ref_count;
79 loader_platform_dl_handle lib_handle;
80};
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060081
Jon Ashburn399c9162015-07-02 09:40:15 -060082struct loader_layer_functions {
Jon Ashburnb2379c52015-08-04 10:22:33 -060083 char str_gipa[MAX_STRING_SIZE];
84 char str_gdpa[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -060085 PFN_vkGetInstanceProcAddr get_instance_proc_addr;
86 PFN_vkGetDeviceProcAddr get_device_proc_addr;
87};
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060088
Jon Ashburn399c9162015-07-02 09:40:15 -060089struct loader_layer_properties {
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -060090 VkLayerProperties info;
Jon Ashburn399c9162015-07-02 09:40:15 -060091 enum layer_type type;
Jon Ashburnb4c24232015-08-20 16:35:30 -060092 char lib_name[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -060093 struct loader_layer_functions functions;
94 struct loader_extension_list instance_extension_list;
95 struct loader_extension_list device_extension_list;
96 struct loader_name_value disable_env_var;
97 struct loader_name_value enable_env_var;
98};
99
100struct loader_layer_list {
101 size_t capacity;
102 uint32_t count;
103 struct loader_layer_properties *list;
Jon Ashburn13482452015-05-12 17:26:48 -0600104};
105
Courtney Goeltzenleuchter8aff3862015-07-05 12:53:31 -0600106struct loader_layer_library_list {
107 size_t capacity;
108 uint32_t count;
109 struct loader_lib_info *list;
110};
111
Jon Ashburn10f4e822015-06-10 10:06:06 -0600112/* per CreateDevice structure */
113struct loader_device {
114 VkLayerDispatchTable loader_dispatch;
115 VkDevice device; // device object from the icd
116
117 uint32_t app_extension_count;
118 VkExtensionProperties *app_extension_props;
119
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600120 struct loader_layer_list activated_layer_list;
Jon Ashburn10f4e822015-06-10 10:06:06 -0600121
122 struct loader_device *next;
123};
124
Jon Ashburn392c5622015-06-10 16:11:42 -0600125/* per ICD structure */
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600126struct loader_icd {
Jon Ashburnb4c24232015-08-20 16:35:30 -0600127 // pointers to find other structs
128 const struct loader_scanned_icds *this_icd_lib;
129 const struct loader_instance *this_instance;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600130
Jon Ashburn10f4e822015-06-10 10:06:06 -0600131 struct loader_device *logical_device_list;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600132 VkInstance instance; // instance object from the icd
Jon Ashburnc89dd4a2015-05-18 13:20:15 -0600133 PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600134 PFN_vkDestroyInstance DestroyInstance;
135 PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
Chris Forbes1c946ec2015-06-21 22:55:02 +1200136 PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures;
Courtney Goeltzenleuchter2b6559e2015-07-12 12:52:09 -0600137 PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties;
Jon Ashburn25c11452015-07-23 18:49:07 -0600138 PFN_vkGetPhysicalDeviceImageFormatProperties GetPhysicalDeviceImageFormatProperties;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600139 PFN_vkCreateDevice CreateDevice;
Tony Barbour4e657ba2015-06-24 16:06:58 -0600140 PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
Cody Northropfc4ad132015-08-03 17:04:53 -0600141 PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties;
Tony Barbour4e657ba2015-06-24 16:06:58 -0600142 PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
Courtney Goeltzenleuchtere25064c2015-09-14 17:22:16 -0600143 PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties;
Mark Lobodzinski0c708be2015-07-03 15:58:09 -0600144 PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600145 PFN_vkDbgCreateMsgCallback DbgCreateMsgCallback;
146 PFN_vkDbgDestroyMsgCallback DbgDestroyMsgCallback;
Ian Elliottec736342015-08-21 15:09:33 -0600147 PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600148
Jon Ashburn10f4e822015-06-10 10:06:06 -0600149 struct loader_icd *next;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600150};
151
Jon Ashburne0367472015-08-18 18:04:47 -0600152/* per ICD library structure */
153struct loader_icd_libs {
154 size_t capacity;
155 uint32_t count;
156 struct loader_scanned_icds *list;
157};
158
Jon Ashburn392c5622015-06-10 16:11:42 -0600159/* per instance structure */
Jon Ashburn13482452015-05-12 17:26:48 -0600160struct loader_instance {
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600161 VkLayerInstanceDispatchTable *disp; // must be first entry in structure
162
Jon Ashburn13482452015-05-12 17:26:48 -0600163 uint32_t total_gpu_count;
Jon Ashburn969caa42015-11-01 14:04:06 -0700164 struct loader_physical_device *phys_devs;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600165 uint32_t total_icd_count;
Jon Ashburn13482452015-05-12 17:26:48 -0600166 struct loader_icd *icds;
167 struct loader_instance *next;
Jon Ashburne503a7d2015-08-14 14:49:22 -0600168 struct loader_extension_list ext_list; // icds and loaders extensions
Jon Ashburne0367472015-08-18 18:04:47 -0600169 struct loader_icd_libs icd_libs;
Jon Ashburnb4c24232015-08-20 16:35:30 -0600170 struct loader_layer_list instance_layer_list;
171 struct loader_layer_list device_layer_list;
172
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600173 struct loader_msg_callback_map_entry *icd_msg_callback_map;
174
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600175 struct loader_layer_list activated_layer_list;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600176
177 bool debug_report_enabled;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600178 VkLayerDbgFunctionNode *DbgFunctionHead;
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600179
Chia-I Wu227c8b32015-10-27 18:04:07 +0800180 VkAllocationCallbacks alloc_callbacks;
Ian Elliotted33eb72015-07-06 14:36:13 -0600181
182 bool wsi_swapchain_enabled;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600183};
184
Jon Ashburn969caa42015-11-01 14:04:06 -0700185/* per enumerated PhysicalDevice structure */
186struct loader_physical_device {
187 VkLayerInstanceDispatchTable *disp; // must be first entry in structure
188 struct loader_instance *this_instance;
189 struct loader_icd *this_icd;
190 VkPhysicalDevice phys_dev; // object from ICD
191 /*
192 * Fill in the cache of available device extensions from
Jon Ashburna1981ff2015-11-02 17:40:01 -0700193 * this physical device. This cache can be used during CreateDevice
Jon Ashburn969caa42015-11-01 14:04:06 -0700194 */
195 struct loader_extension_list device_extension_cache;
196};
197
Jon Ashburn13482452015-05-12 17:26:48 -0600198struct loader_struct {
199 struct loader_instance *instances;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600200
201 unsigned int loaded_layer_lib_count;
Courtney Goeltzenleuchter452303a2015-10-07 09:00:34 -0600202 size_t loaded_layer_lib_capacity;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600203 struct loader_lib_info *loaded_layer_lib_list;
Jon Ashburne0367472015-08-18 18:04:47 -0600204 // TODO add ref counting of ICD libraries
Jon Ashburn269b5922015-07-06 15:40:35 -0600205 // TODO use this struct loader_layer_library_list scanned_layer_libraries;
Jon Ashburne0367472015-08-18 18:04:47 -0600206 // TODO add list of icd libraries for ref counting them for closure
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600207};
208
209struct loader_scanned_icds {
210 char *lib_name;
211 loader_platform_dl_handle handle;
212
Jon Ashburnc7ca48d2015-07-16 10:17:29 -0600213 PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600214 PFN_vkCreateInstance CreateInstance;
Courtney Goeltzenleuchtere25064c2015-09-14 17:22:16 -0600215 PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
Jon Ashburn13482452015-05-12 17:26:48 -0600216};
217
Jon Ashburn399c9162015-07-02 09:40:15 -0600218static inline struct loader_instance *loader_instance(VkInstance instance) {
219 return (struct loader_instance *) instance;
220}
221
Tony Barbour303615c2015-07-03 10:33:54 -0600222static inline void loader_set_dispatch(void* obj, const void *data)
Chia-I Wufe333ed2015-04-11 15:34:07 +0800223{
224 *((const void **) obj) = data;
225}
226
Tony Barbour303615c2015-07-03 10:33:54 -0600227static inline VkLayerDispatchTable *loader_get_dispatch(const void* obj)
Chia-I Wufe333ed2015-04-11 15:34:07 +0800228{
Jon Ashburn62a54d12015-05-01 18:00:33 -0600229 return *((VkLayerDispatchTable **) obj);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800230}
231
Tony Barbour303615c2015-07-03 10:33:54 -0600232static inline VkLayerInstanceDispatchTable *loader_get_instance_dispatch(const void* obj)
Jon Ashburn13482452015-05-12 17:26:48 -0600233{
234 return *((VkLayerInstanceDispatchTable **) obj);
235}
236
Tony Barbour303615c2015-07-03 10:33:54 -0600237static inline void loader_init_dispatch(void* obj, const void *data)
Chia-I Wufe333ed2015-04-11 15:34:07 +0800238{
Jon Ashburn167b2b12015-04-15 13:34:33 -0600239#ifdef DEBUG
Chia-I Wufe333ed2015-04-11 15:34:07 +0800240 assert(valid_loader_magic_value(obj) &&
241 "Incompatible ICD, first dword must be initialized to ICD_LOADER_MAGIC. See loader/README.md for details.");
Jon Ashburn167b2b12015-04-15 13:34:33 -0600242#endif
Chia-I Wufe333ed2015-04-11 15:34:07 +0800243
Jon Ashburn62a54d12015-05-01 18:00:33 -0600244 loader_set_dispatch(obj, data);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800245}
246
Jon Ashburn13482452015-05-12 17:26:48 -0600247/* global variables used across files */
248extern struct loader_struct loader;
Jon Ashburnb4dee9c2015-08-28 15:19:27 -0600249extern THREAD_LOCAL_DECL struct loader_instance *tls_instance;
Jon Ashburne0367472015-08-18 18:04:47 -0600250extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_init);
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600251extern loader_platform_thread_mutex loader_lock;
Jon Ashburn7d4d51c2015-09-22 13:11:00 -0600252extern loader_platform_thread_mutex loader_json_lock;
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600253extern const VkLayerInstanceDispatchTable instance_disp;
Jon Ashburn37e7f972015-04-06 10:58:22 -0600254
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600255struct loader_msg_callback_map_entry {
256 VkDbgMsgCallback icd_obj;
257 VkDbgMsgCallback loader_obj;
258};
259
260bool compare_vk_extension_properties(
261 const VkExtensionProperties* op1,
262 const VkExtensionProperties* op2);
263
Jon Ashburnb4c24232015-08-20 16:35:30 -0600264VkResult loader_validate_layers(
265 const uint32_t layer_count,
266 const char * const *ppEnabledLayerNames,
267 const struct loader_layer_list *list);
Courtney Goeltzenleuchter76ece702015-07-06 17:45:08 -0600268
269VkResult loader_validate_instance_extensions(
Jon Ashburn555d2ed2015-08-14 11:57:54 -0600270 const struct loader_extension_list *icd_exts,
Jon Ashburnf6a69702015-08-11 14:49:54 -0600271 const struct loader_layer_list *instance_layer,
Courtney Goeltzenleuchter76ece702015-07-06 17:45:08 -0600272 const VkInstanceCreateInfo* pCreateInfo);
273
Jon Ashburn13482452015-05-12 17:26:48 -0600274/* instance layer chain termination entrypoint definitions */
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400275VkResult VKAPI loader_CreateInstance(
Jon Ashburn13482452015-05-12 17:26:48 -0600276 const VkInstanceCreateInfo* pCreateInfo,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800277 const VkAllocationCallbacks* pAllocator,
Jon Ashburn13482452015-05-12 17:26:48 -0600278 VkInstance* pInstance);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800279
Mark Lobodzinski025eade2015-09-07 13:59:43 -0600280void VKAPI loader_DestroyInstance(
Chia-I Wu221ca472015-10-26 21:10:41 +0800281 VkInstance instance,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800282 const VkAllocationCallbacks* pAllocator);
Jon Ashburn13482452015-05-12 17:26:48 -0600283
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400284VkResult VKAPI loader_EnumeratePhysicalDevices(
Jon Ashburn13482452015-05-12 17:26:48 -0600285 VkInstance instance,
286 uint32_t* pPhysicalDeviceCount,
287 VkPhysicalDevice* pPhysicalDevices);
Chris Forbes1c946ec2015-06-21 22:55:02 +1200288
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600289void VKAPI loader_GetPhysicalDeviceFeatures(
Chris Forbes1c946ec2015-06-21 22:55:02 +1200290 VkPhysicalDevice physicalDevice,
291 VkPhysicalDeviceFeatures* pFeatures);
292
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600293void VKAPI loader_GetPhysicalDeviceFormatProperties(
Chris Forbes1c946ec2015-06-21 22:55:02 +1200294 VkPhysicalDevice physicalDevice,
295 VkFormat format,
296 VkFormatProperties* pFormatInfo);
297
Chia-I Wuef653f62015-10-31 00:31:16 +0800298VkResult VKAPI loader_GetPhysicalDeviceImageFormatProperties(
299 VkPhysicalDevice physicalDevice,
Jon Ashburn25c11452015-07-23 18:49:07 -0600300 VkFormat format,
301 VkImageType type,
302 VkImageTiling tiling,
303 VkImageUsageFlags usage,
Courtney Goeltzenleuchter4743d002015-09-10 13:44:12 -0600304 VkImageCreateFlags flags,
Jon Ashburn25c11452015-07-23 18:49:07 -0600305 VkImageFormatProperties* pImageFormatProperties);
306
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600307void VKAPI loader_GetPhysicalDeviceSparseImageFormatProperties(
Mark Lobodzinski0c708be2015-07-03 15:58:09 -0600308 VkPhysicalDevice physicalDevice,
309 VkFormat format,
310 VkImageType type,
Chia-I Wubb2b5b32015-10-31 00:31:16 +0800311 VkSampleCountFlagBits samples,
Mark Lobodzinski0c708be2015-07-03 15:58:09 -0600312 VkImageUsageFlags usage,
313 VkImageTiling tiling,
314 uint32_t* pNumProperties,
315 VkSparseImageFormatProperties* pProperties);
Tony Barbour4e657ba2015-06-24 16:06:58 -0600316
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600317void VKAPI loader_GetPhysicalDeviceProperties (
Tony Barbour4e657ba2015-06-24 16:06:58 -0600318 VkPhysicalDevice physicalDevice,
319 VkPhysicalDeviceProperties* pProperties);
320
Courtney Goeltzenleuchtere25064c2015-09-14 17:22:16 -0600321VkResult VKAPI loader_EnumerateDeviceExtensionProperties (VkPhysicalDevice physicalDevice,
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600322 const char *pLayerName, uint32_t *pCount,
Tony Barbour4e657ba2015-06-24 16:06:58 -0600323 VkExtensionProperties* pProperties);
324
Courtney Goeltzenleuchtere25064c2015-09-14 17:22:16 -0600325VkResult VKAPI loader_EnumerateDeviceLayerProperties (VkPhysicalDevice physicalDevice,
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600326 uint32_t *pCount,
327 VkLayerProperties* pProperties);
Tony Barbour4e657ba2015-06-24 16:06:58 -0600328
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600329void VKAPI loader_GetPhysicalDeviceQueueFamilyProperties (
Cody Northropfc4ad132015-08-03 17:04:53 -0600330 VkPhysicalDevice physicalDevice,
331 uint32_t* pCount,
332 VkQueueFamilyProperties* pProperties);
Tony Barbour4e657ba2015-06-24 16:06:58 -0600333
Courtney Goeltzenleuchtere2e76fa2015-10-20 16:40:38 -0600334void VKAPI loader_GetPhysicalDeviceMemoryProperties (
Tony Barbour4e657ba2015-06-24 16:06:58 -0600335 VkPhysicalDevice physicalDevice,
336 VkPhysicalDeviceMemoryProperties * pProperties);
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600337
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400338VkResult VKAPI loader_CreateDevice(
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600339 VkPhysicalDevice gpu,
340 const VkDeviceCreateInfo* pCreateInfo,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800341 const VkAllocationCallbacks* pAllocator,
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600342 VkDevice* pDevice);
Jon Ashburn13482452015-05-12 17:26:48 -0600343
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600344/* helper function definitions */
Jon Ashburne0367472015-08-18 18:04:47 -0600345void loader_initialize(void);
Jon Ashburn02a8d6e2015-07-02 12:59:25 -0600346bool has_vk_extension_property_array(
347 const VkExtensionProperties *vk_ext_prop,
348 const uint32_t count,
349 const VkExtensionProperties *ext_array);
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600350bool has_vk_extension_property(
351 const VkExtensionProperties *vk_ext_prop,
352 const struct loader_extension_list *ext_list);
Jon Ashburn13482452015-05-12 17:26:48 -0600353
Jon Ashburn969caa42015-11-01 14:04:06 -0700354VkResult loader_add_to_ext_list(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600355 const struct loader_instance *inst,
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600356 struct loader_extension_list *ext_list,
357 uint32_t prop_list_count,
Jon Ashburnb7d327c2015-08-04 11:14:18 -0600358 const VkExtensionProperties *props);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600359void loader_destroy_ext_list(
360 const struct loader_instance *inst,
361 struct loader_extension_list *ext_info);
362void loader_delete_layer_properties(
363 const struct loader_instance *inst,
364 struct loader_layer_list *layer_list);
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600365void loader_add_to_layer_list(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600366 const struct loader_instance *inst,
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600367 struct loader_layer_list *list,
368 uint32_t prop_list_count,
369 const struct loader_layer_properties *props);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600370void loader_scanned_icd_clear(
371 const struct loader_instance *inst,
372 struct loader_icd_libs *icd_libs);
373void loader_icd_scan(
374 const struct loader_instance *inst,
375 struct loader_icd_libs *icds);
Jon Ashburnf6a69702015-08-11 14:49:54 -0600376void loader_layer_scan(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600377 const struct loader_instance *inst,
Jon Ashburnf6a69702015-08-11 14:49:54 -0600378 struct loader_layer_list *instance_layers,
379 struct loader_layer_list *device_layers);
Jon Ashburne0367472015-08-18 18:04:47 -0600380void loader_get_icd_loader_instance_extensions(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600381 const struct loader_instance *inst,
Jon Ashburne0367472015-08-18 18:04:47 -0600382 struct loader_icd_libs *icd_libs,
383 struct loader_extension_list *inst_exts);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600384struct loader_icd *loader_get_icd_and_device(
385 const VkDevice device,
386 struct loader_device **found_dev);
Jon Ashburn8a7e5622015-09-30 12:56:42 -0600387struct loader_instance *loader_get_instance(
388 const VkInstance instance);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600389void loader_remove_logical_device(
390 const struct loader_instance *inst,
391 VkDevice device);
Jon Ashburnf6a69702015-08-11 14:49:54 -0600392VkResult loader_enable_instance_layers(
393 struct loader_instance *inst,
394 const VkInstanceCreateInfo *pCreateInfo,
395 const struct loader_layer_list *instance_layers);
Jon Ashburn10f4e822015-06-10 10:06:06 -0600396void loader_deactivate_instance_layers(struct loader_instance *instance);
Jon Ashburn13482452015-05-12 17:26:48 -0600397uint32_t loader_activate_instance_layers(struct loader_instance *inst);
Courtney Goeltzenleuchter1c512402015-06-17 20:51:59 -0600398void loader_activate_instance_layer_extensions(struct loader_instance *inst);
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600399
400void* loader_heap_alloc(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600401 const struct loader_instance *instance,
Jon Ashburnf6a69702015-08-11 14:49:54 -0600402 size_t size,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800403 VkSystemAllocationScope allocationScope);
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600404
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600405void loader_heap_free(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600406 const struct loader_instance *instance,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800407 void *pMemory);
Jon Ashburnb4dee9c2015-08-28 15:19:27 -0600408
409void *loader_tls_heap_alloc(size_t size);
410
Chia-I Wu227c8b32015-10-27 18:04:07 +0800411void loader_tls_heap_free(void *pMemory);
Chia-I Wuc1e0f962014-08-04 08:03:57 +0800412#endif /* LOADER_H */