blob: 019125f00bfb58bedeb0be8ff1f121b862efa025 [file] [log] [blame]
Chia-I Wuc1e0f962014-08-04 08:03:57 +08001/*
Chia-I Wuc1e0f962014-08-04 08:03:57 +08002 *
Jon Ashburn1c75aec2016-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 Goeltzenleuchter8e1b8d92015-12-02 14:53:22 -07006 * Copyright (C) 2015 Google Inc.
Chia-I Wuc1e0f962014-08-04 08:03:57 +08007 *
Jon Ashburn4f80d672016-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 Wuc1e0f962014-08-04 08:03:57 +080011 *
Jon Ashburn4f80d672016-04-19 11:30:31 -060012 * http://www.apache.org/licenses/LICENSE-2.0
Chia-I Wuc1e0f962014-08-04 08:03:57 +080013 *
Jon Ashburn4f80d672016-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 Ashburn1c75aec2016-02-02 17:47:28 -070019 *
20 * Author: Jon Ashburn <jon@lunarg.com>
21 * Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
Courtney Goeltzenleuchterb9ce3952015-10-30 11:14:30 -060022 * Author: Chia-I Wu <olvaffe@gmail.com>
23 * Author: Chia-I Wu <olv@lunarg.com>
Jon Ashburn1c75aec2016-02-02 17:47:28 -070024 * Author: Mark Lobodzinski <mark@LunarG.com>
Courtney Goeltzenleuchterb9ce3952015-10-30 11:14:30 -060025 *
Chia-I Wuc1e0f962014-08-04 08:03:57 +080026 */
27
28#ifndef LOADER_H
29#define LOADER_H
30
David Pinedoa5036622015-11-06 12:54:48 -070031#include <vulkan/vulkan.h>
Aaron Karp95c5f952016-03-13 16:41:59 -040032#include "vk_loader_platform.h"
Mark Lobodzinski663818f2016-05-24 16:04:56 -060033#include "vk_loader_layer.h"
David Pinedoa5036622015-11-06 12:54:48 -070034#include <vulkan/vk_layer.h>
Mark Lobodzinski663818f2016-05-24 16:04:56 -060035
David Pinedoa5036622015-11-06 12:54:48 -070036#include <vulkan/vk_icd.h>
Chia-I Wufe333ed2015-04-11 15:34:07 +080037#include <assert.h>
38
Chia-I Wuc1e0f962014-08-04 08:03:57 +080039#if defined(__GNUC__) && __GNUC__ >= 4
Jon Ashburn1c75aec2016-02-02 17:47:28 -070040#define LOADER_EXPORT __attribute__((visibility("default")))
Chia-I Wuc1e0f962014-08-04 08:03:57 +080041#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
Jon Ashburn1c75aec2016-02-02 17:47:28 -070042#define LOADER_EXPORT __attribute__((visibility("default")))
Chia-I Wuc1e0f962014-08-04 08:03:57 +080043#else
Jon Ashburn1c75aec2016-02-02 17:47:28 -070044#define LOADER_EXPORT
Chia-I Wuc1e0f962014-08-04 08:03:57 +080045#endif
46
Mark Young74dd5d12016-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 Ashburnb2379c52015-08-04 10:22:33 -060050#define MAX_STRING_SIZE 1024
Courtney Goeltzenleuchter44667cc2015-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 Ashburn13482452015-05-12 17:26:48 -060054
Mark Young274e4bc2017-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
61
Jon Ashburn399c9162015-07-02 09:40:15 -060062enum layer_type {
Jon Ashburnc325bc02016-05-16 14:01:18 -060063 VK_LAYER_TYPE_INSTANCE_EXPLICIT = 0x1,
64 VK_LAYER_TYPE_INSTANCE_IMPLICIT = 0x2,
65 VK_LAYER_TYPE_META_EXPLICT = 0x4,
Jon Ashburn399c9162015-07-02 09:40:15 -060066};
67
Mark Lobodzinski8d325802016-02-02 18:53:34 -070068typedef enum VkStringErrorFlagBits {
Jon Ashburnb1cdf2e2016-02-10 20:50:19 -070069 VK_STRING_ERROR_NONE = 0x00000000,
70 VK_STRING_ERROR_LENGTH = 0x00000001,
71 VK_STRING_ERROR_BAD_DATA = 0x00000002,
Mark Lobodzinski8d325802016-02-02 18:53:34 -070072} VkStringErrorFlagBits;
73typedef VkFlags VkStringErrorFlags;
74
Jon Ashburnb1cdf2e2016-02-10 20:50:19 -070075static const int MaxLoaderStringLength = 256;
76static const char UTF8_ONE_BYTE_CODE = 0xC0;
77static const char UTF8_ONE_BYTE_MASK = 0xE0;
78static const char UTF8_TWO_BYTE_CODE = 0xE0;
79static const char UTF8_TWO_BYTE_MASK = 0xF0;
80static const char UTF8_THREE_BYTE_CODE = 0xF0;
81static const char UTF8_THREE_BYTE_MASK = 0xF8;
82static const char UTF8_DATA_BYTE_CODE = 0x80;
83static const char UTF8_DATA_BYTE_MASK = 0xC0;
Mark Lobodzinski8d325802016-02-02 18:53:34 -070084
Mark Lobodzinskibf266f42016-06-29 14:18:30 -060085static const char std_validation_names[7][VK_MAX_EXTENSION_NAME_SIZE] = {
86 "VK_LAYER_GOOGLE_threading", "VK_LAYER_LUNARG_parameter_validation",
87 "VK_LAYER_LUNARG_object_tracker", "VK_LAYER_LUNARG_image",
88 "VK_LAYER_LUNARG_core_validation", "VK_LAYER_LUNARG_swapchain",
89 "VK_LAYER_GOOGLE_unique_objects"};
Jon Ashburnd1eb3322016-02-10 20:59:26 -070090
Mark Young274e4bc2017-01-19 21:10:49 -070091struct VkStructureHeader {
92 VkStructureType sType;
93 const void* pNext;
94};
95
Jon Ashburn6b00b472015-12-10 08:51:10 -070096// form of all dynamic lists/arrays
97// only the list element should be changed
98struct loader_generic_list {
99 size_t capacity;
100 uint32_t count;
101 void *list;
102};
103
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600104struct loader_extension_list {
105 size_t capacity;
106 uint32_t count;
Jon Ashburnb7d327c2015-08-04 11:14:18 -0600107 VkExtensionProperties *list;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600108};
109
Jon Ashburn92cdb012015-12-10 18:17:34 -0700110struct loader_dev_ext_props {
111 VkExtensionProperties props;
112 uint32_t entrypoint_count;
113 char **entrypoints;
114};
115
116struct loader_device_extension_list {
117 size_t capacity;
118 uint32_t count;
119 struct loader_dev_ext_props *list;
120};
121
Jon Ashburn399c9162015-07-02 09:40:15 -0600122struct loader_name_value {
Jon Ashburnb2379c52015-08-04 10:22:33 -0600123 char name[MAX_STRING_SIZE];
124 char value[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -0600125};
126
Jon Ashburn399c9162015-07-02 09:40:15 -0600127struct loader_layer_functions {
Jon Ashburnb2379c52015-08-04 10:22:33 -0600128 char str_gipa[MAX_STRING_SIZE];
129 char str_gdpa[MAX_STRING_SIZE];
Mark Young274e4bc2017-01-19 21:10:49 -0700130 char str_negotiate_interface[MAX_STRING_SIZE];
131 PFN_vkNegotiateLoaderLayerInterfaceVersion negotiate_layer_interface;
Jon Ashburn399c9162015-07-02 09:40:15 -0600132 PFN_vkGetInstanceProcAddr get_instance_proc_addr;
133 PFN_vkGetDeviceProcAddr get_device_proc_addr;
Mark Young274e4bc2017-01-19 21:10:49 -0700134 PFN_GetPhysicalDeviceProcAddr get_physical_device_proc_addr;
Jon Ashburn399c9162015-07-02 09:40:15 -0600135};
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600136
Jon Ashburn399c9162015-07-02 09:40:15 -0600137struct loader_layer_properties {
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600138 VkLayerProperties info;
Jon Ashburn399c9162015-07-02 09:40:15 -0600139 enum layer_type type;
Mark Young274e4bc2017-01-19 21:10:49 -0700140 uint32_t interface_version; // PFN_vkNegotiateLoaderLayerInterfaceVersion
Jon Ashburnb4c24232015-08-20 16:35:30 -0600141 char lib_name[MAX_STRING_SIZE];
Jon Ashburnd3cf9552016-04-20 13:21:17 -0600142 loader_platform_dl_handle lib_handle;
Jon Ashburn399c9162015-07-02 09:40:15 -0600143 struct loader_layer_functions functions;
144 struct loader_extension_list instance_extension_list;
Jon Ashburn92cdb012015-12-10 18:17:34 -0700145 struct loader_device_extension_list device_extension_list;
Jon Ashburn399c9162015-07-02 09:40:15 -0600146 struct loader_name_value disable_env_var;
147 struct loader_name_value enable_env_var;
148};
149
150struct loader_layer_list {
151 size_t capacity;
152 uint32_t count;
153 struct loader_layer_properties *list;
Jon Ashburn13482452015-05-12 17:26:48 -0600154};
155
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700156struct loader_dispatch_hash_list {
157 size_t capacity;
158 uint32_t count;
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700159 uint32_t *index; // index into the dev_ext dispatch table
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700160};
161
Mark Young274e4bc2017-01-19 21:10:49 -0700162
Mark Youngdd904ae2016-09-02 11:41:28 -0600163// loader_dispatch_hash_entry and loader_dev_ext_dispatch_table.dev_ext have
164// one to one correspondence; one loader_dispatch_hash_entry for one dev_ext
165// dispatch entry.
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700166// Also have a one to one correspondence with functions in dev_ext_trampoline.c
167struct loader_dispatch_hash_entry {
168 char *func_name;
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700169 struct loader_dispatch_hash_list list; // to handle hashing collisions
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700170};
171
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700172typedef void(VKAPI_PTR *PFN_vkDevExt)(VkDevice device);
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700173struct loader_dev_ext_dispatch_table {
Mark Young274e4bc2017-01-19 21:10:49 -0700174 PFN_vkDevExt dev_ext[MAX_NUM_UNKNOWN_EXTS];
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700175};
176
177struct loader_dev_dispatch_table {
178 VkLayerDispatchTable core_dispatch;
179 struct loader_dev_ext_dispatch_table ext_dispatch;
180};
181
Mark Young1d645262016-09-07 08:50:32 -0600182// per CreateDevice structure
Jon Ashburn10f4e822015-06-10 10:06:06 -0600183struct loader_device {
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700184 struct loader_dev_dispatch_table loader_dispatch;
Mark Young0f7adeb2016-11-07 13:27:02 -0700185 VkDevice chain_device; // device object from the dispatch chain
186 VkDevice icd_device; // device object from the icd
187 struct loader_physical_device_term *phys_dev_term;
Jon Ashburn10f4e822015-06-10 10:06:06 -0600188
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600189 struct loader_layer_list activated_layer_list;
Jon Ashburn10f4e822015-06-10 10:06:06 -0600190
Mark Young74dd5d12016-06-30 13:02:42 -0600191 VkAllocationCallbacks alloc_callbacks;
192
Jon Ashburn10f4e822015-06-10 10:06:06 -0600193 struct loader_device *next;
194};
195
Jon Ashburn392c5622015-06-10 16:11:42 -0600196/* per ICD structure */
Mark Young26c19372016-11-03 14:27:13 -0600197struct loader_icd_term {
Jon Ashburnb4c24232015-08-20 16:35:30 -0600198 // pointers to find other structs
Mark Young26c19372016-11-03 14:27:13 -0600199 const struct loader_scanned_icd *scanned_icd;
Jon Ashburnb4c24232015-08-20 16:35:30 -0600200 const struct loader_instance *this_instance;
Jon Ashburn10f4e822015-06-10 10:06:06 -0600201 struct loader_device *logical_device_list;
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700202 VkInstance instance; // instance object from the icd
Jon Ashburnc89dd4a2015-05-18 13:20:15 -0600203 PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600204 PFN_vkDestroyInstance DestroyInstance;
205 PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
Chris Forbes1c946ec2015-06-21 22:55:02 +1200206 PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures;
Courtney Goeltzenleuchter2b6559e2015-07-12 12:52:09 -0600207 PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties;
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700208 PFN_vkGetPhysicalDeviceImageFormatProperties
209 GetPhysicalDeviceImageFormatProperties;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600210 PFN_vkCreateDevice CreateDevice;
Tony Barbour4e657ba2015-06-24 16:06:58 -0600211 PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700212 PFN_vkGetPhysicalDeviceQueueFamilyProperties
213 GetPhysicalDeviceQueueFamilyProperties;
Tony Barbour4e657ba2015-06-24 16:06:58 -0600214 PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
Courtney Goeltzenleuchtere25064c2015-09-14 17:22:16 -0600215 PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties;
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700216 PFN_vkGetPhysicalDeviceSparseImageFormatProperties
217 GetPhysicalDeviceSparseImageFormatProperties;
Mark Young274e4bc2017-01-19 21:10:49 -0700218 // WSI extensions
Ian Elliottec736342015-08-21 15:09:33 -0600219 PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700220 PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR
221 GetPhysicalDeviceSurfaceCapabilitiesKHR;
Ian Elliottea666b22015-11-19 16:05:09 -0700222 PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR;
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700223 PFN_vkGetPhysicalDeviceSurfacePresentModesKHR
224 GetPhysicalDeviceSurfacePresentModesKHR;
Ian Elliotte851dd62015-11-24 15:39:10 -0700225#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Young5467d672016-06-28 10:52:43 -0600226 PFN_vkCreateWin32SurfaceKHR CreateWin32SurfaceKHR;
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700227 PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR
228 GetPhysicalDeviceWin32PresentationSupportKHR;
Ian Elliotte851dd62015-11-24 15:39:10 -0700229#endif
230#ifdef VK_USE_PLATFORM_MIR_KHR
Mark Young5467d672016-06-28 10:52:43 -0600231 PFN_vkCreateMirSurfaceKHR CreateMirSurfaceKHR;
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700232 PFN_vkGetPhysicalDeviceMirPresentationSupportKHR
Mark Lobodzinskib16da052016-08-31 09:31:29 -0600233 GetPhysicalDeviceMirPresentationSupportKHR;
Ian Elliotte851dd62015-11-24 15:39:10 -0700234#endif
235#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Mark Young5467d672016-06-28 10:52:43 -0600236 PFN_vkCreateWaylandSurfaceKHR CreateWaylandSurfaceKHR;
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700237 PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
238 GetPhysicalDeviceWaylandPresentationSupportKHR;
Ian Elliotte851dd62015-11-24 15:39:10 -0700239#endif
240#ifdef VK_USE_PLATFORM_XCB_KHR
Mark Young5467d672016-06-28 10:52:43 -0600241 PFN_vkCreateXcbSurfaceKHR CreateXcbSurfaceKHR;
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700242 PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR
243 GetPhysicalDeviceXcbPresentationSupportKHR;
Ian Elliotte851dd62015-11-24 15:39:10 -0700244#endif
245#ifdef VK_USE_PLATFORM_XLIB_KHR
Mark Young5467d672016-06-28 10:52:43 -0600246 PFN_vkCreateXlibSurfaceKHR CreateXlibSurfaceKHR;
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700247 PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR
248 GetPhysicalDeviceXlibPresentationSupportKHR;
Ian Elliotte851dd62015-11-24 15:39:10 -0700249#endif
Jon Ashburncc370d02016-03-08 09:30:30 -0700250 PFN_vkGetPhysicalDeviceDisplayPropertiesKHR
251 GetPhysicalDeviceDisplayPropertiesKHR;
252 PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR
253 GetPhysicalDeviceDisplayPlanePropertiesKHR;
254 PFN_vkGetDisplayPlaneSupportedDisplaysKHR
255 GetDisplayPlaneSupportedDisplaysKHR;
Jon Ashburnc466da52016-04-15 09:25:03 -0600256 PFN_vkGetDisplayModePropertiesKHR GetDisplayModePropertiesKHR;
257 PFN_vkCreateDisplayModeKHR CreateDisplayModeKHR;
258 PFN_vkGetDisplayPlaneCapabilitiesKHR GetDisplayPlaneCapabilitiesKHR;
259 PFN_vkCreateDisplayPlaneSurfaceKHR CreateDisplayPlaneSurfaceKHR;
260 PFN_vkDestroySurfaceKHR DestroySurfaceKHR;
Mark Young5467d672016-06-28 10:52:43 -0600261 PFN_vkCreateSwapchainKHR CreateSwapchainKHR;
Mark Young274e4bc2017-01-19 21:10:49 -0700262 PFN_vkCreateSharedSwapchainsKHR CreateSharedSwapchainsKHR;
263
264 // KHR_get_physical_device_properties2
265 PFN_vkGetPhysicalDeviceFeatures2KHR GetPhysicalDeviceFeatures2KHR;
266 PFN_vkGetPhysicalDeviceProperties2KHR GetPhysicalDeviceProperties2KHR;
267 PFN_vkGetPhysicalDeviceFormatProperties2KHR
268 GetPhysicalDeviceFormatProperties2KHR;
269 PFN_vkGetPhysicalDeviceImageFormatProperties2KHR
270 GetPhysicalDeviceImageFormatProperties2KHR;
271 PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR
272 GetPhysicalDeviceQueueFamilyProperties2KHR;
273 PFN_vkGetPhysicalDeviceMemoryProperties2KHR
274 GetPhysicalDeviceMemoryProperties2KHR;
275 PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR
276 GetPhysicalDeviceSparseImageFormatProperties2KHR;
277
278#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
279 // EXT_acquire_xlib_display
280 PFN_vkAcquireXlibDisplayEXT AcquireXlibDisplayEXT;
281 PFN_vkGetRandROutputDisplayEXT GetRandROutputDisplayEXT;
282#endif
283
284 // EXT_debug_report
285 PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallbackEXT;
286 PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallbackEXT;
287 PFN_vkDebugReportMessageEXT DebugReportMessageEXT;
288
289 // EXT_debug_marker (items needing a trampoline/terminator)
290 PFN_vkDebugMarkerSetObjectTagEXT DebugMarkerSetObjectTagEXT;
291 PFN_vkDebugMarkerSetObjectNameEXT DebugMarkerSetObjectNameEXT;
292
293 // EXT_direct_mode_display
294 PFN_vkReleaseDisplayEXT ReleaseDisplayEXT;
295
296 // EXT_display_surface_counter
297 PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT
298 GetPhysicalDeviceSurfaceCapabilities2EXT;
299
300 // NV_external_memory_capabilities
301 PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV
302 GetPhysicalDeviceExternalImageFormatPropertiesNV;
Mark Young4ab55c42016-12-12 16:14:55 -0700303
304 // NVX_device_generated_commands
305 PFN_vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX
306 GetPhysicalDeviceGeneratedCommandsPropertiesNVX;
307
Mark Young26c19372016-11-03 14:27:13 -0600308 struct loader_icd_term *next;
Mark Young274e4bc2017-01-19 21:10:49 -0700309
310 PFN_PhysDevExt phys_dev_ext[MAX_NUM_UNKNOWN_EXTS];
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600311};
312
Mark Young1d645262016-09-07 08:50:32 -0600313// per ICD library structure
Mark Young26c19372016-11-03 14:27:13 -0600314struct loader_icd_tramp_list {
Jon Ashburne0367472015-08-18 18:04:47 -0600315 size_t capacity;
316 uint32_t count;
Mark Young26c19372016-11-03 14:27:13 -0600317 struct loader_scanned_icd *scanned_list;
Jon Ashburne0367472015-08-18 18:04:47 -0600318};
319
Mark Young1d645262016-09-07 08:50:32 -0600320union loader_instance_extension_enables {
321 struct {
Mark Young274e4bc2017-01-19 21:10:49 -0700322 uint8_t khr_get_physical_device_properties2 : 1;
323 uint8_t ext_acquire_xlib_display : 1;
Mark Young26c19372016-11-03 14:27:13 -0600324 uint8_t ext_debug_report : 1;
Mark Young274e4bc2017-01-19 21:10:49 -0700325 uint8_t ext_direct_mode_display : 1;
326 uint8_t ext_display_surface_counter : 1;
Mark Young1d645262016-09-07 08:50:32 -0600327 uint8_t nv_external_memory_capabilities : 1;
328 };
329 uint64_t padding[4];
330};
331
Mark Young274e4bc2017-01-19 21:10:49 -0700332struct loader_instance_dispatch_table {
333 VkLayerInstanceDispatchTable layer_inst_disp; // must be first entry in structure
334
335 // Physical device functions unknown to the loader
336 PFN_PhysDevExt phys_dev_ext[MAX_NUM_UNKNOWN_EXTS];
337};
338
Mark Young1d645262016-09-07 08:50:32 -0600339// per instance structure
Jon Ashburn13482452015-05-12 17:26:48 -0600340struct loader_instance {
Mark Young274e4bc2017-01-19 21:10:49 -0700341 struct loader_instance_dispatch_table *disp; // must be first entry in structure
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600342
Mark Young26c19372016-11-03 14:27:13 -0600343 uint32_t total_gpu_count;
Lenny Komowe93e87f2016-12-20 15:35:11 -0700344 uint32_t phys_dev_count_term;
345 struct loader_physical_device_term **phys_devs_term;
Lenny Komowaaa115c2016-12-19 17:11:40 -0700346 uint32_t phys_dev_count_tramp;
347 struct loader_physical_device_tramp **phys_devs_tramp;
Mark Young26c19372016-11-03 14:27:13 -0600348
Jon Ashburn13482452015-05-12 17:26:48 -0600349 struct loader_instance *next;
Mark Young26c19372016-11-03 14:27:13 -0600350
351 uint32_t total_icd_count;
352 struct loader_icd_term *icd_terms;
353 struct loader_icd_tramp_list icd_tramp_list;
354
Mark Young274e4bc2017-01-19 21:10:49 -0700355 struct loader_dispatch_hash_entry dev_ext_disp_hash[MAX_NUM_UNKNOWN_EXTS];
356 struct loader_dispatch_hash_entry phys_dev_ext_disp_hash[MAX_NUM_UNKNOWN_EXTS];
Jon Ashburnb4c24232015-08-20 16:35:30 -0600357
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600358 struct loader_msg_callback_map_entry *icd_msg_callback_map;
359
Mark Young26c19372016-11-03 14:27:13 -0600360 struct loader_layer_list instance_layer_list;
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600361 struct loader_layer_list activated_layer_list;
Jon Ashburnc325bc02016-05-16 14:01:18 -0600362 bool activated_layers_are_std_val;
Jon Ashburnc466da52016-04-15 09:25:03 -0600363 VkInstance instance; // layers/ICD instance returned to trampoline
Courtney Goeltzenleuchter0bd705c2016-01-08 12:18:43 -0700364
Mark Young26c19372016-11-03 14:27:13 -0600365 struct loader_extension_list ext_list; // icds and loaders extensions
366 union loader_instance_extension_enables enabled_known_extensions;
367
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600368 VkLayerDbgFunctionNode *DbgFunctionHead;
Ian Elliottdefd6da2016-03-31 10:48:19 -0600369 uint32_t num_tmp_callbacks;
370 VkDebugReportCallbackCreateInfoEXT *tmp_dbg_create_infos;
371 VkDebugReportCallbackEXT *tmp_callbacks;
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600372
Chia-I Wu227c8b32015-10-27 18:04:07 +0800373 VkAllocationCallbacks alloc_callbacks;
Ian Elliotted33eb72015-07-06 14:36:13 -0600374
Ian Elliott54cea232015-10-30 15:28:23 -0600375 bool wsi_surface_enabled;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700376#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600377 bool wsi_win32_surface_enabled;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700378#endif
379#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600380 bool wsi_mir_surface_enabled;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700381#endif
382#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600383 bool wsi_wayland_surface_enabled;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700384#endif
385#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600386 bool wsi_xcb_surface_enabled;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700387#endif
388#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600389 bool wsi_xlib_surface_enabled;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700390#endif
391#ifdef VK_USE_PLATFORM_ANDROID_KHR
392 bool wsi_android_surface_enabled;
393#endif
Jon Ashburncc370d02016-03-08 09:30:30 -0700394 bool wsi_display_enabled;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600395};
396
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700397/* VkPhysicalDevice requires special treatment by loader. Firstly, terminator
Mark Young26c19372016-11-03 14:27:13 -0600398 * code must be able to get the struct loader_icd_term to call into the proper
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700399 * driver (multiple ICD/gpu case). This can be accomplished by wrapping the
400 * created VkPhysicalDevice in loader terminate_EnumeratePhysicalDevices().
Piers Daniell82107a62016-03-29 11:51:11 -0600401 * Secondly, the loader must be able to handle wrapped by layer VkPhysicalDevice
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700402 * in trampoline code. This implies, that the loader trampoline code must also
403 * wrap the VkPhysicalDevice object in trampoline code. Thus, loader has to
404 * wrap the VkPhysicalDevice created object twice. In trampoline code it can't
405 * rely on the terminator object wrapping since a layer may also wrap. Since
406 * trampoline code wraps the VkPhysicalDevice this means all loader trampoline
407 * code that passes a VkPhysicalDevice should unwrap it. */
408
409/* per enumerated PhysicalDevice structure, used to wrap in trampoline code and
410 also same structure used to wrap in terminator code */
Jon Ashburnc3519e42016-03-24 15:49:57 -0600411struct loader_physical_device_tramp {
Mark Young274e4bc2017-01-19 21:10:49 -0700412 struct loader_instance_dispatch_table *disp; // must be first entry in structure
Piers Daniell82107a62016-03-29 11:51:11 -0600413 struct loader_instance *this_instance;
Jon Ashburnc466da52016-04-15 09:25:03 -0600414 VkPhysicalDevice phys_dev; // object from layers/loader terminator
Jon Ashburnc3519e42016-03-24 15:49:57 -0600415};
416
417/* per enumerated PhysicalDevice structure, used to wrap in terminator code */
Mark Young26c19372016-11-03 14:27:13 -0600418struct loader_physical_device_term {
Mark Young274e4bc2017-01-19 21:10:49 -0700419 struct loader_instance_dispatch_table *disp; // must be first entry in structure
Mark Young26c19372016-11-03 14:27:13 -0600420 struct loader_icd_term *this_icd_term;
Mark Young5467d672016-06-28 10:52:43 -0600421 uint8_t icd_index;
Jon Ashburnc3519e42016-03-24 15:49:57 -0600422 VkPhysicalDevice phys_dev; // object from ICD
Jon Ashburn969caa42015-11-01 14:04:06 -0700423};
424
Jon Ashburn13482452015-05-12 17:26:48 -0600425struct loader_struct {
426 struct loader_instance *instances;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600427};
428
Mark Young26c19372016-11-03 14:27:13 -0600429struct loader_scanned_icd {
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600430 char *lib_name;
431 loader_platform_dl_handle handle;
Jon Ashburn27109e82015-11-17 17:35:40 -0700432 uint32_t api_version;
Jon Ashburn68b06d62016-04-25 11:09:37 -0600433 uint32_t interface_version;
Jon Ashburnc7ca48d2015-07-16 10:17:29 -0600434 PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
Mark Young274e4bc2017-01-19 21:10:49 -0700435 PFN_GetPhysicalDeviceProcAddr GetPhysicalDeviceProcAddr;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600436 PFN_vkCreateInstance CreateInstance;
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700437 PFN_vkEnumerateInstanceExtensionProperties
438 EnumerateInstanceExtensionProperties;
Jon Ashburn13482452015-05-12 17:26:48 -0600439};
440
Jon Ashburn399c9162015-07-02 09:40:15 -0600441static inline struct loader_instance *loader_instance(VkInstance instance) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700442 return (struct loader_instance *)instance;
Jon Ashburn399c9162015-07-02 09:40:15 -0600443}
444
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700445static inline VkPhysicalDevice
446loader_unwrap_physical_device(VkPhysicalDevice physicalDevice) {
Piers Daniella9ccaed2016-03-31 14:47:57 -0600447 struct loader_physical_device_tramp *phys_dev =
448 (struct loader_physical_device_tramp *)physicalDevice;
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700449 return phys_dev->phys_dev;
450}
451
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700452static inline void loader_set_dispatch(void *obj, const void *data) {
453 *((const void **)obj) = data;
Chia-I Wufe333ed2015-04-11 15:34:07 +0800454}
455
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700456static inline VkLayerDispatchTable *loader_get_dispatch(const void *obj) {
457 return *((VkLayerDispatchTable **)obj);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800458}
459
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700460static inline struct loader_dev_dispatch_table *
461loader_get_dev_dispatch(const void *obj) {
462 return *((struct loader_dev_dispatch_table **)obj);
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700463}
464
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700465static inline VkLayerInstanceDispatchTable *
Mark Young274e4bc2017-01-19 21:10:49 -0700466loader_get_instance_layer_dispatch(const void *obj) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700467 return *((VkLayerInstanceDispatchTable **)obj);
Jon Ashburn13482452015-05-12 17:26:48 -0600468}
469
Mark Young274e4bc2017-01-19 21:10:49 -0700470static inline struct loader_instance_dispatch_table *
471loader_get_instance_dispatch(const void *obj) {
472 return *((struct loader_instance_dispatch_table **)obj);
473}
474
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700475static inline void loader_init_dispatch(void *obj, const void *data) {
Jon Ashburn167b2b12015-04-15 13:34:33 -0600476#ifdef DEBUG
Chia-I Wufe333ed2015-04-11 15:34:07 +0800477 assert(valid_loader_magic_value(obj) &&
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700478 "Incompatible ICD, first dword must be initialized to "
479 "ICD_LOADER_MAGIC. See loader/README.md for details.");
Jon Ashburn167b2b12015-04-15 13:34:33 -0600480#endif
Chia-I Wufe333ed2015-04-11 15:34:07 +0800481
Jon Ashburn62a54d12015-05-01 18:00:33 -0600482 loader_set_dispatch(obj, data);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800483}
484
Jon Ashburn13482452015-05-12 17:26:48 -0600485/* global variables used across files */
486extern struct loader_struct loader;
Jon Ashburnb4dee9c2015-08-28 15:19:27 -0600487extern THREAD_LOCAL_DECL struct loader_instance *tls_instance;
Jon Ashburne0367472015-08-18 18:04:47 -0600488extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_init);
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600489extern loader_platform_thread_mutex loader_lock;
Jon Ashburn7d4d51c2015-09-22 13:11:00 -0600490extern loader_platform_thread_mutex loader_json_lock;
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600491extern const VkLayerInstanceDispatchTable instance_disp;
Jon Ashburnd1eb3322016-02-10 20:59:26 -0700492extern const char *std_validation_str;
Jon Ashburn37e7f972015-04-06 10:58:22 -0600493
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600494struct loader_msg_callback_map_entry {
Courtney Goeltzenleuchter725db942015-12-09 15:48:16 -0700495 VkDebugReportCallbackEXT icd_obj;
496 VkDebugReportCallbackEXT loader_obj;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600497};
498
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700499/* helper function definitions */
Mark Young26c19372016-11-03 14:27:13 -0600500void *loader_instance_heap_alloc(const struct loader_instance *instance,
501 size_t size,
502 VkSystemAllocationScope allocationScope);
503void loader_instance_heap_free(const struct loader_instance *instance,
504 void *pMemory);
505void *loader_instance_heap_realloc(const struct loader_instance *instance,
506 void *pMemory, size_t orig_size, size_t size,
507 VkSystemAllocationScope alloc_scope);
Mark Young74dd5d12016-06-30 13:02:42 -0600508void *loader_instance_tls_heap_alloc(size_t size);
509void loader_instance_tls_heap_free(void *pMemory);
Mark Young26c19372016-11-03 14:27:13 -0600510void *loader_device_heap_alloc(const struct loader_device *device, size_t size,
511 VkSystemAllocationScope allocationScope);
Mark Young74dd5d12016-06-30 13:02:42 -0600512void loader_device_heap_free(const struct loader_device *device, void *pMemory);
Mark Young26c19372016-11-03 14:27:13 -0600513void *loader_device_heap_realloc(const struct loader_device *device,
514 void *pMemory, size_t orig_size, size_t size,
515 VkSystemAllocationScope alloc_scope);
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700516
Jon Ashburn663f8312016-02-12 08:20:06 -0700517void loader_log(const struct loader_instance *inst, VkFlags msg_type,
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700518 int32_t msg_code, const char *format, ...);
Jon Ashburn663f8312016-02-12 08:20:06 -0700519
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700520bool compare_vk_extension_properties(const VkExtensionProperties *op1,
521 const VkExtensionProperties *op2);
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600522
Mark Lobodzinski8d325802016-02-02 18:53:34 -0700523VkResult loader_validate_layers(const struct loader_instance *inst,
524 const uint32_t layer_count,
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700525 const char *const *ppEnabledLayerNames,
526 const struct loader_layer_list *list);
Courtney Goeltzenleuchter76ece702015-07-06 17:45:08 -0600527
528VkResult loader_validate_instance_extensions(
Mark Lobodzinski8d325802016-02-02 18:53:34 -0700529 const struct loader_instance *inst,
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700530 const struct loader_extension_list *icd_exts,
531 const struct loader_layer_list *instance_layer,
532 const VkInstanceCreateInfo *pCreateInfo);
Courtney Goeltzenleuchter76ece702015-07-06 17:45:08 -0600533
Jon Ashburne0367472015-08-18 18:04:47 -0600534void loader_initialize(void);
Mark Young74dd5d12016-06-30 13:02:42 -0600535VkResult loader_copy_layer_properties(const struct loader_instance *inst,
536 struct loader_layer_properties *dst,
537 struct loader_layer_properties *src);
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700538bool has_vk_extension_property_array(const VkExtensionProperties *vk_ext_prop,
539 const uint32_t count,
540 const VkExtensionProperties *ext_array);
541bool has_vk_extension_property(const VkExtensionProperties *vk_ext_prop,
542 const struct loader_extension_list *ext_list);
Jon Ashburn13482452015-05-12 17:26:48 -0600543
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700544VkResult loader_add_to_ext_list(const struct loader_instance *inst,
545 struct loader_extension_list *ext_list,
546 uint32_t prop_list_count,
547 const VkExtensionProperties *props);
Jon Ashburnc466da52016-04-15 09:25:03 -0600548VkResult
549loader_add_to_dev_ext_list(const struct loader_instance *inst,
550 struct loader_device_extension_list *ext_list,
551 const VkExtensionProperties *props,
552 uint32_t entry_count, char **entrys);
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700553VkResult loader_add_device_extensions(const struct loader_instance *inst,
Jon Ashburnc466da52016-04-15 09:25:03 -0600554 PFN_vkEnumerateDeviceExtensionProperties
555 fpEnumerateDeviceExtensionProperties,
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700556 VkPhysicalDevice physical_device,
557 const char *lib_name,
558 struct loader_extension_list *ext_list);
Mark Youngce38e312016-08-19 15:25:08 -0600559VkResult loader_init_generic_list(const struct loader_instance *inst,
560 struct loader_generic_list *list_info,
561 size_t element_size);
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700562void loader_destroy_generic_list(const struct loader_instance *inst,
563 struct loader_generic_list *list);
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700564void loader_destroy_layer_list(const struct loader_instance *inst,
Mark Young74dd5d12016-06-30 13:02:42 -0600565 struct loader_device *device,
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700566 struct loader_layer_list *layer_list);
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700567void loader_delete_layer_properties(const struct loader_instance *inst,
568 struct loader_layer_list *layer_list);
Mark Young26c19372016-11-03 14:27:13 -0600569bool loader_find_layer_name_array(
570 const char *name, uint32_t layer_count,
571 const char layer_list[][VK_MAX_EXTENSION_NAME_SIZE]);
Mark Young74dd5d12016-06-30 13:02:42 -0600572VkResult loader_expand_layer_names(
Mark Young26c19372016-11-03 14:27:13 -0600573 struct loader_instance *inst, const char *key_name, uint32_t expand_count,
Jon Ashburnd1eb3322016-02-10 20:59:26 -0700574 const char expand_names[][VK_MAX_EXTENSION_NAME_SIZE],
Jon Ashburnc466da52016-04-15 09:25:03 -0600575 uint32_t *layer_count, char const *const **ppp_layer_names);
Jon Ashburnc325bc02016-05-16 14:01:18 -0600576void loader_init_std_validation_props(struct loader_layer_properties *props);
Chris Forbes7333fdd2016-04-06 20:49:02 +1200577void loader_delete_shadow_dev_layer_names(const struct loader_instance *inst,
578 const VkDeviceCreateInfo *orig,
579 VkDeviceCreateInfo *ours);
580void loader_delete_shadow_inst_layer_names(const struct loader_instance *inst,
581 const VkInstanceCreateInfo *orig,
582 VkInstanceCreateInfo *ours);
Mark Young74dd5d12016-06-30 13:02:42 -0600583VkResult loader_add_to_layer_list(const struct loader_instance *inst,
584 struct loader_layer_list *list,
585 uint32_t prop_list_count,
586 const struct loader_layer_properties *props);
Jon Ashburnc466da52016-04-15 09:25:03 -0600587void loader_find_layer_name_add_list(
588 const struct loader_instance *inst, const char *name,
589 const enum layer_type type, const struct loader_layer_list *search_list,
590 struct loader_layer_list *found_list);
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700591void loader_scanned_icd_clear(const struct loader_instance *inst,
Mark Young26c19372016-11-03 14:27:13 -0600592 struct loader_icd_tramp_list *icd_tramp_list);
Mark Young74dd5d12016-06-30 13:02:42 -0600593VkResult loader_icd_scan(const struct loader_instance *inst,
Mark Young26c19372016-11-03 14:27:13 -0600594 struct loader_icd_tramp_list *icd_tramp_list);
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700595void loader_layer_scan(const struct loader_instance *inst,
Jon Ashburnc325bc02016-05-16 14:01:18 -0600596 struct loader_layer_list *instance_layers);
Jeremy Hayes10d78f12016-04-01 11:40:26 -0600597void loader_implicit_layer_scan(const struct loader_instance *inst,
Jon Ashburnc325bc02016-05-16 14:01:18 -0600598 struct loader_layer_list *instance_layers);
Mark Youngce38e312016-08-19 15:25:08 -0600599VkResult loader_get_icd_loader_instance_extensions(
Mark Young26c19372016-11-03 14:27:13 -0600600 const struct loader_instance *inst,
601 struct loader_icd_tramp_list *icd_tramp_list,
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700602 struct loader_extension_list *inst_exts);
Mark Young26c19372016-11-03 14:27:13 -0600603struct loader_icd_term *
604loader_get_icd_and_device(const VkDevice device,
605 struct loader_device **found_dev,
606 uint32_t *icd_index);
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700607void loader_init_dispatch_dev_ext(struct loader_instance *inst,
608 struct loader_device *dev);
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700609void *loader_dev_ext_gpa(struct loader_instance *inst, const char *funcName);
610void *loader_get_dev_ext_trampoline(uint32_t index);
Mark Young274e4bc2017-01-19 21:10:49 -0700611bool loader_phys_dev_ext_gpa(struct loader_instance *inst, const char *funcName,
612 bool perform_checking, void **tramp_addr, void **term_addr);
613void *loader_get_phys_dev_ext_tramp(uint32_t index);
614void *loader_get_phys_dev_ext_termin(uint32_t index);
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700615struct loader_instance *loader_get_instance(const VkInstance instance);
Jon Ashburnd3cf9552016-04-20 13:21:17 -0600616void loader_deactivate_layers(const struct loader_instance *instance,
Mark Young74dd5d12016-06-30 13:02:42 -0600617 struct loader_device *device,
Jon Ashburnd3cf9552016-04-20 13:21:17 -0600618 struct loader_layer_list *list);
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700619struct loader_device *
Mark Young26c19372016-11-03 14:27:13 -0600620loader_create_logical_device(const struct loader_instance *inst,
621 const VkAllocationCallbacks *pAllocator);
Piers Daniell82107a62016-03-29 11:51:11 -0600622void loader_add_logical_device(const struct loader_instance *inst,
Mark Young26c19372016-11-03 14:27:13 -0600623 struct loader_icd_term *icd_term,
Piers Daniell82107a62016-03-29 11:51:11 -0600624 struct loader_device *found_dev);
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700625void loader_remove_logical_device(const struct loader_instance *inst,
Mark Young26c19372016-11-03 14:27:13 -0600626 struct loader_icd_term *icd_term,
Mark Young74dd5d12016-06-30 13:02:42 -0600627 struct loader_device *found_dev,
628 const VkAllocationCallbacks *pAllocator);
Mark Young26c19372016-11-03 14:27:13 -0600629// NOTE: Outside of loader, this entry-point is only proivided for error
630// cleanup.
Mark Young74dd5d12016-06-30 13:02:42 -0600631void loader_destroy_logical_device(const struct loader_instance *inst,
632 struct loader_device *dev,
633 const VkAllocationCallbacks *pAllocator);
634
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700635VkResult
636loader_enable_instance_layers(struct loader_instance *inst,
637 const VkInstanceCreateInfo *pCreateInfo,
638 const struct loader_layer_list *instance_layers);
Jon Ashburn10f4e822015-06-10 10:06:06 -0600639void loader_deactivate_instance_layers(struct loader_instance *instance);
Courtney Goeltzenleuchter0bd705c2016-01-08 12:18:43 -0700640
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700641VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo,
642 const VkAllocationCallbacks *pAllocator,
643 struct loader_instance *inst,
Jon Ashburnd1205a92016-02-03 12:37:30 -0700644 VkInstance *created_instance);
Courtney Goeltzenleuchter0bd705c2016-01-08 12:18:43 -0700645
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700646void loader_activate_instance_layer_extensions(struct loader_instance *inst,
647 VkInstance created_inst);
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700648VkResult
649loader_enable_device_layers(const struct loader_instance *inst,
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700650 struct loader_layer_list *activated_layer_list,
651 const VkDeviceCreateInfo *pCreateInfo,
652 const struct loader_layer_list *device_layers);
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600653
Jon Ashburnc466da52016-04-15 09:25:03 -0600654VkResult
655loader_create_device_chain(const struct loader_physical_device_tramp *pd,
656 const VkDeviceCreateInfo *pCreateInfo,
657 const VkAllocationCallbacks *pAllocator,
658 const struct loader_instance *inst,
659 struct loader_device *dev);
Mark Young274e4bc2017-01-19 21:10:49 -0700660
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700661VkResult loader_validate_device_extensions(
Jon Ashburnc3519e42016-03-24 15:49:57 -0600662 struct loader_physical_device_tramp *phys_dev,
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700663 const struct loader_layer_list *activated_device_layers,
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700664 const struct loader_extension_list *icd_exts,
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700665 const VkDeviceCreateInfo *pCreateInfo);
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600666
Mark Youngd4ff03b2017-01-12 12:27:19 -0700667VkResult setupLoaderTrampPhysDevs(VkInstance instance);
668VkResult setupLoaderTermPhysDevs(struct loader_instance *inst);
669
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700670/* instance layer chain termination entrypoint definitions */
671VKAPI_ATTR VkResult VKAPI_CALL
672terminator_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
673 const VkAllocationCallbacks *pAllocator,
674 VkInstance *pInstance);
Jon Ashburnb4dee9c2015-08-28 15:19:27 -0600675
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700676VKAPI_ATTR void VKAPI_CALL
677terminator_DestroyInstance(VkInstance instance,
678 const VkAllocationCallbacks *pAllocator);
Jon Ashburnb4dee9c2015-08-28 15:19:27 -0600679
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700680VKAPI_ATTR VkResult VKAPI_CALL
681terminator_EnumeratePhysicalDevices(VkInstance instance,
682 uint32_t *pPhysicalDeviceCount,
683 VkPhysicalDevice *pPhysicalDevices);
684
685VKAPI_ATTR void VKAPI_CALL
686terminator_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice,
687 VkPhysicalDeviceFeatures *pFeatures);
688
689VKAPI_ATTR void VKAPI_CALL
690terminator_GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice,
691 VkFormat format,
692 VkFormatProperties *pFormatInfo);
693
694VKAPI_ATTR VkResult VKAPI_CALL
695terminator_GetPhysicalDeviceImageFormatProperties(
696 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,
697 VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags,
698 VkImageFormatProperties *pImageFormatProperties);
699
700VKAPI_ATTR void VKAPI_CALL
701terminator_GetPhysicalDeviceSparseImageFormatProperties(
702 VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type,
703 VkSampleCountFlagBits samples, VkImageUsageFlags usage,
704 VkImageTiling tiling, uint32_t *pNumProperties,
705 VkSparseImageFormatProperties *pProperties);
706
707VKAPI_ATTR void VKAPI_CALL
708terminator_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
709 VkPhysicalDeviceProperties *pProperties);
710
711VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceExtensionProperties(
712 VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pCount,
713 VkExtensionProperties *pProperties);
714
715VKAPI_ATTR VkResult VKAPI_CALL
716terminator_EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice,
717 uint32_t *pCount,
718 VkLayerProperties *pProperties);
719
720VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceQueueFamilyProperties(
721 VkPhysicalDevice physicalDevice, uint32_t *pCount,
722 VkQueueFamilyProperties *pProperties);
723
724VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMemoryProperties(
725 VkPhysicalDevice physicalDevice,
726 VkPhysicalDeviceMemoryProperties *pProperties);
727
728VKAPI_ATTR VkResult VKAPI_CALL
729terminator_CreateDevice(VkPhysicalDevice gpu,
730 const VkDeviceCreateInfo *pCreateInfo,
731 const VkAllocationCallbacks *pAllocator,
732 VkDevice *pDevice);
Mark Lobodzinski8d325802016-02-02 18:53:34 -0700733
Jon Ashburnb1cdf2e2016-02-10 20:50:19 -0700734VkStringErrorFlags vk_string_validate(const int max_length,
735 const char *char_array);
Mark Lobodzinski8d325802016-02-02 18:53:34 -0700736
Chia-I Wuc1e0f962014-08-04 08:03:57 +0800737#endif /* LOADER_H */