blob: bbc1a1ee5133c2745a56a7fa1f58c4aebfe6e09b [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 Elliotted33eb72015-07-06 14:36:13 -060033#include <vk_wsi_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
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -060046#define MAX_EXTENSION_NAME_SIZE (VK_MAX_EXTENSION_NAME-1)
Jon Ashburn10f4e822015-06-10 10:06:06 -060047#define MAX_GPUS_PER_ICD 16
Jon Ashburn13482452015-05-12 17:26:48 -060048
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -060049#define VK_MAJOR(version) (version >> 22)
50#define VK_MINOR(version) ((version >> 12) & 0x3ff)
51#define VK_PATCH(version) (version & 0xfff)
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060052enum extension_origin {
53 VK_EXTENSION_ORIGIN_ICD,
54 VK_EXTENSION_ORIGIN_LAYER,
55 VK_EXTENSION_ORIGIN_LOADER
Jon Ashburn13482452015-05-12 17:26:48 -060056};
57
Jon Ashburn399c9162015-07-02 09:40:15 -060058enum layer_type {
Jon Ashburn9464e772015-07-02 16:10:32 -060059 VK_LAYER_TYPE_DEVICE_EXPLICIT = 0x1,
60 VK_LAYER_TYPE_INSTANCE_EXPLICIT = 0x2,
61 VK_LAYER_TYPE_GLOBAL_EXPLICIT = 0x3, // both instance and device layer, bitwise
62 VK_LAYER_TYPE_DEVICE_IMPLICIT = 0x4,
63 VK_LAYER_TYPE_INSTANCE_IMPLICIT = 0x8,
64 VK_LAYER_TYPE_GLOBAL_IMPLICIT = 0xc, // both instance and device layer, bitwise
Jon Ashburn399c9162015-07-02 09:40:15 -060065};
66
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060067struct loader_extension_property {
68 VkExtensionProperties info;
69 const char *lib_name;
70 enum extension_origin origin;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060071};
72
73struct loader_extension_list {
74 size_t capacity;
75 uint32_t count;
76 struct loader_extension_property *list;
77};
78
Jon Ashburn399c9162015-07-02 09:40:15 -060079struct loader_name_value {
80 char *name;
81 char *value;
82};
83
84struct loader_lib_info {
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060085 char *lib_name;
Jon Ashburn399c9162015-07-02 09:40:15 -060086 uint32_t ref_count;
87 loader_platform_dl_handle lib_handle;
88};
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060089
Jon Ashburn399c9162015-07-02 09:40:15 -060090struct loader_layer_functions {
Jon Ashburn269b5922015-07-06 15:40:35 -060091 char *str_gipa;
92 char *str_gdpa;
Jon Ashburn399c9162015-07-02 09:40:15 -060093 PFN_vkGetInstanceProcAddr get_instance_proc_addr;
94 PFN_vkGetDeviceProcAddr get_device_proc_addr;
95};
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060096
Jon Ashburn399c9162015-07-02 09:40:15 -060097struct loader_layer_properties {
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -060098 VkLayerProperties info;
Jon Ashburn399c9162015-07-02 09:40:15 -060099 enum layer_type type;
Jon Ashburn269b5922015-07-06 15:40:35 -0600100 char *abi_version;
101 char *impl_version;
Jon Ashburn399c9162015-07-02 09:40:15 -0600102 struct loader_lib_info lib_info;
Jon Ashburn399c9162015-07-02 09:40:15 -0600103 struct loader_layer_functions functions;
104 struct loader_extension_list instance_extension_list;
105 struct loader_extension_list device_extension_list;
106 struct loader_name_value disable_env_var;
107 struct loader_name_value enable_env_var;
108};
109
110struct loader_layer_list {
111 size_t capacity;
112 uint32_t count;
113 struct loader_layer_properties *list;
Jon Ashburn13482452015-05-12 17:26:48 -0600114};
115
Courtney Goeltzenleuchter8aff3862015-07-05 12:53:31 -0600116struct loader_layer_library_list {
117 size_t capacity;
118 uint32_t count;
119 struct loader_lib_info *list;
120};
121
Jon Ashburn10f4e822015-06-10 10:06:06 -0600122/* per CreateDevice structure */
123struct loader_device {
124 VkLayerDispatchTable loader_dispatch;
125 VkDevice device; // device object from the icd
126
127 uint32_t app_extension_count;
128 VkExtensionProperties *app_extension_props;
129
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600130 struct loader_layer_list activated_layer_list;
Jon Ashburn10f4e822015-06-10 10:06:06 -0600131
132 struct loader_device *next;
133};
134
Jon Ashburn392c5622015-06-10 16:11:42 -0600135/* per ICD structure */
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600136struct loader_icd {
137 const struct loader_scanned_icds *scanned_icds;
138
Jon Ashburn10f4e822015-06-10 10:06:06 -0600139 struct loader_device *logical_device_list;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600140 uint32_t gpu_count;
Jon Ashburn392c5622015-06-10 16:11:42 -0600141 VkPhysicalDevice *gpus; // enumerated PhysicalDevices
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600142 VkInstance instance; // instance object from the icd
Jon Ashburnc89dd4a2015-05-18 13:20:15 -0600143 PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600144 PFN_vkDestroyInstance DestroyInstance;
145 PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
Chris Forbes1c946ec2015-06-21 22:55:02 +1200146 PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures;
Courtney Goeltzenleuchter2b6559e2015-07-12 12:52:09 -0600147 PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties;
Chris Forbes1c946ec2015-06-21 22:55:02 +1200148 PFN_vkGetPhysicalDeviceLimits GetPhysicalDeviceLimits;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600149 PFN_vkCreateDevice CreateDevice;
Tony Barbour4e657ba2015-06-24 16:06:58 -0600150 PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
Tony Barbour4e657ba2015-06-24 16:06:58 -0600151 PFN_vkGetPhysicalDeviceQueueCount GetPhysicalDeviceQueueCount;
152 PFN_vkGetPhysicalDeviceQueueProperties GetPhysicalDeviceQueueProperties;
153 PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
Tony Barbour4e657ba2015-06-24 16:06:58 -0600154 PFN_vkGetPhysicalDeviceExtensionProperties GetPhysicalDeviceExtensionProperties;
Mark Lobodzinski0c708be2015-07-03 15:58:09 -0600155 PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600156 PFN_vkDbgCreateMsgCallback DbgCreateMsgCallback;
157 PFN_vkDbgDestroyMsgCallback DbgDestroyMsgCallback;
Jon Ashburnc7ca48d2015-07-16 10:17:29 -0600158 PFN_vkGetPhysicalDeviceSurfaceSupportWSI GetPhysicalDeviceSurfaceSupportWSI;
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600159
Courtney Goeltzenleuchter1c512402015-06-17 20:51:59 -0600160 /*
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600161 * Fill in the cache of available global extensions that operate
162 * with this physical device. This cache will be used to satisfy
163 * calls to GetPhysicalDeviceExtensionProperties
Courtney Goeltzenleuchter1c512402015-06-17 20:51:59 -0600164 */
Jon Ashburn10f4e822015-06-10 10:06:06 -0600165 struct loader_extension_list device_extension_cache[MAX_GPUS_PER_ICD];
166 struct loader_icd *next;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600167};
168
Jon Ashburn392c5622015-06-10 16:11:42 -0600169/* per instance structure */
Jon Ashburn13482452015-05-12 17:26:48 -0600170struct loader_instance {
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600171 VkLayerInstanceDispatchTable *disp; // must be first entry in structure
172
Jon Ashburn13482452015-05-12 17:26:48 -0600173 uint32_t total_gpu_count;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600174 uint32_t total_icd_count;
Jon Ashburn13482452015-05-12 17:26:48 -0600175 struct loader_icd *icds;
176 struct loader_instance *next;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600177
178 /* TODO: Should keep track of application provided allocation functions */
179
180 /*
181 * CreateMsgCallback is global and needs to be
182 * applied to all layers and ICDs.
183 * What happens if a layer is enabled on both the instance chain
184 * as well as the device chain and a call to CreateMsgCallback is made?
185 * Do we need to make sure that each layer / driver only gets called once?
186 * Should a layer implementing support for CreateMsgCallback only be allowed (?)
187 * to live on one chain? Or maybe make it the application's responsibility.
188 * If the app enables DRAW_STATE on at both CreateInstance time and CreateDevice
189 * time, CreateMsgCallback will call the DRAW_STATE layer twice. Once via
190 * the instance chain and once via the device chain.
191 * The loader should only return the DEBUG_REPORT extension as supported
192 * for the GetGlobalExtensionSupport call. That should help eliminate one
193 * duplication.
194 * Since the instance chain requires us iterating over the available ICDs
195 * and each ICD will have it's own unique MsgCallback object we need to
196 * track those objects to give back the right one.
197 * This also implies that the loader has to intercept vkDestroyObject and
198 * if the extension is enabled and the object type is a MsgCallback then
199 * we must translate the object into the proper ICD specific ones.
200 * DestroyObject works on a device chain. Should not be what's destroying
201 * the MsgCallback object. That needs to be an instance thing. So, since
202 * we used an instance to create it, we need a custom Destroy that also
203 * takes an instance. That way we can iterate over the ICDs properly.
204 * Example use:
205 * CreateInstance: DEBUG_REPORT
206 * Loader will create instance chain with enabled extensions.
207 * TODO: Should validation layers be enabled here? If not, they will not be in the instance chain.
208 * fn = GetProcAddr(INSTANCE, "vkCreateMsgCallback") -> point to loader's vkCreateMsgCallback
209 * App creates a callback object: fn(..., &MsgCallbackObject1)
210 * Have only established the instance chain so far. Loader will call the instance chain.
211 * Each layer in the instance chain will call down to the next layer, terminating with
212 * the CreateMsgCallback loader terminator function that creates the actual MsgCallbackObject1 object.
213 * The loader CreateMsgCallback terminator will iterate over the ICDs.
214 * Calling each ICD that supports vkCreateMsgCallback and collect answers in icd_msg_callback_map here.
215 * As result is sent back up the chain each layer has opportunity to record the callback operation and
216 * appropriate MsgCallback object.
217 * ...
218 * Any reports matching the flags set in MsgCallbackObject1 will generate the defined callback behavior
219 * in the layer / ICD that initiated that report.
220 * ...
221 * CreateDevice: MemTracker:...
222 * App does not include DEBUG_REPORT as that is a global extension.
223 * TODO: GetExtensionSupport must not report DEBUG_REPORT when using instance.
224 * App MUST include any desired validation layers or they will not participate in the device call chain.
225 * App creates a callback object: fn(..., &MsgCallbackObject2)
226 * Loader's vkCreateMsgCallback is called.
227 * Loader sends call down instance chain - this is a global extension - any validation layer that was
228 * enabled at CreateInstance will be able to register the callback. Loader will iterate over the ICDs and
229 * will record the ICD's version of the MsgCallback2 object here.
230 * ...
231 * Any report will go to the layer's report function and it will check the flags for MsgCallbackObject1
232 * and MsgCallbackObject2 and take the appropriate action as indicated by the app.
233 * ...
234 * App calls vkDestroyMsgCallback( MsgCallbackObject1 )
235 * Loader's DestroyMsgCallback is where call starts. DestroyMsgCallback will be sent down instance chain
236 * ending in the loader's DestroyMsgCallback terminator which will iterate over the ICD's destroying each
237 * ICD version of that MsgCallback object and then destroy the loader's version of the object.
238 * Any reports generated after this will only have MsgCallbackObject2 available.
239 */
240 struct loader_msg_callback_map_entry *icd_msg_callback_map;
241
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600242 struct loader_layer_list activated_layer_list;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600243
244 bool debug_report_enabled;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600245 VkLayerDbgFunctionNode *DbgFunctionHead;
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600246
247 VkAllocCallbacks alloc_callbacks;
Ian Elliotted33eb72015-07-06 14:36:13 -0600248
249 bool wsi_swapchain_enabled;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600250};
251
Jon Ashburn13482452015-05-12 17:26:48 -0600252struct loader_struct {
253 struct loader_instance *instances;
Jon Ashburn13482452015-05-12 17:26:48 -0600254 struct loader_scanned_icds *scanned_icd_list;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600255
256 unsigned int loaded_layer_lib_count;
257 struct loader_lib_info *loaded_layer_lib_list;
258
Jon Ashburn13482452015-05-12 17:26:48 -0600259 char *layer_dirs;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600260
Jon Ashburn269b5922015-07-06 15:40:35 -0600261 // TODO use this struct loader_layer_library_list scanned_layer_libraries;
Jon Ashburn955d54d2015-07-16 17:19:31 -0600262 struct loader_layer_list scanned_instance_layers;
263 struct loader_layer_list scanned_device_layers;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600264
Tony Barbour4e657ba2015-06-24 16:06:58 -0600265 /* Keep track of all the extensions available via GetGlobalExtensionProperties */
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600266 struct loader_extension_list global_extensions;
267};
268
269struct loader_scanned_icds {
270 char *lib_name;
271 loader_platform_dl_handle handle;
272
Jon Ashburnc7ca48d2015-07-16 10:17:29 -0600273 PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600274 PFN_vkCreateInstance CreateInstance;
Tony Barbour4e657ba2015-06-24 16:06:58 -0600275 PFN_vkGetGlobalExtensionProperties GetGlobalExtensionProperties;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600276 VkInstance instance;
277 struct loader_scanned_icds *next;
278
279 /* cache of global extensions for specific ICD */
280 struct loader_extension_list global_extension_list;
281
282 /*
283 * cache of device extensions for specific ICD,
284 * filled in at CreateInstance time
285 */
Courtney Goeltzenleuchter1c512402015-06-17 20:51:59 -0600286 struct loader_extension_list device_extension_list;
Jon Ashburn13482452015-05-12 17:26:48 -0600287};
288
Jon Ashburn399c9162015-07-02 09:40:15 -0600289static inline struct loader_instance *loader_instance(VkInstance instance) {
290 return (struct loader_instance *) instance;
291}
292
Tony Barbour303615c2015-07-03 10:33:54 -0600293static inline void loader_set_dispatch(void* obj, const void *data)
Chia-I Wufe333ed2015-04-11 15:34:07 +0800294{
295 *((const void **) obj) = data;
296}
297
Tony Barbour303615c2015-07-03 10:33:54 -0600298static inline VkLayerDispatchTable *loader_get_dispatch(const void* obj)
Chia-I Wufe333ed2015-04-11 15:34:07 +0800299{
Jon Ashburn62a54d12015-05-01 18:00:33 -0600300 return *((VkLayerDispatchTable **) obj);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800301}
302
Tony Barbour303615c2015-07-03 10:33:54 -0600303static inline VkLayerInstanceDispatchTable *loader_get_instance_dispatch(const void* obj)
Jon Ashburn13482452015-05-12 17:26:48 -0600304{
305 return *((VkLayerInstanceDispatchTable **) obj);
306}
307
Tony Barbour303615c2015-07-03 10:33:54 -0600308static inline void loader_init_dispatch(void* obj, const void *data)
Chia-I Wufe333ed2015-04-11 15:34:07 +0800309{
Jon Ashburn167b2b12015-04-15 13:34:33 -0600310#ifdef DEBUG
Chia-I Wufe333ed2015-04-11 15:34:07 +0800311 assert(valid_loader_magic_value(obj) &&
312 "Incompatible ICD, first dword must be initialized to ICD_LOADER_MAGIC. See loader/README.md for details.");
Jon Ashburn167b2b12015-04-15 13:34:33 -0600313#endif
Chia-I Wufe333ed2015-04-11 15:34:07 +0800314
Jon Ashburn62a54d12015-05-01 18:00:33 -0600315 loader_set_dispatch(obj, data);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800316}
317
Jon Ashburn13482452015-05-12 17:26:48 -0600318/* global variables used across files */
319extern struct loader_struct loader;
320extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_icd);
321extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_layer);
322extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_exts);
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600323extern loader_platform_thread_mutex loader_lock;
324extern const VkLayerInstanceDispatchTable instance_disp;
Jon Ashburn37e7f972015-04-06 10:58:22 -0600325
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600326struct loader_msg_callback_map_entry {
327 VkDbgMsgCallback icd_obj;
328 VkDbgMsgCallback loader_obj;
329};
330
331bool compare_vk_extension_properties(
332 const VkExtensionProperties* op1,
333 const VkExtensionProperties* op2);
334
Courtney Goeltzenleuchter7acb9672015-07-06 20:14:18 -0600335VkResult loader_validate_layers(const uint32_t layer_count, const char * const *ppEnabledLayerNames, struct loader_layer_list *list);
Courtney Goeltzenleuchter76ece702015-07-06 17:45:08 -0600336
337VkResult loader_validate_instance_extensions(
338 const VkInstanceCreateInfo* pCreateInfo);
339
Jon Ashburn13482452015-05-12 17:26:48 -0600340/* instance layer chain termination entrypoint definitions */
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400341VkResult VKAPI loader_CreateInstance(
Jon Ashburn13482452015-05-12 17:26:48 -0600342 const VkInstanceCreateInfo* pCreateInfo,
343 VkInstance* pInstance);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800344
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400345VkResult VKAPI loader_DestroyInstance(
Jon Ashburn13482452015-05-12 17:26:48 -0600346 VkInstance instance);
347
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400348VkResult VKAPI loader_EnumeratePhysicalDevices(
Jon Ashburn13482452015-05-12 17:26:48 -0600349 VkInstance instance,
350 uint32_t* pPhysicalDeviceCount,
351 VkPhysicalDevice* pPhysicalDevices);
Chris Forbes1c946ec2015-06-21 22:55:02 +1200352
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400353VkResult VKAPI loader_GetPhysicalDeviceFeatures(
Chris Forbes1c946ec2015-06-21 22:55:02 +1200354 VkPhysicalDevice physicalDevice,
355 VkPhysicalDeviceFeatures* pFeatures);
356
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400357VkResult VKAPI loader_GetPhysicalDeviceFormatProperties(
Chris Forbes1c946ec2015-06-21 22:55:02 +1200358 VkPhysicalDevice physicalDevice,
359 VkFormat format,
360 VkFormatProperties* pFormatInfo);
361
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400362VkResult VKAPI loader_GetPhysicalDeviceLimits(
Chris Forbes1c946ec2015-06-21 22:55:02 +1200363 VkPhysicalDevice physicalDevice,
364 VkPhysicalDeviceLimits* pLimits);
365
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400366VkResult VKAPI loader_GetPhysicalDeviceSparseImageFormatProperties(
Mark Lobodzinski0c708be2015-07-03 15:58:09 -0600367 VkPhysicalDevice physicalDevice,
368 VkFormat format,
369 VkImageType type,
370 uint32_t samples,
371 VkImageUsageFlags usage,
372 VkImageTiling tiling,
373 uint32_t* pNumProperties,
374 VkSparseImageFormatProperties* pProperties);
Tony Barbour4e657ba2015-06-24 16:06:58 -0600375
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400376VkResult VKAPI loader_GetPhysicalDeviceProperties (
Tony Barbour4e657ba2015-06-24 16:06:58 -0600377 VkPhysicalDevice physicalDevice,
378 VkPhysicalDeviceProperties* pProperties);
379
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400380VkResult VKAPI loader_GetPhysicalDeviceExtensionProperties (VkPhysicalDevice physicalDevice,
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600381 const char *pLayerName, uint32_t *pCount,
Tony Barbour4e657ba2015-06-24 16:06:58 -0600382 VkExtensionProperties* pProperties);
383
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400384VkResult VKAPI loader_GetPhysicalDeviceLayerProperties (VkPhysicalDevice physicalDevice,
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600385 uint32_t *pCount,
386 VkLayerProperties* pProperties);
Tony Barbour4e657ba2015-06-24 16:06:58 -0600387
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400388VkResult VKAPI loader_GetPhysicalDeviceQueueCount (
Tony Barbour4e657ba2015-06-24 16:06:58 -0600389 VkPhysicalDevice physicalDevice,
390 uint32_t* pCount);
391
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400392VkResult VKAPI loader_GetPhysicalDeviceQueueProperties (
Tony Barbour4e657ba2015-06-24 16:06:58 -0600393 VkPhysicalDevice physicalDevice,
394 uint32_t count,
395 VkPhysicalDeviceQueueProperties * pProperties);
396
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400397VkResult VKAPI loader_GetPhysicalDeviceMemoryProperties (
Tony Barbour4e657ba2015-06-24 16:06:58 -0600398 VkPhysicalDevice physicalDevice,
399 VkPhysicalDeviceMemoryProperties * pProperties);
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600400
Dan Ginsburga2d864e2015-07-23 13:15:00 -0400401VkResult VKAPI loader_CreateDevice(
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600402 VkPhysicalDevice gpu,
403 const VkDeviceCreateInfo* pCreateInfo,
404 VkDevice* pDevice);
Jon Ashburn13482452015-05-12 17:26:48 -0600405
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600406/* helper function definitions */
Jon Ashburn02a8d6e2015-07-02 12:59:25 -0600407bool has_vk_extension_property_array(
408 const VkExtensionProperties *vk_ext_prop,
409 const uint32_t count,
410 const VkExtensionProperties *ext_array);
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600411bool has_vk_extension_property(
412 const VkExtensionProperties *vk_ext_prop,
413 const struct loader_extension_list *ext_list);
Jon Ashburn13482452015-05-12 17:26:48 -0600414
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600415void loader_add_to_ext_list(
416 struct loader_extension_list *ext_list,
417 uint32_t prop_list_count,
418 const struct loader_extension_property *props);
Courtney Goeltzenleuchter54fcee12015-06-08 15:09:22 -0600419void loader_destroy_ext_list(struct loader_extension_list *ext_info);
Jon Ashburn13482452015-05-12 17:26:48 -0600420
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600421void loader_add_to_layer_list(
422 struct loader_layer_list *list,
423 uint32_t prop_list_count,
424 const struct loader_layer_properties *props);
Jon Ashburn13482452015-05-12 17:26:48 -0600425void loader_icd_scan(void);
Jon Ashburn399c9162015-07-02 09:40:15 -0600426void loader_layer_scan(void);
Jon Ashburn13482452015-05-12 17:26:48 -0600427void loader_coalesce_extensions(void);
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600428
Jon Ashburn540a90d2015-05-28 19:16:58 -0600429struct loader_icd * loader_get_icd(const VkPhysicalDevice gpu,
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600430 uint32_t *gpu_index);
Jon Ashburn10f4e822015-06-10 10:06:06 -0600431void loader_remove_logical_device(VkDevice device);
Courtney Goeltzenleuchter6c51a6d2015-07-06 09:06:34 -0600432VkResult loader_enable_instance_layers(struct loader_instance *inst, const VkInstanceCreateInfo *pCreateInfo);
Jon Ashburn10f4e822015-06-10 10:06:06 -0600433void loader_deactivate_instance_layers(struct loader_instance *instance);
Jon Ashburn13482452015-05-12 17:26:48 -0600434uint32_t loader_activate_instance_layers(struct loader_instance *inst);
Courtney Goeltzenleuchter1c512402015-06-17 20:51:59 -0600435void loader_activate_instance_layer_extensions(struct loader_instance *inst);
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600436
437void* loader_heap_alloc(
438 struct loader_instance *instance,
439 size_t size,
440 VkSystemAllocType allocType);
441
442void* loader_aligned_heap_alloc(
443 struct loader_instance *instance,
444 size_t size,
445 size_t alignment,
446 VkSystemAllocType allocType);
447
448void loader_heap_free(
449 struct loader_instance *instance,
450 void *pMem);
Chia-I Wuc1e0f962014-08-04 08:03:57 +0800451#endif /* LOADER_H */