blob: 9a4fd8fcc6bdf33faeff4bf86cd0b08dc702a9e5 [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
Jon Ashburn399c9162015-07-02 09:40:15 -060061enum layer_type {
Jon Ashburnc325bc02016-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 Ashburn399c9162015-07-02 09:40:15 -060065};
66
Mark Lobodzinski8d325802016-02-02 18:53:34 -070067typedef enum VkStringErrorFlagBits {
Jon Ashburnb1cdf2e2016-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 Lobodzinski8d325802016-02-02 18:53:34 -070071} VkStringErrorFlagBits;
72typedef VkFlags VkStringErrorFlags;
73
Jon Ashburnb1cdf2e2016-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 Lobodzinski8d325802016-02-02 18:53:34 -070083
Mark Lobodzinski6eaa8fe2017-02-15 14:46:24 -070084static const char std_validation_names[6][VK_MAX_EXTENSION_NAME_SIZE] = {
Mark Lobodzinski91c10752017-01-26 12:16:30 -070085 "VK_LAYER_GOOGLE_threading", "VK_LAYER_LUNARG_parameter_validation", "VK_LAYER_LUNARG_object_tracker",
Mark Lobodzinski6eaa8fe2017-02-15 14:46:24 -070086 "VK_LAYER_LUNARG_core_validation", "VK_LAYER_LUNARG_swapchain", "VK_LAYER_GOOGLE_unique_objects"};
Jon Ashburnd1eb3322016-02-10 20:59:26 -070087
Mark Young274e4bc2017-01-19 21:10:49 -070088struct VkStructureHeader {
89 VkStructureType sType;
Mark Lobodzinski91c10752017-01-26 12:16:30 -070090 const void *pNext;
Mark Young274e4bc2017-01-19 21:10:49 -070091};
92
Jon Ashburn6b00b472015-12-10 08:51:10 -070093// form of all dynamic lists/arrays
94// only the list element should be changed
95struct loader_generic_list {
96 size_t capacity;
97 uint32_t count;
98 void *list;
99};
100
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600101struct loader_extension_list {
102 size_t capacity;
103 uint32_t count;
Jon Ashburnb7d327c2015-08-04 11:14:18 -0600104 VkExtensionProperties *list;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600105};
106
Jon Ashburn92cdb012015-12-10 18:17:34 -0700107struct loader_dev_ext_props {
108 VkExtensionProperties props;
109 uint32_t entrypoint_count;
110 char **entrypoints;
111};
112
113struct loader_device_extension_list {
114 size_t capacity;
115 uint32_t count;
116 struct loader_dev_ext_props *list;
117};
118
Jon Ashburn399c9162015-07-02 09:40:15 -0600119struct loader_name_value {
Jon Ashburnb2379c52015-08-04 10:22:33 -0600120 char name[MAX_STRING_SIZE];
121 char value[MAX_STRING_SIZE];
Jon Ashburn399c9162015-07-02 09:40:15 -0600122};
123
Jon Ashburn399c9162015-07-02 09:40:15 -0600124struct loader_layer_functions {
Jon Ashburnb2379c52015-08-04 10:22:33 -0600125 char str_gipa[MAX_STRING_SIZE];
126 char str_gdpa[MAX_STRING_SIZE];
Mark Young274e4bc2017-01-19 21:10:49 -0700127 char str_negotiate_interface[MAX_STRING_SIZE];
128 PFN_vkNegotiateLoaderLayerInterfaceVersion negotiate_layer_interface;
Jon Ashburn399c9162015-07-02 09:40:15 -0600129 PFN_vkGetInstanceProcAddr get_instance_proc_addr;
130 PFN_vkGetDeviceProcAddr get_device_proc_addr;
Mark Young274e4bc2017-01-19 21:10:49 -0700131 PFN_GetPhysicalDeviceProcAddr get_physical_device_proc_addr;
Jon Ashburn399c9162015-07-02 09:40:15 -0600132};
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600133
Jon Ashburn399c9162015-07-02 09:40:15 -0600134struct loader_layer_properties {
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600135 VkLayerProperties info;
Jon Ashburn399c9162015-07-02 09:40:15 -0600136 enum layer_type type;
Mark Lobodzinskie2859eb2017-01-26 13:34:13 -0700137 uint32_t interface_version; // PFN_vkNegotiateLoaderLayerInterfaceVersion
Jon Ashburnb4c24232015-08-20 16:35:30 -0600138 char lib_name[MAX_STRING_SIZE];
Jon Ashburnd3cf9552016-04-20 13:21:17 -0600139 loader_platform_dl_handle lib_handle;
Jon Ashburn399c9162015-07-02 09:40:15 -0600140 struct loader_layer_functions functions;
141 struct loader_extension_list instance_extension_list;
Jon Ashburn92cdb012015-12-10 18:17:34 -0700142 struct loader_device_extension_list device_extension_list;
Jon Ashburn399c9162015-07-02 09:40:15 -0600143 struct loader_name_value disable_env_var;
144 struct loader_name_value enable_env_var;
145};
146
147struct loader_layer_list {
148 size_t capacity;
149 uint32_t count;
150 struct loader_layer_properties *list;
Jon Ashburn13482452015-05-12 17:26:48 -0600151};
152
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700153struct loader_dispatch_hash_list {
154 size_t capacity;
155 uint32_t count;
Mark Lobodzinskie2859eb2017-01-26 13:34:13 -0700156 uint32_t *index; // index into the dev_ext dispatch table
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700157};
158
Mark Youngdd904ae2016-09-02 11:41:28 -0600159// loader_dispatch_hash_entry and loader_dev_ext_dispatch_table.dev_ext have
160// one to one correspondence; one loader_dispatch_hash_entry for one dev_ext
161// dispatch entry.
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700162// Also have a one to one correspondence with functions in dev_ext_trampoline.c
163struct loader_dispatch_hash_entry {
164 char *func_name;
Mark Lobodzinskie2859eb2017-01-26 13:34:13 -0700165 struct loader_dispatch_hash_list list; // to handle hashing collisions
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700166};
167
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700168typedef void(VKAPI_PTR *PFN_vkDevExt)(VkDevice device);
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700169struct loader_dev_ext_dispatch_table {
Mark Young274e4bc2017-01-19 21:10:49 -0700170 PFN_vkDevExt dev_ext[MAX_NUM_UNKNOWN_EXTS];
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700171};
172
173struct loader_dev_dispatch_table {
174 VkLayerDispatchTable core_dispatch;
175 struct loader_dev_ext_dispatch_table ext_dispatch;
176};
177
Mark Young1d645262016-09-07 08:50:32 -0600178// per CreateDevice structure
Jon Ashburn10f4e822015-06-10 10:06:06 -0600179struct loader_device {
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700180 struct loader_dev_dispatch_table loader_dispatch;
Mark Lobodzinskie2859eb2017-01-26 13:34:13 -0700181 VkDevice chain_device; // device object from the dispatch chain
182 VkDevice icd_device; // device object from the icd
Mark Young0f7adeb2016-11-07 13:27:02 -0700183 struct loader_physical_device_term *phys_dev_term;
Jon Ashburn10f4e822015-06-10 10:06:06 -0600184
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600185 struct loader_layer_list activated_layer_list;
Jon Ashburn10f4e822015-06-10 10:06:06 -0600186
Mark Young74dd5d12016-06-30 13:02:42 -0600187 VkAllocationCallbacks alloc_callbacks;
188
Jon Ashburn10f4e822015-06-10 10:06:06 -0600189 struct loader_device *next;
190};
191
Jon Ashburn392c5622015-06-10 16:11:42 -0600192/* per ICD structure */
Mark Young26c19372016-11-03 14:27:13 -0600193struct loader_icd_term {
Jon Ashburnb4c24232015-08-20 16:35:30 -0600194 // pointers to find other structs
Mark Young26c19372016-11-03 14:27:13 -0600195 const struct loader_scanned_icd *scanned_icd;
Jon Ashburnb4c24232015-08-20 16:35:30 -0600196 const struct loader_instance *this_instance;
Jon Ashburn10f4e822015-06-10 10:06:06 -0600197 struct loader_device *logical_device_list;
Mark Lobodzinskie2859eb2017-01-26 13:34:13 -0700198 VkInstance instance; // instance object from the icd
Jon Ashburnc89dd4a2015-05-18 13:20:15 -0600199 PFN_vkGetDeviceProcAddr GetDeviceProcAddr;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600200 PFN_vkDestroyInstance DestroyInstance;
201 PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices;
Chris Forbes1c946ec2015-06-21 22:55:02 +1200202 PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures;
Courtney Goeltzenleuchter2b6559e2015-07-12 12:52:09 -0600203 PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties;
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700204 PFN_vkGetPhysicalDeviceImageFormatProperties GetPhysicalDeviceImageFormatProperties;
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600205 PFN_vkCreateDevice CreateDevice;
Tony Barbour4e657ba2015-06-24 16:06:58 -0600206 PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties;
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700207 PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties;
Tony Barbour4e657ba2015-06-24 16:06:58 -0600208 PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties;
Courtney Goeltzenleuchtere25064c2015-09-14 17:22:16 -0600209 PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties;
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700210 PFN_vkGetPhysicalDeviceSparseImageFormatProperties GetPhysicalDeviceSparseImageFormatProperties;
Mark Young274e4bc2017-01-19 21:10:49 -0700211 // WSI extensions
Ian Elliottec736342015-08-21 15:09:33 -0600212 PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR;
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700213 PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR GetPhysicalDeviceSurfaceCapabilitiesKHR;
Ian Elliottea666b22015-11-19 16:05:09 -0700214 PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR;
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700215 PFN_vkGetPhysicalDeviceSurfacePresentModesKHR GetPhysicalDeviceSurfacePresentModesKHR;
Ian Elliotte851dd62015-11-24 15:39:10 -0700216#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Young5467d672016-06-28 10:52:43 -0600217 PFN_vkCreateWin32SurfaceKHR CreateWin32SurfaceKHR;
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700218 PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR GetPhysicalDeviceWin32PresentationSupportKHR;
Ian Elliotte851dd62015-11-24 15:39:10 -0700219#endif
220#ifdef VK_USE_PLATFORM_MIR_KHR
Mark Young5467d672016-06-28 10:52:43 -0600221 PFN_vkCreateMirSurfaceKHR CreateMirSurfaceKHR;
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700222 PFN_vkGetPhysicalDeviceMirPresentationSupportKHR GetPhysicalDeviceMirPresentationSupportKHR;
Ian Elliotte851dd62015-11-24 15:39:10 -0700223#endif
224#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Mark Young5467d672016-06-28 10:52:43 -0600225 PFN_vkCreateWaylandSurfaceKHR CreateWaylandSurfaceKHR;
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700226 PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR GetPhysicalDeviceWaylandPresentationSupportKHR;
Ian Elliotte851dd62015-11-24 15:39:10 -0700227#endif
228#ifdef VK_USE_PLATFORM_XCB_KHR
Mark Young5467d672016-06-28 10:52:43 -0600229 PFN_vkCreateXcbSurfaceKHR CreateXcbSurfaceKHR;
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700230 PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR GetPhysicalDeviceXcbPresentationSupportKHR;
Ian Elliotte851dd62015-11-24 15:39:10 -0700231#endif
232#ifdef VK_USE_PLATFORM_XLIB_KHR
Mark Young5467d672016-06-28 10:52:43 -0600233 PFN_vkCreateXlibSurfaceKHR CreateXlibSurfaceKHR;
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700234 PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR GetPhysicalDeviceXlibPresentationSupportKHR;
Ian Elliotte851dd62015-11-24 15:39:10 -0700235#endif
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700236 PFN_vkGetPhysicalDeviceDisplayPropertiesKHR GetPhysicalDeviceDisplayPropertiesKHR;
237 PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR GetPhysicalDeviceDisplayPlanePropertiesKHR;
238 PFN_vkGetDisplayPlaneSupportedDisplaysKHR GetDisplayPlaneSupportedDisplaysKHR;
Jon Ashburnc466da52016-04-15 09:25:03 -0600239 PFN_vkGetDisplayModePropertiesKHR GetDisplayModePropertiesKHR;
240 PFN_vkCreateDisplayModeKHR CreateDisplayModeKHR;
241 PFN_vkGetDisplayPlaneCapabilitiesKHR GetDisplayPlaneCapabilitiesKHR;
242 PFN_vkCreateDisplayPlaneSurfaceKHR CreateDisplayPlaneSurfaceKHR;
243 PFN_vkDestroySurfaceKHR DestroySurfaceKHR;
Mark Young5467d672016-06-28 10:52:43 -0600244 PFN_vkCreateSwapchainKHR CreateSwapchainKHR;
Mark Young274e4bc2017-01-19 21:10:49 -0700245 PFN_vkCreateSharedSwapchainsKHR CreateSharedSwapchainsKHR;
246
247 // KHR_get_physical_device_properties2
248 PFN_vkGetPhysicalDeviceFeatures2KHR GetPhysicalDeviceFeatures2KHR;
249 PFN_vkGetPhysicalDeviceProperties2KHR GetPhysicalDeviceProperties2KHR;
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700250 PFN_vkGetPhysicalDeviceFormatProperties2KHR GetPhysicalDeviceFormatProperties2KHR;
251 PFN_vkGetPhysicalDeviceImageFormatProperties2KHR GetPhysicalDeviceImageFormatProperties2KHR;
252 PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR GetPhysicalDeviceQueueFamilyProperties2KHR;
253 PFN_vkGetPhysicalDeviceMemoryProperties2KHR GetPhysicalDeviceMemoryProperties2KHR;
254 PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR GetPhysicalDeviceSparseImageFormatProperties2KHR;
Mark Young274e4bc2017-01-19 21:10:49 -0700255
256#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
257 // EXT_acquire_xlib_display
258 PFN_vkAcquireXlibDisplayEXT AcquireXlibDisplayEXT;
259 PFN_vkGetRandROutputDisplayEXT GetRandROutputDisplayEXT;
260#endif
261
262 // EXT_debug_report
263 PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallbackEXT;
264 PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallbackEXT;
265 PFN_vkDebugReportMessageEXT DebugReportMessageEXT;
266
267 // EXT_debug_marker (items needing a trampoline/terminator)
268 PFN_vkDebugMarkerSetObjectTagEXT DebugMarkerSetObjectTagEXT;
269 PFN_vkDebugMarkerSetObjectNameEXT DebugMarkerSetObjectNameEXT;
270
271 // EXT_direct_mode_display
272 PFN_vkReleaseDisplayEXT ReleaseDisplayEXT;
273
274 // EXT_display_surface_counter
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700275 PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT GetPhysicalDeviceSurfaceCapabilities2EXT;
Mark Young274e4bc2017-01-19 21:10:49 -0700276
277 // NV_external_memory_capabilities
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700278 PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV GetPhysicalDeviceExternalImageFormatPropertiesNV;
Mark Young4ab55c42016-12-12 16:14:55 -0700279
280 // NVX_device_generated_commands
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700281 PFN_vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX GetPhysicalDeviceGeneratedCommandsPropertiesNVX;
Mark Young4ab55c42016-12-12 16:14:55 -0700282
Mark Young26c19372016-11-03 14:27:13 -0600283 struct loader_icd_term *next;
Mark Young274e4bc2017-01-19 21:10:49 -0700284
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700285 PFN_PhysDevExt phys_dev_ext[MAX_NUM_UNKNOWN_EXTS];
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600286};
287
Mark Young1d645262016-09-07 08:50:32 -0600288// per ICD library structure
Mark Young26c19372016-11-03 14:27:13 -0600289struct loader_icd_tramp_list {
Jon Ashburne0367472015-08-18 18:04:47 -0600290 size_t capacity;
291 uint32_t count;
Mark Young26c19372016-11-03 14:27:13 -0600292 struct loader_scanned_icd *scanned_list;
Jon Ashburne0367472015-08-18 18:04:47 -0600293};
294
Mark Young1d645262016-09-07 08:50:32 -0600295union loader_instance_extension_enables {
296 struct {
Mark Young274e4bc2017-01-19 21:10:49 -0700297 uint8_t khr_get_physical_device_properties2 : 1;
298 uint8_t ext_acquire_xlib_display : 1;
Mark Young26c19372016-11-03 14:27:13 -0600299 uint8_t ext_debug_report : 1;
Mark Young274e4bc2017-01-19 21:10:49 -0700300 uint8_t ext_direct_mode_display : 1;
301 uint8_t ext_display_surface_counter : 1;
Mark Young1d645262016-09-07 08:50:32 -0600302 uint8_t nv_external_memory_capabilities : 1;
303 };
304 uint64_t padding[4];
305};
306
Mark Young274e4bc2017-01-19 21:10:49 -0700307struct loader_instance_dispatch_table {
Mark Lobodzinskie2859eb2017-01-26 13:34:13 -0700308 VkLayerInstanceDispatchTable layer_inst_disp; // must be first entry in structure
Mark Young274e4bc2017-01-19 21:10:49 -0700309
310 // Physical device functions unknown to the loader
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700311 PFN_PhysDevExt phys_dev_ext[MAX_NUM_UNKNOWN_EXTS];
Mark Young274e4bc2017-01-19 21:10:49 -0700312};
313
Mark Young1d645262016-09-07 08:50:32 -0600314// per instance structure
Jon Ashburn13482452015-05-12 17:26:48 -0600315struct loader_instance {
Mark Lobodzinskie2859eb2017-01-26 13:34:13 -0700316 struct loader_instance_dispatch_table *disp; // must be first entry in structure
Jon Ashburnebfa25e2015-05-15 15:09:35 -0600317
Mark Young26c19372016-11-03 14:27:13 -0600318 uint32_t total_gpu_count;
Lenny Komowe93e87f2016-12-20 15:35:11 -0700319 uint32_t phys_dev_count_term;
320 struct loader_physical_device_term **phys_devs_term;
Lenny Komowaaa115c2016-12-19 17:11:40 -0700321 uint32_t phys_dev_count_tramp;
322 struct loader_physical_device_tramp **phys_devs_tramp;
Mark Young26c19372016-11-03 14:27:13 -0600323
Jon Ashburn13482452015-05-12 17:26:48 -0600324 struct loader_instance *next;
Mark Young26c19372016-11-03 14:27:13 -0600325
326 uint32_t total_icd_count;
327 struct loader_icd_term *icd_terms;
328 struct loader_icd_tramp_list icd_tramp_list;
329
Mark Young274e4bc2017-01-19 21:10:49 -0700330 struct loader_dispatch_hash_entry dev_ext_disp_hash[MAX_NUM_UNKNOWN_EXTS];
331 struct loader_dispatch_hash_entry phys_dev_ext_disp_hash[MAX_NUM_UNKNOWN_EXTS];
Jon Ashburnb4c24232015-08-20 16:35:30 -0600332
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600333 struct loader_msg_callback_map_entry *icd_msg_callback_map;
334
Mark Young26c19372016-11-03 14:27:13 -0600335 struct loader_layer_list instance_layer_list;
Courtney Goeltzenleuchter44667cc2015-06-29 15:39:26 -0600336 struct loader_layer_list activated_layer_list;
Jon Ashburnc325bc02016-05-16 14:01:18 -0600337 bool activated_layers_are_std_val;
Mark Lobodzinskie2859eb2017-01-26 13:34:13 -0700338 VkInstance instance; // layers/ICD instance returned to trampoline
Courtney Goeltzenleuchter0bd705c2016-01-08 12:18:43 -0700339
Mark Lobodzinskie2859eb2017-01-26 13:34:13 -0700340 struct loader_extension_list ext_list; // icds and loaders extensions
Mark Young26c19372016-11-03 14:27:13 -0600341 union loader_instance_extension_enables enabled_known_extensions;
342
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600343 VkLayerDbgFunctionNode *DbgFunctionHead;
Ian Elliottdefd6da2016-03-31 10:48:19 -0600344 uint32_t num_tmp_callbacks;
345 VkDebugReportCallbackCreateInfoEXT *tmp_dbg_create_infos;
346 VkDebugReportCallbackEXT *tmp_callbacks;
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600347
Chia-I Wu227c8b32015-10-27 18:04:07 +0800348 VkAllocationCallbacks alloc_callbacks;
Ian Elliotted33eb72015-07-06 14:36:13 -0600349
Ian Elliott54cea232015-10-30 15:28:23 -0600350 bool wsi_surface_enabled;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700351#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600352 bool wsi_win32_surface_enabled;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700353#endif
354#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600355 bool wsi_mir_surface_enabled;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700356#endif
357#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600358 bool wsi_wayland_surface_enabled;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700359#endif
360#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600361 bool wsi_xcb_surface_enabled;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700362#endif
363#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600364 bool wsi_xlib_surface_enabled;
Mark Lobodzinski1ad14b42015-12-10 16:25:21 -0700365#endif
366#ifdef VK_USE_PLATFORM_ANDROID_KHR
367 bool wsi_android_surface_enabled;
368#endif
Jon Ashburncc370d02016-03-08 09:30:30 -0700369 bool wsi_display_enabled;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600370};
371
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700372/* VkPhysicalDevice requires special treatment by loader. Firstly, terminator
Mark Young26c19372016-11-03 14:27:13 -0600373 * code must be able to get the struct loader_icd_term to call into the proper
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700374 * driver (multiple ICD/gpu case). This can be accomplished by wrapping the
375 * created VkPhysicalDevice in loader terminate_EnumeratePhysicalDevices().
Piers Daniell82107a62016-03-29 11:51:11 -0600376 * Secondly, the loader must be able to handle wrapped by layer VkPhysicalDevice
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700377 * in trampoline code. This implies, that the loader trampoline code must also
378 * wrap the VkPhysicalDevice object in trampoline code. Thus, loader has to
379 * wrap the VkPhysicalDevice created object twice. In trampoline code it can't
380 * rely on the terminator object wrapping since a layer may also wrap. Since
381 * trampoline code wraps the VkPhysicalDevice this means all loader trampoline
382 * code that passes a VkPhysicalDevice should unwrap it. */
383
384/* per enumerated PhysicalDevice structure, used to wrap in trampoline code and
385 also same structure used to wrap in terminator code */
Jon Ashburnc3519e42016-03-24 15:49:57 -0600386struct loader_physical_device_tramp {
Mark Lobodzinskie2859eb2017-01-26 13:34:13 -0700387 struct loader_instance_dispatch_table *disp; // must be first entry in structure
Piers Daniell82107a62016-03-29 11:51:11 -0600388 struct loader_instance *this_instance;
Mark Lobodzinskie2859eb2017-01-26 13:34:13 -0700389 VkPhysicalDevice phys_dev; // object from layers/loader terminator
Jon Ashburnc3519e42016-03-24 15:49:57 -0600390};
391
392/* per enumerated PhysicalDevice structure, used to wrap in terminator code */
Mark Young26c19372016-11-03 14:27:13 -0600393struct loader_physical_device_term {
Mark Lobodzinskie2859eb2017-01-26 13:34:13 -0700394 struct loader_instance_dispatch_table *disp; // must be first entry in structure
Mark Young26c19372016-11-03 14:27:13 -0600395 struct loader_icd_term *this_icd_term;
Mark Young5467d672016-06-28 10:52:43 -0600396 uint8_t icd_index;
Mark Lobodzinskie2859eb2017-01-26 13:34:13 -0700397 VkPhysicalDevice phys_dev; // object from ICD
Jon Ashburn969caa42015-11-01 14:04:06 -0700398};
399
Jon Ashburn13482452015-05-12 17:26:48 -0600400struct loader_struct {
401 struct loader_instance *instances;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600402};
403
Mark Young26c19372016-11-03 14:27:13 -0600404struct loader_scanned_icd {
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600405 char *lib_name;
406 loader_platform_dl_handle handle;
Jon Ashburn27109e82015-11-17 17:35:40 -0700407 uint32_t api_version;
Jon Ashburn68b06d62016-04-25 11:09:37 -0600408 uint32_t interface_version;
Jon Ashburnc7ca48d2015-07-16 10:17:29 -0600409 PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
Mark Young274e4bc2017-01-19 21:10:49 -0700410 PFN_GetPhysicalDeviceProcAddr GetPhysicalDeviceProcAddr;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600411 PFN_vkCreateInstance CreateInstance;
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700412 PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
Jon Ashburn13482452015-05-12 17:26:48 -0600413};
414
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700415static inline struct loader_instance *loader_instance(VkInstance instance) { return (struct loader_instance *)instance; }
Jon Ashburn399c9162015-07-02 09:40:15 -0600416
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700417static inline VkPhysicalDevice loader_unwrap_physical_device(VkPhysicalDevice physicalDevice) {
418 struct loader_physical_device_tramp *phys_dev = (struct loader_physical_device_tramp *)physicalDevice;
Jon Ashburnfd02a0f2016-03-01 19:51:07 -0700419 return phys_dev->phys_dev;
420}
421
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700422static inline void loader_set_dispatch(void *obj, const void *data) { *((const void **)obj) = data; }
Chia-I Wufe333ed2015-04-11 15:34:07 +0800423
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700424static inline VkLayerDispatchTable *loader_get_dispatch(const void *obj) { return *((VkLayerDispatchTable **)obj); }
Chia-I Wufe333ed2015-04-11 15:34:07 +0800425
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700426static inline struct loader_dev_dispatch_table *loader_get_dev_dispatch(const void *obj) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700427 return *((struct loader_dev_dispatch_table **)obj);
Jon Ashburn6cb69f42015-11-17 15:31:02 -0700428}
429
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700430static inline VkLayerInstanceDispatchTable *loader_get_instance_layer_dispatch(const void *obj) {
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700431 return *((VkLayerInstanceDispatchTable **)obj);
Jon Ashburn13482452015-05-12 17:26:48 -0600432}
433
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700434static inline struct loader_instance_dispatch_table *loader_get_instance_dispatch(const void *obj) {
Mark Young274e4bc2017-01-19 21:10:49 -0700435 return *((struct loader_instance_dispatch_table **)obj);
436}
437
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700438static inline void loader_init_dispatch(void *obj, const void *data) {
Jon Ashburn167b2b12015-04-15 13:34:33 -0600439#ifdef DEBUG
Mark Lobodzinskie2859eb2017-01-26 13:34:13 -0700440 assert(valid_loader_magic_value(obj) &&
441 "Incompatible ICD, first dword must be initialized to "
442 "ICD_LOADER_MAGIC. See loader/README.md for details.");
Jon Ashburn167b2b12015-04-15 13:34:33 -0600443#endif
Chia-I Wufe333ed2015-04-11 15:34:07 +0800444
Jon Ashburn62a54d12015-05-01 18:00:33 -0600445 loader_set_dispatch(obj, data);
Chia-I Wufe333ed2015-04-11 15:34:07 +0800446}
447
Jon Ashburn13482452015-05-12 17:26:48 -0600448/* global variables used across files */
449extern struct loader_struct loader;
Jon Ashburnb4dee9c2015-08-28 15:19:27 -0600450extern THREAD_LOCAL_DECL struct loader_instance *tls_instance;
Jon Ashburne0367472015-08-18 18:04:47 -0600451extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_init);
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600452extern loader_platform_thread_mutex loader_lock;
Jon Ashburn7d4d51c2015-09-22 13:11:00 -0600453extern loader_platform_thread_mutex loader_json_lock;
Jon Ashburn7e8d8b42015-05-29 13:15:39 -0600454extern const VkLayerInstanceDispatchTable instance_disp;
Jon Ashburnd1eb3322016-02-10 20:59:26 -0700455extern const char *std_validation_str;
Jon Ashburn37e7f972015-04-06 10:58:22 -0600456
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600457struct loader_msg_callback_map_entry {
Courtney Goeltzenleuchter725db942015-12-09 15:48:16 -0700458 VkDebugReportCallbackEXT icd_obj;
459 VkDebugReportCallbackEXT loader_obj;
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600460};
461
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700462/* helper function definitions */
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700463void *loader_instance_heap_alloc(const struct loader_instance *instance, size_t size, VkSystemAllocationScope allocationScope);
464void loader_instance_heap_free(const struct loader_instance *instance, void *pMemory);
465void *loader_instance_heap_realloc(const struct loader_instance *instance, void *pMemory, size_t orig_size, size_t size,
Mark Young26c19372016-11-03 14:27:13 -0600466 VkSystemAllocationScope alloc_scope);
Mark Young74dd5d12016-06-30 13:02:42 -0600467void *loader_instance_tls_heap_alloc(size_t size);
468void loader_instance_tls_heap_free(void *pMemory);
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700469void *loader_device_heap_alloc(const struct loader_device *device, size_t size, VkSystemAllocationScope allocationScope);
Mark Young74dd5d12016-06-30 13:02:42 -0600470void loader_device_heap_free(const struct loader_device *device, void *pMemory);
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700471void *loader_device_heap_realloc(const struct loader_device *device, void *pMemory, size_t orig_size, size_t size,
Mark Young26c19372016-11-03 14:27:13 -0600472 VkSystemAllocationScope alloc_scope);
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700473
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700474void loader_log(const struct loader_instance *inst, VkFlags msg_type, int32_t msg_code, const char *format, ...);
Jon Ashburn663f8312016-02-12 08:20:06 -0700475
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700476bool compare_vk_extension_properties(const VkExtensionProperties *op1, const VkExtensionProperties *op2);
Courtney Goeltzenleuchter67146d02015-06-10 17:39:03 -0600477
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700478VkResult loader_validate_layers(const struct loader_instance *inst, const uint32_t layer_count,
479 const char *const *ppEnabledLayerNames, const struct loader_layer_list *list);
Courtney Goeltzenleuchter76ece702015-07-06 17:45:08 -0600480
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700481VkResult loader_validate_instance_extensions(const struct loader_instance *inst, const struct loader_extension_list *icd_exts,
482 const struct loader_layer_list *instance_layer,
483 const VkInstanceCreateInfo *pCreateInfo);
Courtney Goeltzenleuchter76ece702015-07-06 17:45:08 -0600484
Jon Ashburne0367472015-08-18 18:04:47 -0600485void loader_initialize(void);
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700486VkResult loader_copy_layer_properties(const struct loader_instance *inst, struct loader_layer_properties *dst,
Mark Young74dd5d12016-06-30 13:02:42 -0600487 struct loader_layer_properties *src);
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700488bool has_vk_extension_property_array(const VkExtensionProperties *vk_ext_prop, const uint32_t count,
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700489 const VkExtensionProperties *ext_array);
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700490bool has_vk_extension_property(const VkExtensionProperties *vk_ext_prop, const struct loader_extension_list *ext_list);
Jon Ashburn13482452015-05-12 17:26:48 -0600491
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700492VkResult loader_add_to_ext_list(const struct loader_instance *inst, struct loader_extension_list *ext_list,
493 uint32_t prop_list_count, const VkExtensionProperties *props);
494VkResult loader_add_to_dev_ext_list(const struct loader_instance *inst, struct loader_device_extension_list *ext_list,
495 const VkExtensionProperties *props, uint32_t entry_count, char **entrys);
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700496VkResult loader_add_device_extensions(const struct loader_instance *inst,
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700497 PFN_vkEnumerateDeviceExtensionProperties fpEnumerateDeviceExtensionProperties,
498 VkPhysicalDevice physical_device, const char *lib_name,
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700499 struct loader_extension_list *ext_list);
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700500VkResult loader_init_generic_list(const struct loader_instance *inst, struct loader_generic_list *list_info, size_t element_size);
501void loader_destroy_generic_list(const struct loader_instance *inst, struct loader_generic_list *list);
502void loader_destroy_layer_list(const struct loader_instance *inst, struct loader_device *device,
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700503 struct loader_layer_list *layer_list);
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700504void loader_delete_layer_properties(const struct loader_instance *inst, struct loader_layer_list *layer_list);
505bool loader_find_layer_name_array(const char *name, uint32_t layer_count, const char layer_list[][VK_MAX_EXTENSION_NAME_SIZE]);
506VkResult loader_expand_layer_names(struct loader_instance *inst, const char *key_name, uint32_t expand_count,
507 const char expand_names[][VK_MAX_EXTENSION_NAME_SIZE], uint32_t *layer_count,
508 char const *const **ppp_layer_names);
Jon Ashburnc325bc02016-05-16 14:01:18 -0600509void loader_init_std_validation_props(struct loader_layer_properties *props);
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700510void loader_delete_shadow_dev_layer_names(const struct loader_instance *inst, const VkDeviceCreateInfo *orig,
Chris Forbes7333fdd2016-04-06 20:49:02 +1200511 VkDeviceCreateInfo *ours);
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700512void loader_delete_shadow_inst_layer_names(const struct loader_instance *inst, const VkInstanceCreateInfo *orig,
Chris Forbes7333fdd2016-04-06 20:49:02 +1200513 VkInstanceCreateInfo *ours);
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700514VkResult loader_add_to_layer_list(const struct loader_instance *inst, struct loader_layer_list *list, uint32_t prop_list_count,
Mark Young74dd5d12016-06-30 13:02:42 -0600515 const struct loader_layer_properties *props);
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700516void loader_find_layer_name_add_list(const struct loader_instance *inst, const char *name, const enum layer_type type,
517 const struct loader_layer_list *search_list, struct loader_layer_list *found_list);
518void loader_scanned_icd_clear(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list);
519VkResult loader_icd_scan(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list);
520void loader_layer_scan(const struct loader_instance *inst, struct loader_layer_list *instance_layers);
521void loader_implicit_layer_scan(const struct loader_instance *inst, struct loader_layer_list *instance_layers);
522VkResult loader_get_icd_loader_instance_extensions(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list,
523 struct loader_extension_list *inst_exts);
524struct loader_icd_term *loader_get_icd_and_device(const VkDevice device, struct loader_device **found_dev, uint32_t *icd_index);
525void loader_init_dispatch_dev_ext(struct loader_instance *inst, struct loader_device *dev);
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700526void *loader_dev_ext_gpa(struct loader_instance *inst, const char *funcName);
527void *loader_get_dev_ext_trampoline(uint32_t index);
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700528bool loader_phys_dev_ext_gpa(struct loader_instance *inst, const char *funcName, bool perform_checking, void **tramp_addr,
529 void **term_addr);
Mark Young274e4bc2017-01-19 21:10:49 -0700530void *loader_get_phys_dev_ext_tramp(uint32_t index);
531void *loader_get_phys_dev_ext_termin(uint32_t index);
Jon Ashburn1c75aec2016-02-02 17:47:28 -0700532struct loader_instance *loader_get_instance(const VkInstance instance);
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700533void loader_deactivate_layers(const struct loader_instance *instance, struct loader_device *device, struct loader_layer_list *list);
534struct loader_device *loader_create_logical_device(const struct loader_instance *inst, const VkAllocationCallbacks *pAllocator);
535void loader_add_logical_device(const struct loader_instance *inst, struct loader_icd_term *icd_term,
Piers Daniell82107a62016-03-29 11:51:11 -0600536 struct loader_device *found_dev);
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700537void loader_remove_logical_device(const struct loader_instance *inst, struct loader_icd_term *icd_term,
538 struct loader_device *found_dev, const VkAllocationCallbacks *pAllocator);
Mark Young26c19372016-11-03 14:27:13 -0600539// NOTE: Outside of loader, this entry-point is only proivided for error
540// cleanup.
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700541void loader_destroy_logical_device(const struct loader_instance *inst, struct loader_device *dev,
Mark Young74dd5d12016-06-30 13:02:42 -0600542 const VkAllocationCallbacks *pAllocator);
543
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700544VkResult loader_enable_instance_layers(struct loader_instance *inst, const VkInstanceCreateInfo *pCreateInfo,
545 const struct loader_layer_list *instance_layers);
Jon Ashburn10f4e822015-06-10 10:06:06 -0600546void loader_deactivate_instance_layers(struct loader_instance *instance);
Courtney Goeltzenleuchter0bd705c2016-01-08 12:18:43 -0700547
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700548VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
549 struct loader_instance *inst, VkInstance *created_instance);
Courtney Goeltzenleuchter0bd705c2016-01-08 12:18:43 -0700550
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700551void loader_activate_instance_layer_extensions(struct loader_instance *inst, VkInstance created_inst);
552VkResult loader_enable_device_layers(const struct loader_instance *inst, struct loader_layer_list *activated_layer_list,
553 const VkDeviceCreateInfo *pCreateInfo, const struct loader_layer_list *device_layers);
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600554
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700555VkResult loader_create_device_chain(const struct loader_physical_device_tramp *pd, const VkDeviceCreateInfo *pCreateInfo,
556 const VkAllocationCallbacks *pAllocator, const struct loader_instance *inst,
557 struct loader_device *dev);
Mark Young274e4bc2017-01-19 21:10:49 -0700558
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700559VkResult loader_validate_device_extensions(struct loader_physical_device_tramp *phys_dev,
560 const struct loader_layer_list *activated_device_layers,
561 const struct loader_extension_list *icd_exts, const VkDeviceCreateInfo *pCreateInfo);
Courtney Goeltzenleuchter71b454b2015-07-05 11:28:29 -0600562
Mark Youngd4ff03b2017-01-12 12:27:19 -0700563VkResult setupLoaderTrampPhysDevs(VkInstance instance);
564VkResult setupLoaderTermPhysDevs(struct loader_instance *inst);
565
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700566/* instance layer chain termination entrypoint definitions */
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700567VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
568 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance);
Jon Ashburnb4dee9c2015-08-28 15:19:27 -0600569
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700570VKAPI_ATTR void VKAPI_CALL terminator_DestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator);
Jon Ashburnb4dee9c2015-08-28 15:19:27 -0600571
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700572VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount,
573 VkPhysicalDevice *pPhysicalDevices);
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700574
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700575VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice,
576 VkPhysicalDeviceFeatures *pFeatures);
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700577
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700578VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format,
579 VkFormatProperties *pFormatInfo);
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700580
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700581VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format,
582 VkImageType type, VkImageTiling tiling,
583 VkImageUsageFlags usage, VkImageCreateFlags flags,
584 VkImageFormatProperties *pImageFormatProperties);
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700585
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700586VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format,
587 VkImageType type, VkSampleCountFlagBits samples,
588 VkImageUsageFlags usage, VkImageTiling tiling,
589 uint32_t *pNumProperties,
590 VkSparseImageFormatProperties *pProperties);
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700591
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700592VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
593 VkPhysicalDeviceProperties *pProperties);
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700594
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700595VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
596 const char *pLayerName, uint32_t *pCount,
597 VkExtensionProperties *pProperties);
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700598
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700599VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount,
600 VkLayerProperties *pProperties);
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700601
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700602VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount,
603 VkQueueFamilyProperties *pProperties);
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700604
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700605VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice,
606 VkPhysicalDeviceMemoryProperties *pProperties);
Jon Ashburnc4e9ae62016-02-26 13:14:27 -0700607
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700608VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo,
609 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice);
Mark Lobodzinski8d325802016-02-02 18:53:34 -0700610
Mark Lobodzinski91c10752017-01-26 12:16:30 -0700611VkStringErrorFlags vk_string_validate(const int max_length, const char *char_array);
Mark Lobodzinski8d325802016-02-02 18:53:34 -0700612
Chia-I Wuc1e0f962014-08-04 08:03:57 +0800613#endif /* LOADER_H */