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