blob: f27b892b908f2d3d4e6ee3bee6bca789ac6764a6 [file] [log] [blame]
Chia-I Wu468e3c32014-08-04 08:03:57 +08001/*
Chia-I Wu468e3c32014-08-04 08:03:57 +08002 *
Courtney Goeltzenleuchter8a17da52015-10-29 13:50:34 -06003 * Copyright (C) 2015 Valve Corporation
Chia-I Wu468e3c32014-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 Wu44e42362014-09-02 08:32:09 +080022 *
Courtney Goeltzenleuchter96cd7952015-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 Wu468e3c32014-08-04 08:03:57 +080030 */
31
32#ifndef LOADER_H
33#define LOADER_H
34
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060035#include <vulkan.h>
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060036#include <vk_debug_report_lunarg.h>
Ian Elliott338dedb2015-08-21 15:09:33 -060037#include <vk_ext_khr_swapchain.h>
Tobin Ehlis2d1d9702015-07-03 09:42:57 -060038#include <vk_layer.h>
39#include <vk_icd.h>
Chia-I Wu1d6731b2015-04-11 15:34:07 +080040#include <assert.h>
41
Chia-I Wu468e3c32014-08-04 08:03:57 +080042#if defined(__GNUC__) && __GNUC__ >= 4
43# define LOADER_EXPORT __attribute__((visibility("default")))
44#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
45# define LOADER_EXPORT __attribute__((visibility("default")))
46#else
47# define LOADER_EXPORT
48#endif
49
Jon Ashburn0b728052015-08-04 10:22:33 -060050#define MAX_STRING_SIZE 1024
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -060051#define VK_MAJOR(version) (version >> 22)
52#define VK_MINOR(version) ((version >> 12) & 0x3ff)
53#define VK_PATCH(version) (version & 0xfff)
Jon Ashburnfce93d92015-05-12 17:26:48 -060054
Jon Ashburn68a63922015-07-02 09:40:15 -060055enum layer_type {
Jon Ashburn535bd002015-07-02 16:10:32 -060056 VK_LAYER_TYPE_DEVICE_EXPLICIT = 0x1,
57 VK_LAYER_TYPE_INSTANCE_EXPLICIT = 0x2,
58 VK_LAYER_TYPE_GLOBAL_EXPLICIT = 0x3, // both instance and device layer, bitwise
59 VK_LAYER_TYPE_DEVICE_IMPLICIT = 0x4,
60 VK_LAYER_TYPE_INSTANCE_IMPLICIT = 0x8,
61 VK_LAYER_TYPE_GLOBAL_IMPLICIT = 0xc, // both instance and device layer, bitwise
Jon Ashburn68a63922015-07-02 09:40:15 -060062};
63
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060064struct loader_extension_list {
65 size_t capacity;
66 uint32_t count;
Jon Ashburnc4748dc2015-08-04 11:14:18 -060067 VkExtensionProperties *list;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060068};
69
Jon Ashburn68a63922015-07-02 09:40:15 -060070struct loader_name_value {
Jon Ashburn0b728052015-08-04 10:22:33 -060071 char name[MAX_STRING_SIZE];
72 char value[MAX_STRING_SIZE];
Jon Ashburn68a63922015-07-02 09:40:15 -060073};
74
75struct loader_lib_info {
Jon Ashburne9ca8fa2015-08-20 16:35:30 -060076 char lib_name[MAX_STRING_SIZE];
Jon Ashburn68a63922015-07-02 09:40:15 -060077 uint32_t ref_count;
78 loader_platform_dl_handle lib_handle;
79};
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060080
Jon Ashburn68a63922015-07-02 09:40:15 -060081struct loader_layer_functions {
Jon Ashburn0b728052015-08-04 10:22:33 -060082 char str_gipa[MAX_STRING_SIZE];
83 char str_gdpa[MAX_STRING_SIZE];
Jon Ashburn68a63922015-07-02 09:40:15 -060084 PFN_vkGetInstanceProcAddr get_instance_proc_addr;
85 PFN_vkGetDeviceProcAddr get_device_proc_addr;
86};
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060087
Jon Ashburn68a63922015-07-02 09:40:15 -060088struct loader_layer_properties {
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -060089 VkLayerProperties info;
Jon Ashburn68a63922015-07-02 09:40:15 -060090 enum layer_type type;
Jon Ashburne9ca8fa2015-08-20 16:35:30 -060091 char lib_name[MAX_STRING_SIZE];
Jon Ashburn68a63922015-07-02 09:40:15 -060092 struct loader_layer_functions functions;
93 struct loader_extension_list instance_extension_list;
94 struct loader_extension_list device_extension_list;
95 struct loader_name_value disable_env_var;
96 struct loader_name_value enable_env_var;
97};
98
99struct loader_layer_list {
100 size_t capacity;
101 uint32_t count;
102 struct loader_layer_properties *list;
Jon Ashburnfce93d92015-05-12 17:26:48 -0600103};
104
Courtney Goeltzenleuchterc5cf7d72015-07-05 12:53:31 -0600105struct loader_layer_library_list {
106 size_t capacity;
107 uint32_t count;
108 struct loader_lib_info *list;
109};
110
Jon Ashburncb5a5ac2015-06-10 10:06:06 -0600111/* per CreateDevice structure */
112struct loader_device {
113 VkLayerDispatchTable loader_dispatch;
114 VkDevice device; // device object from the icd
115
116 uint32_t app_extension_count;
117 VkExtensionProperties *app_extension_props;
118
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -0600119 struct loader_layer_list activated_layer_list;
Jon Ashburncb5a5ac2015-06-10 10:06:06 -0600120
121 struct loader_device *next;
122};
123
Jon Ashburn60699262015-06-10 16:11:42 -0600124/* per ICD structure */
Jon Ashburn2666e2f2015-05-15 15:09:35 -0600125struct loader_icd {
Jon Ashburne9ca8fa2015-08-20 16:35:30 -0600126 // pointers to find other structs
127 const struct loader_scanned_icds *this_icd_lib;
128 const struct loader_instance *this_instance;
Jon Ashburn2666e2f2015-05-15 15:09:35 -0600129
Jon Ashburncb5a5ac2015-06-10 10:06:06 -0600130 struct loader_device *logical_device_list;
Jon Ashburn2666e2f2015-05-15 15:09:35 -0600131 VkInstance instance; // instance object from the icd
Jon Ashburn1245cec2015-05-18 13:20:15 -0600132 PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
Jon Ashburn2666e2f2015-05-15 15:09:35 -0600133 PFN_vkDestroyInstance DestroyInstance;
134 PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
Chris Forbesd7576302015-06-21 22:55:02 +1200135 PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures;
Courtney Goeltzenleuchter4da96aa2015-07-12 12:52:09 -0600136 PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties;
Jon Ashburn4e189562015-07-23 18:49:07 -0600137 PFN_vkGetPhysicalDeviceImageFormatProperties GetPhysicalDeviceImageFormatProperties;
Jon Ashburn2666e2f2015-05-15 15:09:35 -0600138 PFN_vkCreateDevice CreateDevice;
Tony Barbour426b9052015-06-24 16:06:58 -0600139 PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
Cody Northropef72e2a2015-08-03 17:04:53 -0600140 PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties;
Tony Barbour426b9052015-06-24 16:06:58 -0600141 PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
Courtney Goeltzenleuchter74c4ce92015-09-14 17:22:16 -0600142 PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties;
Mark Lobodzinski83d4e6a2015-07-03 15:58:09 -0600143 PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600144 PFN_vkDbgCreateMsgCallback DbgCreateMsgCallback;
145 PFN_vkDbgDestroyMsgCallback DbgDestroyMsgCallback;
Ian Elliott338dedb2015-08-21 15:09:33 -0600146 PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -0600147
Jon Ashburncb5a5ac2015-06-10 10:06:06 -0600148 struct loader_icd *next;
Jon Ashburn2666e2f2015-05-15 15:09:35 -0600149};
150
Jon Ashburn754f1992015-08-18 18:04:47 -0600151/* per ICD library structure */
152struct loader_icd_libs {
153 size_t capacity;
154 uint32_t count;
155 struct loader_scanned_icds *list;
156};
157
Jon Ashburn60699262015-06-10 16:11:42 -0600158/* per instance structure */
Jon Ashburnfce93d92015-05-12 17:26:48 -0600159struct loader_instance {
Jon Ashburn2666e2f2015-05-15 15:09:35 -0600160 VkLayerInstanceDispatchTable *disp; // must be first entry in structure
161
Jon Ashburnfce93d92015-05-12 17:26:48 -0600162 uint32_t total_gpu_count;
Jon Ashburn251258f2015-11-01 14:04:06 -0700163 struct loader_physical_device *phys_devs;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600164 uint32_t total_icd_count;
Jon Ashburnfce93d92015-05-12 17:26:48 -0600165 struct loader_icd *icds;
166 struct loader_instance *next;
Jon Ashburn85f98072015-08-14 14:49:22 -0600167 struct loader_extension_list ext_list; // icds and loaders extensions
Jon Ashburn754f1992015-08-18 18:04:47 -0600168 struct loader_icd_libs icd_libs;
Jon Ashburne9ca8fa2015-08-20 16:35:30 -0600169 struct loader_layer_list instance_layer_list;
170 struct loader_layer_list device_layer_list;
171
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600172 struct loader_msg_callback_map_entry *icd_msg_callback_map;
173
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -0600174 struct loader_layer_list activated_layer_list;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600175
176 bool debug_report_enabled;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600177 VkLayerDbgFunctionNode *DbgFunctionHead;
Courtney Goeltzenleuchterb620ace2015-07-05 11:28:29 -0600178
Chia-I Wu1f851912015-10-27 18:04:07 +0800179 VkAllocationCallbacks alloc_callbacks;
Ian Elliott1d73e662015-07-06 14:36:13 -0600180
181 bool wsi_swapchain_enabled;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600182};
183
Jon Ashburn251258f2015-11-01 14:04:06 -0700184/* per enumerated PhysicalDevice structure */
185struct loader_physical_device {
186 VkLayerInstanceDispatchTable *disp; // must be first entry in structure
187 struct loader_instance *this_instance;
188 struct loader_icd *this_icd;
189 VkPhysicalDevice phys_dev; // object from ICD
190 /*
191 * Fill in the cache of available device extensions from
Jon Ashburndb5a5bc2015-11-02 17:40:01 -0700192 * this physical device. This cache can be used during CreateDevice
Jon Ashburn251258f2015-11-01 14:04:06 -0700193 */
194 struct loader_extension_list device_extension_cache;
195};
196
Jon Ashburnfce93d92015-05-12 17:26:48 -0600197struct loader_struct {
198 struct loader_instance *instances;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600199
200 unsigned int loaded_layer_lib_count;
Courtney Goeltzenleuchtera2f21d02015-10-07 09:00:34 -0600201 size_t loaded_layer_lib_capacity;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600202 struct loader_lib_info *loaded_layer_lib_list;
Jon Ashburn754f1992015-08-18 18:04:47 -0600203 // TODO add ref counting of ICD libraries
Jon Ashburn1b111de2015-07-06 15:40:35 -0600204 // TODO use this struct loader_layer_library_list scanned_layer_libraries;
Jon Ashburn754f1992015-08-18 18:04:47 -0600205 // TODO add list of icd libraries for ref counting them for closure
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600206};
207
208struct loader_scanned_icds {
209 char *lib_name;
210 loader_platform_dl_handle handle;
211
Jon Ashburnce7e3d92015-07-16 10:17:29 -0600212 PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600213 PFN_vkCreateInstance CreateInstance;
Courtney Goeltzenleuchter74c4ce92015-09-14 17:22:16 -0600214 PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
Jon Ashburnfce93d92015-05-12 17:26:48 -0600215};
216
Jon Ashburn68a63922015-07-02 09:40:15 -0600217static inline struct loader_instance *loader_instance(VkInstance instance) {
218 return (struct loader_instance *) instance;
219}
220
Tony Barbourde4124d2015-07-03 10:33:54 -0600221static inline void loader_set_dispatch(void* obj, const void *data)
Chia-I Wu1d6731b2015-04-11 15:34:07 +0800222{
223 *((const void **) obj) = data;
224}
225
Tony Barbourde4124d2015-07-03 10:33:54 -0600226static inline VkLayerDispatchTable *loader_get_dispatch(const void* obj)
Chia-I Wu1d6731b2015-04-11 15:34:07 +0800227{
Jon Ashburnda7c20d2015-05-01 18:00:33 -0600228 return *((VkLayerDispatchTable **) obj);
Chia-I Wu1d6731b2015-04-11 15:34:07 +0800229}
230
Tony Barbourde4124d2015-07-03 10:33:54 -0600231static inline VkLayerInstanceDispatchTable *loader_get_instance_dispatch(const void* obj)
Jon Ashburnfce93d92015-05-12 17:26:48 -0600232{
233 return *((VkLayerInstanceDispatchTable **) obj);
234}
235
Tony Barbourde4124d2015-07-03 10:33:54 -0600236static inline void loader_init_dispatch(void* obj, const void *data)
Chia-I Wu1d6731b2015-04-11 15:34:07 +0800237{
Jon Ashburn166641e2015-04-15 13:34:33 -0600238#ifdef DEBUG
Chia-I Wu1d6731b2015-04-11 15:34:07 +0800239 assert(valid_loader_magic_value(obj) &&
240 "Incompatible ICD, first dword must be initialized to ICD_LOADER_MAGIC. See loader/README.md for details.");
Jon Ashburn166641e2015-04-15 13:34:33 -0600241#endif
Chia-I Wu1d6731b2015-04-11 15:34:07 +0800242
Jon Ashburnda7c20d2015-05-01 18:00:33 -0600243 loader_set_dispatch(obj, data);
Chia-I Wu1d6731b2015-04-11 15:34:07 +0800244}
245
Jon Ashburnfce93d92015-05-12 17:26:48 -0600246/* global variables used across files */
247extern struct loader_struct loader;
Jon Ashburn413d6582015-08-28 15:19:27 -0600248extern THREAD_LOCAL_DECL struct loader_instance *tls_instance;
Jon Ashburn754f1992015-08-18 18:04:47 -0600249extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_init);
Jon Ashburnb40f2562015-05-29 13:15:39 -0600250extern loader_platform_thread_mutex loader_lock;
Jon Ashburnd02fc2c2015-09-22 13:11:00 -0600251extern loader_platform_thread_mutex loader_json_lock;
Jon Ashburnb40f2562015-05-29 13:15:39 -0600252extern const VkLayerInstanceDispatchTable instance_disp;
Jon Ashburn301c5f02015-04-06 10:58:22 -0600253
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600254struct loader_msg_callback_map_entry {
255 VkDbgMsgCallback icd_obj;
256 VkDbgMsgCallback loader_obj;
257};
258
259bool compare_vk_extension_properties(
260 const VkExtensionProperties* op1,
261 const VkExtensionProperties* op2);
262
Jon Ashburne9ca8fa2015-08-20 16:35:30 -0600263VkResult loader_validate_layers(
264 const uint32_t layer_count,
265 const char * const *ppEnabledLayerNames,
266 const struct loader_layer_list *list);
Courtney Goeltzenleuchter5d9f29b2015-07-06 17:45:08 -0600267
268VkResult loader_validate_instance_extensions(
Jon Ashburnc1d1eb72015-08-14 11:57:54 -0600269 const struct loader_extension_list *icd_exts,
Jon Ashburn182b8302015-08-11 14:49:54 -0600270 const struct loader_layer_list *instance_layer,
Courtney Goeltzenleuchter5d9f29b2015-07-06 17:45:08 -0600271 const VkInstanceCreateInfo* pCreateInfo);
272
Jon Ashburnfce93d92015-05-12 17:26:48 -0600273/* instance layer chain termination entrypoint definitions */
Dan Ginsburgf99e4102015-07-23 13:15:00 -0400274VkResult VKAPI loader_CreateInstance(
Jon Ashburnfce93d92015-05-12 17:26:48 -0600275 const VkInstanceCreateInfo* pCreateInfo,
Chia-I Wu1f851912015-10-27 18:04:07 +0800276 const VkAllocationCallbacks* pAllocator,
Jon Ashburnfce93d92015-05-12 17:26:48 -0600277 VkInstance* pInstance);
Chia-I Wu1d6731b2015-04-11 15:34:07 +0800278
Mark Lobodzinski67b42b72015-09-07 13:59:43 -0600279void VKAPI loader_DestroyInstance(
Chia-I Wu69f40122015-10-26 21:10:41 +0800280 VkInstance instance,
Chia-I Wu1f851912015-10-27 18:04:07 +0800281 const VkAllocationCallbacks* pAllocator);
Jon Ashburnfce93d92015-05-12 17:26:48 -0600282
Dan Ginsburgf99e4102015-07-23 13:15:00 -0400283VkResult VKAPI loader_EnumeratePhysicalDevices(
Jon Ashburnfce93d92015-05-12 17:26:48 -0600284 VkInstance instance,
285 uint32_t* pPhysicalDeviceCount,
286 VkPhysicalDevice* pPhysicalDevices);
Chris Forbesd7576302015-06-21 22:55:02 +1200287
Courtney Goeltzenleuchter01d2ae12015-10-20 16:40:38 -0600288void VKAPI loader_GetPhysicalDeviceFeatures(
Chris Forbesd7576302015-06-21 22:55:02 +1200289 VkPhysicalDevice physicalDevice,
290 VkPhysicalDeviceFeatures* pFeatures);
291
Courtney Goeltzenleuchter01d2ae12015-10-20 16:40:38 -0600292void VKAPI loader_GetPhysicalDeviceFormatProperties(
Chris Forbesd7576302015-06-21 22:55:02 +1200293 VkPhysicalDevice physicalDevice,
294 VkFormat format,
295 VkFormatProperties* pFormatInfo);
296
Chia-I Wu5202c542015-10-31 00:31:16 +0800297VkResult VKAPI loader_GetPhysicalDeviceImageFormatProperties(
298 VkPhysicalDevice physicalDevice,
Jon Ashburn4e189562015-07-23 18:49:07 -0600299 VkFormat format,
300 VkImageType type,
301 VkImageTiling tiling,
302 VkImageUsageFlags usage,
Courtney Goeltzenleuchter83c95f82015-09-10 13:44:12 -0600303 VkImageCreateFlags flags,
Jon Ashburn4e189562015-07-23 18:49:07 -0600304 VkImageFormatProperties* pImageFormatProperties);
305
Courtney Goeltzenleuchter01d2ae12015-10-20 16:40:38 -0600306void VKAPI loader_GetPhysicalDeviceSparseImageFormatProperties(
Mark Lobodzinski83d4e6a2015-07-03 15:58:09 -0600307 VkPhysicalDevice physicalDevice,
308 VkFormat format,
309 VkImageType type,
Chia-I Wu3138d6a2015-10-31 00:31:16 +0800310 VkSampleCountFlagBits samples,
Mark Lobodzinski83d4e6a2015-07-03 15:58:09 -0600311 VkImageUsageFlags usage,
312 VkImageTiling tiling,
313 uint32_t* pNumProperties,
314 VkSparseImageFormatProperties* pProperties);
Tony Barbour426b9052015-06-24 16:06:58 -0600315
Courtney Goeltzenleuchter01d2ae12015-10-20 16:40:38 -0600316void VKAPI loader_GetPhysicalDeviceProperties (
Tony Barbour426b9052015-06-24 16:06:58 -0600317 VkPhysicalDevice physicalDevice,
318 VkPhysicalDeviceProperties* pProperties);
319
Courtney Goeltzenleuchter74c4ce92015-09-14 17:22:16 -0600320VkResult VKAPI loader_EnumerateDeviceExtensionProperties (VkPhysicalDevice physicalDevice,
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -0600321 const char *pLayerName, uint32_t *pCount,
Tony Barbour426b9052015-06-24 16:06:58 -0600322 VkExtensionProperties* pProperties);
323
Courtney Goeltzenleuchter74c4ce92015-09-14 17:22:16 -0600324VkResult VKAPI loader_EnumerateDeviceLayerProperties (VkPhysicalDevice physicalDevice,
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -0600325 uint32_t *pCount,
326 VkLayerProperties* pProperties);
Tony Barbour426b9052015-06-24 16:06:58 -0600327
Courtney Goeltzenleuchter01d2ae12015-10-20 16:40:38 -0600328void VKAPI loader_GetPhysicalDeviceQueueFamilyProperties (
Cody Northropef72e2a2015-08-03 17:04:53 -0600329 VkPhysicalDevice physicalDevice,
330 uint32_t* pCount,
331 VkQueueFamilyProperties* pProperties);
Tony Barbour426b9052015-06-24 16:06:58 -0600332
Courtney Goeltzenleuchter01d2ae12015-10-20 16:40:38 -0600333void VKAPI loader_GetPhysicalDeviceMemoryProperties (
Tony Barbour426b9052015-06-24 16:06:58 -0600334 VkPhysicalDevice physicalDevice,
335 VkPhysicalDeviceMemoryProperties * pProperties);
Jon Ashburnb40f2562015-05-29 13:15:39 -0600336
Dan Ginsburgf99e4102015-07-23 13:15:00 -0400337VkResult VKAPI loader_CreateDevice(
Jon Ashburn2666e2f2015-05-15 15:09:35 -0600338 VkPhysicalDevice gpu,
339 const VkDeviceCreateInfo* pCreateInfo,
Chia-I Wu1f851912015-10-27 18:04:07 +0800340 const VkAllocationCallbacks* pAllocator,
Jon Ashburn2666e2f2015-05-15 15:09:35 -0600341 VkDevice* pDevice);
Jon Ashburnfce93d92015-05-12 17:26:48 -0600342
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600343/* helper function definitions */
Jon Ashburn754f1992015-08-18 18:04:47 -0600344void loader_initialize(void);
Jon Ashburn60378412015-07-02 12:59:25 -0600345bool has_vk_extension_property_array(
346 const VkExtensionProperties *vk_ext_prop,
347 const uint32_t count,
348 const VkExtensionProperties *ext_array);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600349bool has_vk_extension_property(
350 const VkExtensionProperties *vk_ext_prop,
351 const struct loader_extension_list *ext_list);
Jon Ashburnfce93d92015-05-12 17:26:48 -0600352
Jon Ashburn251258f2015-11-01 14:04:06 -0700353VkResult loader_add_to_ext_list(
Jon Ashburne58f1a32015-08-28 13:38:21 -0600354 const struct loader_instance *inst,
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600355 struct loader_extension_list *ext_list,
356 uint32_t prop_list_count,
Jon Ashburnc4748dc2015-08-04 11:14:18 -0600357 const VkExtensionProperties *props);
Jon Ashburne58f1a32015-08-28 13:38:21 -0600358void loader_destroy_ext_list(
359 const struct loader_instance *inst,
360 struct loader_extension_list *ext_info);
361void loader_delete_layer_properties(
362 const struct loader_instance *inst,
363 struct loader_layer_list *layer_list);
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -0600364void loader_add_to_layer_list(
Jon Ashburne58f1a32015-08-28 13:38:21 -0600365 const struct loader_instance *inst,
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -0600366 struct loader_layer_list *list,
367 uint32_t prop_list_count,
368 const struct loader_layer_properties *props);
Jon Ashburne58f1a32015-08-28 13:38:21 -0600369void loader_scanned_icd_clear(
370 const struct loader_instance *inst,
371 struct loader_icd_libs *icd_libs);
372void loader_icd_scan(
373 const struct loader_instance *inst,
374 struct loader_icd_libs *icds);
Jon Ashburn182b8302015-08-11 14:49:54 -0600375void loader_layer_scan(
Jon Ashburne58f1a32015-08-28 13:38:21 -0600376 const struct loader_instance *inst,
Jon Ashburn182b8302015-08-11 14:49:54 -0600377 struct loader_layer_list *instance_layers,
378 struct loader_layer_list *device_layers);
Jon Ashburn754f1992015-08-18 18:04:47 -0600379void loader_get_icd_loader_instance_extensions(
Jon Ashburne58f1a32015-08-28 13:38:21 -0600380 const struct loader_instance *inst,
Jon Ashburn754f1992015-08-18 18:04:47 -0600381 struct loader_icd_libs *icd_libs,
382 struct loader_extension_list *inst_exts);
Jon Ashburne58f1a32015-08-28 13:38:21 -0600383struct loader_icd *loader_get_icd_and_device(
384 const VkDevice device,
385 struct loader_device **found_dev);
Jon Ashburn0c5eea22015-09-30 12:56:42 -0600386struct loader_instance *loader_get_instance(
387 const VkInstance instance);
Jon Ashburne58f1a32015-08-28 13:38:21 -0600388void loader_remove_logical_device(
389 const struct loader_instance *inst,
390 VkDevice device);
Jon Ashburn182b8302015-08-11 14:49:54 -0600391VkResult loader_enable_instance_layers(
392 struct loader_instance *inst,
393 const VkInstanceCreateInfo *pCreateInfo,
394 const struct loader_layer_list *instance_layers);
Jon Ashburncb5a5ac2015-06-10 10:06:06 -0600395void loader_deactivate_instance_layers(struct loader_instance *instance);
Jon Ashburnfce93d92015-05-12 17:26:48 -0600396uint32_t loader_activate_instance_layers(struct loader_instance *inst);
Courtney Goeltzenleuchter23b5f8d2015-06-17 20:51:59 -0600397void loader_activate_instance_layer_extensions(struct loader_instance *inst);
Courtney Goeltzenleuchterb620ace2015-07-05 11:28:29 -0600398
399void* loader_heap_alloc(
Jon Ashburne58f1a32015-08-28 13:38:21 -0600400 const struct loader_instance *instance,
Jon Ashburn182b8302015-08-11 14:49:54 -0600401 size_t size,
Chia-I Wu1f851912015-10-27 18:04:07 +0800402 VkSystemAllocationScope allocationScope);
Courtney Goeltzenleuchterb620ace2015-07-05 11:28:29 -0600403
Courtney Goeltzenleuchterb620ace2015-07-05 11:28:29 -0600404void loader_heap_free(
Jon Ashburne58f1a32015-08-28 13:38:21 -0600405 const struct loader_instance *instance,
Chia-I Wu1f851912015-10-27 18:04:07 +0800406 void *pMemory);
Jon Ashburn413d6582015-08-28 15:19:27 -0600407
408void *loader_tls_heap_alloc(size_t size);
409
Chia-I Wu1f851912015-10-27 18:04:07 +0800410void loader_tls_heap_free(void *pMemory);
Chia-I Wu468e3c32014-08-04 08:03:57 +0800411#endif /* LOADER_H */