blob: c83faa983bc8357fa8ba9f379a80062343cf9f52 [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
Ian Elliott5fb891a2015-10-30 17:45:05 -060035#if defined _WIN32
36#define VK_USE_PLATFORM_WIN32_KHR
37#else
38//#define VK_USE_PLATFORM_MIR_KHR
39//#define VK_USE_PLATFORM_WAYLAND_KHR
40#define VK_USE_PLATFORM_XCB_KHR
41//#define VK_USE_PLATFORM_XLIB_KHR
42#endif
David Pinedoa5036622015-11-06 12:54:48 -070043#include <vulkan/vulkan.h>
Jon Ashburn3708e792015-11-06 11:02:40 -070044#include <vk_loader_platform.h>
Ian Elliottafaf1852015-11-17 17:29:40 -070045
David Pinedoaf35af72015-11-24 09:00:24 -070046#include <vulkan/vk_lunarg_debug_report.h>
Ian Elliotta77fed72015-11-18 14:57:08 -070047
David Pinedoa5036622015-11-06 12:54:48 -070048#include <vulkan/vk_layer.h>
49#include <vulkan/vk_icd.h>
Chia-I Wufe333ed2015-04-11 15:34:07 +080050#include <assert.h>
51
Chia-I Wuc1e0f962014-08-04 08:03:57 +080052#if defined(__GNUC__) && __GNUC__ >= 4
53# define LOADER_EXPORT __attribute__((visibility("default")))
54#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
55# define LOADER_EXPORT __attribute__((visibility("default")))
56#else
57# define LOADER_EXPORT
58#endif
59
Jon Ashburnb2379c52015-08-04 10:22:33 -060060#define MAX_STRING_SIZE 1024
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -060061#define VK_MAJOR(version) (version >> 22)
62#define VK_MINOR(version) ((version >> 12) & 0x3ff)
63#define VK_PATCH(version) (version & 0xfff)
Jon Ashburn13482452015-05-12 17:26:48 -060064
Jon Ashburn399c9162015-07-02 09:40:15 -060065enum layer_type {
Jon Ashburn9464e772015-07-02 16:10:32 -060066 VK_LAYER_TYPE_DEVICE_EXPLICIT = 0x1,
67 VK_LAYER_TYPE_INSTANCE_EXPLICIT = 0x2,
68 VK_LAYER_TYPE_GLOBAL_EXPLICIT = 0x3, // both instance and device layer, bitwise
69 VK_LAYER_TYPE_DEVICE_IMPLICIT = 0x4,
70 VK_LAYER_TYPE_INSTANCE_IMPLICIT = 0x8,
71 VK_LAYER_TYPE_GLOBAL_IMPLICIT = 0xc, // both instance and device layer, bitwise
Jon Ashburn399c9162015-07-02 09:40:15 -060072};
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 Ashburn399c9162015-07-02 09:40:15 -060080struct loader_name_value {
Jon Ashburnb2379c52015-08-04 10:22:33 -060081 char name[MAX_STRING_SIZE];
82 char value[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -060083};
84
85struct loader_lib_info {
Jon Ashburnb4c24232015-08-20 16:35:30 -060086 char lib_name[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -060087 uint32_t ref_count;
88 loader_platform_dl_handle lib_handle;
89};
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060090
Jon Ashburn399c9162015-07-02 09:40:15 -060091struct loader_layer_functions {
Jon Ashburnb2379c52015-08-04 10:22:33 -060092 char str_gipa[MAX_STRING_SIZE];
93 char str_gdpa[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -060094 PFN_vkGetInstanceProcAddr get_instance_proc_addr;
95 PFN_vkGetDeviceProcAddr get_device_proc_addr;
96};
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -060097
Jon Ashburn399c9162015-07-02 09:40:15 -060098struct loader_layer_properties {
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -060099 VkLayerProperties info;
Jon Ashburn399c9162015-07-02 09:40:15 -0600100 enum layer_type type;
Jon Ashburnb4c24232015-08-20 16:35:30 -0600101 char lib_name[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -0600102 struct loader_layer_functions functions;
103 struct loader_extension_list instance_extension_list;
104 struct loader_extension_list device_extension_list;
105 struct loader_name_value disable_env_var;
106 struct loader_name_value enable_env_var;
107};
108
109struct loader_layer_list {
110 size_t capacity;
111 uint32_t count;
112 struct loader_layer_properties *list;
Jon Ashburn13482452015-05-12 17:26:48 -0600113};
114
Courtney Goeltzenleuchter8aff3862015-07-05 12:53:31 -0600115struct loader_layer_library_list {
116 size_t capacity;
117 uint32_t count;
118 struct loader_lib_info *list;
119};
120
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700121struct loader_dispatch_hash_list {
122 size_t capacity;
123 uint32_t count;
124 uint32_t *index; // index into the dev_ext dispatch table
125};
126
127#define MAX_NUM_DEV_EXTS 250
128// loader_dispatch_hash_entry and loader_dev_ext_dispatch_table.DevExt have one to one
129// correspondence; one loader_dispatch_hash_entry for one DevExt dispatch entry.
130// Also have a one to one correspondence with functions in dev_ext_trampoline.c
131struct loader_dispatch_hash_entry {
132 char *func_name;
133 struct loader_dispatch_hash_list list; // to handle hashing collisions
134};
135
136typedef void (VKAPI_PTR *PFN_vkDevExt)(VkDevice device);
137struct loader_dev_ext_dispatch_table {
138 PFN_vkDevExt DevExt[MAX_NUM_DEV_EXTS];
139};
140
141struct loader_dev_dispatch_table {
142 VkLayerDispatchTable core_dispatch;
143 struct loader_dev_ext_dispatch_table ext_dispatch;
144};
145
Jon Ashburn10f4e822015-06-10 10:06:06 -0600146/* per CreateDevice structure */
147struct loader_device {
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700148 struct loader_dev_dispatch_table loader_dispatch;
Jon Ashburn10f4e822015-06-10 10:06:06 -0600149 VkDevice device; // device object from the icd
150
151 uint32_t app_extension_count;
152 VkExtensionProperties *app_extension_props;
153
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600154 struct loader_layer_list activated_layer_list;
Jon Ashburn10f4e822015-06-10 10:06:06 -0600155
156 struct loader_device *next;
157};
158
Jon Ashburn392c5622015-06-10 16:11:42 -0600159/* per ICD structure */
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600160struct loader_icd {
Jon Ashburnb4c24232015-08-20 16:35:30 -0600161 // pointers to find other structs
162 const struct loader_scanned_icds *this_icd_lib;
163 const struct loader_instance *this_instance;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600164
Jon Ashburn10f4e822015-06-10 10:06:06 -0600165 struct loader_device *logical_device_list;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600166 VkInstance instance; // instance object from the icd
Jon Ashburnc89dd4a2015-05-18 13:20:15 -0600167 PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600168 PFN_vkDestroyInstance DestroyInstance;
169 PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
Chris Forbes1c946ec2015-06-21 22:55:02 +1200170 PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures;
Courtney Goeltzenleuchter2b6559e2015-07-12 12:52:09 -0600171 PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties;
Jon Ashburn25c11452015-07-23 18:49:07 -0600172 PFN_vkGetPhysicalDeviceImageFormatProperties GetPhysicalDeviceImageFormatProperties;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600173 PFN_vkCreateDevice CreateDevice;
Tony Barbour4e657ba2015-06-24 16:06:58 -0600174 PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
Cody Northropfc4ad132015-08-03 17:04:53 -0600175 PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties;
Tony Barbour4e657ba2015-06-24 16:06:58 -0600176 PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
Courtney Goeltzenleuchtere25064c2015-09-14 17:22:16 -0600177 PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties;
Mark Lobodzinski0c708be2015-07-03 15:58:09 -0600178 PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600179 PFN_vkDbgCreateMsgCallback DbgCreateMsgCallback;
180 PFN_vkDbgDestroyMsgCallback DbgDestroyMsgCallback;
Ian Elliottec736342015-08-21 15:09:33 -0600181 PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
Ian Elliottea666b22015-11-19 16:05:09 -0700182 PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR GetPhysicalDeviceSurfaceCapabilitiesKHR;
183 PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR;
184 PFN_vkGetPhysicalDeviceSurfacePresentModesKHR GetPhysicalDeviceSurfacePresentModesKHR;
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600185
Jon Ashburn10f4e822015-06-10 10:06:06 -0600186 struct loader_icd *next;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600187};
188
Jon Ashburne0367472015-08-18 18:04:47 -0600189/* per ICD library structure */
190struct loader_icd_libs {
191 size_t capacity;
192 uint32_t count;
193 struct loader_scanned_icds *list;
194};
195
Jon Ashburn392c5622015-06-10 16:11:42 -0600196/* per instance structure */
Jon Ashburn13482452015-05-12 17:26:48 -0600197struct loader_instance {
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600198 VkLayerInstanceDispatchTable *disp; // must be first entry in structure
199
Jon Ashburn13482452015-05-12 17:26:48 -0600200 uint32_t total_gpu_count;
Jon Ashburn969caa42015-11-01 14:04:06 -0700201 struct loader_physical_device *phys_devs;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600202 uint32_t total_icd_count;
Jon Ashburn13482452015-05-12 17:26:48 -0600203 struct loader_icd *icds;
204 struct loader_instance *next;
Jon Ashburne503a7d2015-08-14 14:49:22 -0600205 struct loader_extension_list ext_list; // icds and loaders extensions
Jon Ashburne0367472015-08-18 18:04:47 -0600206 struct loader_icd_libs icd_libs;
Jon Ashburnb4c24232015-08-20 16:35:30 -0600207 struct loader_layer_list instance_layer_list;
208 struct loader_layer_list device_layer_list;
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700209 struct loader_dispatch_hash_entry disp_hash[MAX_NUM_DEV_EXTS];
Jon Ashburnb4c24232015-08-20 16:35:30 -0600210
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600211 struct loader_msg_callback_map_entry *icd_msg_callback_map;
212
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600213 struct loader_layer_list activated_layer_list;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600214
215 bool debug_report_enabled;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600216 VkLayerDbgFunctionNode *DbgFunctionHead;
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600217
Chia-I Wu227c8b32015-10-27 18:04:07 +0800218 VkAllocationCallbacks alloc_callbacks;
Ian Elliotted33eb72015-07-06 14:36:13 -0600219
Ian Elliott54cea232015-10-30 15:28:23 -0600220 bool wsi_surface_enabled;
221#ifdef _WIN32
222 bool wsi_win32_surface_enabled;
223#else // _WIN32
224 bool wsi_mir_surface_enabled;
225 bool wsi_wayland_surface_enabled;
226 bool wsi_xcb_surface_enabled;
227 bool wsi_xlib_surface_enabled;
228#endif // _WIN32
Ian Elliotted33eb72015-07-06 14:36:13 -0600229 bool wsi_swapchain_enabled;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600230};
231
Jon Ashburn969caa42015-11-01 14:04:06 -0700232/* per enumerated PhysicalDevice structure */
233struct loader_physical_device {
234 VkLayerInstanceDispatchTable *disp; // must be first entry in structure
235 struct loader_instance *this_instance;
236 struct loader_icd *this_icd;
237 VkPhysicalDevice phys_dev; // object from ICD
238 /*
239 * Fill in the cache of available device extensions from
Jon Ashburna1981ff2015-11-02 17:40:01 -0700240 * this physical device. This cache can be used during CreateDevice
Jon Ashburn969caa42015-11-01 14:04:06 -0700241 */
242 struct loader_extension_list device_extension_cache;
243};
244
Jon Ashburn13482452015-05-12 17:26:48 -0600245struct loader_struct {
246 struct loader_instance *instances;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600247
248 unsigned int loaded_layer_lib_count;
Courtney Goeltzenleuchter452303a2015-10-07 09:00:34 -0600249 size_t loaded_layer_lib_capacity;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600250 struct loader_lib_info *loaded_layer_lib_list;
Jon Ashburne0367472015-08-18 18:04:47 -0600251 // TODO add ref counting of ICD libraries
Jon Ashburn269b5922015-07-06 15:40:35 -0600252 // TODO use this struct loader_layer_library_list scanned_layer_libraries;
Jon Ashburne0367472015-08-18 18:04:47 -0600253 // TODO add list of icd libraries for ref counting them for closure
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600254};
255
256struct loader_scanned_icds {
257 char *lib_name;
258 loader_platform_dl_handle handle;
Jon Ashburn27109e82015-11-17 17:35:40 -0700259 uint32_t api_version;
Jon Ashburnc7ca48d2015-07-16 10:17:29 -0600260 PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600261 PFN_vkCreateInstance CreateInstance;
Courtney Goeltzenleuchtere25064c2015-09-14 17:22:16 -0600262 PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
Jon Ashburn13482452015-05-12 17:26:48 -0600263};
264
Jon Ashburn399c9162015-07-02 09:40:15 -0600265static inline struct loader_instance *loader_instance(VkInstance instance) {
266 return (struct loader_instance *) instance;
267}
268
Tony Barbour303615c2015-07-03 10:33:54 -0600269static inline void loader_set_dispatch(void* obj, const void *data)
Chia-I Wufe333ed2015-04-11 15:34:07 +0800270{
271 *((const void **) obj) = data;
272}
273
Tony Barbour303615c2015-07-03 10:33:54 -0600274static inline VkLayerDispatchTable *loader_get_dispatch(const void* obj)
Chia-I Wufe333ed2015-04-11 15:34:07 +0800275{
Jon Ashburn62a54d12015-05-01 18:00:33 -0600276 return *((VkLayerDispatchTable **) obj);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800277}
278
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700279static inline struct loader_dev_dispatch_table *loader_get_dev_dispatch(const void* obj)
280{
281 return *((struct loader_dev_dispatch_table **) obj);
282}
283
Tony Barbour303615c2015-07-03 10:33:54 -0600284static inline VkLayerInstanceDispatchTable *loader_get_instance_dispatch(const void* obj)
Jon Ashburn13482452015-05-12 17:26:48 -0600285{
286 return *((VkLayerInstanceDispatchTable **) obj);
287}
288
Tony Barbour303615c2015-07-03 10:33:54 -0600289static inline void loader_init_dispatch(void* obj, const void *data)
Chia-I Wufe333ed2015-04-11 15:34:07 +0800290{
Jon Ashburn167b2b12015-04-15 13:34:33 -0600291#ifdef DEBUG
Chia-I Wufe333ed2015-04-11 15:34:07 +0800292 assert(valid_loader_magic_value(obj) &&
293 "Incompatible ICD, first dword must be initialized to ICD_LOADER_MAGIC. See loader/README.md for details.");
Jon Ashburn167b2b12015-04-15 13:34:33 -0600294#endif
Chia-I Wufe333ed2015-04-11 15:34:07 +0800295
Jon Ashburn62a54d12015-05-01 18:00:33 -0600296 loader_set_dispatch(obj, data);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800297}
298
Jon Ashburn13482452015-05-12 17:26:48 -0600299/* global variables used across files */
300extern struct loader_struct loader;
Jon Ashburnb4dee9c2015-08-28 15:19:27 -0600301extern THREAD_LOCAL_DECL struct loader_instance *tls_instance;
Jon Ashburne0367472015-08-18 18:04:47 -0600302extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_init);
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600303extern loader_platform_thread_mutex loader_lock;
Jon Ashburn7d4d51c2015-09-22 13:11:00 -0600304extern loader_platform_thread_mutex loader_json_lock;
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600305extern const VkLayerInstanceDispatchTable instance_disp;
Jon Ashburn37e7f972015-04-06 10:58:22 -0600306
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600307struct loader_msg_callback_map_entry {
308 VkDbgMsgCallback icd_obj;
309 VkDbgMsgCallback loader_obj;
310};
311
312bool compare_vk_extension_properties(
313 const VkExtensionProperties* op1,
314 const VkExtensionProperties* op2);
315
Jon Ashburnb4c24232015-08-20 16:35:30 -0600316VkResult loader_validate_layers(
317 const uint32_t layer_count,
318 const char * const *ppEnabledLayerNames,
319 const struct loader_layer_list *list);
Courtney Goeltzenleuchter76ece702015-07-06 17:45:08 -0600320
321VkResult loader_validate_instance_extensions(
Jon Ashburn555d2ed2015-08-14 11:57:54 -0600322 const struct loader_extension_list *icd_exts,
Jon Ashburnf6a69702015-08-11 14:49:54 -0600323 const struct loader_layer_list *instance_layer,
Courtney Goeltzenleuchter76ece702015-07-06 17:45:08 -0600324 const VkInstanceCreateInfo* pCreateInfo);
325
Jon Ashburn13482452015-05-12 17:26:48 -0600326/* instance layer chain termination entrypoint definitions */
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800327VKAPI_ATTR VkResult VKAPI_CALL loader_CreateInstance(
Jon Ashburn13482452015-05-12 17:26:48 -0600328 const VkInstanceCreateInfo* pCreateInfo,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800329 const VkAllocationCallbacks* pAllocator,
Jon Ashburn13482452015-05-12 17:26:48 -0600330 VkInstance* pInstance);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800331
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800332VKAPI_ATTR void VKAPI_CALL loader_DestroyInstance(
Chia-I Wu221ca472015-10-26 21:10:41 +0800333 VkInstance instance,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800334 const VkAllocationCallbacks* pAllocator);
Jon Ashburn13482452015-05-12 17:26:48 -0600335
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800336VKAPI_ATTR VkResult VKAPI_CALL loader_EnumeratePhysicalDevices(
Jon Ashburn13482452015-05-12 17:26:48 -0600337 VkInstance instance,
338 uint32_t* pPhysicalDeviceCount,
339 VkPhysicalDevice* pPhysicalDevices);
Chris Forbes1c946ec2015-06-21 22:55:02 +1200340
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800341VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceFeatures(
Chris Forbes1c946ec2015-06-21 22:55:02 +1200342 VkPhysicalDevice physicalDevice,
343 VkPhysicalDeviceFeatures* pFeatures);
344
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800345VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceFormatProperties(
Chris Forbes1c946ec2015-06-21 22:55:02 +1200346 VkPhysicalDevice physicalDevice,
347 VkFormat format,
348 VkFormatProperties* pFormatInfo);
349
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800350VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceImageFormatProperties(
Chia-I Wuef653f62015-10-31 00:31:16 +0800351 VkPhysicalDevice physicalDevice,
Jon Ashburn25c11452015-07-23 18:49:07 -0600352 VkFormat format,
353 VkImageType type,
354 VkImageTiling tiling,
355 VkImageUsageFlags usage,
Courtney Goeltzenleuchter4743d002015-09-10 13:44:12 -0600356 VkImageCreateFlags flags,
Jon Ashburn25c11452015-07-23 18:49:07 -0600357 VkImageFormatProperties* pImageFormatProperties);
358
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800359VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceSparseImageFormatProperties(
Mark Lobodzinski0c708be2015-07-03 15:58:09 -0600360 VkPhysicalDevice physicalDevice,
361 VkFormat format,
362 VkImageType type,
Chia-I Wubb2b5b32015-10-31 00:31:16 +0800363 VkSampleCountFlagBits samples,
Mark Lobodzinski0c708be2015-07-03 15:58:09 -0600364 VkImageUsageFlags usage,
365 VkImageTiling tiling,
366 uint32_t* pNumProperties,
367 VkSparseImageFormatProperties* pProperties);
Tony Barbour4e657ba2015-06-24 16:06:58 -0600368
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800369VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceProperties (
Tony Barbour4e657ba2015-06-24 16:06:58 -0600370 VkPhysicalDevice physicalDevice,
371 VkPhysicalDeviceProperties* pProperties);
372
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800373VKAPI_ATTR VkResult VKAPI_CALL loader_EnumerateDeviceExtensionProperties (VkPhysicalDevice physicalDevice,
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600374 const char *pLayerName, uint32_t *pCount,
Tony Barbour4e657ba2015-06-24 16:06:58 -0600375 VkExtensionProperties* pProperties);
376
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800377VKAPI_ATTR VkResult VKAPI_CALL loader_EnumerateDeviceLayerProperties (VkPhysicalDevice physicalDevice,
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600378 uint32_t *pCount,
379 VkLayerProperties* pProperties);
Tony Barbour4e657ba2015-06-24 16:06:58 -0600380
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800381VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceQueueFamilyProperties (
Cody Northropfc4ad132015-08-03 17:04:53 -0600382 VkPhysicalDevice physicalDevice,
383 uint32_t* pCount,
384 VkQueueFamilyProperties* pProperties);
Tony Barbour4e657ba2015-06-24 16:06:58 -0600385
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800386VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceMemoryProperties (
Tony Barbour4e657ba2015-06-24 16:06:58 -0600387 VkPhysicalDevice physicalDevice,
388 VkPhysicalDeviceMemoryProperties * pProperties);
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600389
Chia-I Wu2c56bb92015-11-06 06:42:02 +0800390VKAPI_ATTR VkResult VKAPI_CALL loader_CreateDevice(
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600391 VkPhysicalDevice gpu,
392 const VkDeviceCreateInfo* pCreateInfo,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800393 const VkAllocationCallbacks* pAllocator,
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600394 VkDevice* pDevice);
Jon Ashburn13482452015-05-12 17:26:48 -0600395
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600396/* helper function definitions */
Jon Ashburne0367472015-08-18 18:04:47 -0600397void loader_initialize(void);
Jon Ashburn02a8d6e2015-07-02 12:59:25 -0600398bool has_vk_extension_property_array(
399 const VkExtensionProperties *vk_ext_prop,
400 const uint32_t count,
401 const VkExtensionProperties *ext_array);
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600402bool has_vk_extension_property(
403 const VkExtensionProperties *vk_ext_prop,
404 const struct loader_extension_list *ext_list);
Jon Ashburn13482452015-05-12 17:26:48 -0600405
Jon Ashburn969caa42015-11-01 14:04:06 -0700406VkResult loader_add_to_ext_list(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600407 const struct loader_instance *inst,
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600408 struct loader_extension_list *ext_list,
409 uint32_t prop_list_count,
Jon Ashburnb7d327c2015-08-04 11:14:18 -0600410 const VkExtensionProperties *props);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600411void loader_destroy_ext_list(
412 const struct loader_instance *inst,
413 struct loader_extension_list *ext_info);
414void loader_delete_layer_properties(
415 const struct loader_instance *inst,
416 struct loader_layer_list *layer_list);
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600417void loader_add_to_layer_list(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600418 const struct loader_instance *inst,
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600419 struct loader_layer_list *list,
420 uint32_t prop_list_count,
421 const struct loader_layer_properties *props);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600422void loader_scanned_icd_clear(
423 const struct loader_instance *inst,
424 struct loader_icd_libs *icd_libs);
425void loader_icd_scan(
426 const struct loader_instance *inst,
427 struct loader_icd_libs *icds);
Jon Ashburnf6a69702015-08-11 14:49:54 -0600428void loader_layer_scan(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600429 const struct loader_instance *inst,
Jon Ashburnf6a69702015-08-11 14:49:54 -0600430 struct loader_layer_list *instance_layers,
431 struct loader_layer_list *device_layers);
Jon Ashburne0367472015-08-18 18:04:47 -0600432void loader_get_icd_loader_instance_extensions(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600433 const struct loader_instance *inst,
Jon Ashburne0367472015-08-18 18:04:47 -0600434 struct loader_icd_libs *icd_libs,
435 struct loader_extension_list *inst_exts);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600436struct loader_icd *loader_get_icd_and_device(
437 const VkDevice device,
438 struct loader_device **found_dev);
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700439void *loader_dev_ext_gpa(
440 struct loader_instance *inst,
441 const char *funcName);
442void *loader_get_dev_ext_trampoline(
443 uint32_t index);
Jon Ashburn8a7e5622015-09-30 12:56:42 -0600444struct loader_instance *loader_get_instance(
445 const VkInstance instance);
Jon Ashburn8fd90812015-08-28 13:38:21 -0600446void loader_remove_logical_device(
447 const struct loader_instance *inst,
Jon Ashburncfd9c712015-11-19 15:43:26 -0700448 struct loader_icd *icd,
449 struct loader_device *found_dev);
Jon Ashburnf6a69702015-08-11 14:49:54 -0600450VkResult loader_enable_instance_layers(
451 struct loader_instance *inst,
452 const VkInstanceCreateInfo *pCreateInfo,
453 const struct loader_layer_list *instance_layers);
Jon Ashburn10f4e822015-06-10 10:06:06 -0600454void loader_deactivate_instance_layers(struct loader_instance *instance);
Jon Ashburn13482452015-05-12 17:26:48 -0600455uint32_t loader_activate_instance_layers(struct loader_instance *inst);
Courtney Goeltzenleuchter1c512402015-06-17 20:51:59 -0600456void loader_activate_instance_layer_extensions(struct loader_instance *inst);
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600457
458void* loader_heap_alloc(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600459 const struct loader_instance *instance,
Jon Ashburnf6a69702015-08-11 14:49:54 -0600460 size_t size,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800461 VkSystemAllocationScope allocationScope);
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600462
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600463void loader_heap_free(
Jon Ashburn8fd90812015-08-28 13:38:21 -0600464 const struct loader_instance *instance,
Chia-I Wu227c8b32015-10-27 18:04:07 +0800465 void *pMemory);
Jon Ashburnb4dee9c2015-08-28 15:19:27 -0600466
467void *loader_tls_heap_alloc(size_t size);
468
Chia-I Wu227c8b32015-10-27 18:04:07 +0800469void loader_tls_heap_free(void *pMemory);
Chia-I Wuc1e0f962014-08-04 08:03:57 +0800470#endif /* LOADER_H */