Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 1 | /* |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 2 | * |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014-2016 The Khronos Group Inc. |
| 4 | * Copyright (c) 2014-2016 Valve Corporation |
| 5 | * Copyright (c) 2014-2016 LunarG, Inc. |
Courtney Goeltzenleuchter | 8e1b8d9 | 2015-12-02 14:53:22 -0700 | [diff] [blame] | 6 | * Copyright (C) 2015 Google Inc. |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 7 | * |
Jon Ashburn | 4f80d67 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 8 | * 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 Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 11 | * |
Jon Ashburn | 4f80d67 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 12 | * http://www.apache.org/licenses/LICENSE-2.0 |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 13 | * |
Jon Ashburn | 4f80d67 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 14 | * 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 Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 19 | * |
| 20 | * Author: Jon Ashburn <jon@lunarg.com> |
| 21 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
Courtney Goeltzenleuchter | b9ce395 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 22 | * Author: Chia-I Wu <olvaffe@gmail.com> |
| 23 | * Author: Chia-I Wu <olv@lunarg.com> |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 24 | * Author: Mark Lobodzinski <mark@LunarG.com> |
Courtney Goeltzenleuchter | b9ce395 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 25 | * |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #ifndef LOADER_H |
| 29 | #define LOADER_H |
| 30 | |
David Pinedo | a503662 | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 31 | #include <vulkan/vulkan.h> |
Aaron Karp | 95c5f95 | 2016-03-13 16:41:59 -0400 | [diff] [blame] | 32 | #include "vk_loader_platform.h" |
Mark Lobodzinski | 663818f | 2016-05-24 16:04:56 -0600 | [diff] [blame] | 33 | #include "vk_loader_layer.h" |
David Pinedo | a503662 | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 34 | #include <vulkan/vk_layer.h> |
Mark Lobodzinski | 663818f | 2016-05-24 16:04:56 -0600 | [diff] [blame] | 35 | |
David Pinedo | a503662 | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 36 | #include <vulkan/vk_icd.h> |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 37 | #include <assert.h> |
| 38 | |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 39 | #if defined(__GNUC__) && __GNUC__ >= 4 |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 40 | #define LOADER_EXPORT __attribute__((visibility("default"))) |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 41 | #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 42 | #define LOADER_EXPORT __attribute__((visibility("default"))) |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 43 | #else |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 44 | #define LOADER_EXPORT |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 45 | #endif |
| 46 | |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 47 | // A debug option to disable allocators at compile time to investigate future issues. |
| 48 | #define DEBUG_DISABLE_APP_ALLOCATORS 0 |
| 49 | |
Jon Ashburn | b2379c5 | 2015-08-04 10:22:33 -0600 | [diff] [blame] | 50 | #define MAX_STRING_SIZE 1024 |
Courtney Goeltzenleuchter | 44667cc | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 51 | #define VK_MAJOR(version) (version >> 22) |
| 52 | #define VK_MINOR(version) ((version >> 12) & 0x3ff) |
| 53 | #define VK_PATCH(version) (version & 0xfff) |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 54 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 55 | enum layer_type { |
Jon Ashburn | c325bc0 | 2016-05-16 14:01:18 -0600 | [diff] [blame] | 56 | VK_LAYER_TYPE_INSTANCE_EXPLICIT = 0x1, |
| 57 | VK_LAYER_TYPE_INSTANCE_IMPLICIT = 0x2, |
| 58 | VK_LAYER_TYPE_META_EXPLICT = 0x4, |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 59 | }; |
| 60 | |
Mark Lobodzinski | 8d32580 | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 61 | typedef enum VkStringErrorFlagBits { |
Jon Ashburn | b1cdf2e | 2016-02-10 20:50:19 -0700 | [diff] [blame] | 62 | VK_STRING_ERROR_NONE = 0x00000000, |
| 63 | VK_STRING_ERROR_LENGTH = 0x00000001, |
| 64 | VK_STRING_ERROR_BAD_DATA = 0x00000002, |
Mark Lobodzinski | 8d32580 | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 65 | } VkStringErrorFlagBits; |
| 66 | typedef VkFlags VkStringErrorFlags; |
| 67 | |
Jon Ashburn | b1cdf2e | 2016-02-10 20:50:19 -0700 | [diff] [blame] | 68 | static const int MaxLoaderStringLength = 256; |
| 69 | static const char UTF8_ONE_BYTE_CODE = 0xC0; |
| 70 | static const char UTF8_ONE_BYTE_MASK = 0xE0; |
| 71 | static const char UTF8_TWO_BYTE_CODE = 0xE0; |
| 72 | static const char UTF8_TWO_BYTE_MASK = 0xF0; |
| 73 | static const char UTF8_THREE_BYTE_CODE = 0xF0; |
| 74 | static const char UTF8_THREE_BYTE_MASK = 0xF8; |
| 75 | static const char UTF8_DATA_BYTE_CODE = 0x80; |
| 76 | static const char UTF8_DATA_BYTE_MASK = 0xC0; |
Mark Lobodzinski | 8d32580 | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 77 | |
Mark Lobodzinski | bf266f4 | 2016-06-29 14:18:30 -0600 | [diff] [blame] | 78 | static const char std_validation_names[7][VK_MAX_EXTENSION_NAME_SIZE] = { |
| 79 | "VK_LAYER_GOOGLE_threading", "VK_LAYER_LUNARG_parameter_validation", |
| 80 | "VK_LAYER_LUNARG_object_tracker", "VK_LAYER_LUNARG_image", |
| 81 | "VK_LAYER_LUNARG_core_validation", "VK_LAYER_LUNARG_swapchain", |
| 82 | "VK_LAYER_GOOGLE_unique_objects"}; |
Jon Ashburn | d1eb332 | 2016-02-10 20:59:26 -0700 | [diff] [blame] | 83 | |
Jon Ashburn | 6b00b47 | 2015-12-10 08:51:10 -0700 | [diff] [blame] | 84 | // form of all dynamic lists/arrays |
| 85 | // only the list element should be changed |
| 86 | struct loader_generic_list { |
| 87 | size_t capacity; |
| 88 | uint32_t count; |
| 89 | void *list; |
| 90 | }; |
| 91 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 92 | struct loader_extension_list { |
| 93 | size_t capacity; |
| 94 | uint32_t count; |
Jon Ashburn | b7d327c | 2015-08-04 11:14:18 -0600 | [diff] [blame] | 95 | VkExtensionProperties *list; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 96 | }; |
| 97 | |
Jon Ashburn | 92cdb01 | 2015-12-10 18:17:34 -0700 | [diff] [blame] | 98 | struct loader_dev_ext_props { |
| 99 | VkExtensionProperties props; |
| 100 | uint32_t entrypoint_count; |
| 101 | char **entrypoints; |
| 102 | }; |
| 103 | |
| 104 | struct loader_device_extension_list { |
| 105 | size_t capacity; |
| 106 | uint32_t count; |
| 107 | struct loader_dev_ext_props *list; |
| 108 | }; |
| 109 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 110 | struct loader_name_value { |
Jon Ashburn | b2379c5 | 2015-08-04 10:22:33 -0600 | [diff] [blame] | 111 | char name[MAX_STRING_SIZE]; |
| 112 | char value[MAX_STRING_SIZE]; |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 113 | }; |
| 114 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 115 | struct loader_layer_functions { |
Jon Ashburn | b2379c5 | 2015-08-04 10:22:33 -0600 | [diff] [blame] | 116 | char str_gipa[MAX_STRING_SIZE]; |
| 117 | char str_gdpa[MAX_STRING_SIZE]; |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 118 | PFN_vkGetInstanceProcAddr get_instance_proc_addr; |
| 119 | PFN_vkGetDeviceProcAddr get_device_proc_addr; |
| 120 | }; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 121 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 122 | struct loader_layer_properties { |
Courtney Goeltzenleuchter | 44667cc | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 123 | VkLayerProperties info; |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 124 | enum layer_type type; |
Jon Ashburn | b4c2423 | 2015-08-20 16:35:30 -0600 | [diff] [blame] | 125 | char lib_name[MAX_STRING_SIZE]; |
Jon Ashburn | d3cf955 | 2016-04-20 13:21:17 -0600 | [diff] [blame] | 126 | loader_platform_dl_handle lib_handle; |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 127 | struct loader_layer_functions functions; |
| 128 | struct loader_extension_list instance_extension_list; |
Jon Ashburn | 92cdb01 | 2015-12-10 18:17:34 -0700 | [diff] [blame] | 129 | struct loader_device_extension_list device_extension_list; |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 130 | struct loader_name_value disable_env_var; |
| 131 | struct loader_name_value enable_env_var; |
| 132 | }; |
| 133 | |
| 134 | struct loader_layer_list { |
| 135 | size_t capacity; |
| 136 | uint32_t count; |
| 137 | struct loader_layer_properties *list; |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 138 | }; |
| 139 | |
Jon Ashburn | 6cb69f4 | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 140 | struct loader_dispatch_hash_list { |
| 141 | size_t capacity; |
| 142 | uint32_t count; |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 143 | uint32_t *index; // index into the dev_ext dispatch table |
Jon Ashburn | 6cb69f4 | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 144 | }; |
| 145 | |
| 146 | #define MAX_NUM_DEV_EXTS 250 |
Mark Young | dd904ae | 2016-09-02 11:41:28 -0600 | [diff] [blame] | 147 | // loader_dispatch_hash_entry and loader_dev_ext_dispatch_table.dev_ext have |
| 148 | // one to one correspondence; one loader_dispatch_hash_entry for one dev_ext |
| 149 | // dispatch entry. |
Jon Ashburn | 6cb69f4 | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 150 | // Also have a one to one correspondence with functions in dev_ext_trampoline.c |
| 151 | struct loader_dispatch_hash_entry { |
| 152 | char *func_name; |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 153 | struct loader_dispatch_hash_list list; // to handle hashing collisions |
Jon Ashburn | 6cb69f4 | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 154 | }; |
| 155 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 156 | typedef void(VKAPI_PTR *PFN_vkDevExt)(VkDevice device); |
Jon Ashburn | 6cb69f4 | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 157 | struct loader_dev_ext_dispatch_table { |
Mark Young | dd904ae | 2016-09-02 11:41:28 -0600 | [diff] [blame] | 158 | PFN_vkDevExt dev_ext[MAX_NUM_DEV_EXTS]; |
Jon Ashburn | 6cb69f4 | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 159 | }; |
| 160 | |
| 161 | struct loader_dev_dispatch_table { |
| 162 | VkLayerDispatchTable core_dispatch; |
| 163 | struct loader_dev_ext_dispatch_table ext_dispatch; |
| 164 | }; |
| 165 | |
Mark Young | 1d64526 | 2016-09-07 08:50:32 -0600 | [diff] [blame] | 166 | // per CreateDevice structure |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 167 | struct loader_device { |
Jon Ashburn | 6cb69f4 | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 168 | struct loader_dev_dispatch_table loader_dispatch; |
Mark Young | 0f7adeb | 2016-11-07 13:27:02 -0700 | [diff] [blame] | 169 | VkDevice chain_device; // device object from the dispatch chain |
| 170 | VkDevice icd_device; // device object from the icd |
| 171 | struct loader_physical_device_term *phys_dev_term; |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 172 | |
Courtney Goeltzenleuchter | 44667cc | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 173 | struct loader_layer_list activated_layer_list; |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 174 | |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 175 | VkAllocationCallbacks alloc_callbacks; |
| 176 | |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 177 | struct loader_device *next; |
| 178 | }; |
| 179 | |
Jon Ashburn | 392c562 | 2015-06-10 16:11:42 -0600 | [diff] [blame] | 180 | /* per ICD structure */ |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 181 | struct loader_icd_term { |
Jon Ashburn | b4c2423 | 2015-08-20 16:35:30 -0600 | [diff] [blame] | 182 | // pointers to find other structs |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 183 | const struct loader_scanned_icd *scanned_icd; |
Jon Ashburn | b4c2423 | 2015-08-20 16:35:30 -0600 | [diff] [blame] | 184 | const struct loader_instance *this_instance; |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 185 | struct loader_device *logical_device_list; |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 186 | VkInstance instance; // instance object from the icd |
Jon Ashburn | c89dd4a | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 187 | PFN_vkGetDeviceProcAddr GetDeviceProcAddr; |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 188 | PFN_vkDestroyInstance DestroyInstance; |
| 189 | PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices; |
Chris Forbes | 1c946ec | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 190 | PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures; |
Courtney Goeltzenleuchter | 2b6559e | 2015-07-12 12:52:09 -0600 | [diff] [blame] | 191 | PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties; |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 192 | PFN_vkGetPhysicalDeviceImageFormatProperties |
| 193 | GetPhysicalDeviceImageFormatProperties; |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 194 | PFN_vkCreateDevice CreateDevice; |
Tony Barbour | 4e657ba | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 195 | PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties; |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 196 | PFN_vkGetPhysicalDeviceQueueFamilyProperties |
| 197 | GetPhysicalDeviceQueueFamilyProperties; |
Tony Barbour | 4e657ba | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 198 | PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties; |
Courtney Goeltzenleuchter | e25064c | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 199 | PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties; |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 200 | PFN_vkGetPhysicalDeviceSparseImageFormatProperties |
| 201 | GetPhysicalDeviceSparseImageFormatProperties; |
Courtney Goeltzenleuchter | 725db94 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 202 | PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallbackEXT; |
| 203 | PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallbackEXT; |
| 204 | PFN_vkDebugReportMessageEXT DebugReportMessageEXT; |
Mark Young | 0f7adeb | 2016-11-07 13:27:02 -0700 | [diff] [blame] | 205 | PFN_vkDebugMarkerSetObjectTagEXT DebugMarkerSetObjectTagEXT; |
| 206 | PFN_vkDebugMarkerSetObjectNameEXT DebugMarkerSetObjectNameEXT; |
Ian Elliott | ec73634 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 207 | PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR; |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 208 | PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR |
| 209 | GetPhysicalDeviceSurfaceCapabilitiesKHR; |
Ian Elliott | ea666b2 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 210 | PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR; |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 211 | PFN_vkGetPhysicalDeviceSurfacePresentModesKHR |
| 212 | GetPhysicalDeviceSurfacePresentModesKHR; |
Mark Lobodzinski | f739d1d | 2016-08-29 14:21:14 -0600 | [diff] [blame] | 213 | PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV |
| 214 | GetPhysicalDeviceExternalImageFormatPropertiesNV; |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 215 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 216 | PFN_vkCreateWin32SurfaceKHR CreateWin32SurfaceKHR; |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 217 | PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR |
| 218 | GetPhysicalDeviceWin32PresentationSupportKHR; |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 219 | #endif |
| 220 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 221 | PFN_vkCreateMirSurfaceKHR CreateMirSurfaceKHR; |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 222 | PFN_vkGetPhysicalDeviceMirPresentationSupportKHR |
Mark Lobodzinski | b16da05 | 2016-08-31 09:31:29 -0600 | [diff] [blame] | 223 | GetPhysicalDeviceMirPresentationSupportKHR; |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 224 | #endif |
| 225 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 226 | PFN_vkCreateWaylandSurfaceKHR CreateWaylandSurfaceKHR; |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 227 | PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR |
| 228 | GetPhysicalDeviceWaylandPresentationSupportKHR; |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 229 | #endif |
| 230 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 231 | PFN_vkCreateXcbSurfaceKHR CreateXcbSurfaceKHR; |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 232 | PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR |
| 233 | GetPhysicalDeviceXcbPresentationSupportKHR; |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 234 | #endif |
| 235 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 236 | PFN_vkCreateXlibSurfaceKHR CreateXlibSurfaceKHR; |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 237 | PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR |
| 238 | GetPhysicalDeviceXlibPresentationSupportKHR; |
Ian Elliott | e851dd6 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 239 | #endif |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 240 | PFN_vkGetPhysicalDeviceDisplayPropertiesKHR |
| 241 | GetPhysicalDeviceDisplayPropertiesKHR; |
| 242 | PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR |
| 243 | GetPhysicalDeviceDisplayPlanePropertiesKHR; |
| 244 | PFN_vkGetDisplayPlaneSupportedDisplaysKHR |
| 245 | GetDisplayPlaneSupportedDisplaysKHR; |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 246 | PFN_vkGetDisplayModePropertiesKHR GetDisplayModePropertiesKHR; |
| 247 | PFN_vkCreateDisplayModeKHR CreateDisplayModeKHR; |
| 248 | PFN_vkGetDisplayPlaneCapabilitiesKHR GetDisplayPlaneCapabilitiesKHR; |
| 249 | PFN_vkCreateDisplayPlaneSurfaceKHR CreateDisplayPlaneSurfaceKHR; |
| 250 | PFN_vkDestroySurfaceKHR DestroySurfaceKHR; |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 251 | PFN_vkCreateSwapchainKHR CreateSwapchainKHR; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 252 | struct loader_icd_term *next; |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 253 | }; |
| 254 | |
Mark Young | 1d64526 | 2016-09-07 08:50:32 -0600 | [diff] [blame] | 255 | // per ICD library structure |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 256 | struct loader_icd_tramp_list { |
Jon Ashburn | e036747 | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 257 | size_t capacity; |
| 258 | uint32_t count; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 259 | struct loader_scanned_icd *scanned_list; |
Jon Ashburn | e036747 | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 260 | }; |
| 261 | |
Mark Young | 1d64526 | 2016-09-07 08:50:32 -0600 | [diff] [blame] | 262 | union loader_instance_extension_enables { |
| 263 | struct { |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 264 | uint8_t ext_debug_report : 1; |
Mark Young | 1d64526 | 2016-09-07 08:50:32 -0600 | [diff] [blame] | 265 | uint8_t nv_external_memory_capabilities : 1; |
| 266 | }; |
| 267 | uint64_t padding[4]; |
| 268 | }; |
| 269 | |
| 270 | // per instance structure |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 271 | struct loader_instance { |
Jon Ashburn | ebfa25e | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 272 | VkLayerInstanceDispatchTable *disp; // must be first entry in structure |
| 273 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 274 | uint32_t total_gpu_count; |
| 275 | struct loader_physical_device_term *phys_devs_term; |
| 276 | struct loader_physical_device_tramp *phys_devs_tramp; |
| 277 | |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 278 | struct loader_instance *next; |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 279 | |
| 280 | uint32_t total_icd_count; |
| 281 | struct loader_icd_term *icd_terms; |
| 282 | struct loader_icd_tramp_list icd_tramp_list; |
| 283 | |
Jon Ashburn | 6cb69f4 | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 284 | struct loader_dispatch_hash_entry disp_hash[MAX_NUM_DEV_EXTS]; |
Jon Ashburn | b4c2423 | 2015-08-20 16:35:30 -0600 | [diff] [blame] | 285 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 286 | struct loader_msg_callback_map_entry *icd_msg_callback_map; |
| 287 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 288 | struct loader_layer_list instance_layer_list; |
Courtney Goeltzenleuchter | 44667cc | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 289 | struct loader_layer_list activated_layer_list; |
Jon Ashburn | c325bc0 | 2016-05-16 14:01:18 -0600 | [diff] [blame] | 290 | bool activated_layers_are_std_val; |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 291 | VkInstance instance; // layers/ICD instance returned to trampoline |
Courtney Goeltzenleuchter | 0bd705c | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 292 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 293 | struct loader_extension_list ext_list; // icds and loaders extensions |
| 294 | union loader_instance_extension_enables enabled_known_extensions; |
| 295 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 296 | VkLayerDbgFunctionNode *DbgFunctionHead; |
Ian Elliott | defd6da | 2016-03-31 10:48:19 -0600 | [diff] [blame] | 297 | uint32_t num_tmp_callbacks; |
| 298 | VkDebugReportCallbackCreateInfoEXT *tmp_dbg_create_infos; |
| 299 | VkDebugReportCallbackEXT *tmp_callbacks; |
Courtney Goeltzenleuchter | 71b454b | 2015-07-05 11:28:29 -0600 | [diff] [blame] | 300 | |
Chia-I Wu | 227c8b3 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 301 | VkAllocationCallbacks alloc_callbacks; |
Ian Elliott | ed33eb7 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 302 | |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 303 | bool wsi_surface_enabled; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 304 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 305 | bool wsi_win32_surface_enabled; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 306 | #endif |
| 307 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 308 | bool wsi_mir_surface_enabled; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 309 | #endif |
| 310 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 311 | bool wsi_wayland_surface_enabled; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 312 | #endif |
| 313 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 314 | bool wsi_xcb_surface_enabled; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 315 | #endif |
| 316 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Ian Elliott | 54cea23 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 317 | bool wsi_xlib_surface_enabled; |
Mark Lobodzinski | 1ad14b4 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 318 | #endif |
| 319 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 320 | bool wsi_android_surface_enabled; |
| 321 | #endif |
Jon Ashburn | cc370d0 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 322 | bool wsi_display_enabled; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 323 | }; |
| 324 | |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 325 | /* VkPhysicalDevice requires special treatment by loader. Firstly, terminator |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 326 | * code must be able to get the struct loader_icd_term to call into the proper |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 327 | * driver (multiple ICD/gpu case). This can be accomplished by wrapping the |
| 328 | * created VkPhysicalDevice in loader terminate_EnumeratePhysicalDevices(). |
Piers Daniell | 82107a6 | 2016-03-29 11:51:11 -0600 | [diff] [blame] | 329 | * Secondly, the loader must be able to handle wrapped by layer VkPhysicalDevice |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 330 | * in trampoline code. This implies, that the loader trampoline code must also |
| 331 | * wrap the VkPhysicalDevice object in trampoline code. Thus, loader has to |
| 332 | * wrap the VkPhysicalDevice created object twice. In trampoline code it can't |
| 333 | * rely on the terminator object wrapping since a layer may also wrap. Since |
| 334 | * trampoline code wraps the VkPhysicalDevice this means all loader trampoline |
| 335 | * code that passes a VkPhysicalDevice should unwrap it. */ |
| 336 | |
| 337 | /* per enumerated PhysicalDevice structure, used to wrap in trampoline code and |
| 338 | also same structure used to wrap in terminator code */ |
Jon Ashburn | c3519e4 | 2016-03-24 15:49:57 -0600 | [diff] [blame] | 339 | struct loader_physical_device_tramp { |
| 340 | VkLayerInstanceDispatchTable *disp; // must be first entry in structure |
Piers Daniell | 82107a6 | 2016-03-29 11:51:11 -0600 | [diff] [blame] | 341 | struct loader_instance *this_instance; |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 342 | VkPhysicalDevice phys_dev; // object from layers/loader terminator |
Jon Ashburn | c3519e4 | 2016-03-24 15:49:57 -0600 | [diff] [blame] | 343 | }; |
| 344 | |
| 345 | /* per enumerated PhysicalDevice structure, used to wrap in terminator code */ |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 346 | struct loader_physical_device_term { |
Jon Ashburn | 969caa4 | 2015-11-01 14:04:06 -0700 | [diff] [blame] | 347 | VkLayerInstanceDispatchTable *disp; // must be first entry in structure |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 348 | struct loader_icd_term *this_icd_term; |
Mark Young | 5467d67 | 2016-06-28 10:52:43 -0600 | [diff] [blame] | 349 | uint8_t icd_index; |
Jon Ashburn | c3519e4 | 2016-03-24 15:49:57 -0600 | [diff] [blame] | 350 | VkPhysicalDevice phys_dev; // object from ICD |
Jon Ashburn | 969caa4 | 2015-11-01 14:04:06 -0700 | [diff] [blame] | 351 | }; |
| 352 | |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 353 | struct loader_struct { |
| 354 | struct loader_instance *instances; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 355 | }; |
| 356 | |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 357 | struct loader_scanned_icd { |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 358 | char *lib_name; |
| 359 | loader_platform_dl_handle handle; |
Jon Ashburn | 27109e8 | 2015-11-17 17:35:40 -0700 | [diff] [blame] | 360 | uint32_t api_version; |
Jon Ashburn | 68b06d6 | 2016-04-25 11:09:37 -0600 | [diff] [blame] | 361 | uint32_t interface_version; |
Jon Ashburn | c7ca48d | 2015-07-16 10:17:29 -0600 | [diff] [blame] | 362 | PFN_vkGetInstanceProcAddr GetInstanceProcAddr; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 363 | PFN_vkCreateInstance CreateInstance; |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 364 | PFN_vkEnumerateInstanceExtensionProperties |
| 365 | EnumerateInstanceExtensionProperties; |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 366 | }; |
| 367 | |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 368 | static inline struct loader_instance *loader_instance(VkInstance instance) { |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 369 | return (struct loader_instance *)instance; |
Jon Ashburn | 399c916 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 370 | } |
| 371 | |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 372 | static inline VkPhysicalDevice |
| 373 | loader_unwrap_physical_device(VkPhysicalDevice physicalDevice) { |
Piers Daniell | a9ccaed | 2016-03-31 14:47:57 -0600 | [diff] [blame] | 374 | struct loader_physical_device_tramp *phys_dev = |
| 375 | (struct loader_physical_device_tramp *)physicalDevice; |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 376 | return phys_dev->phys_dev; |
| 377 | } |
| 378 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 379 | static inline void loader_set_dispatch(void *obj, const void *data) { |
| 380 | *((const void **)obj) = data; |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 381 | } |
| 382 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 383 | static inline VkLayerDispatchTable *loader_get_dispatch(const void *obj) { |
| 384 | return *((VkLayerDispatchTable **)obj); |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 385 | } |
| 386 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 387 | static inline struct loader_dev_dispatch_table * |
| 388 | loader_get_dev_dispatch(const void *obj) { |
| 389 | return *((struct loader_dev_dispatch_table **)obj); |
Jon Ashburn | 6cb69f4 | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 390 | } |
| 391 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 392 | static inline VkLayerInstanceDispatchTable * |
| 393 | loader_get_instance_dispatch(const void *obj) { |
| 394 | return *((VkLayerInstanceDispatchTable **)obj); |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 395 | } |
| 396 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 397 | static inline void loader_init_dispatch(void *obj, const void *data) { |
Jon Ashburn | 167b2b1 | 2015-04-15 13:34:33 -0600 | [diff] [blame] | 398 | #ifdef DEBUG |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 399 | assert(valid_loader_magic_value(obj) && |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 400 | "Incompatible ICD, first dword must be initialized to " |
| 401 | "ICD_LOADER_MAGIC. See loader/README.md for details."); |
Jon Ashburn | 167b2b1 | 2015-04-15 13:34:33 -0600 | [diff] [blame] | 402 | #endif |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 403 | |
Jon Ashburn | 62a54d1 | 2015-05-01 18:00:33 -0600 | [diff] [blame] | 404 | loader_set_dispatch(obj, data); |
Chia-I Wu | fe333ed | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 405 | } |
| 406 | |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 407 | /* global variables used across files */ |
| 408 | extern struct loader_struct loader; |
Jon Ashburn | b4dee9c | 2015-08-28 15:19:27 -0600 | [diff] [blame] | 409 | extern THREAD_LOCAL_DECL struct loader_instance *tls_instance; |
Jon Ashburn | e036747 | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 410 | extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_init); |
Jon Ashburn | 7e8d8b4 | 2015-05-29 13:15:39 -0600 | [diff] [blame] | 411 | extern loader_platform_thread_mutex loader_lock; |
Jon Ashburn | 7d4d51c | 2015-09-22 13:11:00 -0600 | [diff] [blame] | 412 | extern loader_platform_thread_mutex loader_json_lock; |
Jon Ashburn | 7e8d8b4 | 2015-05-29 13:15:39 -0600 | [diff] [blame] | 413 | extern const VkLayerInstanceDispatchTable instance_disp; |
Jon Ashburn | d1eb332 | 2016-02-10 20:59:26 -0700 | [diff] [blame] | 414 | extern const char *std_validation_str; |
Jon Ashburn | 37e7f97 | 2015-04-06 10:58:22 -0600 | [diff] [blame] | 415 | |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 416 | struct loader_msg_callback_map_entry { |
Courtney Goeltzenleuchter | 725db94 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 417 | VkDebugReportCallbackEXT icd_obj; |
| 418 | VkDebugReportCallbackEXT loader_obj; |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 419 | }; |
| 420 | |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 421 | /* helper function definitions */ |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 422 | void *loader_instance_heap_alloc(const struct loader_instance *instance, |
| 423 | size_t size, |
| 424 | VkSystemAllocationScope allocationScope); |
| 425 | void loader_instance_heap_free(const struct loader_instance *instance, |
| 426 | void *pMemory); |
| 427 | void *loader_instance_heap_realloc(const struct loader_instance *instance, |
| 428 | void *pMemory, size_t orig_size, size_t size, |
| 429 | VkSystemAllocationScope alloc_scope); |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 430 | void *loader_instance_tls_heap_alloc(size_t size); |
| 431 | void loader_instance_tls_heap_free(void *pMemory); |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 432 | void *loader_device_heap_alloc(const struct loader_device *device, size_t size, |
| 433 | VkSystemAllocationScope allocationScope); |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 434 | void loader_device_heap_free(const struct loader_device *device, void *pMemory); |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 435 | void *loader_device_heap_realloc(const struct loader_device *device, |
| 436 | void *pMemory, size_t orig_size, size_t size, |
| 437 | VkSystemAllocationScope alloc_scope); |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 438 | |
Jon Ashburn | 663f831 | 2016-02-12 08:20:06 -0700 | [diff] [blame] | 439 | void loader_log(const struct loader_instance *inst, VkFlags msg_type, |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 440 | int32_t msg_code, const char *format, ...); |
Jon Ashburn | 663f831 | 2016-02-12 08:20:06 -0700 | [diff] [blame] | 441 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 442 | bool compare_vk_extension_properties(const VkExtensionProperties *op1, |
| 443 | const VkExtensionProperties *op2); |
Courtney Goeltzenleuchter | 67146d0 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 444 | |
Mark Lobodzinski | 8d32580 | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 445 | VkResult loader_validate_layers(const struct loader_instance *inst, |
| 446 | const uint32_t layer_count, |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 447 | const char *const *ppEnabledLayerNames, |
| 448 | const struct loader_layer_list *list); |
Courtney Goeltzenleuchter | 76ece70 | 2015-07-06 17:45:08 -0600 | [diff] [blame] | 449 | |
| 450 | VkResult loader_validate_instance_extensions( |
Mark Lobodzinski | 8d32580 | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 451 | const struct loader_instance *inst, |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 452 | const struct loader_extension_list *icd_exts, |
| 453 | const struct loader_layer_list *instance_layer, |
| 454 | const VkInstanceCreateInfo *pCreateInfo); |
Courtney Goeltzenleuchter | 76ece70 | 2015-07-06 17:45:08 -0600 | [diff] [blame] | 455 | |
Jon Ashburn | e036747 | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 456 | void loader_initialize(void); |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 457 | VkResult loader_copy_layer_properties(const struct loader_instance *inst, |
| 458 | struct loader_layer_properties *dst, |
| 459 | struct loader_layer_properties *src); |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 460 | bool has_vk_extension_property_array(const VkExtensionProperties *vk_ext_prop, |
| 461 | const uint32_t count, |
| 462 | const VkExtensionProperties *ext_array); |
| 463 | bool has_vk_extension_property(const VkExtensionProperties *vk_ext_prop, |
| 464 | const struct loader_extension_list *ext_list); |
Jon Ashburn | 1348245 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 465 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 466 | VkResult loader_add_to_ext_list(const struct loader_instance *inst, |
| 467 | struct loader_extension_list *ext_list, |
| 468 | uint32_t prop_list_count, |
| 469 | const VkExtensionProperties *props); |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 470 | VkResult |
| 471 | loader_add_to_dev_ext_list(const struct loader_instance *inst, |
| 472 | struct loader_device_extension_list *ext_list, |
| 473 | const VkExtensionProperties *props, |
| 474 | uint32_t entry_count, char **entrys); |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 475 | VkResult loader_add_device_extensions(const struct loader_instance *inst, |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 476 | PFN_vkEnumerateDeviceExtensionProperties |
| 477 | fpEnumerateDeviceExtensionProperties, |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 478 | VkPhysicalDevice physical_device, |
| 479 | const char *lib_name, |
| 480 | struct loader_extension_list *ext_list); |
Mark Young | ce38e31 | 2016-08-19 15:25:08 -0600 | [diff] [blame] | 481 | VkResult loader_init_generic_list(const struct loader_instance *inst, |
| 482 | struct loader_generic_list *list_info, |
| 483 | size_t element_size); |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 484 | void loader_destroy_generic_list(const struct loader_instance *inst, |
| 485 | struct loader_generic_list *list); |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 486 | void loader_destroy_layer_list(const struct loader_instance *inst, |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 487 | struct loader_device *device, |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 488 | struct loader_layer_list *layer_list); |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 489 | void loader_delete_layer_properties(const struct loader_instance *inst, |
| 490 | struct loader_layer_list *layer_list); |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 491 | bool loader_find_layer_name_array( |
| 492 | const char *name, uint32_t layer_count, |
| 493 | const char layer_list[][VK_MAX_EXTENSION_NAME_SIZE]); |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 494 | VkResult loader_expand_layer_names( |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 495 | struct loader_instance *inst, const char *key_name, uint32_t expand_count, |
Jon Ashburn | d1eb332 | 2016-02-10 20:59:26 -0700 | [diff] [blame] | 496 | const char expand_names[][VK_MAX_EXTENSION_NAME_SIZE], |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 497 | uint32_t *layer_count, char const *const **ppp_layer_names); |
Jon Ashburn | c325bc0 | 2016-05-16 14:01:18 -0600 | [diff] [blame] | 498 | void loader_init_std_validation_props(struct loader_layer_properties *props); |
Chris Forbes | 7333fdd | 2016-04-06 20:49:02 +1200 | [diff] [blame] | 499 | void loader_delete_shadow_dev_layer_names(const struct loader_instance *inst, |
| 500 | const VkDeviceCreateInfo *orig, |
| 501 | VkDeviceCreateInfo *ours); |
| 502 | void loader_delete_shadow_inst_layer_names(const struct loader_instance *inst, |
| 503 | const VkInstanceCreateInfo *orig, |
| 504 | VkInstanceCreateInfo *ours); |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 505 | VkResult loader_add_to_layer_list(const struct loader_instance *inst, |
| 506 | struct loader_layer_list *list, |
| 507 | uint32_t prop_list_count, |
| 508 | const struct loader_layer_properties *props); |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 509 | void loader_find_layer_name_add_list( |
| 510 | const struct loader_instance *inst, const char *name, |
| 511 | const enum layer_type type, const struct loader_layer_list *search_list, |
| 512 | struct loader_layer_list *found_list); |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 513 | void loader_scanned_icd_clear(const struct loader_instance *inst, |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 514 | struct loader_icd_tramp_list *icd_tramp_list); |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 515 | VkResult loader_icd_scan(const struct loader_instance *inst, |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 516 | struct loader_icd_tramp_list *icd_tramp_list); |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 517 | void loader_layer_scan(const struct loader_instance *inst, |
Jon Ashburn | c325bc0 | 2016-05-16 14:01:18 -0600 | [diff] [blame] | 518 | struct loader_layer_list *instance_layers); |
Jeremy Hayes | 10d78f1 | 2016-04-01 11:40:26 -0600 | [diff] [blame] | 519 | void loader_implicit_layer_scan(const struct loader_instance *inst, |
Jon Ashburn | c325bc0 | 2016-05-16 14:01:18 -0600 | [diff] [blame] | 520 | struct loader_layer_list *instance_layers); |
Mark Young | ce38e31 | 2016-08-19 15:25:08 -0600 | [diff] [blame] | 521 | VkResult loader_get_icd_loader_instance_extensions( |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 522 | const struct loader_instance *inst, |
| 523 | struct loader_icd_tramp_list *icd_tramp_list, |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 524 | struct loader_extension_list *inst_exts); |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 525 | struct loader_icd_term * |
| 526 | loader_get_icd_and_device(const VkDevice device, |
| 527 | struct loader_device **found_dev, |
| 528 | uint32_t *icd_index); |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 529 | void loader_init_dispatch_dev_ext(struct loader_instance *inst, |
| 530 | struct loader_device *dev); |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 531 | void *loader_dev_ext_gpa(struct loader_instance *inst, const char *funcName); |
| 532 | void *loader_get_dev_ext_trampoline(uint32_t index); |
Mark Young | 0f7adeb | 2016-11-07 13:27:02 -0700 | [diff] [blame] | 533 | void loader_override_terminating_device_proc(struct loader_device *dev); |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 534 | struct loader_instance *loader_get_instance(const VkInstance instance); |
Jon Ashburn | d3cf955 | 2016-04-20 13:21:17 -0600 | [diff] [blame] | 535 | void loader_deactivate_layers(const struct loader_instance *instance, |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 536 | struct loader_device *device, |
Jon Ashburn | d3cf955 | 2016-04-20 13:21:17 -0600 | [diff] [blame] | 537 | struct loader_layer_list *list); |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 538 | struct loader_device * |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 539 | loader_create_logical_device(const struct loader_instance *inst, |
| 540 | const VkAllocationCallbacks *pAllocator); |
Piers Daniell | 82107a6 | 2016-03-29 11:51:11 -0600 | [diff] [blame] | 541 | void loader_add_logical_device(const struct loader_instance *inst, |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 542 | struct loader_icd_term *icd_term, |
Piers Daniell | 82107a6 | 2016-03-29 11:51:11 -0600 | [diff] [blame] | 543 | struct loader_device *found_dev); |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 544 | void loader_remove_logical_device(const struct loader_instance *inst, |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 545 | struct loader_icd_term *icd_term, |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 546 | struct loader_device *found_dev, |
| 547 | const VkAllocationCallbacks *pAllocator); |
Mark Young | 26c1937 | 2016-11-03 14:27:13 -0600 | [diff] [blame] | 548 | // NOTE: Outside of loader, this entry-point is only proivided for error |
| 549 | // cleanup. |
Mark Young | 74dd5d1 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 550 | void loader_destroy_logical_device(const struct loader_instance *inst, |
| 551 | struct loader_device *dev, |
| 552 | const VkAllocationCallbacks *pAllocator); |
| 553 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 554 | VkResult |
| 555 | loader_enable_instance_layers(struct loader_instance *inst, |
| 556 | const VkInstanceCreateInfo *pCreateInfo, |
| 557 | const struct loader_layer_list *instance_layers); |
Jon Ashburn | 10f4e82 | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 558 | void loader_deactivate_instance_layers(struct loader_instance *instance); |
Courtney Goeltzenleuchter | 0bd705c | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 559 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 560 | VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, |
| 561 | const VkAllocationCallbacks *pAllocator, |
| 562 | struct loader_instance *inst, |
Jon Ashburn | d1205a9 | 2016-02-03 12:37:30 -0700 | [diff] [blame] | 563 | VkInstance *created_instance); |
Courtney Goeltzenleuchter | 0bd705c | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 564 | |
Jon Ashburn | 1c75aec | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 565 | void loader_activate_instance_layer_extensions(struct loader_instance *inst, |
| 566 | VkInstance created_inst); |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 567 | VkResult |
| 568 | loader_enable_device_layers(const struct loader_instance *inst, |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 569 | struct loader_layer_list *activated_layer_list, |
| 570 | const VkDeviceCreateInfo *pCreateInfo, |
| 571 | const struct loader_layer_list *device_layers); |
Courtney Goeltzenleuchter | 71b454b | 2015-07-05 11:28:29 -0600 | [diff] [blame] | 572 | |
Jon Ashburn | c466da5 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 573 | VkResult |
| 574 | loader_create_device_chain(const struct loader_physical_device_tramp *pd, |
| 575 | const VkDeviceCreateInfo *pCreateInfo, |
| 576 | const VkAllocationCallbacks *pAllocator, |
| 577 | const struct loader_instance *inst, |
| 578 | struct loader_device *dev); |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 579 | VkResult loader_validate_device_extensions( |
Jon Ashburn | c3519e4 | 2016-03-24 15:49:57 -0600 | [diff] [blame] | 580 | struct loader_physical_device_tramp *phys_dev, |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 581 | const struct loader_layer_list *activated_device_layers, |
Jon Ashburn | fd02a0f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 582 | const struct loader_extension_list *icd_exts, |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 583 | const VkDeviceCreateInfo *pCreateInfo); |
Courtney Goeltzenleuchter | 71b454b | 2015-07-05 11:28:29 -0600 | [diff] [blame] | 584 | |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 585 | /* instance layer chain termination entrypoint definitions */ |
| 586 | VKAPI_ATTR VkResult VKAPI_CALL |
| 587 | terminator_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, |
| 588 | const VkAllocationCallbacks *pAllocator, |
| 589 | VkInstance *pInstance); |
Jon Ashburn | b4dee9c | 2015-08-28 15:19:27 -0600 | [diff] [blame] | 590 | |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 591 | VKAPI_ATTR void VKAPI_CALL |
| 592 | terminator_DestroyInstance(VkInstance instance, |
| 593 | const VkAllocationCallbacks *pAllocator); |
Jon Ashburn | b4dee9c | 2015-08-28 15:19:27 -0600 | [diff] [blame] | 594 | |
Jon Ashburn | c4e9ae6 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 595 | VKAPI_ATTR VkResult VKAPI_CALL |
| 596 | terminator_EnumeratePhysicalDevices(VkInstance instance, |
| 597 | uint32_t *pPhysicalDeviceCount, |
| 598 | VkPhysicalDevice *pPhysicalDevices); |
| 599 | |
| 600 | VKAPI_ATTR void VKAPI_CALL |
| 601 | terminator_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, |
| 602 | VkPhysicalDeviceFeatures *pFeatures); |
| 603 | |
| 604 | VKAPI_ATTR void VKAPI_CALL |
| 605 | terminator_GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, |
| 606 | VkFormat format, |
| 607 | VkFormatProperties *pFormatInfo); |
| 608 | |
| 609 | VKAPI_ATTR VkResult VKAPI_CALL |
| 610 | terminator_GetPhysicalDeviceImageFormatProperties( |
| 611 | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, |
| 612 | VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, |
| 613 | VkImageFormatProperties *pImageFormatProperties); |
| 614 | |
| 615 | VKAPI_ATTR void VKAPI_CALL |
| 616 | terminator_GetPhysicalDeviceSparseImageFormatProperties( |
| 617 | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, |
| 618 | VkSampleCountFlagBits samples, VkImageUsageFlags usage, |
| 619 | VkImageTiling tiling, uint32_t *pNumProperties, |
| 620 | VkSparseImageFormatProperties *pProperties); |
| 621 | |
| 622 | VKAPI_ATTR void VKAPI_CALL |
| 623 | terminator_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, |
| 624 | VkPhysicalDeviceProperties *pProperties); |
| 625 | |
| 626 | VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceExtensionProperties( |
| 627 | VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pCount, |
| 628 | VkExtensionProperties *pProperties); |
| 629 | |
| 630 | VKAPI_ATTR VkResult VKAPI_CALL |
| 631 | terminator_EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, |
| 632 | uint32_t *pCount, |
| 633 | VkLayerProperties *pProperties); |
| 634 | |
| 635 | VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceQueueFamilyProperties( |
| 636 | VkPhysicalDevice physicalDevice, uint32_t *pCount, |
| 637 | VkQueueFamilyProperties *pProperties); |
| 638 | |
| 639 | VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMemoryProperties( |
| 640 | VkPhysicalDevice physicalDevice, |
| 641 | VkPhysicalDeviceMemoryProperties *pProperties); |
| 642 | |
| 643 | VKAPI_ATTR VkResult VKAPI_CALL |
| 644 | terminator_CreateDevice(VkPhysicalDevice gpu, |
| 645 | const VkDeviceCreateInfo *pCreateInfo, |
| 646 | const VkAllocationCallbacks *pAllocator, |
| 647 | VkDevice *pDevice); |
Mark Lobodzinski | 8d32580 | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 648 | |
Jon Ashburn | b1cdf2e | 2016-02-10 20:50:19 -0700 | [diff] [blame] | 649 | VkStringErrorFlags vk_string_validate(const int max_length, |
| 650 | const char *char_array); |
Mark Lobodzinski | 8d32580 | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 651 | |
Chia-I Wu | c1e0f96 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 652 | #endif /* LOADER_H */ |