blob: a4a9fd25cfe8e2708394787ec3880378492b0960 [file] [log] [blame]
Chia-I Wu19300602014-08-04 08:03:57 +08001/*
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06002 * Vulkan
Chia-I Wu19300602014-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 Wu701f3f62014-09-02 08:32:09 +080023 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
Chia-I Wu19300602014-08-04 08:03:57 +080026 */
27
28#ifndef LOADER_H
29#define LOADER_H
30
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060031#include <vulkan.h>
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -060032#include <vk_debug_report_lunarg.h>
Ian Elliottd3ef02f2015-07-06 14:36:13 -060033#include <vk_wsi_swapchain.h>
Tobin Ehlis0c6f9ee2015-07-03 09:42:57 -060034#include <vk_layer.h>
35#include <vk_icd.h>
Chia-I Wu5291c762015-04-11 15:34:07 +080036#include <assert.h>
37
Chia-I Wu19300602014-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 Goeltzenleuchter110fdf92015-06-29 15:39:26 -060046#define MAX_EXTENSION_NAME_SIZE (VK_MAX_EXTENSION_NAME-1)
Jon Ashburndc6fcad2015-06-10 10:06:06 -060047#define MAX_GPUS_PER_ICD 16
Jon Ashburn27cd5842015-05-12 17:26:48 -060048
Courtney Goeltzenleuchter110fdf92015-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 Goeltzenleuchterf579fa62015-06-10 17:39:03 -060052enum extension_origin {
53 VK_EXTENSION_ORIGIN_ICD,
54 VK_EXTENSION_ORIGIN_LAYER,
55 VK_EXTENSION_ORIGIN_LOADER
Jon Ashburn27cd5842015-05-12 17:26:48 -060056};
57
Jon Ashburn5ef20602015-07-02 09:40:15 -060058enum layer_type {
Jon Ashburn0c26e712015-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 Ashburn5ef20602015-07-02 09:40:15 -060065};
66
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -060067struct loader_extension_property {
68 VkExtensionProperties info;
69 const char *lib_name;
70 enum extension_origin origin;
Courtney Goeltzenleuchterf579fa62015-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 Ashburn5ef20602015-07-02 09:40:15 -060079struct loader_name_value {
80 char *name;
81 char *value;
82};
83
84struct loader_lib_info {
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -060085 char *lib_name;
Jon Ashburn5ef20602015-07-02 09:40:15 -060086 uint32_t ref_count;
87 loader_platform_dl_handle lib_handle;
88};
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -060089
Jon Ashburn5ef20602015-07-02 09:40:15 -060090struct loader_layer_functions {
Jon Ashburn2d0c4bb2015-07-06 15:40:35 -060091 char *str_gipa;
92 char *str_gdpa;
Jon Ashburn5ef20602015-07-02 09:40:15 -060093 PFN_vkGetInstanceProcAddr get_instance_proc_addr;
94 PFN_vkGetDeviceProcAddr get_device_proc_addr;
95};
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -060096
Jon Ashburn5ef20602015-07-02 09:40:15 -060097struct loader_layer_properties {
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060098 VkLayerProperties info;
Jon Ashburn5ef20602015-07-02 09:40:15 -060099 enum layer_type type;
Jon Ashburn2d0c4bb2015-07-06 15:40:35 -0600100 char *abi_version;
101 char *impl_version;
Jon Ashburn5ef20602015-07-02 09:40:15 -0600102 struct loader_lib_info lib_info;
Jon Ashburn5ef20602015-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 Ashburn27cd5842015-05-12 17:26:48 -0600114};
115
Courtney Goeltzenleuchter371de702015-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 Ashburndc6fcad2015-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 Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600130 struct loader_layer_list activated_layer_list;
Jon Ashburndc6fcad2015-06-10 10:06:06 -0600131
132 struct loader_device *next;
133};
134
Jon Ashburn953bb3c2015-06-10 16:11:42 -0600135/* per ICD structure */
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600136struct loader_icd {
137 const struct loader_scanned_icds *scanned_icds;
138
Jon Ashburndc6fcad2015-06-10 10:06:06 -0600139 struct loader_device *logical_device_list;
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600140 uint32_t gpu_count;
Jon Ashburn953bb3c2015-06-10 16:11:42 -0600141 VkPhysicalDevice *gpus; // enumerated PhysicalDevices
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600142 VkInstance instance; // instance object from the icd
Jon Ashburn8d1b0b52015-05-18 13:20:15 -0600143 PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600144 PFN_vkDestroyInstance DestroyInstance;
145 PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
Chris Forbesbc0bb772015-06-21 22:55:02 +1200146 PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures;
Courtney Goeltzenleuchter2caec862015-07-12 12:52:09 -0600147 PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties;
Jon Ashburn754864f2015-07-23 18:49:07 -0600148 PFN_vkGetPhysicalDeviceImageFormatProperties GetPhysicalDeviceImageFormatProperties;
Chris Forbesbc0bb772015-06-21 22:55:02 +1200149 PFN_vkGetPhysicalDeviceLimits GetPhysicalDeviceLimits;
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600150 PFN_vkCreateDevice CreateDevice;
Tony Barbour59a47322015-06-24 16:06:58 -0600151 PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
Tony Barbour59a47322015-06-24 16:06:58 -0600152 PFN_vkGetPhysicalDeviceQueueCount GetPhysicalDeviceQueueCount;
153 PFN_vkGetPhysicalDeviceQueueProperties GetPhysicalDeviceQueueProperties;
154 PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
Tony Barbour59a47322015-06-24 16:06:58 -0600155 PFN_vkGetPhysicalDeviceExtensionProperties GetPhysicalDeviceExtensionProperties;
Mark Lobodzinski16e8bef2015-07-03 15:58:09 -0600156 PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600157 PFN_vkDbgCreateMsgCallback DbgCreateMsgCallback;
158 PFN_vkDbgDestroyMsgCallback DbgDestroyMsgCallback;
Jon Ashburnc624c882015-07-16 10:17:29 -0600159 PFN_vkGetPhysicalDeviceSurfaceSupportWSI GetPhysicalDeviceSurfaceSupportWSI;
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600160
Courtney Goeltzenleuchterd971b612015-06-17 20:51:59 -0600161 /*
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600162 * Fill in the cache of available global extensions that operate
163 * with this physical device. This cache will be used to satisfy
164 * calls to GetPhysicalDeviceExtensionProperties
Courtney Goeltzenleuchterd971b612015-06-17 20:51:59 -0600165 */
Jon Ashburndc6fcad2015-06-10 10:06:06 -0600166 struct loader_extension_list device_extension_cache[MAX_GPUS_PER_ICD];
167 struct loader_icd *next;
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600168};
169
Jon Ashburn953bb3c2015-06-10 16:11:42 -0600170/* per instance structure */
Jon Ashburn27cd5842015-05-12 17:26:48 -0600171struct loader_instance {
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600172 VkLayerInstanceDispatchTable *disp; // must be first entry in structure
173
Jon Ashburn27cd5842015-05-12 17:26:48 -0600174 uint32_t total_gpu_count;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600175 uint32_t total_icd_count;
Jon Ashburn27cd5842015-05-12 17:26:48 -0600176 struct loader_icd *icds;
177 struct loader_instance *next;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600178
179 /* TODO: Should keep track of application provided allocation functions */
180
181 /*
182 * CreateMsgCallback is global and needs to be
183 * applied to all layers and ICDs.
184 * What happens if a layer is enabled on both the instance chain
185 * as well as the device chain and a call to CreateMsgCallback is made?
186 * Do we need to make sure that each layer / driver only gets called once?
187 * Should a layer implementing support for CreateMsgCallback only be allowed (?)
188 * to live on one chain? Or maybe make it the application's responsibility.
189 * If the app enables DRAW_STATE on at both CreateInstance time and CreateDevice
190 * time, CreateMsgCallback will call the DRAW_STATE layer twice. Once via
191 * the instance chain and once via the device chain.
192 * The loader should only return the DEBUG_REPORT extension as supported
193 * for the GetGlobalExtensionSupport call. That should help eliminate one
194 * duplication.
195 * Since the instance chain requires us iterating over the available ICDs
196 * and each ICD will have it's own unique MsgCallback object we need to
197 * track those objects to give back the right one.
198 * This also implies that the loader has to intercept vkDestroyObject and
199 * if the extension is enabled and the object type is a MsgCallback then
200 * we must translate the object into the proper ICD specific ones.
201 * DestroyObject works on a device chain. Should not be what's destroying
202 * the MsgCallback object. That needs to be an instance thing. So, since
203 * we used an instance to create it, we need a custom Destroy that also
204 * takes an instance. That way we can iterate over the ICDs properly.
205 * Example use:
206 * CreateInstance: DEBUG_REPORT
207 * Loader will create instance chain with enabled extensions.
208 * TODO: Should validation layers be enabled here? If not, they will not be in the instance chain.
209 * fn = GetProcAddr(INSTANCE, "vkCreateMsgCallback") -> point to loader's vkCreateMsgCallback
210 * App creates a callback object: fn(..., &MsgCallbackObject1)
211 * Have only established the instance chain so far. Loader will call the instance chain.
212 * Each layer in the instance chain will call down to the next layer, terminating with
213 * the CreateMsgCallback loader terminator function that creates the actual MsgCallbackObject1 object.
214 * The loader CreateMsgCallback terminator will iterate over the ICDs.
215 * Calling each ICD that supports vkCreateMsgCallback and collect answers in icd_msg_callback_map here.
216 * As result is sent back up the chain each layer has opportunity to record the callback operation and
217 * appropriate MsgCallback object.
218 * ...
219 * Any reports matching the flags set in MsgCallbackObject1 will generate the defined callback behavior
220 * in the layer / ICD that initiated that report.
221 * ...
222 * CreateDevice: MemTracker:...
223 * App does not include DEBUG_REPORT as that is a global extension.
224 * TODO: GetExtensionSupport must not report DEBUG_REPORT when using instance.
225 * App MUST include any desired validation layers or they will not participate in the device call chain.
226 * App creates a callback object: fn(..., &MsgCallbackObject2)
227 * Loader's vkCreateMsgCallback is called.
228 * Loader sends call down instance chain - this is a global extension - any validation layer that was
229 * enabled at CreateInstance will be able to register the callback. Loader will iterate over the ICDs and
230 * will record the ICD's version of the MsgCallback2 object here.
231 * ...
232 * Any report will go to the layer's report function and it will check the flags for MsgCallbackObject1
233 * and MsgCallbackObject2 and take the appropriate action as indicated by the app.
234 * ...
235 * App calls vkDestroyMsgCallback( MsgCallbackObject1 )
236 * Loader's DestroyMsgCallback is where call starts. DestroyMsgCallback will be sent down instance chain
237 * ending in the loader's DestroyMsgCallback terminator which will iterate over the ICD's destroying each
238 * ICD version of that MsgCallback object and then destroy the loader's version of the object.
239 * Any reports generated after this will only have MsgCallbackObject2 available.
240 */
241 struct loader_msg_callback_map_entry *icd_msg_callback_map;
242
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600243 struct loader_layer_list activated_layer_list;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600244
245 bool debug_report_enabled;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600246 VkLayerDbgFunctionNode *DbgFunctionHead;
Courtney Goeltzenleuchter7f5aafc2015-07-05 11:28:29 -0600247
248 VkAllocCallbacks alloc_callbacks;
Ian Elliottd3ef02f2015-07-06 14:36:13 -0600249
250 bool wsi_swapchain_enabled;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600251};
252
Jon Ashburn27cd5842015-05-12 17:26:48 -0600253struct loader_struct {
254 struct loader_instance *instances;
Jon Ashburn27cd5842015-05-12 17:26:48 -0600255 struct loader_scanned_icds *scanned_icd_list;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600256
257 unsigned int loaded_layer_lib_count;
258 struct loader_lib_info *loaded_layer_lib_list;
259
Jon Ashburn27cd5842015-05-12 17:26:48 -0600260 char *layer_dirs;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600261
Jon Ashburn2d0c4bb2015-07-06 15:40:35 -0600262 // TODO use this struct loader_layer_library_list scanned_layer_libraries;
Jon Ashburnb2ef1372015-07-16 17:19:31 -0600263 struct loader_layer_list scanned_instance_layers;
264 struct loader_layer_list scanned_device_layers;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600265
Tony Barbour59a47322015-06-24 16:06:58 -0600266 /* Keep track of all the extensions available via GetGlobalExtensionProperties */
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600267 struct loader_extension_list global_extensions;
268};
269
270struct loader_scanned_icds {
271 char *lib_name;
272 loader_platform_dl_handle handle;
273
Jon Ashburnc624c882015-07-16 10:17:29 -0600274 PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600275 PFN_vkCreateInstance CreateInstance;
Tony Barbour59a47322015-06-24 16:06:58 -0600276 PFN_vkGetGlobalExtensionProperties GetGlobalExtensionProperties;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600277 VkInstance instance;
278 struct loader_scanned_icds *next;
279
280 /* cache of global extensions for specific ICD */
281 struct loader_extension_list global_extension_list;
282
283 /*
284 * cache of device extensions for specific ICD,
285 * filled in at CreateInstance time
286 */
Courtney Goeltzenleuchterd971b612015-06-17 20:51:59 -0600287 struct loader_extension_list device_extension_list;
Jon Ashburn27cd5842015-05-12 17:26:48 -0600288};
289
Jon Ashburn5ef20602015-07-02 09:40:15 -0600290static inline struct loader_instance *loader_instance(VkInstance instance) {
291 return (struct loader_instance *) instance;
292}
293
Tony Barbour1d2cd3f2015-07-03 10:33:54 -0600294static inline void loader_set_dispatch(void* obj, const void *data)
Chia-I Wu5291c762015-04-11 15:34:07 +0800295{
296 *((const void **) obj) = data;
297}
298
Tony Barbour1d2cd3f2015-07-03 10:33:54 -0600299static inline VkLayerDispatchTable *loader_get_dispatch(const void* obj)
Chia-I Wu5291c762015-04-11 15:34:07 +0800300{
Jon Ashburn1ed042c2015-05-01 18:00:33 -0600301 return *((VkLayerDispatchTable **) obj);
Chia-I Wu5291c762015-04-11 15:34:07 +0800302}
303
Tony Barbour1d2cd3f2015-07-03 10:33:54 -0600304static inline VkLayerInstanceDispatchTable *loader_get_instance_dispatch(const void* obj)
Jon Ashburn27cd5842015-05-12 17:26:48 -0600305{
306 return *((VkLayerInstanceDispatchTable **) obj);
307}
308
Tony Barbour1d2cd3f2015-07-03 10:33:54 -0600309static inline void loader_init_dispatch(void* obj, const void *data)
Chia-I Wu5291c762015-04-11 15:34:07 +0800310{
Jon Ashburn40066642015-04-15 13:34:33 -0600311#ifdef DEBUG
Chia-I Wu5291c762015-04-11 15:34:07 +0800312 assert(valid_loader_magic_value(obj) &&
313 "Incompatible ICD, first dword must be initialized to ICD_LOADER_MAGIC. See loader/README.md for details.");
Jon Ashburn40066642015-04-15 13:34:33 -0600314#endif
Chia-I Wu5291c762015-04-11 15:34:07 +0800315
Jon Ashburn1ed042c2015-05-01 18:00:33 -0600316 loader_set_dispatch(obj, data);
Chia-I Wu5291c762015-04-11 15:34:07 +0800317}
318
Jon Ashburn27cd5842015-05-12 17:26:48 -0600319/* global variables used across files */
320extern struct loader_struct loader;
321extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_icd);
322extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_layer);
323extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_exts);
Jon Ashburn6301a0f2015-05-29 13:15:39 -0600324extern loader_platform_thread_mutex loader_lock;
325extern const VkLayerInstanceDispatchTable instance_disp;
Jon Ashburnbacb0f52015-04-06 10:58:22 -0600326
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600327struct loader_msg_callback_map_entry {
328 VkDbgMsgCallback icd_obj;
329 VkDbgMsgCallback loader_obj;
330};
331
332bool compare_vk_extension_properties(
333 const VkExtensionProperties* op1,
334 const VkExtensionProperties* op2);
335
Courtney Goeltzenleuchter366b27a2015-07-06 20:14:18 -0600336VkResult loader_validate_layers(const uint32_t layer_count, const char * const *ppEnabledLayerNames, struct loader_layer_list *list);
Courtney Goeltzenleuchter3b8c5ff2015-07-06 17:45:08 -0600337
338VkResult loader_validate_instance_extensions(
339 const VkInstanceCreateInfo* pCreateInfo);
340
Jon Ashburn27cd5842015-05-12 17:26:48 -0600341/* instance layer chain termination entrypoint definitions */
Dan Ginsburg78556e82015-07-23 13:15:00 -0400342VkResult VKAPI loader_CreateInstance(
Jon Ashburn27cd5842015-05-12 17:26:48 -0600343 const VkInstanceCreateInfo* pCreateInfo,
344 VkInstance* pInstance);
Chia-I Wu5291c762015-04-11 15:34:07 +0800345
Dan Ginsburg78556e82015-07-23 13:15:00 -0400346VkResult VKAPI loader_DestroyInstance(
Jon Ashburn27cd5842015-05-12 17:26:48 -0600347 VkInstance instance);
348
Dan Ginsburg78556e82015-07-23 13:15:00 -0400349VkResult VKAPI loader_EnumeratePhysicalDevices(
Jon Ashburn27cd5842015-05-12 17:26:48 -0600350 VkInstance instance,
351 uint32_t* pPhysicalDeviceCount,
352 VkPhysicalDevice* pPhysicalDevices);
Chris Forbesbc0bb772015-06-21 22:55:02 +1200353
Dan Ginsburg78556e82015-07-23 13:15:00 -0400354VkResult VKAPI loader_GetPhysicalDeviceFeatures(
Chris Forbesbc0bb772015-06-21 22:55:02 +1200355 VkPhysicalDevice physicalDevice,
356 VkPhysicalDeviceFeatures* pFeatures);
357
Dan Ginsburg78556e82015-07-23 13:15:00 -0400358VkResult VKAPI loader_GetPhysicalDeviceFormatProperties(
Chris Forbesbc0bb772015-06-21 22:55:02 +1200359 VkPhysicalDevice physicalDevice,
360 VkFormat format,
361 VkFormatProperties* pFormatInfo);
362
Jon Ashburn754864f2015-07-23 18:49:07 -0600363VkResult VKAPI loader_GetPhysicalDeviceImageFormatProperties(
364 VkPhysicalDevice physicalDevice,
365 VkFormat format,
366 VkImageType type,
367 VkImageTiling tiling,
368 VkImageUsageFlags usage,
369 VkImageFormatProperties* pImageFormatProperties);
370
Dan Ginsburg78556e82015-07-23 13:15:00 -0400371VkResult VKAPI loader_GetPhysicalDeviceLimits(
Chris Forbesbc0bb772015-06-21 22:55:02 +1200372 VkPhysicalDevice physicalDevice,
373 VkPhysicalDeviceLimits* pLimits);
374
Dan Ginsburg78556e82015-07-23 13:15:00 -0400375VkResult VKAPI loader_GetPhysicalDeviceSparseImageFormatProperties(
Mark Lobodzinski16e8bef2015-07-03 15:58:09 -0600376 VkPhysicalDevice physicalDevice,
377 VkFormat format,
378 VkImageType type,
379 uint32_t samples,
380 VkImageUsageFlags usage,
381 VkImageTiling tiling,
382 uint32_t* pNumProperties,
383 VkSparseImageFormatProperties* pProperties);
Tony Barbour59a47322015-06-24 16:06:58 -0600384
Dan Ginsburg78556e82015-07-23 13:15:00 -0400385VkResult VKAPI loader_GetPhysicalDeviceProperties (
Tony Barbour59a47322015-06-24 16:06:58 -0600386 VkPhysicalDevice physicalDevice,
387 VkPhysicalDeviceProperties* pProperties);
388
Dan Ginsburg78556e82015-07-23 13:15:00 -0400389VkResult VKAPI loader_GetPhysicalDeviceExtensionProperties (VkPhysicalDevice physicalDevice,
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600390 const char *pLayerName, uint32_t *pCount,
Tony Barbour59a47322015-06-24 16:06:58 -0600391 VkExtensionProperties* pProperties);
392
Dan Ginsburg78556e82015-07-23 13:15:00 -0400393VkResult VKAPI loader_GetPhysicalDeviceLayerProperties (VkPhysicalDevice physicalDevice,
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600394 uint32_t *pCount,
395 VkLayerProperties* pProperties);
Tony Barbour59a47322015-06-24 16:06:58 -0600396
Dan Ginsburg78556e82015-07-23 13:15:00 -0400397VkResult VKAPI loader_GetPhysicalDeviceQueueCount (
Tony Barbour59a47322015-06-24 16:06:58 -0600398 VkPhysicalDevice physicalDevice,
399 uint32_t* pCount);
400
Dan Ginsburg78556e82015-07-23 13:15:00 -0400401VkResult VKAPI loader_GetPhysicalDeviceQueueProperties (
Tony Barbour59a47322015-06-24 16:06:58 -0600402 VkPhysicalDevice physicalDevice,
403 uint32_t count,
404 VkPhysicalDeviceQueueProperties * pProperties);
405
Dan Ginsburg78556e82015-07-23 13:15:00 -0400406VkResult VKAPI loader_GetPhysicalDeviceMemoryProperties (
Tony Barbour59a47322015-06-24 16:06:58 -0600407 VkPhysicalDevice physicalDevice,
408 VkPhysicalDeviceMemoryProperties * pProperties);
Jon Ashburn6301a0f2015-05-29 13:15:39 -0600409
Dan Ginsburg78556e82015-07-23 13:15:00 -0400410VkResult VKAPI loader_CreateDevice(
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600411 VkPhysicalDevice gpu,
412 const VkDeviceCreateInfo* pCreateInfo,
413 VkDevice* pDevice);
Jon Ashburn27cd5842015-05-12 17:26:48 -0600414
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600415/* helper function definitions */
Jon Ashburnbd6c4882015-07-02 12:59:25 -0600416bool has_vk_extension_property_array(
417 const VkExtensionProperties *vk_ext_prop,
418 const uint32_t count,
419 const VkExtensionProperties *ext_array);
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600420bool has_vk_extension_property(
421 const VkExtensionProperties *vk_ext_prop,
422 const struct loader_extension_list *ext_list);
Jon Ashburn27cd5842015-05-12 17:26:48 -0600423
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600424void loader_add_to_ext_list(
425 struct loader_extension_list *ext_list,
426 uint32_t prop_list_count,
427 const struct loader_extension_property *props);
Courtney Goeltzenleuchter7d0023c2015-06-08 15:09:22 -0600428void loader_destroy_ext_list(struct loader_extension_list *ext_info);
Jon Ashburn27cd5842015-05-12 17:26:48 -0600429
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600430void loader_add_to_layer_list(
431 struct loader_layer_list *list,
432 uint32_t prop_list_count,
433 const struct loader_layer_properties *props);
Jon Ashburn27cd5842015-05-12 17:26:48 -0600434void loader_icd_scan(void);
Jon Ashburn5ef20602015-07-02 09:40:15 -0600435void loader_layer_scan(void);
Jon Ashburn27cd5842015-05-12 17:26:48 -0600436void loader_coalesce_extensions(void);
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600437
Jon Ashburn128f9422015-05-28 19:16:58 -0600438struct loader_icd * loader_get_icd(const VkPhysicalDevice gpu,
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600439 uint32_t *gpu_index);
Jon Ashburndc6fcad2015-06-10 10:06:06 -0600440void loader_remove_logical_device(VkDevice device);
Courtney Goeltzenleuchter40caf0b2015-07-06 09:06:34 -0600441VkResult loader_enable_instance_layers(struct loader_instance *inst, const VkInstanceCreateInfo *pCreateInfo);
Jon Ashburndc6fcad2015-06-10 10:06:06 -0600442void loader_deactivate_instance_layers(struct loader_instance *instance);
Jon Ashburn27cd5842015-05-12 17:26:48 -0600443uint32_t loader_activate_instance_layers(struct loader_instance *inst);
Courtney Goeltzenleuchterd971b612015-06-17 20:51:59 -0600444void loader_activate_instance_layer_extensions(struct loader_instance *inst);
Courtney Goeltzenleuchter7f5aafc2015-07-05 11:28:29 -0600445
446void* loader_heap_alloc(
447 struct loader_instance *instance,
448 size_t size,
449 VkSystemAllocType allocType);
450
451void* loader_aligned_heap_alloc(
452 struct loader_instance *instance,
453 size_t size,
454 size_t alignment,
455 VkSystemAllocType allocType);
456
457void loader_heap_free(
458 struct loader_instance *instance,
459 void *pMem);
Chia-I Wu19300602014-08-04 08:03:57 +0800460#endif /* LOADER_H */