Chia-I Wu | 1930060 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 1 | /* |
Chia-I Wu | 1930060 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 2 | * |
Jon Ashburn | 23d36b1 | 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 | f821dad | 2015-12-02 14:53:22 -0700 | [diff] [blame] | 6 | * Copyright (C) 2015 Google Inc. |
Chia-I Wu | 1930060 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 7 | * |
Jon Ashburn | 3ebf125 | 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 | 1930060 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 11 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 12 | * http://www.apache.org/licenses/LICENSE-2.0 |
Chia-I Wu | 1930060 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 13 | * |
Jon Ashburn | 3ebf125 | 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 | 23d36b1 | 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 | 0555952 | 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 | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 24 | * Author: Mark Lobodzinski <mark@LunarG.com> |
Courtney Goeltzenleuchter | 0555952 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 25 | * |
Chia-I Wu | 1930060 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #ifndef LOADER_H |
| 29 | #define LOADER_H |
| 30 | |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 31 | #include <vulkan/vulkan.h> |
Aaron Karp | 848bad4 | 2016-03-13 16:41:59 -0400 | [diff] [blame] | 32 | #include "vk_loader_platform.h" |
Mark Lobodzinski | b87f902 | 2016-05-24 16:04:56 -0600 | [diff] [blame] | 33 | #include "vk_loader_layer.h" |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 34 | #include <vulkan/vk_layer.h> |
Mark Lobodzinski | b87f902 | 2016-05-24 16:04:56 -0600 | [diff] [blame] | 35 | |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 36 | #include <vulkan/vk_icd.h> |
Chia-I Wu | 5291c76 | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 37 | #include <assert.h> |
| 38 | |
Chia-I Wu | 1930060 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 39 | #if defined(__GNUC__) && __GNUC__ >= 4 |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 40 | #define LOADER_EXPORT __attribute__((visibility("default"))) |
Chia-I Wu | 1930060 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 41 | #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 42 | #define LOADER_EXPORT __attribute__((visibility("default"))) |
Chia-I Wu | 1930060 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 43 | #else |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 44 | #define LOADER_EXPORT |
Chia-I Wu | 1930060 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 45 | #endif |
| 46 | |
Mark Young | 0ad8313 | 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 | f73e921 | 2015-08-04 10:22:33 -0600 | [diff] [blame] | 50 | #define MAX_STRING_SIZE 1024 |
Courtney Goeltzenleuchter | 110fdf9 | 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 | 27cd584 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 54 | |
Jon Ashburn | 5ef2060 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 55 | enum layer_type { |
Jon Ashburn | 491cd04 | 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 | 5ef2060 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 59 | }; |
| 60 | |
Mark Lobodzinski | e9f09ef | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 61 | typedef enum VkStringErrorFlagBits { |
Jon Ashburn | f2b4e38 | 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 | e9f09ef | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 65 | } VkStringErrorFlagBits; |
| 66 | typedef VkFlags VkStringErrorFlags; |
| 67 | |
Jon Ashburn | f2b4e38 | 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 | e9f09ef | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 77 | |
Mark Lobodzinski | ed566c3 | 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 | 86a527a | 2016-02-10 20:59:26 -0700 | [diff] [blame] | 83 | |
Jon Ashburn | 6e6a216 | 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 | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 92 | struct loader_extension_list { |
| 93 | size_t capacity; |
| 94 | uint32_t count; |
Jon Ashburn | 5c042ea | 2015-08-04 11:14:18 -0600 | [diff] [blame] | 95 | VkExtensionProperties *list; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 96 | }; |
| 97 | |
Jon Ashburn | 39fbd4e | 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 | 5ef2060 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 110 | struct loader_name_value { |
Jon Ashburn | f73e921 | 2015-08-04 10:22:33 -0600 | [diff] [blame] | 111 | char name[MAX_STRING_SIZE]; |
| 112 | char value[MAX_STRING_SIZE]; |
Jon Ashburn | 5ef2060 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 113 | }; |
| 114 | |
Jon Ashburn | 5ef2060 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 115 | struct loader_layer_functions { |
Jon Ashburn | f73e921 | 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 | 5ef2060 | 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 | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 121 | |
Jon Ashburn | 5ef2060 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 122 | struct loader_layer_properties { |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 123 | VkLayerProperties info; |
Jon Ashburn | 5ef2060 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 124 | enum layer_type type; |
Jon Ashburn | 3d00233 | 2015-08-20 16:35:30 -0600 | [diff] [blame] | 125 | char lib_name[MAX_STRING_SIZE]; |
Jon Ashburn | 4dc1d8a | 2016-04-20 13:21:17 -0600 | [diff] [blame] | 126 | loader_platform_dl_handle lib_handle; |
Jon Ashburn | 5ef2060 | 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 | 39fbd4e | 2015-12-10 18:17:34 -0700 | [diff] [blame] | 129 | struct loader_device_extension_list device_extension_list; |
Jon Ashburn | 5ef2060 | 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 | 27cd584 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 138 | }; |
| 139 | |
Jon Ashburn | fc1031e | 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 | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 143 | uint32_t *index; // index into the dev_ext dispatch table |
Jon Ashburn | fc1031e | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 144 | }; |
| 145 | |
| 146 | #define MAX_NUM_DEV_EXTS 250 |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 147 | // loader_dispatch_hash_entry and loader_dev_ext_dispatch_table.DevExt have one |
| 148 | // to one |
Jon Ashburn | fc1031e | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 149 | // correspondence; one loader_dispatch_hash_entry for one DevExt dispatch entry. |
| 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 | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 153 | struct loader_dispatch_hash_list list; // to handle hashing collisions |
Jon Ashburn | fc1031e | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 154 | }; |
| 155 | |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 156 | typedef void(VKAPI_PTR *PFN_vkDevExt)(VkDevice device); |
Jon Ashburn | fc1031e | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 157 | struct loader_dev_ext_dispatch_table { |
| 158 | PFN_vkDevExt DevExt[MAX_NUM_DEV_EXTS]; |
| 159 | }; |
| 160 | |
| 161 | struct loader_dev_dispatch_table { |
| 162 | VkLayerDispatchTable core_dispatch; |
| 163 | struct loader_dev_ext_dispatch_table ext_dispatch; |
| 164 | }; |
| 165 | |
Jon Ashburn | dc6fcad | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 166 | /* per CreateDevice structure */ |
| 167 | struct loader_device { |
Jon Ashburn | fc1031e | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 168 | struct loader_dev_dispatch_table loader_dispatch; |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 169 | VkDevice device; // device object from the icd |
Jon Ashburn | dc6fcad | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 170 | |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 171 | uint32_t app_extension_count; |
Jon Ashburn | dc6fcad | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 172 | VkExtensionProperties *app_extension_props; |
| 173 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 174 | struct loader_layer_list activated_layer_list; |
Jon Ashburn | dc6fcad | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 175 | |
Mark Young | 0ad8313 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 176 | VkAllocationCallbacks alloc_callbacks; |
| 177 | |
Jon Ashburn | dc6fcad | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 178 | struct loader_device *next; |
| 179 | }; |
| 180 | |
Jon Ashburn | 953bb3c | 2015-06-10 16:11:42 -0600 | [diff] [blame] | 181 | /* per ICD structure */ |
Jon Ashburn | 95a77ba | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 182 | struct loader_icd { |
Jon Ashburn | 3d00233 | 2015-08-20 16:35:30 -0600 | [diff] [blame] | 183 | // pointers to find other structs |
| 184 | const struct loader_scanned_icds *this_icd_lib; |
| 185 | const struct loader_instance *this_instance; |
Jon Ashburn | dc6fcad | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 186 | struct loader_device *logical_device_list; |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 187 | VkInstance instance; // instance object from the icd |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 188 | PFN_vkGetDeviceProcAddr GetDeviceProcAddr; |
Jon Ashburn | 95a77ba | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 189 | PFN_vkDestroyInstance DestroyInstance; |
| 190 | PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices; |
Chris Forbes | bc0bb77 | 2015-06-21 22:55:02 +1200 | [diff] [blame] | 191 | PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures; |
Courtney Goeltzenleuchter | 2caec86 | 2015-07-12 12:52:09 -0600 | [diff] [blame] | 192 | PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties; |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 193 | PFN_vkGetPhysicalDeviceImageFormatProperties |
| 194 | GetPhysicalDeviceImageFormatProperties; |
Jon Ashburn | 95a77ba | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 195 | PFN_vkCreateDevice CreateDevice; |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 196 | PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties; |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 197 | PFN_vkGetPhysicalDeviceQueueFamilyProperties |
| 198 | GetPhysicalDeviceQueueFamilyProperties; |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 199 | PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties; |
Courtney Goeltzenleuchter | 35985f6 | 2015-09-14 17:22:16 -0600 | [diff] [blame] | 200 | PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties; |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 201 | PFN_vkGetPhysicalDeviceSparseImageFormatProperties |
| 202 | GetPhysicalDeviceSparseImageFormatProperties; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 203 | PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallbackEXT; |
| 204 | PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallbackEXT; |
| 205 | PFN_vkDebugReportMessageEXT DebugReportMessageEXT; |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 206 | PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR; |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 207 | PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR |
| 208 | GetPhysicalDeviceSurfaceCapabilitiesKHR; |
Ian Elliott | 486c550 | 2015-11-19 16:05:09 -0700 | [diff] [blame] | 209 | PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR; |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 210 | PFN_vkGetPhysicalDeviceSurfacePresentModesKHR |
| 211 | GetPhysicalDeviceSurfacePresentModesKHR; |
Ian Elliott | 919fa30 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 212 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 213 | PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR |
| 214 | GetPhysicalDeviceWin32PresentationSupportKHR; |
Ian Elliott | 919fa30 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 215 | #endif |
| 216 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 217 | PFN_vkGetPhysicalDeviceMirPresentationSupportKHR |
| 218 | GetPhysicalDeviceMirPresentvationSupportKHR; |
Ian Elliott | 919fa30 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 219 | #endif |
| 220 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 221 | PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR |
| 222 | GetPhysicalDeviceWaylandPresentationSupportKHR; |
Ian Elliott | 919fa30 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 223 | #endif |
| 224 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 225 | PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR |
| 226 | GetPhysicalDeviceXcbPresentationSupportKHR; |
Ian Elliott | 919fa30 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 227 | #endif |
| 228 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 229 | PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR |
| 230 | GetPhysicalDeviceXlibPresentationSupportKHR; |
Ian Elliott | 919fa30 | 2015-11-24 15:39:10 -0700 | [diff] [blame] | 231 | #endif |
Jon Ashburn | c7d3e73 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 232 | PFN_vkGetPhysicalDeviceDisplayPropertiesKHR |
| 233 | GetPhysicalDeviceDisplayPropertiesKHR; |
| 234 | PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR |
| 235 | GetPhysicalDeviceDisplayPlanePropertiesKHR; |
| 236 | PFN_vkGetDisplayPlaneSupportedDisplaysKHR |
| 237 | GetDisplayPlaneSupportedDisplaysKHR; |
Jon Ashburn | cc407a2 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 238 | PFN_vkGetDisplayModePropertiesKHR GetDisplayModePropertiesKHR; |
| 239 | PFN_vkCreateDisplayModeKHR CreateDisplayModeKHR; |
| 240 | PFN_vkGetDisplayPlaneCapabilitiesKHR GetDisplayPlaneCapabilitiesKHR; |
| 241 | PFN_vkCreateDisplayPlaneSurfaceKHR CreateDisplayPlaneSurfaceKHR; |
| 242 | PFN_vkDestroySurfaceKHR DestroySurfaceKHR; |
Jon Ashburn | dc6fcad | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 243 | struct loader_icd *next; |
Jon Ashburn | 95a77ba | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 244 | }; |
| 245 | |
Jon Ashburn | 8810c5f | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 246 | /* per ICD library structure */ |
| 247 | struct loader_icd_libs { |
| 248 | size_t capacity; |
| 249 | uint32_t count; |
| 250 | struct loader_scanned_icds *list; |
| 251 | }; |
| 252 | |
Jon Ashburn | 953bb3c | 2015-06-10 16:11:42 -0600 | [diff] [blame] | 253 | /* per instance structure */ |
Jon Ashburn | 27cd584 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 254 | struct loader_instance { |
Jon Ashburn | 95a77ba | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 255 | VkLayerInstanceDispatchTable *disp; // must be first entry in structure |
| 256 | |
Jon Ashburn | 014438f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 257 | uint32_t total_gpu_count; // count of the next two arrays |
| 258 | struct loader_physical_device *phys_devs_term; |
Jon Ashburn | cc407a2 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 259 | struct loader_physical_device_tramp * |
| 260 | phys_devs; // tramp wrapped physDev obj list |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 261 | uint32_t total_icd_count; |
Jon Ashburn | 27cd584 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 262 | struct loader_icd *icds; |
| 263 | struct loader_instance *next; |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 264 | struct loader_extension_list ext_list; // icds and loaders extensions |
Jon Ashburn | 8810c5f | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 265 | struct loader_icd_libs icd_libs; |
Jon Ashburn | 3d00233 | 2015-08-20 16:35:30 -0600 | [diff] [blame] | 266 | struct loader_layer_list instance_layer_list; |
Jon Ashburn | fc1031e | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 267 | struct loader_dispatch_hash_entry disp_hash[MAX_NUM_DEV_EXTS]; |
Jon Ashburn | 3d00233 | 2015-08-20 16:35:30 -0600 | [diff] [blame] | 268 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 269 | struct loader_msg_callback_map_entry *icd_msg_callback_map; |
| 270 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 271 | struct loader_layer_list activated_layer_list; |
Jon Ashburn | 491cd04 | 2016-05-16 14:01:18 -0600 | [diff] [blame] | 272 | bool activated_layers_are_std_val; |
Jon Ashburn | cc407a2 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 273 | VkInstance instance; // layers/ICD instance returned to trampoline |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 274 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 275 | bool debug_report_enabled; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 276 | VkLayerDbgFunctionNode *DbgFunctionHead; |
Ian Elliott | ad6300f | 2016-03-31 10:48:19 -0600 | [diff] [blame] | 277 | uint32_t num_tmp_callbacks; |
| 278 | VkDebugReportCallbackCreateInfoEXT *tmp_dbg_create_infos; |
| 279 | VkDebugReportCallbackEXT *tmp_callbacks; |
Courtney Goeltzenleuchter | 7f5aafc | 2015-07-05 11:28:29 -0600 | [diff] [blame] | 280 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 281 | VkAllocationCallbacks alloc_callbacks; |
Ian Elliott | d3ef02f | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 282 | |
Ian Elliott | 954fa34 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 283 | bool wsi_surface_enabled; |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 284 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 954fa34 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 285 | bool wsi_win32_surface_enabled; |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 286 | #endif |
| 287 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Ian Elliott | 954fa34 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 288 | bool wsi_mir_surface_enabled; |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 289 | #endif |
| 290 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 954fa34 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 291 | bool wsi_wayland_surface_enabled; |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 292 | #endif |
| 293 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Ian Elliott | 954fa34 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 294 | bool wsi_xcb_surface_enabled; |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 295 | #endif |
| 296 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Ian Elliott | 954fa34 | 2015-10-30 15:28:23 -0600 | [diff] [blame] | 297 | bool wsi_xlib_surface_enabled; |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 298 | #endif |
| 299 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 300 | bool wsi_android_surface_enabled; |
| 301 | #endif |
Jon Ashburn | c7d3e73 | 2016-03-08 09:30:30 -0700 | [diff] [blame] | 302 | bool wsi_display_enabled; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 303 | }; |
| 304 | |
Jon Ashburn | 014438f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 305 | /* VkPhysicalDevice requires special treatment by loader. Firstly, terminator |
| 306 | * code must be able to get the struct loader_icd to call into the proper |
| 307 | * driver (multiple ICD/gpu case). This can be accomplished by wrapping the |
| 308 | * created VkPhysicalDevice in loader terminate_EnumeratePhysicalDevices(). |
Piers Daniell | 295fe40 | 2016-03-29 11:51:11 -0600 | [diff] [blame] | 309 | * Secondly, the loader must be able to handle wrapped by layer VkPhysicalDevice |
Jon Ashburn | 014438f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 310 | * in trampoline code. This implies, that the loader trampoline code must also |
| 311 | * wrap the VkPhysicalDevice object in trampoline code. Thus, loader has to |
| 312 | * wrap the VkPhysicalDevice created object twice. In trampoline code it can't |
| 313 | * rely on the terminator object wrapping since a layer may also wrap. Since |
| 314 | * trampoline code wraps the VkPhysicalDevice this means all loader trampoline |
| 315 | * code that passes a VkPhysicalDevice should unwrap it. */ |
| 316 | |
| 317 | /* per enumerated PhysicalDevice structure, used to wrap in trampoline code and |
| 318 | also same structure used to wrap in terminator code */ |
Jon Ashburn | 787eb25 | 2016-03-24 15:49:57 -0600 | [diff] [blame] | 319 | struct loader_physical_device_tramp { |
| 320 | VkLayerInstanceDispatchTable *disp; // must be first entry in structure |
Piers Daniell | 295fe40 | 2016-03-29 11:51:11 -0600 | [diff] [blame] | 321 | struct loader_instance *this_instance; |
Jon Ashburn | cc407a2 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 322 | VkPhysicalDevice phys_dev; // object from layers/loader terminator |
Jon Ashburn | 787eb25 | 2016-03-24 15:49:57 -0600 | [diff] [blame] | 323 | }; |
| 324 | |
| 325 | /* per enumerated PhysicalDevice structure, used to wrap in terminator code */ |
Jon Ashburn | 24cd4be | 2015-11-01 14:04:06 -0700 | [diff] [blame] | 326 | struct loader_physical_device { |
| 327 | VkLayerInstanceDispatchTable *disp; // must be first entry in structure |
Jon Ashburn | 24cd4be | 2015-11-01 14:04:06 -0700 | [diff] [blame] | 328 | struct loader_icd *this_icd; |
Jon Ashburn | 787eb25 | 2016-03-24 15:49:57 -0600 | [diff] [blame] | 329 | VkPhysicalDevice phys_dev; // object from ICD |
Jon Ashburn | 24cd4be | 2015-11-01 14:04:06 -0700 | [diff] [blame] | 330 | }; |
| 331 | |
Jon Ashburn | 27cd584 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 332 | struct loader_struct { |
| 333 | struct loader_instance *instances; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 334 | }; |
| 335 | |
| 336 | struct loader_scanned_icds { |
| 337 | char *lib_name; |
| 338 | loader_platform_dl_handle handle; |
Jon Ashburn | 005617f | 2015-11-17 17:35:40 -0700 | [diff] [blame] | 339 | uint32_t api_version; |
Jon Ashburn | 17b4c86 | 2016-04-25 11:09:37 -0600 | [diff] [blame] | 340 | uint32_t interface_version; |
Jon Ashburn | c624c88 | 2015-07-16 10:17:29 -0600 | [diff] [blame] | 341 | PFN_vkGetInstanceProcAddr GetInstanceProcAddr; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 342 | PFN_vkCreateInstance CreateInstance; |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 343 | PFN_vkEnumerateInstanceExtensionProperties |
| 344 | EnumerateInstanceExtensionProperties; |
Jon Ashburn | 27cd584 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 345 | }; |
| 346 | |
Jon Ashburn | 5ef2060 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 347 | static inline struct loader_instance *loader_instance(VkInstance instance) { |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 348 | return (struct loader_instance *)instance; |
Jon Ashburn | 5ef2060 | 2015-07-02 09:40:15 -0600 | [diff] [blame] | 349 | } |
| 350 | |
Jon Ashburn | 014438f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 351 | static inline VkPhysicalDevice |
| 352 | loader_unwrap_physical_device(VkPhysicalDevice physicalDevice) { |
Piers Daniell | 61e4538 | 2016-03-31 14:47:57 -0600 | [diff] [blame] | 353 | struct loader_physical_device_tramp *phys_dev = |
| 354 | (struct loader_physical_device_tramp *)physicalDevice; |
Jon Ashburn | 014438f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 355 | return phys_dev->phys_dev; |
| 356 | } |
| 357 | |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 358 | static inline void loader_set_dispatch(void *obj, const void *data) { |
| 359 | *((const void **)obj) = data; |
Chia-I Wu | 5291c76 | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 360 | } |
| 361 | |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 362 | static inline VkLayerDispatchTable *loader_get_dispatch(const void *obj) { |
| 363 | return *((VkLayerDispatchTable **)obj); |
Chia-I Wu | 5291c76 | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 364 | } |
| 365 | |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 366 | static inline struct loader_dev_dispatch_table * |
| 367 | loader_get_dev_dispatch(const void *obj) { |
| 368 | return *((struct loader_dev_dispatch_table **)obj); |
Jon Ashburn | fc1031e | 2015-11-17 15:31:02 -0700 | [diff] [blame] | 369 | } |
| 370 | |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 371 | static inline VkLayerInstanceDispatchTable * |
| 372 | loader_get_instance_dispatch(const void *obj) { |
| 373 | return *((VkLayerInstanceDispatchTable **)obj); |
Jon Ashburn | 27cd584 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 374 | } |
| 375 | |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 376 | static inline void loader_init_dispatch(void *obj, const void *data) { |
Jon Ashburn | 4006664 | 2015-04-15 13:34:33 -0600 | [diff] [blame] | 377 | #ifdef DEBUG |
Chia-I Wu | 5291c76 | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 378 | assert(valid_loader_magic_value(obj) && |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 379 | "Incompatible ICD, first dword must be initialized to " |
| 380 | "ICD_LOADER_MAGIC. See loader/README.md for details."); |
Jon Ashburn | 4006664 | 2015-04-15 13:34:33 -0600 | [diff] [blame] | 381 | #endif |
Chia-I Wu | 5291c76 | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 382 | |
Jon Ashburn | 1ed042c | 2015-05-01 18:00:33 -0600 | [diff] [blame] | 383 | loader_set_dispatch(obj, data); |
Chia-I Wu | 5291c76 | 2015-04-11 15:34:07 +0800 | [diff] [blame] | 384 | } |
| 385 | |
Jon Ashburn | 27cd584 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 386 | /* global variables used across files */ |
| 387 | extern struct loader_struct loader; |
Jon Ashburn | 87d6aa9 | 2015-08-28 15:19:27 -0600 | [diff] [blame] | 388 | extern THREAD_LOCAL_DECL struct loader_instance *tls_instance; |
Jon Ashburn | 8810c5f | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 389 | extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_init); |
Jon Ashburn | 6301a0f | 2015-05-29 13:15:39 -0600 | [diff] [blame] | 390 | extern loader_platform_thread_mutex loader_lock; |
Jon Ashburn | 6461ef2 | 2015-09-22 13:11:00 -0600 | [diff] [blame] | 391 | extern loader_platform_thread_mutex loader_json_lock; |
Jon Ashburn | 6301a0f | 2015-05-29 13:15:39 -0600 | [diff] [blame] | 392 | extern const VkLayerInstanceDispatchTable instance_disp; |
Jon Ashburn | 86a527a | 2016-02-10 20:59:26 -0700 | [diff] [blame] | 393 | extern const char *std_validation_str; |
Jon Ashburn | bacb0f5 | 2015-04-06 10:58:22 -0600 | [diff] [blame] | 394 | |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 395 | struct loader_msg_callback_map_entry { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 396 | VkDebugReportCallbackEXT icd_obj; |
| 397 | VkDebugReportCallbackEXT loader_obj; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 398 | }; |
| 399 | |
Jon Ashburn | 1530c34 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 400 | /* helper function definitions */ |
Mark Young | 0ad8313 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 401 | void *loader_instance_heap_alloc(const struct loader_instance *instance, size_t size, VkSystemAllocationScope allocationScope); |
| 402 | void loader_instance_heap_free(const struct loader_instance *instance, void *pMemory); |
| 403 | void *loader_instance_heap_realloc(const struct loader_instance *instance, void *pMemory, size_t orig_size, size_t size, VkSystemAllocationScope alloc_scope); |
| 404 | void *loader_instance_tls_heap_alloc(size_t size); |
| 405 | void loader_instance_tls_heap_free(void *pMemory); |
| 406 | void *loader_device_heap_alloc(const struct loader_device *device, size_t size, VkSystemAllocationScope allocationScope); |
| 407 | void loader_device_heap_free(const struct loader_device *device, void *pMemory); |
| 408 | void *loader_device_heap_realloc(const struct loader_device *device, void *pMemory, size_t orig_size, size_t size, VkSystemAllocationScope alloc_scope); |
Jon Ashburn | 1530c34 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 409 | |
Jon Ashburn | 2e37d75 | 2016-02-12 08:20:06 -0700 | [diff] [blame] | 410 | void loader_log(const struct loader_instance *inst, VkFlags msg_type, |
Jon Ashburn | 1530c34 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 411 | int32_t msg_code, const char *format, ...); |
Jon Ashburn | 2e37d75 | 2016-02-12 08:20:06 -0700 | [diff] [blame] | 412 | |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 413 | bool compare_vk_extension_properties(const VkExtensionProperties *op1, |
| 414 | const VkExtensionProperties *op2); |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 415 | |
Mark Lobodzinski | e9f09ef | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 416 | VkResult loader_validate_layers(const struct loader_instance *inst, |
| 417 | const uint32_t layer_count, |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 418 | const char *const *ppEnabledLayerNames, |
| 419 | const struct loader_layer_list *list); |
Courtney Goeltzenleuchter | 3b8c5ff | 2015-07-06 17:45:08 -0600 | [diff] [blame] | 420 | |
| 421 | VkResult loader_validate_instance_extensions( |
Mark Lobodzinski | e9f09ef | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 422 | const struct loader_instance *inst, |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 423 | const struct loader_extension_list *icd_exts, |
| 424 | const struct loader_layer_list *instance_layer, |
| 425 | const VkInstanceCreateInfo *pCreateInfo); |
Courtney Goeltzenleuchter | 3b8c5ff | 2015-07-06 17:45:08 -0600 | [diff] [blame] | 426 | |
Jon Ashburn | 8810c5f | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 427 | void loader_initialize(void); |
Mark Young | 0ad8313 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 428 | VkResult loader_copy_layer_properties(const struct loader_instance *inst, |
| 429 | struct loader_layer_properties *dst, |
| 430 | struct loader_layer_properties *src); |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 431 | bool has_vk_extension_property_array(const VkExtensionProperties *vk_ext_prop, |
| 432 | const uint32_t count, |
| 433 | const VkExtensionProperties *ext_array); |
| 434 | bool has_vk_extension_property(const VkExtensionProperties *vk_ext_prop, |
| 435 | const struct loader_extension_list *ext_list); |
Jon Ashburn | 27cd584 | 2015-05-12 17:26:48 -0600 | [diff] [blame] | 436 | |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 437 | VkResult loader_add_to_ext_list(const struct loader_instance *inst, |
| 438 | struct loader_extension_list *ext_list, |
| 439 | uint32_t prop_list_count, |
| 440 | const VkExtensionProperties *props); |
Jon Ashburn | cc407a2 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 441 | VkResult |
| 442 | loader_add_to_dev_ext_list(const struct loader_instance *inst, |
| 443 | struct loader_device_extension_list *ext_list, |
| 444 | const VkExtensionProperties *props, |
| 445 | uint32_t entry_count, char **entrys); |
Jon Ashburn | 1530c34 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 446 | VkResult loader_add_device_extensions(const struct loader_instance *inst, |
Jon Ashburn | cc407a2 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 447 | PFN_vkEnumerateDeviceExtensionProperties |
| 448 | fpEnumerateDeviceExtensionProperties, |
Jon Ashburn | 1530c34 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 449 | VkPhysicalDevice physical_device, |
| 450 | const char *lib_name, |
| 451 | struct loader_extension_list *ext_list); |
| 452 | bool loader_init_generic_list(const struct loader_instance *inst, |
| 453 | struct loader_generic_list *list_info, |
| 454 | size_t element_size); |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 455 | void loader_destroy_generic_list(const struct loader_instance *inst, |
| 456 | struct loader_generic_list *list); |
Jon Ashburn | 1530c34 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 457 | void loader_destroy_layer_list(const struct loader_instance *inst, |
Mark Young | 0ad8313 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 458 | struct loader_device *device, |
Jon Ashburn | 1530c34 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 459 | struct loader_layer_list *layer_list); |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 460 | void loader_delete_layer_properties(const struct loader_instance *inst, |
| 461 | struct loader_layer_list *layer_list); |
Jon Ashburn | 491cd04 | 2016-05-16 14:01:18 -0600 | [diff] [blame] | 462 | bool loader_find_layer_name_array(const char *name, uint32_t layer_count, |
| 463 | const char layer_list[][VK_MAX_EXTENSION_NAME_SIZE]); |
Mark Young | 0ad8313 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 464 | VkResult loader_expand_layer_names( |
Jon Ashburn | 491cd04 | 2016-05-16 14:01:18 -0600 | [diff] [blame] | 465 | struct loader_instance *inst, const char *key_name, |
Jon Ashburn | 86a527a | 2016-02-10 20:59:26 -0700 | [diff] [blame] | 466 | uint32_t expand_count, |
| 467 | const char expand_names[][VK_MAX_EXTENSION_NAME_SIZE], |
Jon Ashburn | cc407a2 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 468 | uint32_t *layer_count, char const *const **ppp_layer_names); |
Jon Ashburn | 491cd04 | 2016-05-16 14:01:18 -0600 | [diff] [blame] | 469 | void loader_init_std_validation_props(struct loader_layer_properties *props); |
Chris Forbes | bd9de05 | 2016-04-06 20:49:02 +1200 | [diff] [blame] | 470 | void loader_delete_shadow_dev_layer_names(const struct loader_instance *inst, |
| 471 | const VkDeviceCreateInfo *orig, |
| 472 | VkDeviceCreateInfo *ours); |
| 473 | void loader_delete_shadow_inst_layer_names(const struct loader_instance *inst, |
| 474 | const VkInstanceCreateInfo *orig, |
| 475 | VkInstanceCreateInfo *ours); |
Mark Young | 0ad8313 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 476 | VkResult loader_add_to_layer_list(const struct loader_instance *inst, |
| 477 | struct loader_layer_list *list, |
| 478 | uint32_t prop_list_count, |
| 479 | const struct loader_layer_properties *props); |
Jon Ashburn | cc407a2 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 480 | void loader_find_layer_name_add_list( |
| 481 | const struct loader_instance *inst, const char *name, |
| 482 | const enum layer_type type, const struct loader_layer_list *search_list, |
| 483 | struct loader_layer_list *found_list); |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 484 | void loader_scanned_icd_clear(const struct loader_instance *inst, |
| 485 | struct loader_icd_libs *icd_libs); |
Mark Young | 0ad8313 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 486 | VkResult loader_icd_scan(const struct loader_instance *inst, |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 487 | struct loader_icd_libs *icds); |
| 488 | void loader_layer_scan(const struct loader_instance *inst, |
Jon Ashburn | 491cd04 | 2016-05-16 14:01:18 -0600 | [diff] [blame] | 489 | struct loader_layer_list *instance_layers); |
Jeremy Hayes | 3e2bd5a | 2016-04-01 11:40:26 -0600 | [diff] [blame] | 490 | void loader_implicit_layer_scan(const struct loader_instance *inst, |
Jon Ashburn | 491cd04 | 2016-05-16 14:01:18 -0600 | [diff] [blame] | 491 | struct loader_layer_list *instance_layers); |
Jon Ashburn | 8810c5f | 2015-08-18 18:04:47 -0600 | [diff] [blame] | 492 | void loader_get_icd_loader_instance_extensions( |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 493 | const struct loader_instance *inst, struct loader_icd_libs *icd_libs, |
| 494 | struct loader_extension_list *inst_exts); |
| 495 | struct loader_icd *loader_get_icd_and_device(const VkDevice device, |
| 496 | struct loader_device **found_dev); |
Jon Ashburn | 1530c34 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 497 | void loader_init_dispatch_dev_ext(struct loader_instance *inst, |
| 498 | struct loader_device *dev); |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 499 | void *loader_dev_ext_gpa(struct loader_instance *inst, const char *funcName); |
| 500 | void *loader_get_dev_ext_trampoline(uint32_t index); |
| 501 | struct loader_instance *loader_get_instance(const VkInstance instance); |
Jon Ashburn | 4dc1d8a | 2016-04-20 13:21:17 -0600 | [diff] [blame] | 502 | void loader_deactivate_layers(const struct loader_instance *instance, |
Mark Young | 0ad8313 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 503 | struct loader_device *device, |
Jon Ashburn | 4dc1d8a | 2016-04-20 13:21:17 -0600 | [diff] [blame] | 504 | struct loader_layer_list *list); |
Jon Ashburn | 1530c34 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 505 | struct loader_device * |
Mark Young | 0ad8313 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 506 | loader_create_logical_device(const struct loader_instance *inst, const VkAllocationCallbacks *pAllocator); |
Piers Daniell | 295fe40 | 2016-03-29 11:51:11 -0600 | [diff] [blame] | 507 | void loader_add_logical_device(const struct loader_instance *inst, |
| 508 | struct loader_icd *icd, |
| 509 | struct loader_device *found_dev); |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 510 | void loader_remove_logical_device(const struct loader_instance *inst, |
| 511 | struct loader_icd *icd, |
Mark Young | 0ad8313 | 2016-06-30 13:02:42 -0600 | [diff] [blame] | 512 | struct loader_device *found_dev, |
| 513 | const VkAllocationCallbacks *pAllocator); |
| 514 | // NOTE: Outside of loader, this entry-point is only proivided for error cleanup. |
| 515 | void loader_destroy_logical_device(const struct loader_instance *inst, |
| 516 | struct loader_device *dev, |
| 517 | const VkAllocationCallbacks *pAllocator); |
| 518 | |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 519 | VkResult |
| 520 | loader_enable_instance_layers(struct loader_instance *inst, |
| 521 | const VkInstanceCreateInfo *pCreateInfo, |
| 522 | const struct loader_layer_list *instance_layers); |
Jon Ashburn | dc6fcad | 2015-06-10 10:06:06 -0600 | [diff] [blame] | 523 | void loader_deactivate_instance_layers(struct loader_instance *instance); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 524 | |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 525 | VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, |
| 526 | const VkAllocationCallbacks *pAllocator, |
| 527 | struct loader_instance *inst, |
Jon Ashburn | 6e0a213 | 2016-02-03 12:37:30 -0700 | [diff] [blame] | 528 | VkInstance *created_instance); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 529 | |
Jon Ashburn | 23d36b1 | 2016-02-02 17:47:28 -0700 | [diff] [blame] | 530 | void loader_activate_instance_layer_extensions(struct loader_instance *inst, |
| 531 | VkInstance created_inst); |
Jon Ashburn | 1530c34 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 532 | VkResult |
| 533 | loader_enable_device_layers(const struct loader_instance *inst, |
Jon Ashburn | 1530c34 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 534 | struct loader_layer_list *activated_layer_list, |
| 535 | const VkDeviceCreateInfo *pCreateInfo, |
| 536 | const struct loader_layer_list *device_layers); |
Courtney Goeltzenleuchter | 7f5aafc | 2015-07-05 11:28:29 -0600 | [diff] [blame] | 537 | |
Jon Ashburn | cc407a2 | 2016-04-15 09:25:03 -0600 | [diff] [blame] | 538 | VkResult |
| 539 | loader_create_device_chain(const struct loader_physical_device_tramp *pd, |
| 540 | const VkDeviceCreateInfo *pCreateInfo, |
| 541 | const VkAllocationCallbacks *pAllocator, |
| 542 | const struct loader_instance *inst, |
| 543 | struct loader_device *dev); |
Jon Ashburn | 1530c34 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 544 | VkResult loader_validate_device_extensions( |
Jon Ashburn | 787eb25 | 2016-03-24 15:49:57 -0600 | [diff] [blame] | 545 | struct loader_physical_device_tramp *phys_dev, |
Jon Ashburn | 1530c34 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 546 | const struct loader_layer_list *activated_device_layers, |
Jon Ashburn | 014438f | 2016-03-01 19:51:07 -0700 | [diff] [blame] | 547 | const struct loader_extension_list *icd_exts, |
Jon Ashburn | 1530c34 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 548 | const VkDeviceCreateInfo *pCreateInfo); |
Courtney Goeltzenleuchter | 7f5aafc | 2015-07-05 11:28:29 -0600 | [diff] [blame] | 549 | |
Jon Ashburn | 1530c34 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 550 | /* instance layer chain termination entrypoint definitions */ |
| 551 | VKAPI_ATTR VkResult VKAPI_CALL |
| 552 | terminator_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, |
| 553 | const VkAllocationCallbacks *pAllocator, |
| 554 | VkInstance *pInstance); |
Jon Ashburn | 87d6aa9 | 2015-08-28 15:19:27 -0600 | [diff] [blame] | 555 | |
Jon Ashburn | 1530c34 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 556 | VKAPI_ATTR void VKAPI_CALL |
| 557 | terminator_DestroyInstance(VkInstance instance, |
| 558 | const VkAllocationCallbacks *pAllocator); |
Jon Ashburn | 87d6aa9 | 2015-08-28 15:19:27 -0600 | [diff] [blame] | 559 | |
Jon Ashburn | 1530c34 | 2016-02-26 13:14:27 -0700 | [diff] [blame] | 560 | VKAPI_ATTR VkResult VKAPI_CALL |
| 561 | terminator_EnumeratePhysicalDevices(VkInstance instance, |
| 562 | uint32_t *pPhysicalDeviceCount, |
| 563 | VkPhysicalDevice *pPhysicalDevices); |
| 564 | |
| 565 | VKAPI_ATTR void VKAPI_CALL |
| 566 | terminator_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, |
| 567 | VkPhysicalDeviceFeatures *pFeatures); |
| 568 | |
| 569 | VKAPI_ATTR void VKAPI_CALL |
| 570 | terminator_GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, |
| 571 | VkFormat format, |
| 572 | VkFormatProperties *pFormatInfo); |
| 573 | |
| 574 | VKAPI_ATTR VkResult VKAPI_CALL |
| 575 | terminator_GetPhysicalDeviceImageFormatProperties( |
| 576 | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, |
| 577 | VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, |
| 578 | VkImageFormatProperties *pImageFormatProperties); |
| 579 | |
| 580 | VKAPI_ATTR void VKAPI_CALL |
| 581 | terminator_GetPhysicalDeviceSparseImageFormatProperties( |
| 582 | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, |
| 583 | VkSampleCountFlagBits samples, VkImageUsageFlags usage, |
| 584 | VkImageTiling tiling, uint32_t *pNumProperties, |
| 585 | VkSparseImageFormatProperties *pProperties); |
| 586 | |
| 587 | VKAPI_ATTR void VKAPI_CALL |
| 588 | terminator_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, |
| 589 | VkPhysicalDeviceProperties *pProperties); |
| 590 | |
| 591 | VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceExtensionProperties( |
| 592 | VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pCount, |
| 593 | VkExtensionProperties *pProperties); |
| 594 | |
| 595 | VKAPI_ATTR VkResult VKAPI_CALL |
| 596 | terminator_EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, |
| 597 | uint32_t *pCount, |
| 598 | VkLayerProperties *pProperties); |
| 599 | |
| 600 | VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceQueueFamilyProperties( |
| 601 | VkPhysicalDevice physicalDevice, uint32_t *pCount, |
| 602 | VkQueueFamilyProperties *pProperties); |
| 603 | |
| 604 | VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMemoryProperties( |
| 605 | VkPhysicalDevice physicalDevice, |
| 606 | VkPhysicalDeviceMemoryProperties *pProperties); |
| 607 | |
| 608 | VKAPI_ATTR VkResult VKAPI_CALL |
| 609 | terminator_CreateDevice(VkPhysicalDevice gpu, |
| 610 | const VkDeviceCreateInfo *pCreateInfo, |
| 611 | const VkAllocationCallbacks *pAllocator, |
| 612 | VkDevice *pDevice); |
Mark Lobodzinski | e9f09ef | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 613 | |
Jon Ashburn | f2b4e38 | 2016-02-10 20:50:19 -0700 | [diff] [blame] | 614 | VkStringErrorFlags vk_string_validate(const int max_length, |
| 615 | const char *char_array); |
Mark Lobodzinski | e9f09ef | 2016-02-02 18:53:34 -0700 | [diff] [blame] | 616 | |
Chia-I Wu | 1930060 | 2014-08-04 08:03:57 +0800 | [diff] [blame] | 617 | #endif /* LOADER_H */ |