Tobin Ehlis | c345b8b | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Vulkan |
| 3 | * |
| 4 | * Copyright (C) 2015 LunarG, Inc. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | #include <stdio.h> |
| 26 | #include <stdlib.h> |
| 27 | #include <string.h> |
| 28 | #include <unordered_map> |
| 29 | #include <memory> |
| 30 | |
| 31 | #include "vk_loader_platform.h" |
| 32 | #include "vk_dispatch_table_helper.h" |
| 33 | #include "vk_struct_string_helper_cpp.h" |
| 34 | #if defined(__GNUC__) |
| 35 | #pragma GCC diagnostic ignored "-Wwrite-strings" |
| 36 | #endif |
| 37 | #if defined(__GNUC__) |
| 38 | #pragma GCC diagnostic warning "-Wwrite-strings" |
| 39 | #endif |
| 40 | #include "vk_struct_size_helper.h" |
| 41 | #include "device_limits.h" |
| 42 | #include "vk_layer_config.h" |
| 43 | #include "vk_debug_marker_layer.h" |
| 44 | // The following is #included again to catch certain OS-specific functions |
| 45 | // being used: |
| 46 | #include "vk_loader_platform.h" |
| 47 | #include "vk_layer_msg.h" |
| 48 | #include "vk_layer_table.h" |
| 49 | #include "vk_layer_debug_marker_table.h" |
| 50 | #include "vk_layer_data.h" |
| 51 | #include "vk_layer_logging.h" |
| 52 | #include "vk_layer_extension_utils.h" |
| 53 | |
| 54 | typedef struct _layer_data { |
| 55 | debug_report_data *report_data; |
| 56 | // TODO: put instance data here |
| 57 | VkDbgMsgCallback logging_callback; |
| 58 | } layer_data; |
| 59 | |
| 60 | static std::unordered_map<void *, layer_data *> layer_data_map; |
| 61 | static device_table_map device_limits_device_table_map; |
| 62 | static instance_table_map device_limits_instance_table_map; |
| 63 | |
| 64 | // Track state of each instance |
| 65 | unordered_map<VkInstance, unique_ptr<INSTANCE_STATE>> instanceMap; |
| 66 | unordered_map<VkPhysicalDevice, unique_ptr<PHYSICAL_DEVICE_STATE>> physicalDeviceMap; |
| 67 | unordered_map<VkPhysicalDevice, unordered_map<uint32_t, unique_ptr<VkQueueFamilyProperties>>> queueFamilyPropertiesMap; |
| 68 | unordered_map<VkPhysicalDevice, unique_ptr<VkPhysicalDeviceFeatures>> physicalDeviceFeaturesMap; |
| 69 | unordered_map<VkDevice, VkPhysicalDevice> deviceMap; |
| 70 | |
| 71 | struct devExts { |
| 72 | bool debug_marker_enabled; |
| 73 | }; |
| 74 | |
| 75 | static std::unordered_map<void *, struct devExts> deviceExtMap; |
| 76 | |
| 77 | static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce); |
| 78 | |
| 79 | // TODO : This can be much smarter, using separate locks for separate global data |
| 80 | static int globalLockInitialized = 0; |
| 81 | static loader_platform_thread_mutex globalLock; |
| 82 | |
| 83 | template layer_data *get_my_data_ptr<layer_data>( |
| 84 | void *data_key, |
| 85 | std::unordered_map<void *, layer_data *> &data_map); |
| 86 | |
| 87 | debug_report_data *mdd(void* object) |
| 88 | { |
| 89 | dispatch_key key = get_dispatch_key(object); |
| 90 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
| 91 | #if DISPATCH_MAP_DEBUG |
| 92 | fprintf(stderr, "MDD: map: %p, object: %p, key: %p, data: %p\n", &layer_data_map, object, key, my_data); |
| 93 | #endif |
| 94 | return my_data->report_data; |
| 95 | } |
| 96 | |
| 97 | debug_report_data *mid(VkInstance object) |
| 98 | { |
| 99 | dispatch_key key = get_dispatch_key(object); |
| 100 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
| 101 | #if DISPATCH_MAP_DEBUG |
| 102 | fprintf(stderr, "MID: map: %p, object: %p, key: %p, data: %p\n", &layer_data_map, object, key, my_data); |
| 103 | #endif |
| 104 | return my_data->report_data; |
| 105 | } |
| 106 | |
| 107 | static void init_device_limits(layer_data *my_data) |
| 108 | { |
| 109 | uint32_t report_flags = 0; |
| 110 | uint32_t debug_action = 0; |
| 111 | FILE *log_output = NULL; |
| 112 | const char *option_str; |
| 113 | // initialize DeviceLimits options |
| 114 | report_flags = getLayerOptionFlags("DeviceLimitsReportFlags", 0); |
| 115 | getLayerOptionEnum("DeviceLimitsDebugAction", (uint32_t *) &debug_action); |
| 116 | |
| 117 | if (debug_action & VK_DBG_LAYER_ACTION_LOG_MSG) |
| 118 | { |
| 119 | option_str = getLayerOption("DeviceLimitsLogFilename"); |
| 120 | if (option_str) |
| 121 | { |
| 122 | log_output = fopen(option_str, "w"); |
| 123 | } |
| 124 | if (log_output == NULL) |
| 125 | log_output = stdout; |
| 126 | |
| 127 | layer_create_msg_callback(my_data->report_data, report_flags, log_callback, (void *) log_output, &my_data->logging_callback); |
| 128 | } |
| 129 | |
| 130 | if (!globalLockInitialized) |
| 131 | { |
| 132 | // TODO/TBD: Need to delete this mutex sometime. How??? One |
| 133 | // suggestion is to call this during vkCreateInstance(), and then we |
| 134 | // can clean it up during vkDestroyInstance(). However, that requires |
| 135 | // that the layer have per-instance locks. We need to come back and |
| 136 | // address this soon. |
| 137 | loader_platform_thread_create_mutex(&globalLock); |
| 138 | globalLockInitialized = 1; |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | VK_LAYER_EXPORT VkResult VKAPI vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, VkInstance* pInstance) |
| 143 | { |
| 144 | VkLayerInstanceDispatchTable *pTable = get_dispatch_table(device_limits_instance_table_map,*pInstance); |
| 145 | VkResult result = pTable->CreateInstance(pCreateInfo, pInstance); |
| 146 | |
| 147 | if (result == VK_SUCCESS) { |
| 148 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); |
| 149 | my_data->report_data = debug_report_create_instance( |
| 150 | pTable, |
| 151 | *pInstance, |
| 152 | pCreateInfo->extensionCount, |
| 153 | pCreateInfo->ppEnabledExtensionNames); |
| 154 | |
| 155 | init_device_limits(my_data); |
| 156 | instanceMap[*pInstance] = unique_ptr<INSTANCE_STATE>(new INSTANCE_STATE()); |
| 157 | } |
| 158 | return result; |
| 159 | } |
| 160 | |
| 161 | /* hook DestroyInstance to remove tableInstanceMap entry */ |
Mark Lobodzinski | 67b42b7 | 2015-09-07 13:59:43 -0600 | [diff] [blame^] | 162 | VK_LAYER_EXPORT void VKAPI vkDestroyInstance(VkInstance instance) |
Tobin Ehlis | c345b8b | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 163 | { |
| 164 | dispatch_key key = get_dispatch_key(instance); |
| 165 | VkLayerInstanceDispatchTable *pTable = get_dispatch_table(device_limits_instance_table_map, instance); |
Mark Lobodzinski | 67b42b7 | 2015-09-07 13:59:43 -0600 | [diff] [blame^] | 166 | pTable->DestroyInstance(instance); |
Tobin Ehlis | c345b8b | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 167 | |
| 168 | // Clean up logging callback, if any |
| 169 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
| 170 | if (my_data->logging_callback) { |
| 171 | layer_destroy_msg_callback(my_data->report_data, my_data->logging_callback); |
| 172 | } |
| 173 | |
| 174 | layer_debug_report_destroy_instance(my_data->report_data); |
| 175 | layer_data_map.erase(pTable); |
| 176 | instanceMap.erase(instance); |
| 177 | device_limits_instance_table_map.erase(key); |
Tobin Ehlis | c345b8b | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | VK_LAYER_EXPORT VkResult VKAPI vkEnumeratePhysicalDevices(VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices) |
| 181 | { |
| 182 | auto it = instanceMap.find(instance); |
| 183 | if (it != instanceMap.end()) { |
| 184 | // For this instance, flag when vkEnumeratePhysicalDevices goes to QUERY_COUNT and then QUERY_DETAILS |
| 185 | if (NULL == pPhysicalDevices) { |
| 186 | it->second->vkEnumeratePhysicalDevicesState = QUERY_COUNT; |
| 187 | } else { |
| 188 | if (UNCALLED == it->second->vkEnumeratePhysicalDevicesState) { |
| 189 | // Flag error here, shouldn't be calling this without having queried count |
| 190 | log_msg(mid(instance), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_INSTANCE, 0, 0, DEVLIMITS_MUST_QUERY_COUNT, "DL", |
| 191 | "Invalid call sequence to vkEnumeratePhysicalDevices() w/ non-NULL pPhysicalDevices. You should first call vkEnumeratePhysicalDevices() w/ NULL pPhysicalDevices to query pPhysicalDeviceCount."); |
| 192 | } // TODO : Could also flag a warning if re-calling this function in QUERY_DETAILS state |
| 193 | else if (it->second->physicalDevicesCount != *pPhysicalDeviceCount) { |
| 194 | log_msg(mid(instance), VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_PHYSICAL_DEVICE, 0, 0, DEVLIMITS_COUNT_MISMATCH, "DL", |
| 195 | "Call to vkEnumeratePhysicalDevices() w/ pPhysicalDeviceCount value %u, but actual count supported by this instance is %u.", *pPhysicalDeviceCount, it->second->physicalDevicesCount); |
| 196 | } |
| 197 | it->second->vkEnumeratePhysicalDevicesState = QUERY_DETAILS; |
| 198 | } |
| 199 | VkResult result = get_dispatch_table(device_limits_instance_table_map,instance)->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices); |
| 200 | if (NULL == pPhysicalDevices) { |
| 201 | it->second->physicalDevicesCount = *pPhysicalDeviceCount; |
| 202 | } else { // Save physical devices |
| 203 | for (uint32_t i=0; i < *pPhysicalDeviceCount; i++) { |
| 204 | physicalDeviceMap[pPhysicalDevices[i]] = unique_ptr<PHYSICAL_DEVICE_STATE>(new PHYSICAL_DEVICE_STATE()); |
| 205 | } |
| 206 | } |
| 207 | return result; |
| 208 | } else { |
| 209 | log_msg(mid(instance), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_INSTANCE, 0, 0, DEVLIMITS_INVALID_INSTANCE, "DL", |
| 210 | "Invalid instance (%#" PRIxLEAST64 ") passed into vkEnumeratePhysicalDevices().", instance); |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures) |
| 215 | { |
| 216 | auto it = physicalDeviceMap.find(physicalDevice); |
| 217 | if (it != physicalDeviceMap.end()) { |
| 218 | VkResult result = get_dispatch_table(device_limits_instance_table_map, physicalDevice)->GetPhysicalDeviceFeatures(physicalDevice, pFeatures); |
| 219 | // Save Features |
| 220 | physicalDeviceFeaturesMap[physicalDevice] = unique_ptr<VkPhysicalDeviceFeatures>(new VkPhysicalDeviceFeatures(*pFeatures)); |
| 221 | return result; |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties) |
| 226 | { |
| 227 | VkResult result = get_dispatch_table(device_limits_instance_table_map, physicalDevice)->GetPhysicalDeviceFormatProperties(physicalDevice, format, pFormatProperties); |
| 228 | return result; |
| 229 | } |
| 230 | |
| 231 | VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageFormatProperties* pImageFormatProperties) |
| 232 | { |
| 233 | VkResult result = get_dispatch_table(device_limits_instance_table_map, physicalDevice)->GetPhysicalDeviceImageFormatProperties(physicalDevice, format, type, tiling, usage, pImageFormatProperties); |
| 234 | return result; |
| 235 | } |
| 236 | |
| 237 | VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties) |
| 238 | { |
| 239 | VkResult result = get_dispatch_table(device_limits_instance_table_map, physicalDevice)->GetPhysicalDeviceProperties(physicalDevice, pProperties); |
| 240 | return result; |
| 241 | } |
| 242 | |
| 243 | VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t* pCount, VkQueueFamilyProperties* pQueueFamilyProperties) |
| 244 | { |
| 245 | auto it = physicalDeviceMap.find(physicalDevice); |
| 246 | if (it != physicalDeviceMap.end()) { |
| 247 | if (NULL == pQueueFamilyProperties) { |
| 248 | it->second->vkGetPhysicalDeviceQueueFamilyPropertiesState = QUERY_COUNT; |
| 249 | } else { |
| 250 | // Verify that for each physical device, this function is called first with NULL pQueueFamilyProperties ptr in order to get count |
| 251 | if (UNCALLED == it->second->vkGetPhysicalDeviceQueueFamilyPropertiesState) { |
| 252 | log_msg(mdd(physicalDevice), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_PHYSICAL_DEVICE, 0, 0, DEVLIMITS_MUST_QUERY_COUNT, "DL", |
| 253 | "Invalid call sequence to vkGetPhysicalDeviceQueueFamilyProperties() w/ non-NULL pQueueFamilyProperties. You should first call vkGetPhysicalDeviceQueueFamilyProperties() w/ NULL pQueueFamilyProperties to query pCount."); |
| 254 | } |
| 255 | if (it->second->queueFamilyPropertiesCount != *pCount) { |
| 256 | log_msg(mdd(physicalDevice), VK_DBG_REPORT_WARN_BIT, VK_OBJECT_TYPE_PHYSICAL_DEVICE, 0, 0, DEVLIMITS_COUNT_MISMATCH, "DL", |
| 257 | "Call to vkGetPhysicalDeviceQueueFamilyProperties() w/ pCount value %u, but actual count supported by this physicalDevice is %u.", *pCount, it->second->queueFamilyPropertiesCount); |
| 258 | } |
| 259 | it->second->vkGetPhysicalDeviceQueueFamilyPropertiesState = QUERY_DETAILS; |
| 260 | } |
| 261 | // Then verify that pCount that is passed in on second call matches what was returned |
| 262 | VkResult result = get_dispatch_table(device_limits_instance_table_map, physicalDevice)->GetPhysicalDeviceQueueFamilyProperties(physicalDevice, pCount, pQueueFamilyProperties); |
| 263 | if (NULL == pQueueFamilyProperties) { |
| 264 | it->second->queueFamilyPropertiesCount = *pCount; |
| 265 | } else { // Save queue family properties |
| 266 | for (uint32_t i=0; i < *pCount; i++) { |
| 267 | queueFamilyPropertiesMap[physicalDevice][i] = unique_ptr<VkQueueFamilyProperties>(new VkQueueFamilyProperties(pQueueFamilyProperties[i])); |
| 268 | } |
| 269 | } |
| 270 | return result; |
| 271 | } else { |
| 272 | log_msg(mdd(physicalDevice), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_PHYSICAL_DEVICE, 0, 0, DEVLIMITS_INVALID_PHYSICAL_DEVICE, "DL", |
| 273 | "Invalid physicalDevice (%#" PRIxLEAST64 ") passed into vkGetPhysicalDeviceQueueFamilyProperties().", physicalDevice); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties* pMemoryProperties) |
| 278 | { |
| 279 | VkResult result = get_dispatch_table(device_limits_instance_table_map, physicalDevice)->GetPhysicalDeviceMemoryProperties(physicalDevice, pMemoryProperties); |
| 280 | return result; |
| 281 | } |
| 282 | |
| 283 | VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, uint32_t samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t* pNumProperties, VkSparseImageFormatProperties* pProperties) |
| 284 | { |
| 285 | VkResult result = get_dispatch_table(device_limits_instance_table_map, physicalDevice)->GetPhysicalDeviceSparseImageFormatProperties(physicalDevice, format, type, samples, usage, tiling, pNumProperties, pProperties); |
| 286 | return result; |
| 287 | } |
| 288 | |
| 289 | static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device) |
| 290 | { |
| 291 | uint32_t i; |
| 292 | VkLayerDispatchTable *pDisp = get_dispatch_table(device_limits_device_table_map, device); |
| 293 | deviceExtMap[pDisp].debug_marker_enabled = false; |
| 294 | |
| 295 | for (i = 0; i < pCreateInfo->extensionCount; i++) { |
| 296 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], DEBUG_MARKER_EXTENSION_NAME) == 0) { |
| 297 | /* Found a matching extension name, mark it enabled and init dispatch table*/ |
| 298 | initDebugMarkerTable(device); |
| 299 | deviceExtMap[pDisp].debug_marker_enabled = true; |
| 300 | } |
| 301 | |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice) |
| 306 | { |
| 307 | // Check that the requested queue properties are valid |
| 308 | for (uint32_t i=0; i<pCreateInfo->queueRecordCount; i++) { |
| 309 | uint32_t requestedIndex = pCreateInfo->pRequestedQueues[i].queueFamilyIndex; |
| 310 | auto qfp_it = queueFamilyPropertiesMap[gpu].find(requestedIndex); |
| 311 | if (qfp_it == queueFamilyPropertiesMap[gpu].end()) { // requested index is out of bounds for this physical device |
| 312 | log_msg(mdd(gpu), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_PHYSICAL_DEVICE, 0, 0, DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, "DL", |
| 313 | "Invalid queue create request in vkCreateDevice(). Invalid queueFamilyIndex %u requested.", requestedIndex); |
| 314 | } else if (pCreateInfo->pRequestedQueues[i].queueCount > qfp_it->second->queueCount) { |
| 315 | log_msg(mdd(gpu), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_PHYSICAL_DEVICE, 0, 0, DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, "DL", |
| 316 | "Invalid queue create request in vkCreateDevice(). QueueFamilyIndex %u only has %u queues, but requested queueCount is %u.", requestedIndex, qfp_it->second->queueCount, pCreateInfo->pRequestedQueues[i].queueCount); |
| 317 | } |
| 318 | } |
| 319 | VkLayerDispatchTable *pDeviceTable = get_dispatch_table(device_limits_device_table_map, *pDevice); |
| 320 | VkResult result = pDeviceTable->CreateDevice(gpu, pCreateInfo, pDevice); |
| 321 | if (result == VK_SUCCESS) { |
| 322 | layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(gpu), layer_data_map); |
| 323 | VkLayerDispatchTable *pTable = get_dispatch_table(device_limits_device_table_map, *pDevice); |
| 324 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map); |
| 325 | my_device_data->report_data = layer_debug_report_create_device(my_instance_data->report_data, *pDevice); |
| 326 | createDeviceRegisterExtensions(pCreateInfo, *pDevice); |
| 327 | deviceMap[*pDevice] = gpu; |
| 328 | } |
| 329 | return result; |
| 330 | } |
| 331 | |
Mark Lobodzinski | 67b42b7 | 2015-09-07 13:59:43 -0600 | [diff] [blame^] | 332 | VK_LAYER_EXPORT void VKAPI vkDestroyDevice(VkDevice device) |
Tobin Ehlis | c345b8b | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 333 | { |
| 334 | // Free device lifetime allocations |
| 335 | dispatch_key key = get_dispatch_key(device); |
| 336 | VkLayerDispatchTable *pDisp = get_dispatch_table(device_limits_device_table_map, device); |
Mark Lobodzinski | 67b42b7 | 2015-09-07 13:59:43 -0600 | [diff] [blame^] | 337 | pDisp->DestroyDevice(device); |
Tobin Ehlis | c345b8b | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 338 | deviceExtMap.erase(pDisp); |
| 339 | device_limits_device_table_map.erase(key); |
| 340 | tableDebugMarkerMap.erase(pDisp); |
Tobin Ehlis | c345b8b | 2015-09-03 09:50:06 -0600 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | static const VkLayerProperties ds_global_layers[] = { |
| 344 | { |
| 345 | "DeviceLimits", |
| 346 | VK_API_VERSION, |
| 347 | VK_MAKE_VERSION(0, 1, 0), |
| 348 | "Validation layer: DeviceLimits", |
| 349 | } |
| 350 | }; |
| 351 | |
| 352 | VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionProperties( |
| 353 | const char *pLayerName, |
| 354 | uint32_t *pCount, |
| 355 | VkExtensionProperties* pProperties) |
| 356 | { |
| 357 | /* DeviceLimits does not have any global extensions */ |
| 358 | return util_GetExtensionProperties(0, NULL, pCount, pProperties); |
| 359 | } |
| 360 | |
| 361 | VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalLayerProperties( |
| 362 | uint32_t *pCount, |
| 363 | VkLayerProperties* pProperties) |
| 364 | { |
| 365 | return util_GetLayerProperties(ARRAY_SIZE(ds_global_layers), |
| 366 | ds_global_layers, |
| 367 | pCount, pProperties); |
| 368 | } |
| 369 | |
| 370 | static const VkExtensionProperties ds_device_extensions[] = { |
| 371 | { |
| 372 | DEBUG_MARKER_EXTENSION_NAME, |
| 373 | VK_MAKE_VERSION(0, 1, 0), |
| 374 | } |
| 375 | }; |
| 376 | |
| 377 | static const VkLayerProperties ds_device_layers[] = { |
| 378 | { |
| 379 | "DeviceLimits", |
| 380 | VK_API_VERSION, |
| 381 | VK_MAKE_VERSION(0, 1, 0), |
| 382 | "Validation layer: DeviceLimits", |
| 383 | } |
| 384 | }; |
| 385 | |
| 386 | VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionProperties( |
| 387 | VkPhysicalDevice physicalDevice, |
| 388 | const char* pLayerName, |
| 389 | uint32_t* pCount, |
| 390 | VkExtensionProperties* pProperties) |
| 391 | { |
| 392 | /* Device Limits does not have any physical device extensions */ |
| 393 | return util_GetExtensionProperties(ARRAY_SIZE(ds_device_extensions), ds_device_extensions, |
| 394 | pCount, pProperties); |
| 395 | } |
| 396 | |
| 397 | VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceLayerProperties( |
| 398 | VkPhysicalDevice physicalDevice, |
| 399 | uint32_t* pCount, |
| 400 | VkLayerProperties* pProperties) |
| 401 | { |
| 402 | /* Device Limits' physical device layers are the same as global */ |
| 403 | return util_GetLayerProperties(ARRAY_SIZE(ds_device_layers), ds_device_layers, |
| 404 | pCount, pProperties); |
| 405 | } |
| 406 | |
| 407 | VK_LAYER_EXPORT VkResult VKAPI vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue* pQueue) |
| 408 | { |
| 409 | VkPhysicalDevice gpu = deviceMap[device]; |
| 410 | auto qfp_it = queueFamilyPropertiesMap[gpu].find(queueFamilyIndex); |
| 411 | if (qfp_it == queueFamilyPropertiesMap[gpu].end()) { // requested index is out of bounds for this physical device |
| 412 | log_msg(mdd(gpu), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_PHYSICAL_DEVICE, 0, 0, DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, "DL", |
| 413 | "Invalid queueFamilyIndex %u requested in vkGetDeviceQueue().", queueFamilyIndex); |
| 414 | } else if (queueIndex >= qfp_it->second->queueCount) { |
| 415 | log_msg(mdd(gpu), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_PHYSICAL_DEVICE, 0, 0, DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, "DL", |
| 416 | "Invalid queue request in vkGetDeviceQueue(). QueueFamilyIndex %u only has %u queues, but requested queueIndex is %u.", queueFamilyIndex, qfp_it->second->queueCount, queueIndex); |
| 417 | } |
| 418 | VkResult result = get_dispatch_table(device_limits_device_table_map, device)->GetDeviceQueue(device, queueFamilyIndex, queueIndex, pQueue); |
| 419 | return result; |
| 420 | } |
| 421 | |
| 422 | VK_LAYER_EXPORT VkResult VKAPI vkDbgCreateMsgCallback( |
| 423 | VkInstance instance, |
| 424 | VkFlags msgFlags, |
| 425 | const PFN_vkDbgMsgCallback pfnMsgCallback, |
| 426 | void* pUserData, |
| 427 | VkDbgMsgCallback* pMsgCallback) |
| 428 | { |
| 429 | VkLayerInstanceDispatchTable *pTable = get_dispatch_table(device_limits_instance_table_map, instance); |
| 430 | VkResult res = pTable->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); |
| 431 | if (VK_SUCCESS == res) { |
| 432 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 433 | res = layer_create_msg_callback(my_data->report_data, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); |
| 434 | } |
| 435 | return res; |
| 436 | } |
| 437 | |
| 438 | VK_LAYER_EXPORT VkResult VKAPI vkDbgDestroyMsgCallback( |
| 439 | VkInstance instance, |
| 440 | VkDbgMsgCallback msgCallback) |
| 441 | { |
| 442 | VkLayerInstanceDispatchTable *pTable = get_dispatch_table(device_limits_instance_table_map, instance); |
| 443 | VkResult res = pTable->DbgDestroyMsgCallback(instance, msgCallback); |
| 444 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 445 | layer_destroy_msg_callback(my_data->report_data, msgCallback); |
| 446 | return res; |
| 447 | } |
| 448 | |
| 449 | VK_LAYER_EXPORT PFN_vkVoidFunction VKAPI vkGetDeviceProcAddr(VkDevice dev, const char* funcName) |
| 450 | { |
| 451 | if (dev == NULL) |
| 452 | return NULL; |
| 453 | |
| 454 | /* loader uses this to force layer initialization; device object is wrapped */ |
| 455 | if (!strcmp(funcName, "vkGetDeviceProcAddr")) { |
| 456 | initDeviceTable(device_limits_device_table_map, (const VkBaseLayerObject *) dev); |
| 457 | return (PFN_vkVoidFunction) vkGetDeviceProcAddr; |
| 458 | } |
| 459 | if (!strcmp(funcName, "vkCreateDevice")) |
| 460 | return (PFN_vkVoidFunction) vkCreateDevice; |
| 461 | if (!strcmp(funcName, "vkDestroyDevice")) |
| 462 | return (PFN_vkVoidFunction) vkDestroyDevice; |
| 463 | /*if (!strcmp(funcName, "vkQueueSubmit")) |
| 464 | return (PFN_vkVoidFunction) vkQueueSubmit;*/ |
| 465 | if (!strcmp(funcName, "vkGetDeviceQueue")) |
| 466 | return (PFN_vkVoidFunction) vkGetDeviceQueue; |
| 467 | /* if (!strcmp(funcName, "vkDestroyFence")) |
| 468 | return (PFN_vkVoidFunction) vkDestroyFence; |
| 469 | if (!strcmp(funcName, "vkDestroySemaphore")) |
| 470 | return (PFN_vkVoidFunction) vkDestroySemaphore; |
| 471 | if (!strcmp(funcName, "vkDestroyEvent")) |
| 472 | return (PFN_vkVoidFunction) vkDestroyEvent; |
| 473 | if (!strcmp(funcName, "vkDestroyQueryPool")) |
| 474 | return (PFN_vkVoidFunction) vkDestroyQueryPool; |
| 475 | if (!strcmp(funcName, "vkDestroyBuffer")) |
| 476 | return (PFN_vkVoidFunction) vkDestroyBuffer; |
| 477 | if (!strcmp(funcName, "vkDestroyBufferView")) |
| 478 | return (PFN_vkVoidFunction) vkDestroyBufferView; |
| 479 | if (!strcmp(funcName, "vkDestroyImage")) |
| 480 | return (PFN_vkVoidFunction) vkDestroyImage; |
| 481 | if (!strcmp(funcName, "vkDestroyImageView")) |
| 482 | return (PFN_vkVoidFunction) vkDestroyImageView; |
| 483 | if (!strcmp(funcName, "vkDestroyShaderModule")) |
| 484 | return (PFN_vkVoidFunction) vkDestroyShaderModule; |
| 485 | if (!strcmp(funcName, "vkDestroyShader")) |
| 486 | return (PFN_vkVoidFunction) vkDestroyShader; |
| 487 | if (!strcmp(funcName, "vkDestroyPipeline")) |
| 488 | return (PFN_vkVoidFunction) vkDestroyPipeline; |
| 489 | if (!strcmp(funcName, "vkDestroyPipelineLayout")) |
| 490 | return (PFN_vkVoidFunction) vkDestroyPipelineLayout; |
| 491 | if (!strcmp(funcName, "vkDestroySampler")) |
| 492 | return (PFN_vkVoidFunction) vkDestroySampler; |
| 493 | if (!strcmp(funcName, "vkDestroyDescriptorSetLayout")) |
| 494 | return (PFN_vkVoidFunction) vkDestroyDescriptorSetLayout; |
| 495 | if (!strcmp(funcName, "vkDestroyDescriptorPool")) |
| 496 | return (PFN_vkVoidFunction) vkDestroyDescriptorPool; |
| 497 | if (!strcmp(funcName, "vkDestroyDynamicViewportState")) |
| 498 | return (PFN_vkVoidFunction) vkDestroyDynamicViewportState; |
| 499 | if (!strcmp(funcName, "vkDestroyDynamicLineWidthState")) |
| 500 | return (PFN_vkVoidFunction) vkDestroyDynamicLineWidthState; |
| 501 | if (!strcmp(funcName, "vkDestroyDynamicDepthBiasState")) |
| 502 | return (PFN_vkVoidFunction) vkDestroyDynamicDepthBiasState; |
| 503 | if (!strcmp(funcName, "vkDestroyDynamicBlendState")) |
| 504 | return (PFN_vkVoidFunction) vkDestroyDynamicBlendState; |
| 505 | if (!strcmp(funcName, "vkDestroyDynamicDepthBoundsState")) |
| 506 | return (PFN_vkVoidFunction) vkDestroyDynamicDepthBoundsState; |
| 507 | if (!strcmp(funcName, "vkDestroyDynamicStencilState")) |
| 508 | return (PFN_vkVoidFunction) vkDestroyDynamicStencilState; |
| 509 | if (!strcmp(funcName, "vkDestroyCommandBuffer")) |
| 510 | return (PFN_vkVoidFunction) vkDestroyCommandBuffer; |
| 511 | if (!strcmp(funcName, "vkDestroyFramebuffer")) |
| 512 | return (PFN_vkVoidFunction) vkDestroyFramebuffer; |
| 513 | if (!strcmp(funcName, "vkDestroyRenderPass")) |
| 514 | return (PFN_vkVoidFunction) vkDestroyRenderPass; |
| 515 | if (!strcmp(funcName, "vkCreateBufferView")) |
| 516 | return (PFN_vkVoidFunction) vkCreateBufferView; |
| 517 | if (!strcmp(funcName, "vkCreateImageView")) |
| 518 | return (PFN_vkVoidFunction) vkCreateImageView; |
| 519 | if (!strcmp(funcName, "CreatePipelineCache")) |
| 520 | return (PFN_vkVoidFunction) vkCreatePipelineCache; |
| 521 | if (!strcmp(funcName, "DestroyPipelineCache")) |
| 522 | return (PFN_vkVoidFunction) vkDestroyPipelineCache; |
| 523 | if (!strcmp(funcName, "GetPipelineCacheSize")) |
| 524 | return (PFN_vkVoidFunction) vkGetPipelineCacheSize; |
| 525 | if (!strcmp(funcName, "GetPipelineCacheData")) |
| 526 | return (PFN_vkVoidFunction) vkGetPipelineCacheData; |
| 527 | if (!strcmp(funcName, "MergePipelineCaches")) |
| 528 | return (PFN_vkVoidFunction) vkMergePipelineCaches; |
| 529 | if (!strcmp(funcName, "vkCreateGraphicsPipelines")) |
| 530 | return (PFN_vkVoidFunction) vkCreateGraphicsPipelines; |
| 531 | if (!strcmp(funcName, "vkCreateSampler")) |
| 532 | return (PFN_vkVoidFunction) vkCreateSampler; |
| 533 | if (!strcmp(funcName, "vkCreateDescriptorSetLayout")) |
| 534 | return (PFN_vkVoidFunction) vkCreateDescriptorSetLayout; |
| 535 | if (!strcmp(funcName, "vkCreatePipelineLayout")) |
| 536 | return (PFN_vkVoidFunction) vkCreatePipelineLayout; |
| 537 | if (!strcmp(funcName, "vkCreateDescriptorPool")) |
| 538 | return (PFN_vkVoidFunction) vkCreateDescriptorPool; |
| 539 | if (!strcmp(funcName, "vkResetDescriptorPool")) |
| 540 | return (PFN_vkVoidFunction) vkResetDescriptorPool; |
| 541 | if (!strcmp(funcName, "vkAllocDescriptorSets")) |
| 542 | return (PFN_vkVoidFunction) vkAllocDescriptorSets; |
| 543 | if (!strcmp(funcName, "vkUpdateDescriptorSets")) |
| 544 | return (PFN_vkVoidFunction) vkUpdateDescriptorSets; |
| 545 | if (!strcmp(funcName, "vkCreateDynamicViewportState")) |
| 546 | return (PFN_vkVoidFunction) vkCreateDynamicViewportState; |
| 547 | if (!strcmp(funcName, "vkCreateDynamicLineWidthState")) |
| 548 | return (PFN_vkVoidFunction) vkCreateDynamicLineWidthState; |
| 549 | if (!strcmp(funcName, "vkCreateDynamicDepthBiasState")) |
| 550 | return (PFN_vkVoidFunction) vkCreateDynamicDepthBiasState; |
| 551 | if (!strcmp(funcName, "vkCreateDynamicBlendState")) |
| 552 | return (PFN_vkVoidFunction) vkCreateDynamicBlendState; |
| 553 | if (!strcmp(funcName, "vkCreateDynamicDepthBoundsState")) |
| 554 | return (PFN_vkVoidFunction) vkCreateDynamicDepthBoundsState; |
| 555 | if (!strcmp(funcName, "vkCreateDynamicStencilState")) |
| 556 | return (PFN_vkVoidFunction) vkCreateDynamicStencilState; |
| 557 | if (!strcmp(funcName, "vkCreateCommandBuffer")) |
| 558 | return (PFN_vkVoidFunction) vkCreateCommandBuffer; |
| 559 | if (!strcmp(funcName, "vkBeginCommandBuffer")) |
| 560 | return (PFN_vkVoidFunction) vkBeginCommandBuffer; |
| 561 | if (!strcmp(funcName, "vkEndCommandBuffer")) |
| 562 | return (PFN_vkVoidFunction) vkEndCommandBuffer; |
| 563 | if (!strcmp(funcName, "vkResetCommandBuffer")) |
| 564 | return (PFN_vkVoidFunction) vkResetCommandBuffer; |
| 565 | if (!strcmp(funcName, "vkCmdBindPipeline")) |
| 566 | return (PFN_vkVoidFunction) vkCmdBindPipeline; |
| 567 | if (!strcmp(funcName, "vkCmdBindDynamicViewportState")) |
| 568 | return (PFN_vkVoidFunction) vkCmdBindDynamicViewportState; |
| 569 | if (!strcmp(funcName, "vkCmdBindDynamicLineWidthState")) |
| 570 | return (PFN_vkVoidFunction) vkCmdBindDynamicLineWidthState; |
| 571 | if (!strcmp(funcName, "vkCmdBindDynamicDepthBiasState")) |
| 572 | return (PFN_vkVoidFunction) vkCmdBindDynamicDepthBiasState; |
| 573 | if (!strcmp(funcName, "vkCmdBindDynamicBlendState")) |
| 574 | return (PFN_vkVoidFunction) vkCmdBindDynamicBlendState; |
| 575 | if (!strcmp(funcName, "vkCmdBindDynamicDepthBoundsState")) |
| 576 | return (PFN_vkVoidFunction) vkCmdBindDynamicDepthBoundsState; |
| 577 | if (!strcmp(funcName, "vkCmdBindDynamicStencilState")) |
| 578 | return (PFN_vkVoidFunction) vkCmdBindDynamicStencilState; |
| 579 | if (!strcmp(funcName, "vkCmdBindDescriptorSets")) |
| 580 | return (PFN_vkVoidFunction) vkCmdBindDescriptorSets; |
| 581 | if (!strcmp(funcName, "vkCmdBindVertexBuffers")) |
| 582 | return (PFN_vkVoidFunction) vkCmdBindVertexBuffers; |
| 583 | if (!strcmp(funcName, "vkCmdBindIndexBuffer")) |
| 584 | return (PFN_vkVoidFunction) vkCmdBindIndexBuffer; |
| 585 | if (!strcmp(funcName, "vkCmdDraw")) |
| 586 | return (PFN_vkVoidFunction) vkCmdDraw; |
| 587 | if (!strcmp(funcName, "vkCmdDrawIndexed")) |
| 588 | return (PFN_vkVoidFunction) vkCmdDrawIndexed; |
| 589 | if (!strcmp(funcName, "vkCmdDrawIndirect")) |
| 590 | return (PFN_vkVoidFunction) vkCmdDrawIndirect; |
| 591 | if (!strcmp(funcName, "vkCmdDrawIndexedIndirect")) |
| 592 | return (PFN_vkVoidFunction) vkCmdDrawIndexedIndirect; |
| 593 | if (!strcmp(funcName, "vkCmdDispatch")) |
| 594 | return (PFN_vkVoidFunction) vkCmdDispatch; |
| 595 | if (!strcmp(funcName, "vkCmdDispatchIndirect")) |
| 596 | return (PFN_vkVoidFunction) vkCmdDispatchIndirect; |
| 597 | if (!strcmp(funcName, "vkCmdCopyBuffer")) |
| 598 | return (PFN_vkVoidFunction) vkCmdCopyBuffer; |
| 599 | if (!strcmp(funcName, "vkCmdCopyImage")) |
| 600 | return (PFN_vkVoidFunction) vkCmdCopyImage; |
| 601 | if (!strcmp(funcName, "vkCmdCopyBufferToImage")) |
| 602 | return (PFN_vkVoidFunction) vkCmdCopyBufferToImage; |
| 603 | if (!strcmp(funcName, "vkCmdCopyImageToBuffer")) |
| 604 | return (PFN_vkVoidFunction) vkCmdCopyImageToBuffer; |
| 605 | if (!strcmp(funcName, "vkCmdUpdateBuffer")) |
| 606 | return (PFN_vkVoidFunction) vkCmdUpdateBuffer; |
| 607 | if (!strcmp(funcName, "vkCmdFillBuffer")) |
| 608 | return (PFN_vkVoidFunction) vkCmdFillBuffer; |
| 609 | if (!strcmp(funcName, "vkCmdClearColorImage")) |
| 610 | return (PFN_vkVoidFunction) vkCmdClearColorImage; |
| 611 | if (!strcmp(funcName, "vkCmdClearDepthStencilImage")) |
| 612 | return (PFN_vkVoidFunction) vkCmdClearDepthStencilImage; |
| 613 | if (!strcmp(funcName, "vkCmdClearColorAttachment")) |
| 614 | return (PFN_vkVoidFunction) vkCmdClearColorAttachment; |
| 615 | if (!strcmp(funcName, "vkCmdClearDepthStencilAttachment")) |
| 616 | return (PFN_vkVoidFunction) vkCmdClearDepthStencilAttachment; |
| 617 | if (!strcmp(funcName, "vkCmdResolveImage")) |
| 618 | return (PFN_vkVoidFunction) vkCmdResolveImage; |
| 619 | if (!strcmp(funcName, "vkCmdSetEvent")) |
| 620 | return (PFN_vkVoidFunction) vkCmdSetEvent; |
| 621 | if (!strcmp(funcName, "vkCmdResetEvent")) |
| 622 | return (PFN_vkVoidFunction) vkCmdResetEvent; |
| 623 | if (!strcmp(funcName, "vkCmdWaitEvents")) |
| 624 | return (PFN_vkVoidFunction) vkCmdWaitEvents; |
| 625 | if (!strcmp(funcName, "vkCmdPipelineBarrier")) |
| 626 | return (PFN_vkVoidFunction) vkCmdPipelineBarrier; |
| 627 | if (!strcmp(funcName, "vkCmdBeginQuery")) |
| 628 | return (PFN_vkVoidFunction) vkCmdBeginQuery; |
| 629 | if (!strcmp(funcName, "vkCmdEndQuery")) |
| 630 | return (PFN_vkVoidFunction) vkCmdEndQuery; |
| 631 | if (!strcmp(funcName, "vkCmdResetQueryPool")) |
| 632 | return (PFN_vkVoidFunction) vkCmdResetQueryPool; |
| 633 | if (!strcmp(funcName, "vkCmdWriteTimestamp")) |
| 634 | return (PFN_vkVoidFunction) vkCmdWriteTimestamp; |
| 635 | if (!strcmp(funcName, "vkCreateFramebuffer")) |
| 636 | return (PFN_vkVoidFunction) vkCreateFramebuffer; |
| 637 | if (!strcmp(funcName, "vkCreateRenderPass")) |
| 638 | return (PFN_vkVoidFunction) vkCreateRenderPass; |
| 639 | if (!strcmp(funcName, "vkCmdBeginRenderPass")) |
| 640 | return (PFN_vkVoidFunction) vkCmdBeginRenderPass; |
| 641 | if (!strcmp(funcName, "vkCmdNextSubpass")) |
| 642 | return (PFN_vkVoidFunction) vkCmdNextSubpass; |
| 643 | if (!strcmp(funcName, "vkCmdEndRenderPass")) |
| 644 | return (PFN_vkVoidFunction) vkCmdEndRenderPass;*/ |
| 645 | |
| 646 | VkLayerDispatchTable* pTable = get_dispatch_table(device_limits_device_table_map, dev); |
| 647 | if (deviceExtMap.size() == 0 || deviceExtMap[pTable].debug_marker_enabled) |
| 648 | { |
| 649 | // if (!strcmp(funcName, "vkCmdDbgMarkerBegin")) |
| 650 | // return (PFN_vkVoidFunction) vkCmdDbgMarkerBegin; |
| 651 | // if (!strcmp(funcName, "vkCmdDbgMarkerEnd")) |
| 652 | // return (PFN_vkVoidFunction) vkCmdDbgMarkerEnd; |
| 653 | // if (!strcmp(funcName, "vkDbgSetObjectTag")) |
| 654 | // return (void*) vkDbgSetObjectTag; |
| 655 | // if (!strcmp(funcName, "vkDbgSetObjectName")) |
| 656 | // return (void*) vkDbgSetObjectName; |
| 657 | } |
| 658 | { |
| 659 | if (pTable->GetDeviceProcAddr == NULL) |
| 660 | return NULL; |
| 661 | return pTable->GetDeviceProcAddr(dev, funcName); |
| 662 | } |
| 663 | } |
| 664 | |
| 665 | VK_LAYER_EXPORT PFN_vkVoidFunction VKAPI vkGetInstanceProcAddr(VkInstance instance, const char* funcName) |
| 666 | { |
| 667 | PFN_vkVoidFunction fptr; |
| 668 | if (instance == NULL) |
| 669 | return NULL; |
| 670 | |
| 671 | /* loader uses this to force layer initialization; instance object is wrapped */ |
| 672 | if (!strcmp(funcName, "vkGetInstanceProcAddr")) { |
| 673 | initInstanceTable(device_limits_instance_table_map, (const VkBaseLayerObject *) instance); |
| 674 | return (PFN_vkVoidFunction) vkGetInstanceProcAddr; |
| 675 | } |
| 676 | if (!strcmp(funcName, "vkCreateInstance")) |
| 677 | return (PFN_vkVoidFunction) vkCreateInstance; |
| 678 | if (!strcmp(funcName, "vkDestroyInstance")) |
| 679 | return (PFN_vkVoidFunction) vkDestroyInstance; |
| 680 | if (!strcmp(funcName, "vkEnumeratePhysicalDevices")) |
| 681 | return (PFN_vkVoidFunction) vkEnumeratePhysicalDevices; |
| 682 | if (!strcmp(funcName, "vkGetPhysicalDeviceFeatures")) |
| 683 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceFeatures; |
| 684 | if (!strcmp(funcName, "vkGetPhysicalDeviceFormatProperties")) |
| 685 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceFormatProperties; |
| 686 | if (!strcmp(funcName, "vkGetPhysicalDeviceImageFormatProperties")) |
| 687 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceImageFormatProperties; |
| 688 | if (!strcmp(funcName, "vkGetPhysicalDeviceProperties")) |
| 689 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceProperties; |
| 690 | if (!strcmp(funcName, "vkGetPhysicalDeviceQueueFamilyProperties")) |
| 691 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceQueueFamilyProperties; |
| 692 | if (!strcmp(funcName, "vkGetPhysicalDeviceMemoryProperties")) |
| 693 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceMemoryProperties; |
| 694 | if (!strcmp(funcName, "vkGetPhysicalDeviceLayerProperties")) |
| 695 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceLayerProperties; |
| 696 | if (!strcmp(funcName, "vkGetPhysicalDeviceExtensionProperties")) |
| 697 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceExtensionProperties; |
| 698 | if (!strcmp(funcName, "vkGetPhysicalDeviceSparseImageFormatProperties")) |
| 699 | return (PFN_vkVoidFunction) vkGetPhysicalDeviceSparseImageFormatProperties; |
| 700 | if (!strcmp(funcName, "vkGetGlobalLayerProperties")) |
| 701 | return (PFN_vkVoidFunction) vkGetGlobalLayerProperties; |
| 702 | if (!strcmp(funcName, "vkGetGlobalExtensionProperties")) |
| 703 | return (PFN_vkVoidFunction) vkGetGlobalExtensionProperties; |
| 704 | |
| 705 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map); |
| 706 | fptr = debug_report_get_instance_proc_addr(my_data->report_data, funcName); |
| 707 | if (fptr) |
| 708 | return fptr; |
| 709 | |
| 710 | { |
| 711 | VkLayerInstanceDispatchTable* pTable = get_dispatch_table(device_limits_instance_table_map, instance); |
| 712 | if (pTable->GetInstanceProcAddr == NULL) |
| 713 | return NULL; |
| 714 | return pTable->GetInstanceProcAddr(instance, funcName); |
| 715 | } |
| 716 | } |