blob: 390d0cc4891e88c0332e686533eccd328434bf51 [file] [log] [blame]
Chia-I Wu19300602014-08-04 08:03:57 +08001/*
Chia-I Wu19300602014-08-04 08:03:57 +08002 *
Courtney Goeltzenleuchterfcbe16f2015-10-29 13:50:34 -06003 * Copyright (C) 2015 Valve Corporation
Chia-I Wu19300602014-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 Wu701f3f62014-09-02 08:32:09 +080022 *
Courtney Goeltzenleuchter05559522015-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 Wu19300602014-08-04 08:03:57 +080030 */
31
32#ifndef LOADER_H
33#define LOADER_H
34
David Pinedo9316d3b2015-11-06 12:54:48 -070035#include <vulkan/vulkan.h>
Jon Ashburn8a39efc2015-11-06 11:02:40 -070036#include <vk_loader_platform.h>
David Pinedo9316d3b2015-11-06 12:54:48 -070037#include <vulkan/vk_debug_report_lunarg.h>
38#include <vulkan/vk_ext_khr_swapchain.h>
39#include <vulkan/vk_layer.h>
40#include <vulkan/vk_icd.h>
Chia-I Wu5291c762015-04-11 15:34:07 +080041#include <assert.h>
42
Chia-I Wu19300602014-08-04 08:03:57 +080043#if defined(__GNUC__) && __GNUC__ >= 4
44# define LOADER_EXPORT __attribute__((visibility("default")))
45#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
46# define LOADER_EXPORT __attribute__((visibility("default")))
47#else
48# define LOADER_EXPORT
49#endif
50
Jon Ashburnf73e9212015-08-04 10:22:33 -060051#define MAX_STRING_SIZE 1024
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060052#define VK_MAJOR(version) (version >> 22)
53#define VK_MINOR(version) ((version >> 12) & 0x3ff)
54#define VK_PATCH(version) (version & 0xfff)
Jon Ashburn27cd5842015-05-12 17:26:48 -060055
Jon Ashburn5ef20602015-07-02 09:40:15 -060056enum layer_type {
Jon Ashburn0c26e712015-07-02 16:10:32 -060057 VK_LAYER_TYPE_DEVICE_EXPLICIT = 0x1,
58 VK_LAYER_TYPE_INSTANCE_EXPLICIT = 0x2,
59 VK_LAYER_TYPE_GLOBAL_EXPLICIT = 0x3, // both instance and device layer, bitwise
60 VK_LAYER_TYPE_DEVICE_IMPLICIT = 0x4,
61 VK_LAYER_TYPE_INSTANCE_IMPLICIT = 0x8,
62 VK_LAYER_TYPE_GLOBAL_IMPLICIT = 0xc, // both instance and device layer, bitwise
Jon Ashburn5ef20602015-07-02 09:40:15 -060063};
64
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -060065struct loader_extension_list {
66 size_t capacity;
67 uint32_t count;
Jon Ashburn5c042ea2015-08-04 11:14:18 -060068 VkExtensionProperties *list;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -060069};
70
Jon Ashburn5ef20602015-07-02 09:40:15 -060071struct loader_name_value {
Jon Ashburnf73e9212015-08-04 10:22:33 -060072 char name[MAX_STRING_SIZE];
73 char value[MAX_STRING_SIZE];
Jon Ashburn5ef20602015-07-02 09:40:15 -060074};
75
76struct loader_lib_info {
Jon Ashburn3d002332015-08-20 16:35:30 -060077 char lib_name[MAX_STRING_SIZE];
Jon Ashburn5ef20602015-07-02 09:40:15 -060078 uint32_t ref_count;
79 loader_platform_dl_handle lib_handle;
80};
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -060081
Jon Ashburn5ef20602015-07-02 09:40:15 -060082struct loader_layer_functions {
Jon Ashburnf73e9212015-08-04 10:22:33 -060083 char str_gipa[MAX_STRING_SIZE];
84 char str_gdpa[MAX_STRING_SIZE];
Jon Ashburn5ef20602015-07-02 09:40:15 -060085 PFN_vkGetInstanceProcAddr get_instance_proc_addr;
86 PFN_vkGetDeviceProcAddr get_device_proc_addr;
87};
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -060088
Jon Ashburn5ef20602015-07-02 09:40:15 -060089struct loader_layer_properties {
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060090 VkLayerProperties info;
Jon Ashburn5ef20602015-07-02 09:40:15 -060091 enum layer_type type;
Jon Ashburn3d002332015-08-20 16:35:30 -060092 char lib_name[MAX_STRING_SIZE];
Jon Ashburn5ef20602015-07-02 09:40:15 -060093 struct loader_layer_functions functions;
94 struct loader_extension_list instance_extension_list;
95 struct loader_extension_list device_extension_list;
96 struct loader_name_value disable_env_var;
97 struct loader_name_value enable_env_var;
98};
99
100struct loader_layer_list {
101 size_t capacity;
102 uint32_t count;
103 struct loader_layer_properties *list;
Jon Ashburn27cd5842015-05-12 17:26:48 -0600104};
105
Courtney Goeltzenleuchter371de702015-07-05 12:53:31 -0600106struct loader_layer_library_list {
107 size_t capacity;
108 uint32_t count;
109 struct loader_lib_info *list;
110};
111
Jon Ashburnfc1031e2015-11-17 15:31:02 -0700112struct loader_dispatch_hash_list {
113 size_t capacity;
114 uint32_t count;
115 uint32_t *index; // index into the dev_ext dispatch table
116};
117
118#define MAX_NUM_DEV_EXTS 250
119// loader_dispatch_hash_entry and loader_dev_ext_dispatch_table.DevExt have one to one
120// correspondence; one loader_dispatch_hash_entry for one DevExt dispatch entry.
121// Also have a one to one correspondence with functions in dev_ext_trampoline.c
122struct loader_dispatch_hash_entry {
123 char *func_name;
124 struct loader_dispatch_hash_list list; // to handle hashing collisions
125};
126
127typedef void (VKAPI_PTR *PFN_vkDevExt)(VkDevice device);
128struct loader_dev_ext_dispatch_table {
129 PFN_vkDevExt DevExt[MAX_NUM_DEV_EXTS];
130};
131
132struct loader_dev_dispatch_table {
133 VkLayerDispatchTable core_dispatch;
134 struct loader_dev_ext_dispatch_table ext_dispatch;
135};
136
Jon Ashburndc6fcad2015-06-10 10:06:06 -0600137/* per CreateDevice structure */
138struct loader_device {
Jon Ashburnfc1031e2015-11-17 15:31:02 -0700139 struct loader_dev_dispatch_table loader_dispatch;
Jon Ashburndc6fcad2015-06-10 10:06:06 -0600140 VkDevice device; // device object from the icd
141
142 uint32_t app_extension_count;
143 VkExtensionProperties *app_extension_props;
144
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600145 struct loader_layer_list activated_layer_list;
Jon Ashburndc6fcad2015-06-10 10:06:06 -0600146
147 struct loader_device *next;
148};
149
Jon Ashburn953bb3c2015-06-10 16:11:42 -0600150/* per ICD structure */
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600151struct loader_icd {
Jon Ashburn3d002332015-08-20 16:35:30 -0600152 // pointers to find other structs
153 const struct loader_scanned_icds *this_icd_lib;
154 const struct loader_instance *this_instance;
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600155
Jon Ashburndc6fcad2015-06-10 10:06:06 -0600156 struct loader_device *logical_device_list;
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600157 VkInstance instance; // instance object from the icd
Jon Ashburn8d1b0b52015-05-18 13:20:15 -0600158 PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600159 PFN_vkDestroyInstance DestroyInstance;
160 PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
Chris Forbesbc0bb772015-06-21 22:55:02 +1200161 PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures;
Courtney Goeltzenleuchter2caec862015-07-12 12:52:09 -0600162 PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties;
Jon Ashburn754864f2015-07-23 18:49:07 -0600163 PFN_vkGetPhysicalDeviceImageFormatProperties GetPhysicalDeviceImageFormatProperties;
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600164 PFN_vkCreateDevice CreateDevice;
Tony Barbour59a47322015-06-24 16:06:58 -0600165 PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
Cody Northropd0802882015-08-03 17:04:53 -0600166 PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties;
Tony Barbour59a47322015-06-24 16:06:58 -0600167 PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
Courtney Goeltzenleuchter35985f62015-09-14 17:22:16 -0600168 PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties;
Mark Lobodzinski16e8bef2015-07-03 15:58:09 -0600169 PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600170 PFN_vkDbgCreateMsgCallback DbgCreateMsgCallback;
171 PFN_vkDbgDestroyMsgCallback DbgDestroyMsgCallback;
Ian Elliott7e40db92015-08-21 15:09:33 -0600172 PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600173
Jon Ashburndc6fcad2015-06-10 10:06:06 -0600174 struct loader_icd *next;
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600175};
176
Jon Ashburn8810c5f2015-08-18 18:04:47 -0600177/* per ICD library structure */
178struct loader_icd_libs {
179 size_t capacity;
180 uint32_t count;
181 struct loader_scanned_icds *list;
182};
183
Jon Ashburn953bb3c2015-06-10 16:11:42 -0600184/* per instance structure */
Jon Ashburn27cd5842015-05-12 17:26:48 -0600185struct loader_instance {
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600186 VkLayerInstanceDispatchTable *disp; // must be first entry in structure
187
Jon Ashburn27cd5842015-05-12 17:26:48 -0600188 uint32_t total_gpu_count;
Jon Ashburn24cd4be2015-11-01 14:04:06 -0700189 struct loader_physical_device *phys_devs;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600190 uint32_t total_icd_count;
Jon Ashburn27cd5842015-05-12 17:26:48 -0600191 struct loader_icd *icds;
192 struct loader_instance *next;
Jon Ashburn5c6a46f2015-08-14 14:49:22 -0600193 struct loader_extension_list ext_list; // icds and loaders extensions
Jon Ashburn8810c5f2015-08-18 18:04:47 -0600194 struct loader_icd_libs icd_libs;
Jon Ashburn3d002332015-08-20 16:35:30 -0600195 struct loader_layer_list instance_layer_list;
196 struct loader_layer_list device_layer_list;
Jon Ashburnfc1031e2015-11-17 15:31:02 -0700197 struct loader_dispatch_hash_entry disp_hash[MAX_NUM_DEV_EXTS];
Jon Ashburn3d002332015-08-20 16:35:30 -0600198
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600199 struct loader_msg_callback_map_entry *icd_msg_callback_map;
200
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600201 struct loader_layer_list activated_layer_list;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600202
203 bool debug_report_enabled;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600204 VkLayerDbgFunctionNode *DbgFunctionHead;
Courtney Goeltzenleuchter7f5aafc2015-07-05 11:28:29 -0600205
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800206 VkAllocationCallbacks alloc_callbacks;
Ian Elliottd3ef02f2015-07-06 14:36:13 -0600207
208 bool wsi_swapchain_enabled;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600209};
210
Jon Ashburn24cd4be2015-11-01 14:04:06 -0700211/* per enumerated PhysicalDevice structure */
212struct loader_physical_device {
213 VkLayerInstanceDispatchTable *disp; // must be first entry in structure
214 struct loader_instance *this_instance;
215 struct loader_icd *this_icd;
216 VkPhysicalDevice phys_dev; // object from ICD
217 /*
218 * Fill in the cache of available device extensions from
Jon Ashburn00eb6c02015-11-02 17:40:01 -0700219 * this physical device. This cache can be used during CreateDevice
Jon Ashburn24cd4be2015-11-01 14:04:06 -0700220 */
221 struct loader_extension_list device_extension_cache;
222};
223
Jon Ashburn27cd5842015-05-12 17:26:48 -0600224struct loader_struct {
225 struct loader_instance *instances;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600226
227 unsigned int loaded_layer_lib_count;
Courtney Goeltzenleuchterdad30df2015-10-07 09:00:34 -0600228 size_t loaded_layer_lib_capacity;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600229 struct loader_lib_info *loaded_layer_lib_list;
Jon Ashburn8810c5f2015-08-18 18:04:47 -0600230 // TODO add ref counting of ICD libraries
Jon Ashburn2d0c4bb2015-07-06 15:40:35 -0600231 // TODO use this struct loader_layer_library_list scanned_layer_libraries;
Jon Ashburn8810c5f2015-08-18 18:04:47 -0600232 // TODO add list of icd libraries for ref counting them for closure
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600233};
234
235struct loader_scanned_icds {
236 char *lib_name;
237 loader_platform_dl_handle handle;
Jon Ashburn005617f2015-11-17 17:35:40 -0700238 uint32_t api_version;
Jon Ashburnc624c882015-07-16 10:17:29 -0600239 PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600240 PFN_vkCreateInstance CreateInstance;
Courtney Goeltzenleuchter35985f62015-09-14 17:22:16 -0600241 PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
Jon Ashburn27cd5842015-05-12 17:26:48 -0600242};
243
Jon Ashburn5ef20602015-07-02 09:40:15 -0600244static inline struct loader_instance *loader_instance(VkInstance instance) {
245 return (struct loader_instance *) instance;
246}
247
Tony Barbour1d2cd3f2015-07-03 10:33:54 -0600248static inline void loader_set_dispatch(void* obj, const void *data)
Chia-I Wu5291c762015-04-11 15:34:07 +0800249{
250 *((const void **) obj) = data;
251}
252
Tony Barbour1d2cd3f2015-07-03 10:33:54 -0600253static inline VkLayerDispatchTable *loader_get_dispatch(const void* obj)
Chia-I Wu5291c762015-04-11 15:34:07 +0800254{
Jon Ashburn1ed042c2015-05-01 18:00:33 -0600255 return *((VkLayerDispatchTable **) obj);
Chia-I Wu5291c762015-04-11 15:34:07 +0800256}
257
Jon Ashburnfc1031e2015-11-17 15:31:02 -0700258static inline struct loader_dev_dispatch_table *loader_get_dev_dispatch(const void* obj)
259{
260 return *((struct loader_dev_dispatch_table **) obj);
261}
262
Tony Barbour1d2cd3f2015-07-03 10:33:54 -0600263static inline VkLayerInstanceDispatchTable *loader_get_instance_dispatch(const void* obj)
Jon Ashburn27cd5842015-05-12 17:26:48 -0600264{
265 return *((VkLayerInstanceDispatchTable **) obj);
266}
267
Tony Barbour1d2cd3f2015-07-03 10:33:54 -0600268static inline void loader_init_dispatch(void* obj, const void *data)
Chia-I Wu5291c762015-04-11 15:34:07 +0800269{
Jon Ashburn40066642015-04-15 13:34:33 -0600270#ifdef DEBUG
Chia-I Wu5291c762015-04-11 15:34:07 +0800271 assert(valid_loader_magic_value(obj) &&
272 "Incompatible ICD, first dword must be initialized to ICD_LOADER_MAGIC. See loader/README.md for details.");
Jon Ashburn40066642015-04-15 13:34:33 -0600273#endif
Chia-I Wu5291c762015-04-11 15:34:07 +0800274
Jon Ashburn1ed042c2015-05-01 18:00:33 -0600275 loader_set_dispatch(obj, data);
Chia-I Wu5291c762015-04-11 15:34:07 +0800276}
277
Jon Ashburn27cd5842015-05-12 17:26:48 -0600278/* global variables used across files */
279extern struct loader_struct loader;
Jon Ashburn87d6aa92015-08-28 15:19:27 -0600280extern THREAD_LOCAL_DECL struct loader_instance *tls_instance;
Jon Ashburn8810c5f2015-08-18 18:04:47 -0600281extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_init);
Jon Ashburn6301a0f2015-05-29 13:15:39 -0600282extern loader_platform_thread_mutex loader_lock;
Jon Ashburn6461ef22015-09-22 13:11:00 -0600283extern loader_platform_thread_mutex loader_json_lock;
Jon Ashburn6301a0f2015-05-29 13:15:39 -0600284extern const VkLayerInstanceDispatchTable instance_disp;
Jon Ashburnbacb0f52015-04-06 10:58:22 -0600285
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600286struct loader_msg_callback_map_entry {
287 VkDbgMsgCallback icd_obj;
288 VkDbgMsgCallback loader_obj;
289};
290
291bool compare_vk_extension_properties(
292 const VkExtensionProperties* op1,
293 const VkExtensionProperties* op2);
294
Jon Ashburn3d002332015-08-20 16:35:30 -0600295VkResult loader_validate_layers(
296 const uint32_t layer_count,
297 const char * const *ppEnabledLayerNames,
298 const struct loader_layer_list *list);
Courtney Goeltzenleuchter3b8c5ff2015-07-06 17:45:08 -0600299
300VkResult loader_validate_instance_extensions(
Jon Ashburn9a4c6aa2015-08-14 11:57:54 -0600301 const struct loader_extension_list *icd_exts,
Jon Ashburnb82c1852015-08-11 14:49:54 -0600302 const struct loader_layer_list *instance_layer,
Courtney Goeltzenleuchter3b8c5ff2015-07-06 17:45:08 -0600303 const VkInstanceCreateInfo* pCreateInfo);
304
Jon Ashburn27cd5842015-05-12 17:26:48 -0600305/* instance layer chain termination entrypoint definitions */
Chia-I Wu9ab61502015-11-06 06:42:02 +0800306VKAPI_ATTR VkResult VKAPI_CALL loader_CreateInstance(
Jon Ashburn27cd5842015-05-12 17:26:48 -0600307 const VkInstanceCreateInfo* pCreateInfo,
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800308 const VkAllocationCallbacks* pAllocator,
Jon Ashburn27cd5842015-05-12 17:26:48 -0600309 VkInstance* pInstance);
Chia-I Wu5291c762015-04-11 15:34:07 +0800310
Chia-I Wu9ab61502015-11-06 06:42:02 +0800311VKAPI_ATTR void VKAPI_CALL loader_DestroyInstance(
Chia-I Wuf7458c52015-10-26 21:10:41 +0800312 VkInstance instance,
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800313 const VkAllocationCallbacks* pAllocator);
Jon Ashburn27cd5842015-05-12 17:26:48 -0600314
Chia-I Wu9ab61502015-11-06 06:42:02 +0800315VKAPI_ATTR VkResult VKAPI_CALL loader_EnumeratePhysicalDevices(
Jon Ashburn27cd5842015-05-12 17:26:48 -0600316 VkInstance instance,
317 uint32_t* pPhysicalDeviceCount,
318 VkPhysicalDevice* pPhysicalDevices);
Chris Forbesbc0bb772015-06-21 22:55:02 +1200319
Chia-I Wu9ab61502015-11-06 06:42:02 +0800320VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceFeatures(
Chris Forbesbc0bb772015-06-21 22:55:02 +1200321 VkPhysicalDevice physicalDevice,
322 VkPhysicalDeviceFeatures* pFeatures);
323
Chia-I Wu9ab61502015-11-06 06:42:02 +0800324VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceFormatProperties(
Chris Forbesbc0bb772015-06-21 22:55:02 +1200325 VkPhysicalDevice physicalDevice,
326 VkFormat format,
327 VkFormatProperties* pFormatInfo);
328
Chia-I Wu9ab61502015-11-06 06:42:02 +0800329VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceImageFormatProperties(
Chia-I Wu17241042015-10-31 00:31:16 +0800330 VkPhysicalDevice physicalDevice,
Jon Ashburn754864f2015-07-23 18:49:07 -0600331 VkFormat format,
332 VkImageType type,
333 VkImageTiling tiling,
334 VkImageUsageFlags usage,
Courtney Goeltzenleuchtera22097a2015-09-10 13:44:12 -0600335 VkImageCreateFlags flags,
Jon Ashburn754864f2015-07-23 18:49:07 -0600336 VkImageFormatProperties* pImageFormatProperties);
337
Chia-I Wu9ab61502015-11-06 06:42:02 +0800338VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceSparseImageFormatProperties(
Mark Lobodzinski16e8bef2015-07-03 15:58:09 -0600339 VkPhysicalDevice physicalDevice,
340 VkFormat format,
341 VkImageType type,
Chia-I Wu5c17c962015-10-31 00:31:16 +0800342 VkSampleCountFlagBits samples,
Mark Lobodzinski16e8bef2015-07-03 15:58:09 -0600343 VkImageUsageFlags usage,
344 VkImageTiling tiling,
345 uint32_t* pNumProperties,
346 VkSparseImageFormatProperties* pProperties);
Tony Barbour59a47322015-06-24 16:06:58 -0600347
Chia-I Wu9ab61502015-11-06 06:42:02 +0800348VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceProperties (
Tony Barbour59a47322015-06-24 16:06:58 -0600349 VkPhysicalDevice physicalDevice,
350 VkPhysicalDeviceProperties* pProperties);
351
Chia-I Wu9ab61502015-11-06 06:42:02 +0800352VKAPI_ATTR VkResult VKAPI_CALL loader_EnumerateDeviceExtensionProperties (VkPhysicalDevice physicalDevice,
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600353 const char *pLayerName, uint32_t *pCount,
Tony Barbour59a47322015-06-24 16:06:58 -0600354 VkExtensionProperties* pProperties);
355
Chia-I Wu9ab61502015-11-06 06:42:02 +0800356VKAPI_ATTR VkResult VKAPI_CALL loader_EnumerateDeviceLayerProperties (VkPhysicalDevice physicalDevice,
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600357 uint32_t *pCount,
358 VkLayerProperties* pProperties);
Tony Barbour59a47322015-06-24 16:06:58 -0600359
Chia-I Wu9ab61502015-11-06 06:42:02 +0800360VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceQueueFamilyProperties (
Cody Northropd0802882015-08-03 17:04:53 -0600361 VkPhysicalDevice physicalDevice,
362 uint32_t* pCount,
363 VkQueueFamilyProperties* pProperties);
Tony Barbour59a47322015-06-24 16:06:58 -0600364
Chia-I Wu9ab61502015-11-06 06:42:02 +0800365VKAPI_ATTR void VKAPI_CALL loader_GetPhysicalDeviceMemoryProperties (
Tony Barbour59a47322015-06-24 16:06:58 -0600366 VkPhysicalDevice physicalDevice,
367 VkPhysicalDeviceMemoryProperties * pProperties);
Jon Ashburn6301a0f2015-05-29 13:15:39 -0600368
Chia-I Wu9ab61502015-11-06 06:42:02 +0800369VKAPI_ATTR VkResult VKAPI_CALL loader_CreateDevice(
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600370 VkPhysicalDevice gpu,
371 const VkDeviceCreateInfo* pCreateInfo,
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800372 const VkAllocationCallbacks* pAllocator,
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600373 VkDevice* pDevice);
Jon Ashburn27cd5842015-05-12 17:26:48 -0600374
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600375/* helper function definitions */
Jon Ashburn8810c5f2015-08-18 18:04:47 -0600376void loader_initialize(void);
Jon Ashburnbd6c4882015-07-02 12:59:25 -0600377bool has_vk_extension_property_array(
378 const VkExtensionProperties *vk_ext_prop,
379 const uint32_t count,
380 const VkExtensionProperties *ext_array);
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600381bool has_vk_extension_property(
382 const VkExtensionProperties *vk_ext_prop,
383 const struct loader_extension_list *ext_list);
Jon Ashburn27cd5842015-05-12 17:26:48 -0600384
Jon Ashburn24cd4be2015-11-01 14:04:06 -0700385VkResult loader_add_to_ext_list(
Jon Ashburne39a4f82015-08-28 13:38:21 -0600386 const struct loader_instance *inst,
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600387 struct loader_extension_list *ext_list,
388 uint32_t prop_list_count,
Jon Ashburn5c042ea2015-08-04 11:14:18 -0600389 const VkExtensionProperties *props);
Jon Ashburne39a4f82015-08-28 13:38:21 -0600390void loader_destroy_ext_list(
391 const struct loader_instance *inst,
392 struct loader_extension_list *ext_info);
393void loader_delete_layer_properties(
394 const struct loader_instance *inst,
395 struct loader_layer_list *layer_list);
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600396void loader_add_to_layer_list(
Jon Ashburne39a4f82015-08-28 13:38:21 -0600397 const struct loader_instance *inst,
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600398 struct loader_layer_list *list,
399 uint32_t prop_list_count,
400 const struct loader_layer_properties *props);
Jon Ashburne39a4f82015-08-28 13:38:21 -0600401void loader_scanned_icd_clear(
402 const struct loader_instance *inst,
403 struct loader_icd_libs *icd_libs);
404void loader_icd_scan(
405 const struct loader_instance *inst,
406 struct loader_icd_libs *icds);
Jon Ashburnb82c1852015-08-11 14:49:54 -0600407void loader_layer_scan(
Jon Ashburne39a4f82015-08-28 13:38:21 -0600408 const struct loader_instance *inst,
Jon Ashburnb82c1852015-08-11 14:49:54 -0600409 struct loader_layer_list *instance_layers,
410 struct loader_layer_list *device_layers);
Jon Ashburn8810c5f2015-08-18 18:04:47 -0600411void loader_get_icd_loader_instance_extensions(
Jon Ashburne39a4f82015-08-28 13:38:21 -0600412 const struct loader_instance *inst,
Jon Ashburn8810c5f2015-08-18 18:04:47 -0600413 struct loader_icd_libs *icd_libs,
414 struct loader_extension_list *inst_exts);
Jon Ashburne39a4f82015-08-28 13:38:21 -0600415struct loader_icd *loader_get_icd_and_device(
416 const VkDevice device,
417 struct loader_device **found_dev);
Jon Ashburnfc1031e2015-11-17 15:31:02 -0700418void *loader_dev_ext_gpa(
419 struct loader_instance *inst,
420 const char *funcName);
421void *loader_get_dev_ext_trampoline(
422 uint32_t index);
Jon Ashburne0e64572015-09-30 12:56:42 -0600423struct loader_instance *loader_get_instance(
424 const VkInstance instance);
Jon Ashburne39a4f82015-08-28 13:38:21 -0600425void loader_remove_logical_device(
426 const struct loader_instance *inst,
Jon Ashburn781a7ae2015-11-19 15:43:26 -0700427 struct loader_icd *icd,
428 struct loader_device *found_dev);
Jon Ashburnb82c1852015-08-11 14:49:54 -0600429VkResult loader_enable_instance_layers(
430 struct loader_instance *inst,
431 const VkInstanceCreateInfo *pCreateInfo,
432 const struct loader_layer_list *instance_layers);
Jon Ashburndc6fcad2015-06-10 10:06:06 -0600433void loader_deactivate_instance_layers(struct loader_instance *instance);
Jon Ashburn27cd5842015-05-12 17:26:48 -0600434uint32_t loader_activate_instance_layers(struct loader_instance *inst);
Courtney Goeltzenleuchterd971b612015-06-17 20:51:59 -0600435void loader_activate_instance_layer_extensions(struct loader_instance *inst);
Courtney Goeltzenleuchter7f5aafc2015-07-05 11:28:29 -0600436
437void* loader_heap_alloc(
Jon Ashburne39a4f82015-08-28 13:38:21 -0600438 const struct loader_instance *instance,
Jon Ashburnb82c1852015-08-11 14:49:54 -0600439 size_t size,
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800440 VkSystemAllocationScope allocationScope);
Courtney Goeltzenleuchter7f5aafc2015-07-05 11:28:29 -0600441
Courtney Goeltzenleuchter7f5aafc2015-07-05 11:28:29 -0600442void loader_heap_free(
Jon Ashburne39a4f82015-08-28 13:38:21 -0600443 const struct loader_instance *instance,
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800444 void *pMemory);
Jon Ashburn87d6aa92015-08-28 15:19:27 -0600445
446void *loader_tls_heap_alloc(size_t size);
447
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800448void loader_tls_heap_free(void *pMemory);
Chia-I Wu19300602014-08-04 08:03:57 +0800449#endif /* LOADER_H */