blob: fb0bc89631f45f33c0920113692b1e9982ed0007 [file] [log] [blame]
Chia-I Wu19300602014-08-04 08:03:57 +08001/*
Chia-I Wu19300602014-08-04 08:03:57 +08002 *
Jon Ashburn23d36b12016-02-02 17:47:28 -07003 * Copyright (c) 2014-2016 The Khronos Group Inc.
4 * Copyright (c) 2014-2016 Valve Corporation
5 * Copyright (c) 2014-2016 LunarG, Inc.
Courtney Goeltzenleuchterf821dad2015-12-02 14:53:22 -07006 * Copyright (C) 2015 Google Inc.
Chia-I Wu19300602014-08-04 08:03:57 +08007 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -06008 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
Chia-I Wu19300602014-08-04 08:03:57 +080011 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -060012 * http://www.apache.org/licenses/LICENSE-2.0
Chia-I Wu19300602014-08-04 08:03:57 +080013 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -060014 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
Jon Ashburn23d36b12016-02-02 17:47:28 -070019 *
20 * Author: Jon Ashburn <jon@lunarg.com>
21 * Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
Courtney Goeltzenleuchter05559522015-10-30 11:14:30 -060022 * Author: Chia-I Wu <olvaffe@gmail.com>
23 * Author: Chia-I Wu <olv@lunarg.com>
Jon Ashburn23d36b12016-02-02 17:47:28 -070024 * Author: Mark Lobodzinski <mark@LunarG.com>
Courtney Goeltzenleuchter05559522015-10-30 11:14:30 -060025 *
Chia-I Wu19300602014-08-04 08:03:57 +080026 */
27
28#ifndef LOADER_H
29#define LOADER_H
30
David Pinedo9316d3b2015-11-06 12:54:48 -070031#include <vulkan/vulkan.h>
Aaron Karp848bad42016-03-13 16:41:59 -040032#include "vk_loader_platform.h"
Mark Lobodzinskib87f9022016-05-24 16:04:56 -060033#include "vk_loader_layer.h"
David Pinedo9316d3b2015-11-06 12:54:48 -070034#include <vulkan/vk_layer.h>
Mark Lobodzinskib87f9022016-05-24 16:04:56 -060035
David Pinedo9316d3b2015-11-06 12:54:48 -070036#include <vulkan/vk_icd.h>
Chia-I Wu5291c762015-04-11 15:34:07 +080037#include <assert.h>
38
Chia-I Wu19300602014-08-04 08:03:57 +080039#if defined(__GNUC__) && __GNUC__ >= 4
Jon Ashburn23d36b12016-02-02 17:47:28 -070040#define LOADER_EXPORT __attribute__((visibility("default")))
Chia-I Wu19300602014-08-04 08:03:57 +080041#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
Jon Ashburn23d36b12016-02-02 17:47:28 -070042#define LOADER_EXPORT __attribute__((visibility("default")))
Chia-I Wu19300602014-08-04 08:03:57 +080043#else
Jon Ashburn23d36b12016-02-02 17:47:28 -070044#define LOADER_EXPORT
Chia-I Wu19300602014-08-04 08:03:57 +080045#endif
46
Mark Young0ad83132016-06-30 13:02:42 -060047// A debug option to disable allocators at compile time to investigate future issues.
48#define DEBUG_DISABLE_APP_ALLOCATORS 0
49
Jon Ashburnf73e9212015-08-04 10:22:33 -060050#define MAX_STRING_SIZE 1024
Courtney Goeltzenleuchter110fdf92015-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 Ashburn27cd5842015-05-12 17:26:48 -060054
Mark Young39389872017-01-19 21:10:49 -070055// This is defined in vk_layer.h, but if there's problems we need to create the define
56// here.
57#ifndef MAX_NUM_UNKNOWN_EXTS
58#define MAX_NUM_UNKNOWN_EXTS 250
59#endif
60
Jon Ashburn5ef20602015-07-02 09:40:15 -060061enum layer_type {
Jon Ashburn491cd042016-05-16 14:01:18 -060062 VK_LAYER_TYPE_INSTANCE_EXPLICIT = 0x1,
63 VK_LAYER_TYPE_INSTANCE_IMPLICIT = 0x2,
64 VK_LAYER_TYPE_META_EXPLICT = 0x4,
Jon Ashburn5ef20602015-07-02 09:40:15 -060065};
66
Mark Lobodzinskie9f09ef2016-02-02 18:53:34 -070067typedef enum VkStringErrorFlagBits {
Jon Ashburnf2b4e382016-02-10 20:50:19 -070068 VK_STRING_ERROR_NONE = 0x00000000,
69 VK_STRING_ERROR_LENGTH = 0x00000001,
70 VK_STRING_ERROR_BAD_DATA = 0x00000002,
Mark Lobodzinskie9f09ef2016-02-02 18:53:34 -070071} VkStringErrorFlagBits;
72typedef VkFlags VkStringErrorFlags;
73
Jon Ashburnf2b4e382016-02-10 20:50:19 -070074static const int MaxLoaderStringLength = 256;
75static const char UTF8_ONE_BYTE_CODE = 0xC0;
76static const char UTF8_ONE_BYTE_MASK = 0xE0;
77static const char UTF8_TWO_BYTE_CODE = 0xE0;
78static const char UTF8_TWO_BYTE_MASK = 0xF0;
79static const char UTF8_THREE_BYTE_CODE = 0xF0;
80static const char UTF8_THREE_BYTE_MASK = 0xF8;
81static const char UTF8_DATA_BYTE_CODE = 0x80;
82static const char UTF8_DATA_BYTE_MASK = 0xC0;
Mark Lobodzinskie9f09ef2016-02-02 18:53:34 -070083
Mark Lobodzinskied566c32016-06-29 14:18:30 -060084static const char std_validation_names[7][VK_MAX_EXTENSION_NAME_SIZE] = {
Mark Lobodzinski729a8d32017-01-26 12:16:30 -070085 "VK_LAYER_GOOGLE_threading", "VK_LAYER_LUNARG_parameter_validation", "VK_LAYER_LUNARG_object_tracker",
86 "VK_LAYER_LUNARG_image", "VK_LAYER_LUNARG_core_validation", "VK_LAYER_LUNARG_swapchain",
87 "VK_LAYER_GOOGLE_unique_objects"};
Jon Ashburn86a527a2016-02-10 20:59:26 -070088
Mark Young39389872017-01-19 21:10:49 -070089struct VkStructureHeader {
90 VkStructureType sType;
Mark Lobodzinski729a8d32017-01-26 12:16:30 -070091 const void *pNext;
Mark Young39389872017-01-19 21:10:49 -070092};
93
Jon Ashburn6e6a2162015-12-10 08:51:10 -070094// form of all dynamic lists/arrays
95// only the list element should be changed
96struct loader_generic_list {
97 size_t capacity;
98 uint32_t count;
99 void *list;
100};
101
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600102struct loader_extension_list {
103 size_t capacity;
104 uint32_t count;
Jon Ashburn5c042ea2015-08-04 11:14:18 -0600105 VkExtensionProperties *list;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600106};
107
Jon Ashburn39fbd4e2015-12-10 18:17:34 -0700108struct loader_dev_ext_props {
109 VkExtensionProperties props;
110 uint32_t entrypoint_count;
111 char **entrypoints;
112};
113
114struct loader_device_extension_list {
115 size_t capacity;
116 uint32_t count;
117 struct loader_dev_ext_props *list;
118};
119
Jon Ashburn5ef20602015-07-02 09:40:15 -0600120struct loader_name_value {
Jon Ashburnf73e9212015-08-04 10:22:33 -0600121 char name[MAX_STRING_SIZE];
122 char value[MAX_STRING_SIZE];
Jon Ashburn5ef20602015-07-02 09:40:15 -0600123};
124
Jon Ashburn5ef20602015-07-02 09:40:15 -0600125struct loader_layer_functions {
Jon Ashburnf73e9212015-08-04 10:22:33 -0600126 char str_gipa[MAX_STRING_SIZE];
127 char str_gdpa[MAX_STRING_SIZE];
Mark Young39389872017-01-19 21:10:49 -0700128 char str_negotiate_interface[MAX_STRING_SIZE];
129 PFN_vkNegotiateLoaderLayerInterfaceVersion negotiate_layer_interface;
Jon Ashburn5ef20602015-07-02 09:40:15 -0600130 PFN_vkGetInstanceProcAddr get_instance_proc_addr;
131 PFN_vkGetDeviceProcAddr get_device_proc_addr;
Mark Young39389872017-01-19 21:10:49 -0700132 PFN_GetPhysicalDeviceProcAddr get_physical_device_proc_addr;
Jon Ashburn5ef20602015-07-02 09:40:15 -0600133};
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600134
Jon Ashburn5ef20602015-07-02 09:40:15 -0600135struct loader_layer_properties {
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600136 VkLayerProperties info;
Jon Ashburn5ef20602015-07-02 09:40:15 -0600137 enum layer_type type;
Mark Lobodzinski64318ba2017-01-26 13:34:13 -0700138 uint32_t interface_version; // PFN_vkNegotiateLoaderLayerInterfaceVersion
Jon Ashburn3d002332015-08-20 16:35:30 -0600139 char lib_name[MAX_STRING_SIZE];
Jon Ashburn4dc1d8a2016-04-20 13:21:17 -0600140 loader_platform_dl_handle lib_handle;
Jon Ashburn5ef20602015-07-02 09:40:15 -0600141 struct loader_layer_functions functions;
142 struct loader_extension_list instance_extension_list;
Jon Ashburn39fbd4e2015-12-10 18:17:34 -0700143 struct loader_device_extension_list device_extension_list;
Jon Ashburn5ef20602015-07-02 09:40:15 -0600144 struct loader_name_value disable_env_var;
145 struct loader_name_value enable_env_var;
146};
147
148struct loader_layer_list {
149 size_t capacity;
150 uint32_t count;
151 struct loader_layer_properties *list;
Jon Ashburn27cd5842015-05-12 17:26:48 -0600152};
153
Jon Ashburnfc1031e2015-11-17 15:31:02 -0700154struct loader_dispatch_hash_list {
155 size_t capacity;
156 uint32_t count;
Mark Lobodzinski64318ba2017-01-26 13:34:13 -0700157 uint32_t *index; // index into the dev_ext dispatch table
Jon Ashburnfc1031e2015-11-17 15:31:02 -0700158};
159
Mark Young8191d9f2016-09-02 11:41:28 -0600160// loader_dispatch_hash_entry and loader_dev_ext_dispatch_table.dev_ext have
161// one to one correspondence; one loader_dispatch_hash_entry for one dev_ext
162// dispatch entry.
Jon Ashburnfc1031e2015-11-17 15:31:02 -0700163// Also have a one to one correspondence with functions in dev_ext_trampoline.c
164struct loader_dispatch_hash_entry {
165 char *func_name;
Mark Lobodzinski64318ba2017-01-26 13:34:13 -0700166 struct loader_dispatch_hash_list list; // to handle hashing collisions
Jon Ashburnfc1031e2015-11-17 15:31:02 -0700167};
168
Jon Ashburn23d36b12016-02-02 17:47:28 -0700169typedef void(VKAPI_PTR *PFN_vkDevExt)(VkDevice device);
Jon Ashburnfc1031e2015-11-17 15:31:02 -0700170struct loader_dev_ext_dispatch_table {
Mark Young39389872017-01-19 21:10:49 -0700171 PFN_vkDevExt dev_ext[MAX_NUM_UNKNOWN_EXTS];
Jon Ashburnfc1031e2015-11-17 15:31:02 -0700172};
173
174struct loader_dev_dispatch_table {
175 VkLayerDispatchTable core_dispatch;
176 struct loader_dev_ext_dispatch_table ext_dispatch;
177};
178
Mark Young35159af2016-09-07 08:50:32 -0600179// per CreateDevice structure
Jon Ashburndc6fcad2015-06-10 10:06:06 -0600180struct loader_device {
Jon Ashburnfc1031e2015-11-17 15:31:02 -0700181 struct loader_dev_dispatch_table loader_dispatch;
Mark Lobodzinski64318ba2017-01-26 13:34:13 -0700182 VkDevice chain_device; // device object from the dispatch chain
183 VkDevice icd_device; // device object from the icd
Mark Young65cb3662016-11-07 13:27:02 -0700184 struct loader_physical_device_term *phys_dev_term;
Jon Ashburndc6fcad2015-06-10 10:06:06 -0600185
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600186 struct loader_layer_list activated_layer_list;
Jon Ashburndc6fcad2015-06-10 10:06:06 -0600187
Mark Young0ad83132016-06-30 13:02:42 -0600188 VkAllocationCallbacks alloc_callbacks;
189
Jon Ashburndc6fcad2015-06-10 10:06:06 -0600190 struct loader_device *next;
191};
192
Jon Ashburn953bb3c2015-06-10 16:11:42 -0600193/* per ICD structure */
Mark Young0153e0b2016-11-03 14:27:13 -0600194struct loader_icd_term {
Jon Ashburn3d002332015-08-20 16:35:30 -0600195 // pointers to find other structs
Mark Young0153e0b2016-11-03 14:27:13 -0600196 const struct loader_scanned_icd *scanned_icd;
Jon Ashburn3d002332015-08-20 16:35:30 -0600197 const struct loader_instance *this_instance;
Jon Ashburndc6fcad2015-06-10 10:06:06 -0600198 struct loader_device *logical_device_list;
Mark Lobodzinski64318ba2017-01-26 13:34:13 -0700199 VkInstance instance; // instance object from the icd
Jon Ashburn8d1b0b52015-05-18 13:20:15 -0600200 PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600201 PFN_vkDestroyInstance DestroyInstance;
202 PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
Chris Forbesbc0bb772015-06-21 22:55:02 +1200203 PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures;
Courtney Goeltzenleuchter2caec862015-07-12 12:52:09 -0600204 PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties;
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700205 PFN_vkGetPhysicalDeviceImageFormatProperties GetPhysicalDeviceImageFormatProperties;
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600206 PFN_vkCreateDevice CreateDevice;
Tony Barbour59a47322015-06-24 16:06:58 -0600207 PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700208 PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties;
Tony Barbour59a47322015-06-24 16:06:58 -0600209 PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
Courtney Goeltzenleuchter35985f62015-09-14 17:22:16 -0600210 PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties;
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700211 PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties;
Mark Young39389872017-01-19 21:10:49 -0700212 // WSI extensions
Ian Elliott7e40db92015-08-21 15:09:33 -0600213 PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700214 PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR GetPhysicalDeviceSurfaceCapabilitiesKHR;
Ian Elliott486c5502015-11-19 16:05:09 -0700215 PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR;
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700216 PFN_vkGetPhysicalDeviceSurfacePresentModesKHR GetPhysicalDeviceSurfacePresentModesKHR;
Ian Elliott919fa302015-11-24 15:39:10 -0700217#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Young16573c72016-06-28 10:52:43 -0600218 PFN_vkCreateWin32SurfaceKHR CreateWin32SurfaceKHR;
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700219 PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR GetPhysicalDeviceWin32PresentationSupportKHR;
Ian Elliott919fa302015-11-24 15:39:10 -0700220#endif
221#ifdef VK_USE_PLATFORM_MIR_KHR
Mark Young16573c72016-06-28 10:52:43 -0600222 PFN_vkCreateMirSurfaceKHR CreateMirSurfaceKHR;
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700223 PFN_vkGetPhysicalDeviceMirPresentationSupportKHR GetPhysicalDeviceMirPresentationSupportKHR;
Ian Elliott919fa302015-11-24 15:39:10 -0700224#endif
225#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Mark Young16573c72016-06-28 10:52:43 -0600226 PFN_vkCreateWaylandSurfaceKHR CreateWaylandSurfaceKHR;
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700227 PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR GetPhysicalDeviceWaylandPresentationSupportKHR;
Ian Elliott919fa302015-11-24 15:39:10 -0700228#endif
229#ifdef VK_USE_PLATFORM_XCB_KHR
Mark Young16573c72016-06-28 10:52:43 -0600230 PFN_vkCreateXcbSurfaceKHR CreateXcbSurfaceKHR;
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700231 PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR GetPhysicalDeviceXcbPresentationSupportKHR;
Ian Elliott919fa302015-11-24 15:39:10 -0700232#endif
233#ifdef VK_USE_PLATFORM_XLIB_KHR
Mark Young16573c72016-06-28 10:52:43 -0600234 PFN_vkCreateXlibSurfaceKHR CreateXlibSurfaceKHR;
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700235 PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR GetPhysicalDeviceXlibPresentationSupportKHR;
Ian Elliott919fa302015-11-24 15:39:10 -0700236#endif
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700237 PFN_vkGetPhysicalDeviceDisplayPropertiesKHR GetPhysicalDeviceDisplayPropertiesKHR;
238 PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR GetPhysicalDeviceDisplayPlanePropertiesKHR;
239 PFN_vkGetDisplayPlaneSupportedDisplaysKHR GetDisplayPlaneSupportedDisplaysKHR;
Jon Ashburncc407a22016-04-15 09:25:03 -0600240 PFN_vkGetDisplayModePropertiesKHR GetDisplayModePropertiesKHR;
241 PFN_vkCreateDisplayModeKHR CreateDisplayModeKHR;
242 PFN_vkGetDisplayPlaneCapabilitiesKHR GetDisplayPlaneCapabilitiesKHR;
243 PFN_vkCreateDisplayPlaneSurfaceKHR CreateDisplayPlaneSurfaceKHR;
244 PFN_vkDestroySurfaceKHR DestroySurfaceKHR;
Mark Young16573c72016-06-28 10:52:43 -0600245 PFN_vkCreateSwapchainKHR CreateSwapchainKHR;
Mark Young39389872017-01-19 21:10:49 -0700246 PFN_vkCreateSharedSwapchainsKHR CreateSharedSwapchainsKHR;
247
248 // KHR_get_physical_device_properties2
249 PFN_vkGetPhysicalDeviceFeatures2KHR GetPhysicalDeviceFeatures2KHR;
250 PFN_vkGetPhysicalDeviceProperties2KHR GetPhysicalDeviceProperties2KHR;
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700251 PFN_vkGetPhysicalDeviceFormatProperties2KHR GetPhysicalDeviceFormatProperties2KHR;
252 PFN_vkGetPhysicalDeviceImageFormatProperties2KHR GetPhysicalDeviceImageFormatProperties2KHR;
253 PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR GetPhysicalDeviceQueueFamilyProperties2KHR;
254 PFN_vkGetPhysicalDeviceMemoryProperties2KHR GetPhysicalDeviceMemoryProperties2KHR;
255 PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR GetPhysicalDeviceSparseImageFormatProperties2KHR;
Mark Young39389872017-01-19 21:10:49 -0700256
257#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
258 // EXT_acquire_xlib_display
259 PFN_vkAcquireXlibDisplayEXT AcquireXlibDisplayEXT;
260 PFN_vkGetRandROutputDisplayEXT GetRandROutputDisplayEXT;
261#endif
262
263 // EXT_debug_report
264 PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallbackEXT;
265 PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallbackEXT;
266 PFN_vkDebugReportMessageEXT DebugReportMessageEXT;
267
268 // EXT_debug_marker (items needing a trampoline/terminator)
269 PFN_vkDebugMarkerSetObjectTagEXT DebugMarkerSetObjectTagEXT;
270 PFN_vkDebugMarkerSetObjectNameEXT DebugMarkerSetObjectNameEXT;
271
272 // EXT_direct_mode_display
273 PFN_vkReleaseDisplayEXT ReleaseDisplayEXT;
274
275 // EXT_display_surface_counter
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700276 PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT GetPhysicalDeviceSurfaceCapabilities2EXT;
Mark Young39389872017-01-19 21:10:49 -0700277
278 // NV_external_memory_capabilities
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700279 PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV GetPhysicalDeviceExternalImageFormatPropertiesNV;
Mark Youngfa552782016-12-12 16:14:55 -0700280
281 // NVX_device_generated_commands
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700282 PFN_vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX GetPhysicalDeviceGeneratedCommandsPropertiesNVX;
Mark Youngfa552782016-12-12 16:14:55 -0700283
Mark Young0153e0b2016-11-03 14:27:13 -0600284 struct loader_icd_term *next;
Mark Young39389872017-01-19 21:10:49 -0700285
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700286 PFN_PhysDevExt phys_dev_ext[MAX_NUM_UNKNOWN_EXTS];
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600287};
288
Mark Young35159af2016-09-07 08:50:32 -0600289// per ICD library structure
Mark Young0153e0b2016-11-03 14:27:13 -0600290struct loader_icd_tramp_list {
Jon Ashburn8810c5f2015-08-18 18:04:47 -0600291 size_t capacity;
292 uint32_t count;
Mark Young0153e0b2016-11-03 14:27:13 -0600293 struct loader_scanned_icd *scanned_list;
Jon Ashburn8810c5f2015-08-18 18:04:47 -0600294};
295
Mark Young35159af2016-09-07 08:50:32 -0600296union loader_instance_extension_enables {
297 struct {
Mark Young39389872017-01-19 21:10:49 -0700298 uint8_t khr_get_physical_device_properties2 : 1;
299 uint8_t ext_acquire_xlib_display : 1;
Mark Young0153e0b2016-11-03 14:27:13 -0600300 uint8_t ext_debug_report : 1;
Mark Young39389872017-01-19 21:10:49 -0700301 uint8_t ext_direct_mode_display : 1;
302 uint8_t ext_display_surface_counter : 1;
Mark Young35159af2016-09-07 08:50:32 -0600303 uint8_t nv_external_memory_capabilities : 1;
304 };
305 uint64_t padding[4];
306};
307
Mark Young39389872017-01-19 21:10:49 -0700308struct loader_instance_dispatch_table {
Mark Lobodzinski64318ba2017-01-26 13:34:13 -0700309 VkLayerInstanceDispatchTable layer_inst_disp; // must be first entry in structure
Mark Young39389872017-01-19 21:10:49 -0700310
311 // Physical device functions unknown to the loader
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700312 PFN_PhysDevExt phys_dev_ext[MAX_NUM_UNKNOWN_EXTS];
Mark Young39389872017-01-19 21:10:49 -0700313};
314
Mark Young35159af2016-09-07 08:50:32 -0600315// per instance structure
Jon Ashburn27cd5842015-05-12 17:26:48 -0600316struct loader_instance {
Mark Lobodzinski64318ba2017-01-26 13:34:13 -0700317 struct loader_instance_dispatch_table *disp; // must be first entry in structure
Jon Ashburn95a77ba2015-05-15 15:09:35 -0600318
Mark Young0153e0b2016-11-03 14:27:13 -0600319 uint32_t total_gpu_count;
Lenny Komow8a1f8a52016-12-20 15:35:11 -0700320 uint32_t phys_dev_count_term;
321 struct loader_physical_device_term **phys_devs_term;
Lenny Komowb9f70c32016-12-19 17:11:40 -0700322 uint32_t phys_dev_count_tramp;
323 struct loader_physical_device_tramp **phys_devs_tramp;
Mark Young0153e0b2016-11-03 14:27:13 -0600324
Jon Ashburn27cd5842015-05-12 17:26:48 -0600325 struct loader_instance *next;
Mark Young0153e0b2016-11-03 14:27:13 -0600326
327 uint32_t total_icd_count;
328 struct loader_icd_term *icd_terms;
329 struct loader_icd_tramp_list icd_tramp_list;
330
Mark Young39389872017-01-19 21:10:49 -0700331 struct loader_dispatch_hash_entry dev_ext_disp_hash[MAX_NUM_UNKNOWN_EXTS];
332 struct loader_dispatch_hash_entry phys_dev_ext_disp_hash[MAX_NUM_UNKNOWN_EXTS];
Jon Ashburn3d002332015-08-20 16:35:30 -0600333
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600334 struct loader_msg_callback_map_entry *icd_msg_callback_map;
335
Mark Young0153e0b2016-11-03 14:27:13 -0600336 struct loader_layer_list instance_layer_list;
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -0600337 struct loader_layer_list activated_layer_list;
Jon Ashburn491cd042016-05-16 14:01:18 -0600338 bool activated_layers_are_std_val;
Mark Lobodzinski64318ba2017-01-26 13:34:13 -0700339 VkInstance instance; // layers/ICD instance returned to trampoline
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700340
Mark Lobodzinski64318ba2017-01-26 13:34:13 -0700341 struct loader_extension_list ext_list; // icds and loaders extensions
Mark Young0153e0b2016-11-03 14:27:13 -0600342 union loader_instance_extension_enables enabled_known_extensions;
343
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600344 VkLayerDbgFunctionNode *DbgFunctionHead;
Ian Elliottad6300f2016-03-31 10:48:19 -0600345 uint32_t num_tmp_callbacks;
346 VkDebugReportCallbackCreateInfoEXT *tmp_dbg_create_infos;
347 VkDebugReportCallbackEXT *tmp_callbacks;
Courtney Goeltzenleuchter7f5aafc2015-07-05 11:28:29 -0600348
Chia-I Wu3432a0c2015-10-27 18:04:07 +0800349 VkAllocationCallbacks alloc_callbacks;
Ian Elliottd3ef02f2015-07-06 14:36:13 -0600350
Ian Elliott954fa342015-10-30 15:28:23 -0600351 bool wsi_surface_enabled;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700352#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600353 bool wsi_win32_surface_enabled;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700354#endif
355#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600356 bool wsi_mir_surface_enabled;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700357#endif
358#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600359 bool wsi_wayland_surface_enabled;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700360#endif
361#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600362 bool wsi_xcb_surface_enabled;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700363#endif
364#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600365 bool wsi_xlib_surface_enabled;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700366#endif
367#ifdef VK_USE_PLATFORM_ANDROID_KHR
368 bool wsi_android_surface_enabled;
369#endif
Jon Ashburnc7d3e732016-03-08 09:30:30 -0700370 bool wsi_display_enabled;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600371};
372
Jon Ashburn014438f2016-03-01 19:51:07 -0700373/* VkPhysicalDevice requires special treatment by loader. Firstly, terminator
Mark Young0153e0b2016-11-03 14:27:13 -0600374 * code must be able to get the struct loader_icd_term to call into the proper
Jon Ashburn014438f2016-03-01 19:51:07 -0700375 * driver (multiple ICD/gpu case). This can be accomplished by wrapping the
376 * created VkPhysicalDevice in loader terminate_EnumeratePhysicalDevices().
Piers Daniell295fe402016-03-29 11:51:11 -0600377 * Secondly, the loader must be able to handle wrapped by layer VkPhysicalDevice
Jon Ashburn014438f2016-03-01 19:51:07 -0700378 * in trampoline code. This implies, that the loader trampoline code must also
379 * wrap the VkPhysicalDevice object in trampoline code. Thus, loader has to
380 * wrap the VkPhysicalDevice created object twice. In trampoline code it can't
381 * rely on the terminator object wrapping since a layer may also wrap. Since
382 * trampoline code wraps the VkPhysicalDevice this means all loader trampoline
383 * code that passes a VkPhysicalDevice should unwrap it. */
384
385/* per enumerated PhysicalDevice structure, used to wrap in trampoline code and
386 also same structure used to wrap in terminator code */
Jon Ashburn787eb252016-03-24 15:49:57 -0600387struct loader_physical_device_tramp {
Mark Lobodzinski64318ba2017-01-26 13:34:13 -0700388 struct loader_instance_dispatch_table *disp; // must be first entry in structure
Piers Daniell295fe402016-03-29 11:51:11 -0600389 struct loader_instance *this_instance;
Mark Lobodzinski64318ba2017-01-26 13:34:13 -0700390 VkPhysicalDevice phys_dev; // object from layers/loader terminator
Jon Ashburn787eb252016-03-24 15:49:57 -0600391};
392
393/* per enumerated PhysicalDevice structure, used to wrap in terminator code */
Mark Young0153e0b2016-11-03 14:27:13 -0600394struct loader_physical_device_term {
Mark Lobodzinski64318ba2017-01-26 13:34:13 -0700395 struct loader_instance_dispatch_table *disp; // must be first entry in structure
Mark Young0153e0b2016-11-03 14:27:13 -0600396 struct loader_icd_term *this_icd_term;
Mark Young16573c72016-06-28 10:52:43 -0600397 uint8_t icd_index;
Mark Lobodzinski64318ba2017-01-26 13:34:13 -0700398 VkPhysicalDevice phys_dev; // object from ICD
Jon Ashburn24cd4be2015-11-01 14:04:06 -0700399};
400
Jon Ashburn27cd5842015-05-12 17:26:48 -0600401struct loader_struct {
402 struct loader_instance *instances;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600403};
404
Mark Young0153e0b2016-11-03 14:27:13 -0600405struct loader_scanned_icd {
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600406 char *lib_name;
407 loader_platform_dl_handle handle;
Jon Ashburn005617f2015-11-17 17:35:40 -0700408 uint32_t api_version;
Jon Ashburn17b4c862016-04-25 11:09:37 -0600409 uint32_t interface_version;
Jon Ashburnc624c882015-07-16 10:17:29 -0600410 PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
Mark Young39389872017-01-19 21:10:49 -0700411 PFN_GetPhysicalDeviceProcAddr GetPhysicalDeviceProcAddr;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600412 PFN_vkCreateInstance CreateInstance;
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700413 PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
Jon Ashburn27cd5842015-05-12 17:26:48 -0600414};
415
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700416static inline struct loader_instance *loader_instance(VkInstance instance) { return (struct loader_instance *)instance; }
Jon Ashburn5ef20602015-07-02 09:40:15 -0600417
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700418static inline VkPhysicalDevice loader_unwrap_physical_device(VkPhysicalDevice physicalDevice) {
419 struct loader_physical_device_tramp *phys_dev = (struct loader_physical_device_tramp *)physicalDevice;
Jon Ashburn014438f2016-03-01 19:51:07 -0700420 return phys_dev->phys_dev;
421}
422
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700423static inline void loader_set_dispatch(void *obj, const void *data) { *((const void **)obj) = data; }
Chia-I Wu5291c762015-04-11 15:34:07 +0800424
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700425static inline VkLayerDispatchTable *loader_get_dispatch(const void *obj) { return *((VkLayerDispatchTable **)obj); }
Chia-I Wu5291c762015-04-11 15:34:07 +0800426
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700427static inline struct loader_dev_dispatch_table *loader_get_dev_dispatch(const void *obj) {
Jon Ashburn23d36b12016-02-02 17:47:28 -0700428 return *((struct loader_dev_dispatch_table **)obj);
Jon Ashburnfc1031e2015-11-17 15:31:02 -0700429}
430
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700431static inline VkLayerInstanceDispatchTable *loader_get_instance_layer_dispatch(const void *obj) {
Jon Ashburn23d36b12016-02-02 17:47:28 -0700432 return *((VkLayerInstanceDispatchTable **)obj);
Jon Ashburn27cd5842015-05-12 17:26:48 -0600433}
434
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700435static inline struct loader_instance_dispatch_table *loader_get_instance_dispatch(const void *obj) {
Mark Young39389872017-01-19 21:10:49 -0700436 return *((struct loader_instance_dispatch_table **)obj);
437}
438
Jon Ashburn23d36b12016-02-02 17:47:28 -0700439static inline void loader_init_dispatch(void *obj, const void *data) {
Jon Ashburn40066642015-04-15 13:34:33 -0600440#ifdef DEBUG
Mark Lobodzinski64318ba2017-01-26 13:34:13 -0700441 assert(valid_loader_magic_value(obj) &&
442 "Incompatible ICD, first dword must be initialized to "
443 "ICD_LOADER_MAGIC. See loader/README.md for details.");
Jon Ashburn40066642015-04-15 13:34:33 -0600444#endif
Chia-I Wu5291c762015-04-11 15:34:07 +0800445
Jon Ashburn1ed042c2015-05-01 18:00:33 -0600446 loader_set_dispatch(obj, data);
Chia-I Wu5291c762015-04-11 15:34:07 +0800447}
448
Jon Ashburn27cd5842015-05-12 17:26:48 -0600449/* global variables used across files */
450extern struct loader_struct loader;
Jon Ashburn87d6aa92015-08-28 15:19:27 -0600451extern THREAD_LOCAL_DECL struct loader_instance *tls_instance;
Jon Ashburn8810c5f2015-08-18 18:04:47 -0600452extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_init);
Jon Ashburn6301a0f2015-05-29 13:15:39 -0600453extern loader_platform_thread_mutex loader_lock;
Jon Ashburn6461ef22015-09-22 13:11:00 -0600454extern loader_platform_thread_mutex loader_json_lock;
Jon Ashburn6301a0f2015-05-29 13:15:39 -0600455extern const VkLayerInstanceDispatchTable instance_disp;
Jon Ashburn86a527a2016-02-10 20:59:26 -0700456extern const char *std_validation_str;
Jon Ashburnbacb0f52015-04-06 10:58:22 -0600457
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600458struct loader_msg_callback_map_entry {
Courtney Goeltzenleuchter7415d5a2015-12-09 15:48:16 -0700459 VkDebugReportCallbackEXT icd_obj;
460 VkDebugReportCallbackEXT loader_obj;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600461};
462
Jon Ashburn1530c342016-02-26 13:14:27 -0700463/* helper function definitions */
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700464void *loader_instance_heap_alloc(const struct loader_instance *instance, size_t size, VkSystemAllocationScope allocationScope);
465void loader_instance_heap_free(const struct loader_instance *instance, void *pMemory);
466void *loader_instance_heap_realloc(const struct loader_instance *instance, void *pMemory, size_t orig_size, size_t size,
Mark Young0153e0b2016-11-03 14:27:13 -0600467 VkSystemAllocationScope alloc_scope);
Mark Young0ad83132016-06-30 13:02:42 -0600468void *loader_instance_tls_heap_alloc(size_t size);
469void loader_instance_tls_heap_free(void *pMemory);
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700470void *loader_device_heap_alloc(const struct loader_device *device, size_t size, VkSystemAllocationScope allocationScope);
Mark Young0ad83132016-06-30 13:02:42 -0600471void loader_device_heap_free(const struct loader_device *device, void *pMemory);
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700472void *loader_device_heap_realloc(const struct loader_device *device, void *pMemory, size_t orig_size, size_t size,
Mark Young0153e0b2016-11-03 14:27:13 -0600473 VkSystemAllocationScope alloc_scope);
Jon Ashburn1530c342016-02-26 13:14:27 -0700474
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700475void loader_log(const struct loader_instance *inst, VkFlags msg_type, int32_t msg_code, const char *format, ...);
Jon Ashburn2e37d752016-02-12 08:20:06 -0700476
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700477bool compare_vk_extension_properties(const VkExtensionProperties *op1, const VkExtensionProperties *op2);
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600478
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700479VkResult loader_validate_layers(const struct loader_instance *inst, const uint32_t layer_count,
480 const char *const *ppEnabledLayerNames, const struct loader_layer_list *list);
Courtney Goeltzenleuchter3b8c5ff2015-07-06 17:45:08 -0600481
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700482VkResult loader_validate_instance_extensions(const struct loader_instance *inst, const struct loader_extension_list *icd_exts,
483 const struct loader_layer_list *instance_layer,
484 const VkInstanceCreateInfo *pCreateInfo);
Courtney Goeltzenleuchter3b8c5ff2015-07-06 17:45:08 -0600485
Jon Ashburn8810c5f2015-08-18 18:04:47 -0600486void loader_initialize(void);
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700487VkResult loader_copy_layer_properties(const struct loader_instance *inst, struct loader_layer_properties *dst,
Mark Young0ad83132016-06-30 13:02:42 -0600488 struct loader_layer_properties *src);
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700489bool has_vk_extension_property_array(const VkExtensionProperties *vk_ext_prop, const uint32_t count,
Jon Ashburn23d36b12016-02-02 17:47:28 -0700490 const VkExtensionProperties *ext_array);
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700491bool has_vk_extension_property(const VkExtensionProperties *vk_ext_prop, const struct loader_extension_list *ext_list);
Jon Ashburn27cd5842015-05-12 17:26:48 -0600492
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700493VkResult loader_add_to_ext_list(const struct loader_instance *inst, struct loader_extension_list *ext_list,
494 uint32_t prop_list_count, const VkExtensionProperties *props);
495VkResult loader_add_to_dev_ext_list(const struct loader_instance *inst, struct loader_device_extension_list *ext_list,
496 const VkExtensionProperties *props, uint32_t entry_count, char **entrys);
Jon Ashburn1530c342016-02-26 13:14:27 -0700497VkResult loader_add_device_extensions(const struct loader_instance *inst,
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700498 PFN_vkEnumerateDeviceExtensionProperties fpEnumerateDeviceExtensionProperties,
499 VkPhysicalDevice physical_device, const char *lib_name,
Jon Ashburn1530c342016-02-26 13:14:27 -0700500 struct loader_extension_list *ext_list);
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700501VkResult loader_init_generic_list(const struct loader_instance *inst, struct loader_generic_list *list_info, size_t element_size);
502void loader_destroy_generic_list(const struct loader_instance *inst, struct loader_generic_list *list);
503void loader_destroy_layer_list(const struct loader_instance *inst, struct loader_device *device,
Jon Ashburn1530c342016-02-26 13:14:27 -0700504 struct loader_layer_list *layer_list);
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700505void loader_delete_layer_properties(const struct loader_instance *inst, struct loader_layer_list *layer_list);
506bool loader_find_layer_name_array(const char *name, uint32_t layer_count, const char layer_list[][VK_MAX_EXTENSION_NAME_SIZE]);
507VkResult loader_expand_layer_names(struct loader_instance *inst, const char *key_name, uint32_t expand_count,
508 const char expand_names[][VK_MAX_EXTENSION_NAME_SIZE], uint32_t *layer_count,
509 char const *const **ppp_layer_names);
Jon Ashburn491cd042016-05-16 14:01:18 -0600510void loader_init_std_validation_props(struct loader_layer_properties *props);
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700511void loader_delete_shadow_dev_layer_names(const struct loader_instance *inst, const VkDeviceCreateInfo *orig,
Chris Forbesbd9de052016-04-06 20:49:02 +1200512 VkDeviceCreateInfo *ours);
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700513void loader_delete_shadow_inst_layer_names(const struct loader_instance *inst, const VkInstanceCreateInfo *orig,
Chris Forbesbd9de052016-04-06 20:49:02 +1200514 VkInstanceCreateInfo *ours);
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700515VkResult loader_add_to_layer_list(const struct loader_instance *inst, struct loader_layer_list *list, uint32_t prop_list_count,
Mark Young0ad83132016-06-30 13:02:42 -0600516 const struct loader_layer_properties *props);
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700517void loader_find_layer_name_add_list(const struct loader_instance *inst, const char *name, const enum layer_type type,
518 const struct loader_layer_list *search_list, struct loader_layer_list *found_list);
519void loader_scanned_icd_clear(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list);
520VkResult loader_icd_scan(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list);
521void loader_layer_scan(const struct loader_instance *inst, struct loader_layer_list *instance_layers);
522void loader_implicit_layer_scan(const struct loader_instance *inst, struct loader_layer_list *instance_layers);
523VkResult loader_get_icd_loader_instance_extensions(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list,
524 struct loader_extension_list *inst_exts);
525struct loader_icd_term *loader_get_icd_and_device(const VkDevice device, struct loader_device **found_dev, uint32_t *icd_index);
526void loader_init_dispatch_dev_ext(struct loader_instance *inst, struct loader_device *dev);
Jon Ashburn23d36b12016-02-02 17:47:28 -0700527void *loader_dev_ext_gpa(struct loader_instance *inst, const char *funcName);
528void *loader_get_dev_ext_trampoline(uint32_t index);
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700529bool loader_phys_dev_ext_gpa(struct loader_instance *inst, const char *funcName, bool perform_checking, void **tramp_addr,
530 void **term_addr);
Mark Young39389872017-01-19 21:10:49 -0700531void *loader_get_phys_dev_ext_tramp(uint32_t index);
532void *loader_get_phys_dev_ext_termin(uint32_t index);
Jon Ashburn23d36b12016-02-02 17:47:28 -0700533struct loader_instance *loader_get_instance(const VkInstance instance);
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700534void loader_deactivate_layers(const struct loader_instance *instance, struct loader_device *device, struct loader_layer_list *list);
535struct loader_device *loader_create_logical_device(const struct loader_instance *inst, const VkAllocationCallbacks *pAllocator);
536void loader_add_logical_device(const struct loader_instance *inst, struct loader_icd_term *icd_term,
Piers Daniell295fe402016-03-29 11:51:11 -0600537 struct loader_device *found_dev);
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700538void loader_remove_logical_device(const struct loader_instance *inst, struct loader_icd_term *icd_term,
539 struct loader_device *found_dev, const VkAllocationCallbacks *pAllocator);
Mark Young0153e0b2016-11-03 14:27:13 -0600540// NOTE: Outside of loader, this entry-point is only proivided for error
541// cleanup.
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700542void loader_destroy_logical_device(const struct loader_instance *inst, struct loader_device *dev,
Mark Young0ad83132016-06-30 13:02:42 -0600543 const VkAllocationCallbacks *pAllocator);
544
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700545VkResult loader_enable_instance_layers(struct loader_instance *inst, const VkInstanceCreateInfo *pCreateInfo,
546 const struct loader_layer_list *instance_layers);
Jon Ashburndc6fcad2015-06-10 10:06:06 -0600547void loader_deactivate_instance_layers(struct loader_instance *instance);
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700548
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700549VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
550 struct loader_instance *inst, VkInstance *created_instance);
Courtney Goeltzenleuchter00150eb2016-01-08 12:18:43 -0700551
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700552void loader_activate_instance_layer_extensions(struct loader_instance *inst, VkInstance created_inst);
553VkResult loader_enable_device_layers(const struct loader_instance *inst, struct loader_layer_list *activated_layer_list,
554 const VkDeviceCreateInfo *pCreateInfo, const struct loader_layer_list *device_layers);
Courtney Goeltzenleuchter7f5aafc2015-07-05 11:28:29 -0600555
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700556VkResult loader_create_device_chain(const struct loader_physical_device_tramp *pd, const VkDeviceCreateInfo *pCreateInfo,
557 const VkAllocationCallbacks *pAllocator, const struct loader_instance *inst,
558 struct loader_device *dev);
Mark Young39389872017-01-19 21:10:49 -0700559
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700560VkResult loader_validate_device_extensions(struct loader_physical_device_tramp *phys_dev,
561 const struct loader_layer_list *activated_device_layers,
562 const struct loader_extension_list *icd_exts, const VkDeviceCreateInfo *pCreateInfo);
Courtney Goeltzenleuchter7f5aafc2015-07-05 11:28:29 -0600563
Mark Young6267ae62017-01-12 12:27:19 -0700564VkResult setupLoaderTrampPhysDevs(VkInstance instance);
565VkResult setupLoaderTermPhysDevs(struct loader_instance *inst);
566
Jon Ashburn1530c342016-02-26 13:14:27 -0700567/* instance layer chain termination entrypoint definitions */
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700568VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
569 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance);
Jon Ashburn87d6aa92015-08-28 15:19:27 -0600570
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700571VKAPI_ATTR void VKAPI_CALL terminator_DestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator);
Jon Ashburn87d6aa92015-08-28 15:19:27 -0600572
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700573VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
574 VkPhysicalDevice *pPhysicalDevices);
Jon Ashburn1530c342016-02-26 13:14:27 -0700575
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700576VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice,
577 VkPhysicalDeviceFeatures *pFeatures);
Jon Ashburn1530c342016-02-26 13:14:27 -0700578
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700579VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format,
580 VkFormatProperties *pFormatInfo);
Jon Ashburn1530c342016-02-26 13:14:27 -0700581
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700582VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format,
583 VkImageType type, VkImageTiling tiling,
584 VkImageUsageFlags usage, VkImageCreateFlags flags,
585 VkImageFormatProperties *pImageFormatProperties);
Jon Ashburn1530c342016-02-26 13:14:27 -0700586
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700587VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format,
588 VkImageType type, VkSampleCountFlagBits samples,
589 VkImageUsageFlags usage, VkImageTiling tiling,
590 uint32_t *pNumProperties,
591 VkSparseImageFormatProperties *pProperties);
Jon Ashburn1530c342016-02-26 13:14:27 -0700592
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700593VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
594 VkPhysicalDeviceProperties *pProperties);
Jon Ashburn1530c342016-02-26 13:14:27 -0700595
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700596VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
597 const char *pLayerName, uint32_t *pCount,
598 VkExtensionProperties *pProperties);
Jon Ashburn1530c342016-02-26 13:14:27 -0700599
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700600VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount,
601 VkLayerProperties *pProperties);
Jon Ashburn1530c342016-02-26 13:14:27 -0700602
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700603VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount,
604 VkQueueFamilyProperties *pProperties);
Jon Ashburn1530c342016-02-26 13:14:27 -0700605
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700606VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice,
607 VkPhysicalDeviceMemoryProperties *pProperties);
Jon Ashburn1530c342016-02-26 13:14:27 -0700608
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700609VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo,
610 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice);
Mark Lobodzinskie9f09ef2016-02-02 18:53:34 -0700611
Mark Lobodzinski729a8d32017-01-26 12:16:30 -0700612VkStringErrorFlags vk_string_validate(const int max_length, const char *char_array);
Mark Lobodzinskie9f09ef2016-02-02 18:53:34 -0700613
Chia-I Wu19300602014-08-04 08:03:57 +0800614#endif /* LOADER_H */