blob: 371a3069ef1ccff0a17fa650666042cf7b257567 [file] [log] [blame]
Chia-I Wu468e3c32014-08-04 08:03:57 +08001/*
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002 * Vulkan
Chia-I Wu468e3c32014-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 Wu44e42362014-09-02 08:32:09 +080023 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
Chia-I Wu468e3c32014-08-04 08:03:57 +080026 */
27
28#ifndef LOADER_H
29#define LOADER_H
30
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060031#include <vulkan.h>
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060032#include <vk_debug_report_lunarg.h>
Chia-I Wu5b66aa52015-04-16 22:02:10 +080033#include <vk_wsi_lunarg.h>
Tobin Ehlis2d1d9702015-07-03 09:42:57 -060034#include <vk_layer.h>
35#include <vk_icd.h>
Chia-I Wu1d6731b2015-04-11 15:34:07 +080036#include <assert.h>
37
Chia-I Wu468e3c32014-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 Goeltzenleuchter18061cd2015-06-29 15:39:26 -060046#define MAX_EXTENSION_NAME_SIZE (VK_MAX_EXTENSION_NAME-1)
Jon Ashburncb5a5ac2015-06-10 10:06:06 -060047#define MAX_GPUS_PER_ICD 16
Jon Ashburnfce93d92015-05-12 17:26:48 -060048
Courtney Goeltzenleuchter18061cd2015-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 Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060052enum extension_origin {
53 VK_EXTENSION_ORIGIN_ICD,
54 VK_EXTENSION_ORIGIN_LAYER,
55 VK_EXTENSION_ORIGIN_LOADER
Jon Ashburnfce93d92015-05-12 17:26:48 -060056};
57
Jon Ashburn68a63922015-07-02 09:40:15 -060058enum layer_type {
Jon Ashburn535bd002015-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 Ashburn68a63922015-07-02 09:40:15 -060065};
66
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060067struct loader_extension_property {
68 VkExtensionProperties info;
69 const char *lib_name;
70 enum extension_origin origin;
Courtney Goeltzenleuchter1c7c65d2015-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 Ashburn68a63922015-07-02 09:40:15 -060079struct loader_name_value {
80 char *name;
81 char *value;
82};
83
84struct loader_lib_info {
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060085 char *lib_name;
Jon Ashburn68a63922015-07-02 09:40:15 -060086 uint32_t ref_count;
87 loader_platform_dl_handle lib_handle;
88};
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060089
Jon Ashburn68a63922015-07-02 09:40:15 -060090struct loader_layer_functions {
91 PFN_vkGetInstanceProcAddr get_instance_proc_addr;
92 PFN_vkGetDeviceProcAddr get_device_proc_addr;
93};
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060094
Jon Ashburn68a63922015-07-02 09:40:15 -060095struct loader_layer_properties {
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -060096 VkLayerProperties info;
Jon Ashburn68a63922015-07-02 09:40:15 -060097 enum layer_type type;
98 struct loader_lib_info lib_info;
Jon Ashburn68a63922015-07-02 09:40:15 -060099 struct loader_layer_functions functions;
100 struct loader_extension_list instance_extension_list;
101 struct loader_extension_list device_extension_list;
102 struct loader_name_value disable_env_var;
103 struct loader_name_value enable_env_var;
104};
105
106struct loader_layer_list {
107 size_t capacity;
108 uint32_t count;
109 struct loader_layer_properties *list;
Jon Ashburnfce93d92015-05-12 17:26:48 -0600110};
111
Courtney Goeltzenleuchterc5cf7d72015-07-05 12:53:31 -0600112struct loader_layer_library_list {
113 size_t capacity;
114 uint32_t count;
115 struct loader_lib_info *list;
116};
117
Jon Ashburncb5a5ac2015-06-10 10:06:06 -0600118/* per CreateDevice structure */
119struct loader_device {
120 VkLayerDispatchTable loader_dispatch;
121 VkDevice device; // device object from the icd
122
123 uint32_t app_extension_count;
124 VkExtensionProperties *app_extension_props;
125
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -0600126 struct loader_layer_list activated_layer_list;
Jon Ashburncb5a5ac2015-06-10 10:06:06 -0600127
128 struct loader_device *next;
129};
130
Jon Ashburn60699262015-06-10 16:11:42 -0600131/* per ICD structure */
Jon Ashburn2666e2f2015-05-15 15:09:35 -0600132struct loader_icd {
133 const struct loader_scanned_icds *scanned_icds;
134
Jon Ashburncb5a5ac2015-06-10 10:06:06 -0600135 struct loader_device *logical_device_list;
Jon Ashburn2666e2f2015-05-15 15:09:35 -0600136 uint32_t gpu_count;
Jon Ashburn60699262015-06-10 16:11:42 -0600137 VkPhysicalDevice *gpus; // enumerated PhysicalDevices
Jon Ashburn2666e2f2015-05-15 15:09:35 -0600138 VkInstance instance; // instance object from the icd
Jon Ashburn1245cec2015-05-18 13:20:15 -0600139 PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
Jon Ashburn2666e2f2015-05-15 15:09:35 -0600140 PFN_vkDestroyInstance DestroyInstance;
141 PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
Chris Forbesd7576302015-06-21 22:55:02 +1200142 PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures;
143 PFN_vkGetPhysicalDeviceFormatInfo GetPhysicalDeviceFormatInfo;
144 PFN_vkGetPhysicalDeviceLimits GetPhysicalDeviceLimits;
Jon Ashburn2666e2f2015-05-15 15:09:35 -0600145 PFN_vkCreateDevice CreateDevice;
Tony Barbour426b9052015-06-24 16:06:58 -0600146 PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
147 PFN_vkGetPhysicalDevicePerformance GetPhysicalDevicePerformance;
148 PFN_vkGetPhysicalDeviceQueueCount GetPhysicalDeviceQueueCount;
149 PFN_vkGetPhysicalDeviceQueueProperties GetPhysicalDeviceQueueProperties;
150 PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
Tony Barbour426b9052015-06-24 16:06:58 -0600151 PFN_vkGetPhysicalDeviceExtensionProperties GetPhysicalDeviceExtensionProperties;
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -0600152 PFN_vkGetPhysicalDeviceLayerProperties GetPhysicalDeviceLayerProperties;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600153 PFN_vkDbgCreateMsgCallback DbgCreateMsgCallback;
154 PFN_vkDbgDestroyMsgCallback DbgDestroyMsgCallback;
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -0600155
Courtney Goeltzenleuchter23b5f8d2015-06-17 20:51:59 -0600156 /*
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -0600157 * Fill in the cache of available layers that operate
158 * with this physical device. This cache will be used to satisfy
159 * calls to GetPhysicalDeviceLayerProperties
160 */
161 struct loader_layer_list layer_properties_cache;
162
163 /*
164 * Fill in the cache of available global extensions that operate
165 * with this physical device. This cache will be used to satisfy
166 * calls to GetPhysicalDeviceExtensionProperties
Courtney Goeltzenleuchter23b5f8d2015-06-17 20:51:59 -0600167 */
Jon Ashburncb5a5ac2015-06-10 10:06:06 -0600168 struct loader_extension_list device_extension_cache[MAX_GPUS_PER_ICD];
169 struct loader_icd *next;
Jon Ashburn2666e2f2015-05-15 15:09:35 -0600170};
171
Jon Ashburn60699262015-06-10 16:11:42 -0600172/* per instance structure */
Jon Ashburnfce93d92015-05-12 17:26:48 -0600173struct loader_instance {
Jon Ashburn2666e2f2015-05-15 15:09:35 -0600174 VkLayerInstanceDispatchTable *disp; // must be first entry in structure
175
Jon Ashburnfce93d92015-05-12 17:26:48 -0600176 uint32_t total_gpu_count;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600177 uint32_t total_icd_count;
Jon Ashburnfce93d92015-05-12 17:26:48 -0600178 struct loader_icd *icds;
179 struct loader_instance *next;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600180
181 /* TODO: Should keep track of application provided allocation functions */
182
183 /*
184 * CreateMsgCallback is global and needs to be
185 * applied to all layers and ICDs.
186 * What happens if a layer is enabled on both the instance chain
187 * as well as the device chain and a call to CreateMsgCallback is made?
188 * Do we need to make sure that each layer / driver only gets called once?
189 * Should a layer implementing support for CreateMsgCallback only be allowed (?)
190 * to live on one chain? Or maybe make it the application's responsibility.
191 * If the app enables DRAW_STATE on at both CreateInstance time and CreateDevice
192 * time, CreateMsgCallback will call the DRAW_STATE layer twice. Once via
193 * the instance chain and once via the device chain.
194 * The loader should only return the DEBUG_REPORT extension as supported
195 * for the GetGlobalExtensionSupport call. That should help eliminate one
196 * duplication.
197 * Since the instance chain requires us iterating over the available ICDs
198 * and each ICD will have it's own unique MsgCallback object we need to
199 * track those objects to give back the right one.
200 * This also implies that the loader has to intercept vkDestroyObject and
201 * if the extension is enabled and the object type is a MsgCallback then
202 * we must translate the object into the proper ICD specific ones.
203 * DestroyObject works on a device chain. Should not be what's destroying
204 * the MsgCallback object. That needs to be an instance thing. So, since
205 * we used an instance to create it, we need a custom Destroy that also
206 * takes an instance. That way we can iterate over the ICDs properly.
207 * Example use:
208 * CreateInstance: DEBUG_REPORT
209 * Loader will create instance chain with enabled extensions.
210 * TODO: Should validation layers be enabled here? If not, they will not be in the instance chain.
211 * fn = GetProcAddr(INSTANCE, "vkCreateMsgCallback") -> point to loader's vkCreateMsgCallback
212 * App creates a callback object: fn(..., &MsgCallbackObject1)
213 * Have only established the instance chain so far. Loader will call the instance chain.
214 * Each layer in the instance chain will call down to the next layer, terminating with
215 * the CreateMsgCallback loader terminator function that creates the actual MsgCallbackObject1 object.
216 * The loader CreateMsgCallback terminator will iterate over the ICDs.
217 * Calling each ICD that supports vkCreateMsgCallback and collect answers in icd_msg_callback_map here.
218 * As result is sent back up the chain each layer has opportunity to record the callback operation and
219 * appropriate MsgCallback object.
220 * ...
221 * Any reports matching the flags set in MsgCallbackObject1 will generate the defined callback behavior
222 * in the layer / ICD that initiated that report.
223 * ...
224 * CreateDevice: MemTracker:...
225 * App does not include DEBUG_REPORT as that is a global extension.
226 * TODO: GetExtensionSupport must not report DEBUG_REPORT when using instance.
227 * App MUST include any desired validation layers or they will not participate in the device call chain.
228 * App creates a callback object: fn(..., &MsgCallbackObject2)
229 * Loader's vkCreateMsgCallback is called.
230 * Loader sends call down instance chain - this is a global extension - any validation layer that was
231 * enabled at CreateInstance will be able to register the callback. Loader will iterate over the ICDs and
232 * will record the ICD's version of the MsgCallback2 object here.
233 * ...
234 * Any report will go to the layer's report function and it will check the flags for MsgCallbackObject1
235 * and MsgCallbackObject2 and take the appropriate action as indicated by the app.
236 * ...
237 * App calls vkDestroyMsgCallback( MsgCallbackObject1 )
238 * Loader's DestroyMsgCallback is where call starts. DestroyMsgCallback will be sent down instance chain
239 * ending in the loader's DestroyMsgCallback terminator which will iterate over the ICD's destroying each
240 * ICD version of that MsgCallback object and then destroy the loader's version of the object.
241 * Any reports generated after this will only have MsgCallbackObject2 available.
242 */
243 struct loader_msg_callback_map_entry *icd_msg_callback_map;
244
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -0600245 struct loader_layer_list activated_layer_list;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600246
247 bool debug_report_enabled;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600248 VkLayerDbgFunctionNode *DbgFunctionHead;
Courtney Goeltzenleuchterb620ace2015-07-05 11:28:29 -0600249
250 VkAllocCallbacks alloc_callbacks;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600251};
252
Jon Ashburnfce93d92015-05-12 17:26:48 -0600253struct loader_struct {
254 struct loader_instance *instances;
Jon Ashburnfce93d92015-05-12 17:26:48 -0600255 struct loader_scanned_icds *scanned_icd_list;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600256
257 unsigned int loaded_layer_lib_count;
258 struct loader_lib_info *loaded_layer_lib_list;
259
Jon Ashburnfce93d92015-05-12 17:26:48 -0600260 char *layer_dirs;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600261
Courtney Goeltzenleuchterc5cf7d72015-07-05 12:53:31 -0600262 struct loader_layer_library_list scanned_layer_libraries;
263 struct loader_layer_list global_layer_list;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600264
Tony Barbour426b9052015-06-24 16:06:58 -0600265 /* Keep track of all the extensions available via GetGlobalExtensionProperties */
Courtney Goeltzenleuchter1c7c65d2015-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
273 PFN_vkCreateInstance CreateInstance;
274 PFN_vkDestroyInstance DestroyInstance;
275 PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
Tony Barbour426b9052015-06-24 16:06:58 -0600276 PFN_vkGetGlobalExtensionProperties GetGlobalExtensionProperties;
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -0600277 PFN_vkGetGlobalLayerProperties GetGlobalLayerProperties;
278 PFN_vkGetPhysicalDeviceLayerProperties GetPhysicalDeviceLayerProperties;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600279 VkInstance instance;
280 struct loader_scanned_icds *next;
281
282 /* cache of global extensions for specific ICD */
283 struct loader_extension_list global_extension_list;
284
285 /*
286 * cache of device extensions for specific ICD,
287 * filled in at CreateInstance time
288 */
Courtney Goeltzenleuchter23b5f8d2015-06-17 20:51:59 -0600289 struct loader_extension_list device_extension_list;
Jon Ashburnfce93d92015-05-12 17:26:48 -0600290};
291
Jon Ashburn68a63922015-07-02 09:40:15 -0600292static inline struct loader_instance *loader_instance(VkInstance instance) {
293 return (struct loader_instance *) instance;
294}
295
Jon Ashburnda7c20d2015-05-01 18:00:33 -0600296static inline void loader_set_dispatch(VkObject obj, const void *data)
Chia-I Wu1d6731b2015-04-11 15:34:07 +0800297{
298 *((const void **) obj) = data;
299}
300
Jon Ashburnda7c20d2015-05-01 18:00:33 -0600301static inline VkLayerDispatchTable *loader_get_dispatch(const VkObject obj)
Chia-I Wu1d6731b2015-04-11 15:34:07 +0800302{
Jon Ashburnda7c20d2015-05-01 18:00:33 -0600303 return *((VkLayerDispatchTable **) obj);
Chia-I Wu1d6731b2015-04-11 15:34:07 +0800304}
305
Jon Ashburnfce93d92015-05-12 17:26:48 -0600306static inline VkLayerInstanceDispatchTable *loader_get_instance_dispatch(const VkObject obj)
307{
308 return *((VkLayerInstanceDispatchTable **) obj);
309}
310
Jon Ashburnda7c20d2015-05-01 18:00:33 -0600311static inline void loader_init_dispatch(VkObject obj, const void *data)
Chia-I Wu1d6731b2015-04-11 15:34:07 +0800312{
Jon Ashburn166641e2015-04-15 13:34:33 -0600313#ifdef DEBUG
Chia-I Wu1d6731b2015-04-11 15:34:07 +0800314 assert(valid_loader_magic_value(obj) &&
315 "Incompatible ICD, first dword must be initialized to ICD_LOADER_MAGIC. See loader/README.md for details.");
Jon Ashburn166641e2015-04-15 13:34:33 -0600316#endif
Chia-I Wu1d6731b2015-04-11 15:34:07 +0800317
Jon Ashburnda7c20d2015-05-01 18:00:33 -0600318 loader_set_dispatch(obj, data);
Chia-I Wu1d6731b2015-04-11 15:34:07 +0800319}
320
Jon Ashburnfce93d92015-05-12 17:26:48 -0600321/* global variables used across files */
322extern struct loader_struct loader;
323extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_icd);
324extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_layer);
325extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_exts);
Jon Ashburnb40f2562015-05-29 13:15:39 -0600326extern loader_platform_thread_mutex loader_lock;
327extern const VkLayerInstanceDispatchTable instance_disp;
Jon Ashburn301c5f02015-04-06 10:58:22 -0600328
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600329struct loader_msg_callback_map_entry {
330 VkDbgMsgCallback icd_obj;
331 VkDbgMsgCallback loader_obj;
332};
333
334bool compare_vk_extension_properties(
335 const VkExtensionProperties* op1,
336 const VkExtensionProperties* op2);
337
Courtney Goeltzenleuchtera17697f2015-07-06 20:14:18 -0600338VkResult loader_validate_layers(const uint32_t layer_count, const char * const *ppEnabledLayerNames, struct loader_layer_list *list);
Courtney Goeltzenleuchter5d9f29b2015-07-06 17:45:08 -0600339
340VkResult loader_validate_instance_extensions(
341 const VkInstanceCreateInfo* pCreateInfo);
342
Jon Ashburnfce93d92015-05-12 17:26:48 -0600343/* instance layer chain termination entrypoint definitions */
344VkResult loader_CreateInstance(
345 const VkInstanceCreateInfo* pCreateInfo,
346 VkInstance* pInstance);
Chia-I Wu1d6731b2015-04-11 15:34:07 +0800347
Jon Ashburnfce93d92015-05-12 17:26:48 -0600348VkResult loader_DestroyInstance(
349 VkInstance instance);
350
351VkResult loader_EnumeratePhysicalDevices(
352 VkInstance instance,
353 uint32_t* pPhysicalDeviceCount,
354 VkPhysicalDevice* pPhysicalDevices);
Chris Forbesd7576302015-06-21 22:55:02 +1200355
Chris Forbesd7576302015-06-21 22:55:02 +1200356VkResult loader_GetPhysicalDeviceFeatures(
357 VkPhysicalDevice physicalDevice,
358 VkPhysicalDeviceFeatures* pFeatures);
359
360VkResult loader_GetPhysicalDeviceFormatInfo(
361 VkPhysicalDevice physicalDevice,
362 VkFormat format,
363 VkFormatProperties* pFormatInfo);
364
365VkResult loader_GetPhysicalDeviceLimits(
366 VkPhysicalDevice physicalDevice,
367 VkPhysicalDeviceLimits* pLimits);
368
Tony Barbour426b9052015-06-24 16:06:58 -0600369
370VkResult loader_GetPhysicalDeviceProperties (
371 VkPhysicalDevice physicalDevice,
372 VkPhysicalDeviceProperties* pProperties);
373
374VkResult loader_GetPhysicalDevicePerformance (
375 VkPhysicalDevice physicalDevice,
376 VkPhysicalDevicePerformance* pPerformance);
377
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -0600378VkResult loader_GetPhysicalDeviceExtensionProperties (VkPhysicalDevice physicalDevice,
379 const char *pLayerName, uint32_t *pCount,
Tony Barbour426b9052015-06-24 16:06:58 -0600380 VkExtensionProperties* pProperties);
381
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -0600382VkResult loader_GetPhysicalDeviceLayerProperties (VkPhysicalDevice physicalDevice,
383 uint32_t *pCount,
384 VkLayerProperties* pProperties);
Tony Barbour426b9052015-06-24 16:06:58 -0600385
386VkResult loader_GetPhysicalDeviceQueueCount (
387 VkPhysicalDevice physicalDevice,
388 uint32_t* pCount);
389
390VkResult loader_GetPhysicalDeviceQueueProperties (
391 VkPhysicalDevice physicalDevice,
392 uint32_t count,
393 VkPhysicalDeviceQueueProperties * pProperties);
394
395VkResult loader_GetPhysicalDeviceMemoryProperties (
396 VkPhysicalDevice physicalDevice,
397 VkPhysicalDeviceMemoryProperties * pProperties);
Jon Ashburnb40f2562015-05-29 13:15:39 -0600398
Jon Ashburn2666e2f2015-05-15 15:09:35 -0600399VkResult loader_CreateDevice(
400 VkPhysicalDevice gpu,
401 const VkDeviceCreateInfo* pCreateInfo,
402 VkDevice* pDevice);
Jon Ashburnfce93d92015-05-12 17:26:48 -0600403
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600404/* helper function definitions */
Jon Ashburn60378412015-07-02 12:59:25 -0600405bool has_vk_extension_property_array(
406 const VkExtensionProperties *vk_ext_prop,
407 const uint32_t count,
408 const VkExtensionProperties *ext_array);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600409bool has_vk_extension_property(
410 const VkExtensionProperties *vk_ext_prop,
411 const struct loader_extension_list *ext_list);
Jon Ashburnfce93d92015-05-12 17:26:48 -0600412
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600413void loader_add_to_ext_list(
414 struct loader_extension_list *ext_list,
415 uint32_t prop_list_count,
416 const struct loader_extension_property *props);
Courtney Goeltzenleuchter3d8dc1f2015-06-08 15:09:22 -0600417void loader_destroy_ext_list(struct loader_extension_list *ext_info);
Jon Ashburnfce93d92015-05-12 17:26:48 -0600418
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -0600419void loader_add_to_layer_list(
420 struct loader_layer_list *list,
421 uint32_t prop_list_count,
422 const struct loader_layer_properties *props);
Jon Ashburnfce93d92015-05-12 17:26:48 -0600423void loader_icd_scan(void);
Jon Ashburn68a63922015-07-02 09:40:15 -0600424void loader_layer_scan(void);
Jon Ashburnfce93d92015-05-12 17:26:48 -0600425void loader_coalesce_extensions(void);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600426
Jon Ashburnd5df54d2015-05-28 19:16:58 -0600427struct loader_icd * loader_get_icd(const VkPhysicalDevice gpu,
Jon Ashburn2666e2f2015-05-15 15:09:35 -0600428 uint32_t *gpu_index);
Jon Ashburncb5a5ac2015-06-10 10:06:06 -0600429void loader_remove_logical_device(VkDevice device);
Courtney Goeltzenleuchter1fcceeb2015-07-06 09:06:34 -0600430VkResult loader_enable_instance_layers(struct loader_instance *inst, const VkInstanceCreateInfo *pCreateInfo);
Jon Ashburncb5a5ac2015-06-10 10:06:06 -0600431void loader_deactivate_instance_layers(struct loader_instance *instance);
Jon Ashburnfce93d92015-05-12 17:26:48 -0600432uint32_t loader_activate_instance_layers(struct loader_instance *inst);
Courtney Goeltzenleuchter23b5f8d2015-06-17 20:51:59 -0600433void loader_activate_instance_layer_extensions(struct loader_instance *inst);
Courtney Goeltzenleuchterb620ace2015-07-05 11:28:29 -0600434
435void* loader_heap_alloc(
436 struct loader_instance *instance,
437 size_t size,
438 VkSystemAllocType allocType);
439
440void* loader_aligned_heap_alloc(
441 struct loader_instance *instance,
442 size_t size,
443 size_t alignment,
444 VkSystemAllocType allocType);
445
446void loader_heap_free(
447 struct loader_instance *instance,
448 void *pMem);
Chia-I Wu468e3c32014-08-04 08:03:57 +0800449#endif /* LOADER_H */