blob: 1c1dd2dc3115b2199f6d5f80602dc3fccc5f696c [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>
Ian Elliottafaf1852015-11-17 17:29:40 -070037
David Pinedoaf35af72015-11-24 09:00:24 -070038#include <vulkan/vk_lunarg_debug_report.h>
Ian Elliotta77fed72015-11-18 14:57:08 -070039
David Pinedoa5036622015-11-06 12:54:48 -070040#include <vulkan/vk_layer.h>
41#include <vulkan/vk_icd.h>
Chia-I Wufe333ed2015-04-11 15:34:07 +080042#include <assert.h>
43
Chia-I Wuc1e0f962014-08-04 08:03:57 +080044#if defined(__GNUC__) && __GNUC__ >= 4
45# define LOADER_EXPORT __attribute__((visibility("default")))
46#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
47# define LOADER_EXPORT __attribute__((visibility("default")))
48#else
49# define LOADER_EXPORT
50#endif
51
Jon Ashburnb2379c52015-08-04 10:22:33 -060052#define MAX_STRING_SIZE 1024
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -060053#define VK_MAJOR(version) (version >> 22)
54#define VK_MINOR(version) ((version >> 12) & 0x3ff)
55#define VK_PATCH(version) (version & 0xfff)
Jon Ashburn13482452015-05-12 17:26:48 -060056
Jon Ashburn399c9162015-07-02 09:40:15 -060057enum layer_type {
Jon Ashburn9464e772015-07-02 16:10:32 -060058 VK_LAYER_TYPE_DEVICE_EXPLICIT = 0x1,
59 VK_LAYER_TYPE_INSTANCE_EXPLICIT = 0x2,
60 VK_LAYER_TYPE_GLOBAL_EXPLICIT = 0x3, // both instance and device layer, bitwise
61 VK_LAYER_TYPE_DEVICE_IMPLICIT = 0x4,
62 VK_LAYER_TYPE_INSTANCE_IMPLICIT = 0x8,
63 VK_LAYER_TYPE_GLOBAL_IMPLICIT = 0xc, // both instance and device layer, bitwise
Jon Ashburn399c9162015-07-02 09:40:15 -060064};
65
Jon Ashburn6b00b472015-12-10 08:51:10 -070066// form of all dynamic lists/arrays
67// only the list element should be changed
68struct loader_generic_list {
69 size_t capacity;
70 uint32_t count;
71 void *list;
72};
73
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060074struct loader_extension_list {
75 size_t capacity;
76 uint32_t count;
Jon Ashburnb7d327c2015-08-04 11:14:18 -060077 VkExtensionProperties *list;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060078};
79
Jon Ashburn92cdb012015-12-10 18:17:34 -070080struct loader_dev_ext_props {
81 VkExtensionProperties props;
82 uint32_t entrypoint_count;
83 char **entrypoints;
84};
85
86struct loader_device_extension_list {
87 size_t capacity;
88 uint32_t count;
89 struct loader_dev_ext_props *list;
90};
91
Jon Ashburn399c9162015-07-02 09:40:15 -060092struct loader_name_value {
Jon Ashburnb2379c52015-08-04 10:22:33 -060093 char name[MAX_STRING_SIZE];
94 char value[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -060095};
96
97struct loader_lib_info {
Jon Ashburnb4c24232015-08-20 16:35:30 -060098 char lib_name[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -060099 uint32_t ref_count;
100 loader_platform_dl_handle lib_handle;
101};
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600102
Jon Ashburn399c9162015-07-02 09:40:15 -0600103struct loader_layer_functions {
Jon Ashburnb2379c52015-08-04 10:22:33 -0600104 char str_gipa[MAX_STRING_SIZE];
105 char str_gdpa[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -0600106 PFN_vkGetInstanceProcAddr get_instance_proc_addr;
107 PFN_vkGetDeviceProcAddr get_device_proc_addr;
108};
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600109
Jon Ashburn399c9162015-07-02 09:40:15 -0600110struct loader_layer_properties {
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600111 VkLayerProperties info;
Jon Ashburn399c9162015-07-02 09:40:15 -0600112 enum layer_type type;
Jon Ashburnb4c24232015-08-20 16:35:30 -0600113 char lib_name[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -0600114 struct loader_layer_functions functions;
115 struct loader_extension_list instance_extension_list;
Jon Ashburn92cdb012015-12-10 18:17:34 -0700116 struct loader_device_extension_list device_extension_list;
Jon Ashburn399c9162015-07-02 09:40:15 -0600117 struct loader_name_value disable_env_var;
118 struct loader_name_value enable_env_var;
119};
120
121struct loader_layer_list {
122 size_t capacity;
123 uint32_t count;
124 struct loader_layer_properties *list;
Jon Ashburn13482452015-05-12 17:26:48 -0600125};
126
Courtney Goeltzenleuchter8aff3862015-07-05 12:53:31 -0600127struct loader_layer_library_list {
128 size_t capacity;
129 uint32_t count;
130 struct loader_lib_info *list;
131};
132
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700133struct loader_dispatch_hash_list {
134 size_t capacity;
135 uint32_t count;
136 uint32_t *index; // index into the dev_ext dispatch table
137};
138
139#define MAX_NUM_DEV_EXTS 250
140// loader_dispatch_hash_entry and loader_dev_ext_dispatch_table.DevExt have one to one
141// correspondence; one loader_dispatch_hash_entry for one DevExt dispatch entry.
142// Also have a one to one correspondence with functions in dev_ext_trampoline.c
143struct loader_dispatch_hash_entry {
144 char *func_name;
145 struct loader_dispatch_hash_list list; // to handle hashing collisions
146};
147
148typedef void (VKAPI_PTR *PFN_vkDevExt)(VkDevice device);
149struct loader_dev_ext_dispatch_table {
150 PFN_vkDevExt DevExt[MAX_NUM_DEV_EXTS];
151};
152
153struct loader_dev_dispatch_table {
154 VkLayerDispatchTable core_dispatch;
155 struct loader_dev_ext_dispatch_table ext_dispatch;
156};
157
Jon Ashburn10f4e822015-06-10 10:06:06 -0600158/* per CreateDevice structure */
159struct loader_device {
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700160 struct loader_dev_dispatch_table loader_dispatch;
Jon Ashburn10f4e822015-06-10 10:06:06 -0600161 VkDevice device; // device object from the icd
162
163 uint32_t app_extension_count;
164 VkExtensionProperties *app_extension_props;
165
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600166 struct loader_layer_list activated_layer_list;
Jon Ashburn10f4e822015-06-10 10:06:06 -0600167
168 struct loader_device *next;
169};
170
Jon Ashburn392c5622015-06-10 16:11:42 -0600171/* per ICD structure */
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600172struct loader_icd {
Jon Ashburnb4c24232015-08-20 16:35:30 -0600173 // pointers to find other structs
174 const struct loader_scanned_icds *this_icd_lib;
175 const struct loader_instance *this_instance;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600176
Jon Ashburn10f4e822015-06-10 10:06:06 -0600177 struct loader_device *logical_device_list;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600178 VkInstance instance; // instance object from the icd
Jon Ashburnc89dd4a2015-05-18 13:20:15 -0600179 PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600180 PFN_vkDestroyInstance DestroyInstance;
181 PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
Chris Forbes1c946ec2015-06-21 22:55:02 +1200182 PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures;
Courtney Goeltzenleuchter2b6559e2015-07-12 12:52:09 -0600183 PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties;
Jon Ashburn25c11452015-07-23 18:49:07 -0600184 PFN_vkGetPhysicalDeviceImageFormatProperties GetPhysicalDeviceImageFormatProperties;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600185 PFN_vkCreateDevice CreateDevice;
Tony Barbour4e657ba2015-06-24 16:06:58 -0600186 PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
Cody Northropfc4ad132015-08-03 17:04:53 -0600187 PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties;
Tony Barbour4e657ba2015-06-24 16:06:58 -0600188 PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
Courtney Goeltzenleuchtere25064c2015-09-14 17:22:16 -0600189 PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties;
Mark Lobodzinski0c708be2015-07-03 15:58:09 -0600190 PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600191 PFN_vkDbgCreateMsgCallback DbgCreateMsgCallback;
192 PFN_vkDbgDestroyMsgCallback DbgDestroyMsgCallback;
Ian Elliottec736342015-08-21 15:09:33 -0600193 PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
Ian Elliottea666b22015-11-19 16:05:09 -0700194 PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR GetPhysicalDeviceSurfaceCapabilitiesKHR;
195 PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR;
196 PFN_vkGetPhysicalDeviceSurfacePresentModesKHR GetPhysicalDeviceSurfacePresentModesKHR;
Ian Elliotte851dd62015-11-24 15:39:10 -0700197#ifdef VK_USE_PLATFORM_WIN32_KHR
198 PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR GetPhysicalDeviceWin32PresentationSupportKHR;
199#endif
200#ifdef VK_USE_PLATFORM_MIR_KHR
201 PFN_vkGetPhysicalDeviceMirPresentationSupportKHR GetPhysicalDeviceMirPresentvationSupportKHR;
202#endif
203#ifdef VK_USE_PLATFORM_WAYLAND_KHR
204 PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR GetPhysicalDeviceWaylandPresentationSupportKHR;
205#endif
206#ifdef VK_USE_PLATFORM_XCB_KHR
207 PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR GetPhysicalDeviceXcbPresentationSupportKHR;
208#endif
209#ifdef VK_USE_PLATFORM_XLIB_KHR
210 PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR GetPhysicalDeviceXlibPresentationSupportKHR;
211#endif
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600212
Jon Ashburn10f4e822015-06-10 10:06:06 -0600213 struct loader_icd *next;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600214};
215
Jon Ashburne0367472015-08-18 18:04:47 -0600216/* per ICD library structure */
217struct loader_icd_libs {
218 size_t capacity;
219 uint32_t count;
220 struct loader_scanned_icds *list;
221};
222
Jon Ashburn392c5622015-06-10 16:11:42 -0600223/* per instance structure */
Jon Ashburn13482452015-05-12 17:26:48 -0600224struct loader_instance {
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600225 VkLayerInstanceDispatchTable *disp; // must be first entry in structure
226
Jon Ashburn13482452015-05-12 17:26:48 -0600227 uint32_t total_gpu_count;
Jon Ashburn969caa42015-11-01 14:04:06 -0700228 struct loader_physical_device *phys_devs;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600229 uint32_t total_icd_count;
Jon Ashburn13482452015-05-12 17:26:48 -0600230 struct loader_icd *icds;
231 struct loader_instance *next;
Jon Ashburne503a7d2015-08-14 14:49:22 -0600232 struct loader_extension_list ext_list; // icds and loaders extensions
Jon Ashburne0367472015-08-18 18:04:47 -0600233 struct loader_icd_libs icd_libs;
Jon Ashburnb4c24232015-08-20 16:35:30 -0600234 struct loader_layer_list instance_layer_list;
235 struct loader_layer_list device_layer_list;
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700236 struct loader_dispatch_hash_entry disp_hash[MAX_NUM_DEV_EXTS];
Jon Ashburnb4c24232015-08-20 16:35:30 -0600237
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600238 struct loader_msg_callback_map_entry *icd_msg_callback_map;
239
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600240 struct loader_layer_list activated_layer_list;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600241
242 bool debug_report_enabled;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600243 VkLayerDbgFunctionNode *DbgFunctionHead;
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600244
Chia-I Wu227c8b32015-10-27 18:04:07 +0800245 VkAllocationCallbacks alloc_callbacks;
Ian Elliotted33eb72015-07-06 14:36:13 -0600246
Ian Elliott54cea232015-10-30 15:28:23 -0600247 bool wsi_surface_enabled;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700248#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600249 bool wsi_win32_surface_enabled;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700250#endif
251#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600252 bool wsi_mir_surface_enabled;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700253#endif
254#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600255 bool wsi_wayland_surface_enabled;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700256#endif
257#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600258 bool wsi_xcb_surface_enabled;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700259#endif
260#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600261 bool wsi_xlib_surface_enabled;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700262#endif
263#ifdef VK_USE_PLATFORM_ANDROID_KHR
264 bool wsi_android_surface_enabled;
265#endif
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600266};
267
Jon Ashburn969caa42015-11-01 14:04:06 -0700268/* per enumerated PhysicalDevice structure */
269struct loader_physical_device {
270 VkLayerInstanceDispatchTable *disp; // must be first entry in structure
271 struct loader_instance *this_instance;
272 struct loader_icd *this_icd;
273 VkPhysicalDevice phys_dev; // object from ICD
274 /*
275 * Fill in the cache of available device extensions from
Jon Ashburna1981ff2015-11-02 17:40:01 -0700276 * this physical device. This cache can be used during CreateDevice
Jon Ashburn969caa42015-11-01 14:04:06 -0700277 */
278 struct loader_extension_list device_extension_cache;
279};
280
Jon Ashburn13482452015-05-12 17:26:48 -0600281struct loader_struct {
282 struct loader_instance *instances;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600283
284 unsigned int loaded_layer_lib_count;
Courtney Goeltzenleuchter452303a2015-10-07 09:00:34 -0600285 size_t loaded_layer_lib_capacity;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600286 struct loader_lib_info *loaded_layer_lib_list;
Jon Ashburne0367472015-08-18 18:04:47 -0600287 // TODO add ref counting of ICD libraries
Jon Ashburn269b5922015-07-06 15:40:35 -0600288 // TODO use this struct loader_layer_library_list scanned_layer_libraries;
Jon Ashburne0367472015-08-18 18:04:47 -0600289 // TODO add list of icd libraries for ref counting them for closure
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600290};
291
292struct loader_scanned_icds {
293 char *lib_name;
294 loader_platform_dl_handle handle;
Jon Ashburn27109e82015-11-17 17:35:40 -0700295 uint32_t api_version;
Jon Ashburnc7ca48d2015-07-16 10:17:29 -0600296 PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600297 PFN_vkCreateInstance CreateInstance;
Courtney Goeltzenleuchtere25064c2015-09-14 17:22:16 -0600298 PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
Jon Ashburn13482452015-05-12 17:26:48 -0600299};
300
Jon Ashburn399c9162015-07-02 09:40:15 -0600301static inline struct loader_instance *loader_instance(VkInstance instance) {
302 return (struct loader_instance *) instance;
303}
304
Tony Barbour303615c2015-07-03 10:33:54 -0600305static inline void loader_set_dispatch(void* obj, const void *data)
Chia-I Wufe333ed2015-04-11 15:34:07 +0800306{
307 *((const void **) obj) = data;
308}
309
Tony Barbour303615c2015-07-03 10:33:54 -0600310static inline VkLayerDispatchTable *loader_get_dispatch(const void* obj)
Chia-I Wufe333ed2015-04-11 15:34:07 +0800311{
Jon Ashburn62a54d12015-05-01 18:00:33 -0600312 return *((VkLayerDispatchTable **) obj);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800313}
314
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700315static inline struct loader_dev_dispatch_table *loader_get_dev_dispatch(const void* obj)
316{
317 return *((struct loader_dev_dispatch_table **) obj);
318}
319
Tony Barbour303615c2015-07-03 10:33:54 -0600320static inline VkLayerInstanceDispatchTable *loader_get_instance_dispatch(const void* obj)
Jon Ashburn13482452015-05-12 17:26:48 -0600321{
322 return *((VkLayerInstanceDispatchTable **) obj);
323}
324
Tony Barbour303615c2015-07-03 10:33:54 -0600325static inline void loader_init_dispatch(void* obj, const void *data)
Chia-I Wufe333ed2015-04-11 15:34:07 +0800326{
Jon Ashburn167b2b12015-04-15 13:34:33 -0600327#ifdef DEBUG
Chia-I Wufe333ed2015-04-11 15:34:07 +0800328 assert(valid_loader_magic_value(obj) &&
329 "Incompatible ICD, first dword must be initialized to ICD_LOADER_MAGIC. See loader/README.md for details.");
Jon Ashburn167b2b12015-04-15 13:34:33 -0600330#endif
Chia-I Wufe333ed2015-04-11 15:34:07 +0800331
Jon Ashburn62a54d12015-05-01 18:00:33 -0600332 loader_set_dispatch(obj, data);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800333}
334
Jon Ashburn13482452015-05-12 17:26:48 -0600335/* global variables used across files */
336extern struct loader_struct loader;
Jon Ashburnb4dee9c2015-08-28 15:19:27 -0600337extern THREAD_LOCAL_DECL struct loader_instance *tls_instance;
Jon Ashburne0367472015-08-18 18:04:47 -0600338extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_init);
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600339extern loader_platform_thread_mutex loader_lock;
Jon Ashburn7d4d51c2015-09-22 13:11:00 -0600340extern loader_platform_thread_mutex loader_json_lock;
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600341extern const VkLayerInstanceDispatchTable instance_disp;
Jon Ashburn37e7f972015-04-06 10:58:22 -0600342
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600343struct loader_msg_callback_map_entry {
344 VkDbgMsgCallback icd_obj;
345 VkDbgMsgCallback loader_obj;
346};
347
348bool compare_vk_extension_properties(
349 const VkExtensionProperties* op1,
350 const VkExtensionProperties* op2);
351
Jon Ashburnb4c24232015-08-20 16:35:30 -0600352VkResult loader_validate_layers(
353 const uint32_t layer_count,
354 const char * const *ppEnabledLayerNames,
355 const struct loader_layer_list *list);
Courtney Goeltzenleuchter76ece702015-07-06 17:45:08 -0600356
357VkResult loader_validate_instance_extensions(
Jon Ashburn555d2ed2015-08-14 11:57:54 -0600358 const struct loader_extension_list *icd_exts,
Jon Ashburnf6a69702015-08-11 14:49:54 -0600359 const struct loader_layer_list *instance_layer,
Courtney Goeltzenleuchter76ece702015-07-06 17:45:08 -0600360 const VkInstanceCreateInfo* pCreateInfo);
361
Jon Ashburn13482452015-05-12 17:26:48 -0600362/* instance layer chain termination entrypoint definitions */
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800363VKAPI_ATTR VkResult VKAPI_CALL loader_CreateInstance(
Jon Ashburn13482452015-05-12 17:26:48 -0600364 const VkInstanceCreateInfo* pCreateInfo,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800365 const VkAllocationCallbacks* pAllocator,
Jon Ashburn13482452015-05-12 17:26:48 -0600366 VkInstance* pInstance);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800367
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800368VKAPI_ATTR void VKAPI_CALL loader_DestroyInstance(
Chia-I Wu221ca472015-10-26 21:10:41 +0800369 VkInstance instance,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800370 const VkAllocationCallbacks* pAllocator);
Jon Ashburn13482452015-05-12 17:26:48 -0600371
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800372VKAPI_ATTR VkResult VKAPI_CALL loader_EnumeratePhysicalDevices(
Jon Ashburn13482452015-05-12 17:26:48 -0600373 VkInstance instance,
374 uint32_t* pPhysicalDeviceCount,
375 VkPhysicalDevice* pPhysicalDevices);
Chris Forbes1c946ec2015-06-21 22:55:02 +1200376
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800377VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceFeatures(
Chris Forbes1c946ec2015-06-21 22:55:02 +1200378 VkPhysicalDevice physicalDevice,
379 VkPhysicalDeviceFeatures* pFeatures);
380
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800381VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceFormatProperties(
Chris Forbes1c946ec2015-06-21 22:55:02 +1200382 VkPhysicalDevice physicalDevice,
383 VkFormat format,
384 VkFormatProperties* pFormatInfo);
385
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800386VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceImageFormatProperties(
Chia-I Wuef653f62015-10-31 00:31:16 +0800387 VkPhysicalDevice physicalDevice,
Jon Ashburn25c11452015-07-23 18:49:07 -0600388 VkFormat format,
389 VkImageType type,
390 VkImageTiling tiling,
391 VkImageUsageFlags usage,
Courtney Goeltzenleuchter4743d002015-09-10 13:44:12 -0600392 VkImageCreateFlags flags,
Jon Ashburn25c11452015-07-23 18:49:07 -0600393 VkImageFormatProperties* pImageFormatProperties);
394
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800395VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceSparseImageFormatProperties(
Mark Lobodzinski0c708be2015-07-03 15:58:09 -0600396 VkPhysicalDevice physicalDevice,
397 VkFormat format,
398 VkImageType type,
Chia-I Wubb2b5b32015-10-31 00:31:16 +0800399 VkSampleCountFlagBits samples,
Mark Lobodzinski0c708be2015-07-03 15:58:09 -0600400 VkImageUsageFlags usage,
401 VkImageTiling tiling,
402 uint32_t* pNumProperties,
403 VkSparseImageFormatProperties* pProperties);
Tony Barbour4e657ba2015-06-24 16:06:58 -0600404
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800405VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceProperties (
Tony Barbour4e657ba2015-06-24 16:06:58 -0600406 VkPhysicalDevice physicalDevice,
407 VkPhysicalDeviceProperties* pProperties);
408
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800409VKAPI_ATTR VkResult VKAPI_CALL loader_EnumerateDeviceExtensionProperties (VkPhysicalDevice physicalDevice,
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600410 const char *pLayerName, uint32_t *pCount,
Tony Barbour4e657ba2015-06-24 16:06:58 -0600411 VkExtensionProperties* pProperties);
412
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800413VKAPI_ATTR VkResult VKAPI_CALL loader_EnumerateDeviceLayerProperties (VkPhysicalDevice physicalDevice,
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600414 uint32_t *pCount,
415 VkLayerProperties* pProperties);
Tony Barbour4e657ba2015-06-24 16:06:58 -0600416
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800417VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceQueueFamilyProperties (
Cody Northropfc4ad132015-08-03 17:04:53 -0600418 VkPhysicalDevice physicalDevice,
419 uint32_t* pCount,
420 VkQueueFamilyProperties* pProperties);
Tony Barbour4e657ba2015-06-24 16:06:58 -0600421
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800422VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceMemoryProperties (
Tony Barbour4e657ba2015-06-24 16:06:58 -0600423 VkPhysicalDevice physicalDevice,
424 VkPhysicalDeviceMemoryProperties * pProperties);
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600425
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800426VKAPI_ATTR VkResult VKAPI_CALL loader_CreateDevice(
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600427 VkPhysicalDevice gpu,
428 const VkDeviceCreateInfo* pCreateInfo,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800429 const VkAllocationCallbacks* pAllocator,
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600430 VkDevice* pDevice);
Jon Ashburn13482452015-05-12 17:26:48 -0600431
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600432/* helper function definitions */
Jon Ashburne0367472015-08-18 18:04:47 -0600433void loader_initialize(void);
Jon Ashburn02a8d6e2015-07-02 12:59:25 -0600434bool has_vk_extension_property_array(
435 const VkExtensionProperties *vk_ext_prop,
436 const uint32_t count,
437 const VkExtensionProperties *ext_array);
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600438bool has_vk_extension_property(
439 const VkExtensionProperties *vk_ext_prop,
440 const struct loader_extension_list *ext_list);
Jon Ashburn13482452015-05-12 17:26:48 -0600441
Jon Ashburn969caa42015-11-01 14:04:06 -0700442VkResult loader_add_to_ext_list(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600443 const struct loader_instance *inst,
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600444 struct loader_extension_list *ext_list,
445 uint32_t prop_list_count,
Jon Ashburnb7d327c2015-08-04 11:14:18 -0600446 const VkExtensionProperties *props);
Jon Ashburn6b00b472015-12-10 08:51:10 -0700447void loader_destroy_generic_list(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600448 const struct loader_instance *inst,
Jon Ashburn6b00b472015-12-10 08:51:10 -0700449 struct loader_generic_list *list);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600450void loader_delete_layer_properties(
451 const struct loader_instance *inst,
452 struct loader_layer_list *layer_list);
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600453void loader_add_to_layer_list(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600454 const struct loader_instance *inst,
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600455 struct loader_layer_list *list,
456 uint32_t prop_list_count,
457 const struct loader_layer_properties *props);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600458void loader_scanned_icd_clear(
459 const struct loader_instance *inst,
460 struct loader_icd_libs *icd_libs);
461void loader_icd_scan(
462 const struct loader_instance *inst,
463 struct loader_icd_libs *icds);
Jon Ashburnf6a69702015-08-11 14:49:54 -0600464void loader_layer_scan(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600465 const struct loader_instance *inst,
Jon Ashburnf6a69702015-08-11 14:49:54 -0600466 struct loader_layer_list *instance_layers,
467 struct loader_layer_list *device_layers);
Jon Ashburne0367472015-08-18 18:04:47 -0600468void loader_get_icd_loader_instance_extensions(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600469 const struct loader_instance *inst,
Jon Ashburne0367472015-08-18 18:04:47 -0600470 struct loader_icd_libs *icd_libs,
471 struct loader_extension_list *inst_exts);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600472struct loader_icd *loader_get_icd_and_device(
473 const VkDevice device,
474 struct loader_device **found_dev);
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700475void *loader_dev_ext_gpa(
476 struct loader_instance *inst,
477 const char *funcName);
478void *loader_get_dev_ext_trampoline(
479 uint32_t index);
Jon Ashburn8a7e5622015-09-30 12:56:42 -0600480struct loader_instance *loader_get_instance(
481 const VkInstance instance);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600482void loader_remove_logical_device(
483 const struct loader_instance *inst,
Jon Ashburncfd9c712015-11-19 15:43:26 -0700484 struct loader_icd *icd,
485 struct loader_device *found_dev);
Jon Ashburnf6a69702015-08-11 14:49:54 -0600486VkResult loader_enable_instance_layers(
487 struct loader_instance *inst,
488 const VkInstanceCreateInfo *pCreateInfo,
489 const struct loader_layer_list *instance_layers);
Jon Ashburn10f4e822015-06-10 10:06:06 -0600490void loader_deactivate_instance_layers(struct loader_instance *instance);
Jon Ashburn13482452015-05-12 17:26:48 -0600491uint32_t loader_activate_instance_layers(struct loader_instance *inst);
Courtney Goeltzenleuchter1c512402015-06-17 20:51:59 -0600492void loader_activate_instance_layer_extensions(struct loader_instance *inst);
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600493
494void* loader_heap_alloc(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600495 const struct loader_instance *instance,
Jon Ashburnf6a69702015-08-11 14:49:54 -0600496 size_t size,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800497 VkSystemAllocationScope allocationScope);
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600498
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600499void loader_heap_free(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600500 const struct loader_instance *instance,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800501 void *pMemory);
Jon Ashburnb4dee9c2015-08-28 15:19:27 -0600502
503void *loader_tls_heap_alloc(size_t size);
504
Chia-I Wu227c8b32015-10-27 18:04:07 +0800505void loader_tls_heap_free(void *pMemory);
Chia-I Wuc1e0f962014-08-04 08:03:57 +0800506#endif /* LOADER_H */