From 8d476fc845f9535e4f2d3ef15089a4bdab364ac8 Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Tue, 22 Nov 2016 21:29:18 -0600 Subject: [PATCH] Update the Vulkan loader to the latest version --- src/xenia/ui/vulkan/vulkan_device.cc | 31 +- src/xenia/ui/vulkan/vulkan_device.h | 2 - third_party/vulkan/loader/cJSON.c | 4 + third_party/vulkan/loader/cJSON.h | 2 + third_party/vulkan/loader/debug_report.c | 281 ++- .../vulkan/loader/dev_ext_trampoline.c | 1500 +++++------ third_party/vulkan/loader/dirent_on_windows.c | 16 +- third_party/vulkan/loader/extensions.c | 279 +++ third_party/vulkan/loader/extensions.h | 47 + third_party/vulkan/loader/gpa_helper.h | 4 + third_party/vulkan/loader/loader.c | 2183 +++++++++++------ third_party/vulkan/loader/loader.h | 188 +- third_party/vulkan/loader/premake5.lua | 1 + third_party/vulkan/loader/table_ops.h | 59 +- third_party/vulkan/loader/trampoline.c | 431 ++-- .../vulkan/loader/vk_loader_platform.h | 139 +- third_party/vulkan/loader/wsi.c | 1332 +++++----- third_party/vulkan/loader/wsi.h | 35 + third_party/vulkan/vk_icd.h | 9 +- third_party/vulkan/vk_layer.h | 13 + third_party/vulkan/vk_platform.h | 14 +- third_party/vulkan/vulkan.h | 241 +- 22 files changed, 4245 insertions(+), 2566 deletions(-) create mode 100644 third_party/vulkan/loader/extensions.c create mode 100644 third_party/vulkan/loader/extensions.h diff --git a/src/xenia/ui/vulkan/vulkan_device.cc b/src/xenia/ui/vulkan/vulkan_device.cc index 28b48c7ec..178e2d3cc 100644 --- a/src/xenia/ui/vulkan/vulkan_device.cc +++ b/src/xenia/ui/vulkan/vulkan_device.cc @@ -227,46 +227,19 @@ void VulkanDevice::ReleaseQueue(VkQueue queue) { void VulkanDevice::DbgSetObjectName(VkDevice device, uint64_t object, VkDebugReportObjectTypeEXT object_type, std::string name) { - PFN_vkDebugMarkerSetObjectNameEXT pfn_vkDebugMarkerSetObjectNameEXT = nullptr; - if (!pfn_vkDebugMarkerSetObjectNameEXT) { - pfn_vkDebugMarkerSetObjectNameEXT = - (PFN_vkDebugMarkerSetObjectNameEXT)vkGetDeviceProcAddr( - device, "vkDebugMarkerSetObjectNameEXT"); - - if (!pfn_vkDebugMarkerSetObjectNameEXT) { - return; - } - } - VkDebugMarkerObjectNameInfoEXT info; info.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT; info.pNext = nullptr; info.objectType = object_type; info.object = object; info.pObjectName = name.c_str(); - pfn_vkDebugMarkerSetObjectNameEXT(device, &info); + vkDebugMarkerSetObjectNameEXT(device, &info); } void VulkanDevice::DbgSetObjectName(uint64_t object, VkDebugReportObjectTypeEXT object_type, std::string name) { - if (!pfn_vkDebugMarkerSetObjectNameEXT_) { - pfn_vkDebugMarkerSetObjectNameEXT_ = - (PFN_vkDebugMarkerSetObjectNameEXT)vkGetDeviceProcAddr( - handle, "vkDebugMarkerSetObjectNameEXT"); - - if (!pfn_vkDebugMarkerSetObjectNameEXT_) { - return; - } - } - - VkDebugMarkerObjectNameInfoEXT info; - info.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT; - info.pNext = nullptr; - info.objectType = object_type; - info.object = object; - info.pObjectName = name.c_str(); - pfn_vkDebugMarkerSetObjectNameEXT_(handle, &info); + DbgSetObjectName(*this, object, object_type, name); } bool VulkanDevice::is_renderdoc_attached() const { diff --git a/src/xenia/ui/vulkan/vulkan_device.h b/src/xenia/ui/vulkan/vulkan_device.h index 6ec7ce64e..08886e487 100644 --- a/src/xenia/ui/vulkan/vulkan_device.h +++ b/src/xenia/ui/vulkan/vulkan_device.h @@ -101,8 +101,6 @@ class VulkanDevice { std::vector required_layers_; std::vector required_extensions_; - PFN_vkDebugMarkerSetObjectNameEXT pfn_vkDebugMarkerSetObjectNameEXT_; - DeviceInfo device_info_; uint32_t queue_family_index_ = 0; std::mutex queue_mutex_; diff --git a/third_party/vulkan/loader/cJSON.c b/third_party/vulkan/loader/cJSON.c index fc3ba0494..e7266c382 100644 --- a/third_party/vulkan/loader/cJSON.c +++ b/third_party/vulkan/loader/cJSON.c @@ -88,6 +88,10 @@ void cJSON_Delete(cJSON *c) { } } +void cJSON_Free(void *p) { + cJSON_free(p); +} + /* Parse the input text to generate a number, and populate the result into item. */ static const char *parse_number(cJSON *item, const char *num) { diff --git a/third_party/vulkan/loader/cJSON.h b/third_party/vulkan/loader/cJSON.h index c6a57be57..cab30515e 100644 --- a/third_party/vulkan/loader/cJSON.h +++ b/third_party/vulkan/loader/cJSON.h @@ -84,6 +84,8 @@ extern char *cJSON_PrintUnformatted(cJSON *item); extern char *cJSON_PrintBuffered(cJSON *item, int prebuffer, int fmt); /* Delete a cJSON entity and all subentities. */ extern void cJSON_Delete(cJSON *c); +/* Delete an item allocated inside the JSON parser*/ +extern void cJSON_Free(void *p); /* Returns the number of items in an array (or object). */ extern int cJSON_GetArraySize(cJSON *array); diff --git a/third_party/vulkan/loader/debug_report.c b/third_party/vulkan/loader/debug_report.c index c339c7011..b404a51ac 100644 --- a/third_party/vulkan/loader/debug_report.c +++ b/third_party/vulkan/loader/debug_report.c @@ -49,12 +49,12 @@ void debug_report_add_instance_extensions( void debug_report_create_instance(struct loader_instance *ptr_instance, const VkInstanceCreateInfo *pCreateInfo) { - ptr_instance->debug_report_enabled = false; + ptr_instance->enabled_known_extensions.ext_debug_report = 0; for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_DEBUG_REPORT_EXTENSION_NAME) == 0) { - ptr_instance->debug_report_enabled = true; + ptr_instance->enabled_known_extensions.ext_debug_report = 1; return; } } @@ -65,18 +65,27 @@ util_CreateDebugReportCallback(struct loader_instance *inst, VkDebugReportCallbackCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT callback) { - VkLayerDbgFunctionNode *pNewDbgFuncNode; + VkLayerDbgFunctionNode *pNewDbgFuncNode = NULL; + +#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) + { +#else if (pAllocator != NULL) { - pNewDbgFuncNode = (VkLayerDbgFunctionNode *)pAllocator->pfnAllocation( - pAllocator->pUserData, sizeof(VkLayerDbgFunctionNode), - sizeof(int *), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + pNewDbgFuncNode = + (VkLayerDbgFunctionNode *)pAllocator->pfnAllocation( + pAllocator->pUserData, sizeof(VkLayerDbgFunctionNode), + sizeof(int *), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); } else { - pNewDbgFuncNode = (VkLayerDbgFunctionNode *)loader_heap_alloc( - inst, sizeof(VkLayerDbgFunctionNode), - VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); +#endif + pNewDbgFuncNode = + (VkLayerDbgFunctionNode *)loader_instance_heap_alloc( + inst, sizeof(VkLayerDbgFunctionNode), + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); } - if (!pNewDbgFuncNode) + if (!pNewDbgFuncNode) { return VK_ERROR_OUT_OF_HOST_MEMORY; + } + memset(pNewDbgFuncNode, 0, sizeof(VkLayerDbgFunctionNode)); pNewDbgFuncNode->msgCallback = callback; pNewDbgFuncNode->pfnMsgCallback = pCreateInfo->pfnCallback; @@ -88,17 +97,14 @@ util_CreateDebugReportCallback(struct loader_instance *inst, return VK_SUCCESS; } -static VKAPI_ATTR VkResult VKAPI_CALL debug_report_CreateDebugReportCallback( - VkInstance instance, VkDebugReportCallbackCreateInfoEXT *pCreateInfo, - VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pCallback) { +static VKAPI_ATTR VkResult VKAPI_CALL debug_report_CreateDebugReportCallbackEXT( + VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, + const VkAllocationCallbacks *pAllocator, + VkDebugReportCallbackEXT *pCallback) { struct loader_instance *inst = loader_get_instance(instance); loader_platform_thread_lock_mutex(&loader_lock); VkResult result = inst->disp->CreateDebugReportCallbackEXT( instance, pCreateInfo, pAllocator, pCallback); - if (result == VK_SUCCESS) { - result = util_CreateDebugReportCallback(inst, pCreateInfo, pAllocator, - *pCallback); - } loader_platform_thread_unlock_mutex(&loader_lock); return result; } @@ -137,10 +143,14 @@ void util_DestroyDebugReportCallback(struct loader_instance *inst, pPrev->pNext = pTrav->pNext; if (inst->DbgFunctionHead == pTrav) inst->DbgFunctionHead = pTrav->pNext; +#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) + { +#else if (pAllocator != NULL) { pAllocator->pfnFree(pAllocator->pUserData, pTrav); } else { - loader_heap_free(inst, pTrav); +#endif + loader_instance_heap_free(inst, pTrav); } break; } @@ -159,6 +169,8 @@ VkResult util_CopyDebugReportCreateInfos( uint32_t *num_callbacks, VkDebugReportCallbackCreateInfoEXT **infos, VkDebugReportCallbackEXT **callbacks) { uint32_t n = *num_callbacks = 0; + VkDebugReportCallbackCreateInfoEXT *pInfos = NULL; + VkDebugReportCallbackEXT *pCallbacks = NULL; // NOTE: The loader is not using pAllocator, and so this function doesn't // either. @@ -176,20 +188,45 @@ VkResult util_CopyDebugReportCreateInfos( return VK_SUCCESS; } - // 2nd, allocate memory for each VkDebugReportCallbackCreateInfoEXT: - VkDebugReportCallbackCreateInfoEXT *pInfos = *infos = - ((VkDebugReportCallbackCreateInfoEXT *)malloc( +// 2nd, allocate memory for each VkDebugReportCallbackCreateInfoEXT: +#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) + { +#else + if (pAllocator != NULL) { + pInfos = *infos = + ((VkDebugReportCallbackCreateInfoEXT *)pAllocator->pfnAllocation( + pAllocator->pUserData, + n * sizeof(VkDebugReportCallbackCreateInfoEXT), sizeof(void *), + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT)); + } else { +#endif + pInfos = *infos = ((VkDebugReportCallbackCreateInfoEXT *)malloc( n * sizeof(VkDebugReportCallbackCreateInfoEXT))); + } if (!pInfos) { return VK_ERROR_OUT_OF_HOST_MEMORY; } - // 3rd, allocate memory for a unique handle for each callback: - VkDebugReportCallbackEXT *pCallbacks = *callbacks = - ((VkDebugReportCallbackEXT *)malloc(n * - sizeof(VkDebugReportCallbackEXT))); - if (!pCallbacks) { - free(pInfos); - return VK_ERROR_OUT_OF_HOST_MEMORY; +// 3rd, allocate memory for a unique handle for each callback: +#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) + { +#else + if (pAllocator != NULL) { + pCallbacks = *callbacks = + ((VkDebugReportCallbackEXT *)pAllocator->pfnAllocation( + pAllocator->pUserData, n * sizeof(VkDebugReportCallbackEXT), + sizeof(void *), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT)); + if (!pCallbacks) { + pAllocator->pfnFree(pAllocator->pUserData, pInfos); + return VK_ERROR_OUT_OF_HOST_MEMORY; + } + } else { +#endif + pCallbacks = *callbacks = ((VkDebugReportCallbackEXT *)malloc( + n * sizeof(VkDebugReportCallbackEXT))); + if (!pCallbacks) { + free(pInfos); + return VK_ERROR_OUT_OF_HOST_MEMORY; + } } // 4th, copy each VkDebugReportCallbackCreateInfoEXT for use by // vkDestroyInstance, and assign a unique handle to each callback (just @@ -199,7 +236,7 @@ VkResult util_CopyDebugReportCreateInfos( if (((VkInstanceCreateInfo *)pNext)->sType == VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT) { memcpy(pInfos, pNext, sizeof(VkDebugReportCallbackCreateInfoEXT)); - *pCallbacks++ = (VkDebugReportCallbackEXT)pInfos++; + *pCallbacks++ = (VkDebugReportCallbackEXT)(uintptr_t)pInfos++; } pNext = (void *)((VkInstanceCreateInfo *)pNext)->pNext; } @@ -211,8 +248,17 @@ VkResult util_CopyDebugReportCreateInfos( void util_FreeDebugReportCreateInfos(const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackCreateInfoEXT *infos, VkDebugReportCallbackEXT *callbacks) { - free(infos); - free(callbacks); +#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) + { +#else + if (pAllocator != NULL) { + pAllocator->pfnFree(pAllocator->pUserData, infos); + pAllocator->pfnFree(pAllocator->pUserData, callbacks); + } else { +#endif + free(infos); + free(callbacks); + } } VkResult util_CreateDebugReportCallbacks( @@ -243,9 +289,9 @@ void util_DestroyDebugReportCallbacks(struct loader_instance *inst, } static VKAPI_ATTR void VKAPI_CALL -debug_report_DestroyDebugReportCallback(VkInstance instance, - VkDebugReportCallbackEXT callback, - VkAllocationCallbacks *pAllocator) { +debug_report_DestroyDebugReportCallbackEXT( + VkInstance instance, VkDebugReportCallbackEXT callback, + const VkAllocationCallbacks *pAllocator) { struct loader_instance *inst = loader_get_instance(instance); loader_platform_thread_lock_mutex(&loader_lock); @@ -256,7 +302,7 @@ debug_report_DestroyDebugReportCallback(VkInstance instance, loader_platform_thread_unlock_mutex(&loader_lock); } -static VKAPI_ATTR void VKAPI_CALL debug_report_DebugReportMessage( +static VKAPI_ATTR void VKAPI_CALL debug_report_DebugReportMessageEXT( VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location, int32_t msgCode, const char *pLayerPrefix, const char *pMsg) { @@ -275,101 +321,178 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDebugReportCallback( VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pCallback) { - VkDebugReportCallbackEXT *icd_info; - const struct loader_icd *icd; + VkDebugReportCallbackEXT *icd_info = NULL; + const struct loader_icd_term *icd_term; struct loader_instance *inst = (struct loader_instance *)instance; VkResult res = VK_SUCCESS; uint32_t storage_idx; + VkLayerDbgFunctionNode *pNewDbgFuncNode = NULL; - icd_info = calloc(sizeof(VkDebugReportCallbackEXT), inst->total_icd_count); +#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) + { +#else + if (pAllocator != NULL) { + icd_info = ((VkDebugReportCallbackEXT *)pAllocator->pfnAllocation( + pAllocator->pUserData, + inst->total_icd_count * sizeof(VkDebugReportCallbackEXT), + sizeof(void *), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT)); + memset(icd_info, 0, + inst->total_icd_count * sizeof(VkDebugReportCallbackEXT)); + } else { +#endif + icd_info = + calloc(sizeof(VkDebugReportCallbackEXT), inst->total_icd_count); + } if (!icd_info) { - return VK_ERROR_OUT_OF_HOST_MEMORY; + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } storage_idx = 0; - for (icd = inst->icds; icd; icd = icd->next) { - if (!icd->CreateDebugReportCallbackEXT) { + for (icd_term = inst->icd_terms; icd_term; icd_term = icd_term->next) { + if (!icd_term->CreateDebugReportCallbackEXT) { continue; } - res = icd->CreateDebugReportCallbackEXT( - icd->instance, pCreateInfo, pAllocator, &icd_info[storage_idx]); + res = icd_term->CreateDebugReportCallbackEXT(icd_term->instance, + pCreateInfo, pAllocator, + &icd_info[storage_idx]); if (res != VK_SUCCESS) { - break; + goto out; } storage_idx++; } - /* roll back on errors */ - if (icd) { + // Setup the debug report callback in the terminator since a layer may want + // to grab the information itself (RenderDoc) and then return back to the + // user callback a sub-set of the messages. +#if (DEBUG_DISABLE_APP_ALLOCATORS == 0) + if (pAllocator != NULL) { + pNewDbgFuncNode = + (VkLayerDbgFunctionNode *)pAllocator->pfnAllocation( + pAllocator->pUserData, sizeof(VkLayerDbgFunctionNode), + sizeof(int *), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + } else { +#else + { +#endif + pNewDbgFuncNode = + (VkLayerDbgFunctionNode *)loader_instance_heap_alloc( + inst, sizeof(VkLayerDbgFunctionNode), + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + } + if (!pNewDbgFuncNode) { + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; + } + memset(pNewDbgFuncNode, 0, sizeof(VkLayerDbgFunctionNode)); + + pNewDbgFuncNode->pfnMsgCallback = pCreateInfo->pfnCallback; + pNewDbgFuncNode->msgFlags = pCreateInfo->flags; + pNewDbgFuncNode->pUserData = pCreateInfo->pUserData; + pNewDbgFuncNode->pNext = inst->DbgFunctionHead; + inst->DbgFunctionHead = pNewDbgFuncNode; + + *(VkDebugReportCallbackEXT **)pCallback = icd_info; + pNewDbgFuncNode->msgCallback = *pCallback; + +out: + + // Roll back on errors + if (VK_SUCCESS != res) { storage_idx = 0; - for (icd = inst->icds; icd; icd = icd->next) { - if (NULL == icd->DestroyDebugReportCallbackEXT) { + for (icd_term = inst->icd_terms; icd_term; icd_term = icd_term->next) { + if (NULL == icd_term->DestroyDebugReportCallbackEXT) { continue; } if (icd_info[storage_idx]) { - icd->DestroyDebugReportCallbackEXT( - icd->instance, icd_info[storage_idx], pAllocator); + icd_term->DestroyDebugReportCallbackEXT( + icd_term->instance, icd_info[storage_idx], pAllocator); } storage_idx++; } - return res; +#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) + { +#else + if (pAllocator != NULL) { + if (NULL != pNewDbgFuncNode) { + pAllocator->pfnFree(pAllocator->pUserData, pNewDbgFuncNode); + } + if (NULL != icd_info) { + pAllocator->pfnFree(pAllocator->pUserData, icd_info); + } + } else { +#endif + if (NULL != pNewDbgFuncNode) { + free(pNewDbgFuncNode); + } + if (NULL != icd_info) { + free(icd_info); + } + } } - *(VkDebugReportCallbackEXT **)pCallback = icd_info; - - return VK_SUCCESS; + return res; } /* * This is the instance chain terminator function * for DestroyDebugReportCallback */ -VKAPI_ATTR void VKAPI_CALL -terminator_DestroyDebugReportCallback(VkInstance instance, - VkDebugReportCallbackEXT callback, - const VkAllocationCallbacks *pAllocator) { +VKAPI_ATTR void VKAPI_CALL terminator_DestroyDebugReportCallback( + VkInstance instance, VkDebugReportCallbackEXT callback, + const VkAllocationCallbacks *pAllocator) { uint32_t storage_idx; VkDebugReportCallbackEXT *icd_info; - const struct loader_icd *icd; + const struct loader_icd_term *icd_term; struct loader_instance *inst = (struct loader_instance *)instance; icd_info = *(VkDebugReportCallbackEXT **)&callback; storage_idx = 0; - for (icd = inst->icds; icd; icd = icd->next) { - if (NULL == icd->DestroyDebugReportCallbackEXT) { + for (icd_term = inst->icd_terms; icd_term; icd_term = icd_term->next) { + if (NULL == icd_term->DestroyDebugReportCallbackEXT) { continue; } if (icd_info[storage_idx]) { - icd->DestroyDebugReportCallbackEXT( - icd->instance, icd_info[storage_idx], pAllocator); + icd_term->DestroyDebugReportCallbackEXT( + icd_term->instance, icd_info[storage_idx], pAllocator); } storage_idx++; } + +#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) + { +#else + if (pAllocator != NULL) { + pAllocator->pfnFree(pAllocator->pUserData, icd_info); + } else { +#endif + free(icd_info); + } } /* * This is the instance chain terminator function * for DebugReportMessage */ -VKAPI_ATTR void VKAPI_CALL -terminator_DebugReportMessage(VkInstance instance, VkDebugReportFlagsEXT flags, - VkDebugReportObjectTypeEXT objType, - uint64_t object, size_t location, int32_t msgCode, - const char *pLayerPrefix, const char *pMsg) { - const struct loader_icd *icd; +VKAPI_ATTR void VKAPI_CALL terminator_DebugReportMessage( + VkInstance instance, VkDebugReportFlagsEXT flags, + VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location, + int32_t msgCode, const char *pLayerPrefix, const char *pMsg) { + const struct loader_icd_term *icd_term; struct loader_instance *inst = (struct loader_instance *)instance; loader_platform_thread_lock_mutex(&loader_lock); - for (icd = inst->icds; icd; icd = icd->next) { - if (icd->DebugReportMessageEXT != NULL) { - icd->DebugReportMessageEXT(icd->instance, flags, objType, object, - location, msgCode, pLayerPrefix, pMsg); + for (icd_term = inst->icd_terms; icd_term; icd_term = icd_term->next) { + if (icd_term->DebugReportMessageEXT != NULL) { + icd_term->DebugReportMessageEXT(icd_term->instance, flags, objType, + object, location, msgCode, + pLayerPrefix, pMsg); } } @@ -392,20 +515,20 @@ bool debug_report_instance_gpa(struct loader_instance *ptr_instance, *addr = NULL; if (!strcmp("vkCreateDebugReportCallbackEXT", name)) { - *addr = ptr_instance->debug_report_enabled - ? (void *)debug_report_CreateDebugReportCallback + *addr = (ptr_instance->enabled_known_extensions.ext_debug_report == 1) + ? (void *)debug_report_CreateDebugReportCallbackEXT : NULL; return true; } if (!strcmp("vkDestroyDebugReportCallbackEXT", name)) { - *addr = ptr_instance->debug_report_enabled - ? (void *)debug_report_DestroyDebugReportCallback + *addr = (ptr_instance->enabled_known_extensions.ext_debug_report == 1) + ? (void *)debug_report_DestroyDebugReportCallbackEXT : NULL; return true; } if (!strcmp("vkDebugReportMessageEXT", name)) { - *addr = ptr_instance->debug_report_enabled - ? (void *)debug_report_DebugReportMessage + *addr = (ptr_instance->enabled_known_extensions.ext_debug_report == 1) + ? (void *)debug_report_DebugReportMessageEXT : NULL; return true; } diff --git a/third_party/vulkan/loader/dev_ext_trampoline.c b/third_party/vulkan/loader/dev_ext_trampoline.c index b63f82839..e417e7ecd 100644 --- a/third_party/vulkan/loader/dev_ext_trampoline.c +++ b/third_party/vulkan/loader/dev_ext_trampoline.c @@ -24,2008 +24,2008 @@ #pragma GCC optimize(3) // force gcc to use tail-calls #endif -VKAPI_ATTR void VKAPI_CALL vkDevExt0(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext0(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[0](device); + disp->ext_dispatch.dev_ext[0](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt1(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext1(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[1](device); + disp->ext_dispatch.dev_ext[1](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt2(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext2(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[2](device); + disp->ext_dispatch.dev_ext[2](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt3(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext3(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[3](device); + disp->ext_dispatch.dev_ext[3](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt4(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext4(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[4](device); + disp->ext_dispatch.dev_ext[4](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt5(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext5(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[5](device); + disp->ext_dispatch.dev_ext[5](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt6(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext6(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[6](device); + disp->ext_dispatch.dev_ext[6](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt7(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext7(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[7](device); + disp->ext_dispatch.dev_ext[7](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt8(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext8(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[8](device); + disp->ext_dispatch.dev_ext[8](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt9(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext9(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[9](device); + disp->ext_dispatch.dev_ext[9](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt10(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext10(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[10](device); + disp->ext_dispatch.dev_ext[10](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt11(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext11(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[11](device); + disp->ext_dispatch.dev_ext[11](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt12(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext12(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[12](device); + disp->ext_dispatch.dev_ext[12](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt13(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext13(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[13](device); + disp->ext_dispatch.dev_ext[13](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt14(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext14(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[14](device); + disp->ext_dispatch.dev_ext[14](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt15(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext15(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[15](device); + disp->ext_dispatch.dev_ext[15](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt16(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext16(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[16](device); + disp->ext_dispatch.dev_ext[16](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt17(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext17(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[17](device); + disp->ext_dispatch.dev_ext[17](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt18(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext18(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[18](device); + disp->ext_dispatch.dev_ext[18](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt19(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext19(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[19](device); + disp->ext_dispatch.dev_ext[19](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt20(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext20(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[20](device); + disp->ext_dispatch.dev_ext[20](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt21(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext21(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[21](device); + disp->ext_dispatch.dev_ext[21](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt22(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext22(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[22](device); + disp->ext_dispatch.dev_ext[22](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt23(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext23(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[23](device); + disp->ext_dispatch.dev_ext[23](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt24(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext24(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[24](device); + disp->ext_dispatch.dev_ext[24](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt25(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext25(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[25](device); + disp->ext_dispatch.dev_ext[25](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt26(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext26(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[26](device); + disp->ext_dispatch.dev_ext[26](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt27(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext27(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[27](device); + disp->ext_dispatch.dev_ext[27](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt28(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext28(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[28](device); + disp->ext_dispatch.dev_ext[28](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt29(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext29(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[29](device); + disp->ext_dispatch.dev_ext[29](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt30(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext30(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[30](device); + disp->ext_dispatch.dev_ext[30](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt31(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext31(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[31](device); + disp->ext_dispatch.dev_ext[31](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt32(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext32(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[32](device); + disp->ext_dispatch.dev_ext[32](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt33(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext33(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[33](device); + disp->ext_dispatch.dev_ext[33](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt34(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext34(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[34](device); + disp->ext_dispatch.dev_ext[34](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt35(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext35(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[35](device); + disp->ext_dispatch.dev_ext[35](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt36(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext36(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[36](device); + disp->ext_dispatch.dev_ext[36](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt37(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext37(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[37](device); + disp->ext_dispatch.dev_ext[37](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt38(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext38(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[38](device); + disp->ext_dispatch.dev_ext[38](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt39(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext39(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[39](device); + disp->ext_dispatch.dev_ext[39](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt40(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext40(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[40](device); + disp->ext_dispatch.dev_ext[40](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt41(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext41(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[41](device); + disp->ext_dispatch.dev_ext[41](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt42(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext42(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[42](device); + disp->ext_dispatch.dev_ext[42](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt43(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext43(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[43](device); + disp->ext_dispatch.dev_ext[43](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt44(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext44(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[44](device); + disp->ext_dispatch.dev_ext[44](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt45(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext45(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[45](device); + disp->ext_dispatch.dev_ext[45](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt46(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext46(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[46](device); + disp->ext_dispatch.dev_ext[46](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt47(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext47(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[47](device); + disp->ext_dispatch.dev_ext[47](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt48(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext48(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[48](device); + disp->ext_dispatch.dev_ext[48](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt49(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext49(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[49](device); + disp->ext_dispatch.dev_ext[49](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt50(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext50(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[50](device); + disp->ext_dispatch.dev_ext[50](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt51(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext51(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[51](device); + disp->ext_dispatch.dev_ext[51](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt52(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext52(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[52](device); + disp->ext_dispatch.dev_ext[52](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt53(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext53(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[53](device); + disp->ext_dispatch.dev_ext[53](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt54(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext54(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[54](device); + disp->ext_dispatch.dev_ext[54](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt55(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext55(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[55](device); + disp->ext_dispatch.dev_ext[55](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt56(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext56(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[56](device); + disp->ext_dispatch.dev_ext[56](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt57(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext57(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[57](device); + disp->ext_dispatch.dev_ext[57](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt58(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext58(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[58](device); + disp->ext_dispatch.dev_ext[58](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt59(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext59(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[59](device); + disp->ext_dispatch.dev_ext[59](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt60(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext60(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[60](device); + disp->ext_dispatch.dev_ext[60](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt61(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext61(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[61](device); + disp->ext_dispatch.dev_ext[61](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt62(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext62(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[62](device); + disp->ext_dispatch.dev_ext[62](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt63(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext63(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[63](device); + disp->ext_dispatch.dev_ext[63](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt64(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext64(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[64](device); + disp->ext_dispatch.dev_ext[64](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt65(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext65(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[65](device); + disp->ext_dispatch.dev_ext[65](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt66(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext66(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[66](device); + disp->ext_dispatch.dev_ext[66](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt67(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext67(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[67](device); + disp->ext_dispatch.dev_ext[67](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt68(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext68(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[68](device); + disp->ext_dispatch.dev_ext[68](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt69(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext69(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[69](device); + disp->ext_dispatch.dev_ext[69](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt70(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext70(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[70](device); + disp->ext_dispatch.dev_ext[70](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt71(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext71(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[71](device); + disp->ext_dispatch.dev_ext[71](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt72(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext72(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[72](device); + disp->ext_dispatch.dev_ext[72](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt73(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext73(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[73](device); + disp->ext_dispatch.dev_ext[73](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt74(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext74(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[74](device); + disp->ext_dispatch.dev_ext[74](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt75(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext75(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[75](device); + disp->ext_dispatch.dev_ext[75](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt76(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext76(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[76](device); + disp->ext_dispatch.dev_ext[76](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt77(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext77(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[77](device); + disp->ext_dispatch.dev_ext[77](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt78(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext78(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[78](device); + disp->ext_dispatch.dev_ext[78](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt79(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext79(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[79](device); + disp->ext_dispatch.dev_ext[79](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt80(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext80(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[80](device); + disp->ext_dispatch.dev_ext[80](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt81(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext81(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[81](device); + disp->ext_dispatch.dev_ext[81](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt82(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext82(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[82](device); + disp->ext_dispatch.dev_ext[82](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt83(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext83(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[83](device); + disp->ext_dispatch.dev_ext[83](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt84(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext84(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[84](device); + disp->ext_dispatch.dev_ext[84](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt85(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext85(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[85](device); + disp->ext_dispatch.dev_ext[85](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt86(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext86(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[86](device); + disp->ext_dispatch.dev_ext[86](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt87(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext87(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[87](device); + disp->ext_dispatch.dev_ext[87](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt88(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext88(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[88](device); + disp->ext_dispatch.dev_ext[88](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt89(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext89(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[89](device); + disp->ext_dispatch.dev_ext[89](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt90(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext90(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[90](device); + disp->ext_dispatch.dev_ext[90](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt91(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext91(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[91](device); + disp->ext_dispatch.dev_ext[91](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt92(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext92(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[92](device); + disp->ext_dispatch.dev_ext[92](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt93(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext93(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[93](device); + disp->ext_dispatch.dev_ext[93](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt94(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext94(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[94](device); + disp->ext_dispatch.dev_ext[94](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt95(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext95(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[95](device); + disp->ext_dispatch.dev_ext[95](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt96(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext96(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[96](device); + disp->ext_dispatch.dev_ext[96](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt97(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext97(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[97](device); + disp->ext_dispatch.dev_ext[97](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt98(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext98(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[98](device); + disp->ext_dispatch.dev_ext[98](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt99(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext99(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[99](device); + disp->ext_dispatch.dev_ext[99](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt100(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext100(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[100](device); + disp->ext_dispatch.dev_ext[100](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt101(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext101(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[101](device); + disp->ext_dispatch.dev_ext[101](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt102(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext102(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[102](device); + disp->ext_dispatch.dev_ext[102](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt103(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext103(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[103](device); + disp->ext_dispatch.dev_ext[103](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt104(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext104(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[104](device); + disp->ext_dispatch.dev_ext[104](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt105(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext105(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[105](device); + disp->ext_dispatch.dev_ext[105](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt106(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext106(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[106](device); + disp->ext_dispatch.dev_ext[106](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt107(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext107(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[107](device); + disp->ext_dispatch.dev_ext[107](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt108(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext108(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[108](device); + disp->ext_dispatch.dev_ext[108](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt109(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext109(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[109](device); + disp->ext_dispatch.dev_ext[109](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt110(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext110(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[110](device); + disp->ext_dispatch.dev_ext[110](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt111(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext111(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[111](device); + disp->ext_dispatch.dev_ext[111](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt112(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext112(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[112](device); + disp->ext_dispatch.dev_ext[112](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt113(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext113(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[113](device); + disp->ext_dispatch.dev_ext[113](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt114(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext114(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[114](device); + disp->ext_dispatch.dev_ext[114](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt115(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext115(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[115](device); + disp->ext_dispatch.dev_ext[115](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt116(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext116(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[116](device); + disp->ext_dispatch.dev_ext[116](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt117(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext117(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[117](device); + disp->ext_dispatch.dev_ext[117](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt118(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext118(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[118](device); + disp->ext_dispatch.dev_ext[118](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt119(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext119(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[119](device); + disp->ext_dispatch.dev_ext[119](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt120(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext120(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[120](device); + disp->ext_dispatch.dev_ext[120](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt121(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext121(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[121](device); + disp->ext_dispatch.dev_ext[121](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt122(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext122(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[122](device); + disp->ext_dispatch.dev_ext[122](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt123(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext123(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[123](device); + disp->ext_dispatch.dev_ext[123](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt124(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext124(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[124](device); + disp->ext_dispatch.dev_ext[124](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt125(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext125(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[125](device); + disp->ext_dispatch.dev_ext[125](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt126(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext126(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[126](device); + disp->ext_dispatch.dev_ext[126](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt127(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext127(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[127](device); + disp->ext_dispatch.dev_ext[127](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt128(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext128(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[128](device); + disp->ext_dispatch.dev_ext[128](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt129(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext129(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[129](device); + disp->ext_dispatch.dev_ext[129](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt130(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext130(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[130](device); + disp->ext_dispatch.dev_ext[130](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt131(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext131(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[131](device); + disp->ext_dispatch.dev_ext[131](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt132(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext132(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[132](device); + disp->ext_dispatch.dev_ext[132](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt133(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext133(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[133](device); + disp->ext_dispatch.dev_ext[133](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt134(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext134(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[134](device); + disp->ext_dispatch.dev_ext[134](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt135(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext135(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[135](device); + disp->ext_dispatch.dev_ext[135](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt136(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext136(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[136](device); + disp->ext_dispatch.dev_ext[136](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt137(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext137(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[137](device); + disp->ext_dispatch.dev_ext[137](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt138(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext138(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[138](device); + disp->ext_dispatch.dev_ext[138](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt139(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext139(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[139](device); + disp->ext_dispatch.dev_ext[139](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt140(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext140(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[140](device); + disp->ext_dispatch.dev_ext[140](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt141(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext141(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[141](device); + disp->ext_dispatch.dev_ext[141](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt142(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext142(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[142](device); + disp->ext_dispatch.dev_ext[142](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt143(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext143(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[143](device); + disp->ext_dispatch.dev_ext[143](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt144(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext144(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[144](device); + disp->ext_dispatch.dev_ext[144](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt145(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext145(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[145](device); + disp->ext_dispatch.dev_ext[145](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt146(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext146(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[146](device); + disp->ext_dispatch.dev_ext[146](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt147(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext147(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[147](device); + disp->ext_dispatch.dev_ext[147](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt148(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext148(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[148](device); + disp->ext_dispatch.dev_ext[148](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt149(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext149(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[149](device); + disp->ext_dispatch.dev_ext[149](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt150(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext150(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[150](device); + disp->ext_dispatch.dev_ext[150](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt151(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext151(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[151](device); + disp->ext_dispatch.dev_ext[151](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt152(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext152(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[152](device); + disp->ext_dispatch.dev_ext[152](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt153(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext153(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[153](device); + disp->ext_dispatch.dev_ext[153](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt154(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext154(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[154](device); + disp->ext_dispatch.dev_ext[154](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt155(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext155(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[155](device); + disp->ext_dispatch.dev_ext[155](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt156(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext156(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[156](device); + disp->ext_dispatch.dev_ext[156](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt157(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext157(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[157](device); + disp->ext_dispatch.dev_ext[157](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt158(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext158(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[158](device); + disp->ext_dispatch.dev_ext[158](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt159(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext159(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[159](device); + disp->ext_dispatch.dev_ext[159](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt160(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext160(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[160](device); + disp->ext_dispatch.dev_ext[160](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt161(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext161(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[161](device); + disp->ext_dispatch.dev_ext[161](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt162(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext162(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[162](device); + disp->ext_dispatch.dev_ext[162](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt163(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext163(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[163](device); + disp->ext_dispatch.dev_ext[163](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt164(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext164(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[164](device); + disp->ext_dispatch.dev_ext[164](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt165(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext165(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[165](device); + disp->ext_dispatch.dev_ext[165](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt166(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext166(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[166](device); + disp->ext_dispatch.dev_ext[166](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt167(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext167(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[167](device); + disp->ext_dispatch.dev_ext[167](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt168(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext168(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[168](device); + disp->ext_dispatch.dev_ext[168](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt169(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext169(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[169](device); + disp->ext_dispatch.dev_ext[169](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt170(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext170(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[170](device); + disp->ext_dispatch.dev_ext[170](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt171(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext171(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[171](device); + disp->ext_dispatch.dev_ext[171](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt172(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext172(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[172](device); + disp->ext_dispatch.dev_ext[172](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt173(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext173(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[173](device); + disp->ext_dispatch.dev_ext[173](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt174(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext174(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[174](device); + disp->ext_dispatch.dev_ext[174](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt175(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext175(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[175](device); + disp->ext_dispatch.dev_ext[175](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt176(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext176(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[176](device); + disp->ext_dispatch.dev_ext[176](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt177(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext177(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[177](device); + disp->ext_dispatch.dev_ext[177](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt178(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext178(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[178](device); + disp->ext_dispatch.dev_ext[178](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt179(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext179(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[179](device); + disp->ext_dispatch.dev_ext[179](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt180(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext180(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[180](device); + disp->ext_dispatch.dev_ext[180](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt181(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext181(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[181](device); + disp->ext_dispatch.dev_ext[181](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt182(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext182(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[182](device); + disp->ext_dispatch.dev_ext[182](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt183(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext183(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[183](device); + disp->ext_dispatch.dev_ext[183](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt184(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext184(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[184](device); + disp->ext_dispatch.dev_ext[184](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt185(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext185(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[185](device); + disp->ext_dispatch.dev_ext[185](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt186(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext186(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[186](device); + disp->ext_dispatch.dev_ext[186](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt187(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext187(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[187](device); + disp->ext_dispatch.dev_ext[187](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt188(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext188(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[188](device); + disp->ext_dispatch.dev_ext[188](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt189(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext189(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[189](device); + disp->ext_dispatch.dev_ext[189](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt190(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext190(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[190](device); + disp->ext_dispatch.dev_ext[190](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt191(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext191(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[191](device); + disp->ext_dispatch.dev_ext[191](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt192(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext192(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[192](device); + disp->ext_dispatch.dev_ext[192](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt193(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext193(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[193](device); + disp->ext_dispatch.dev_ext[193](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt194(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext194(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[194](device); + disp->ext_dispatch.dev_ext[194](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt195(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext195(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[195](device); + disp->ext_dispatch.dev_ext[195](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt196(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext196(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[196](device); + disp->ext_dispatch.dev_ext[196](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt197(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext197(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[197](device); + disp->ext_dispatch.dev_ext[197](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt198(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext198(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[198](device); + disp->ext_dispatch.dev_ext[198](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt199(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext199(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[199](device); + disp->ext_dispatch.dev_ext[199](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt200(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext200(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[200](device); + disp->ext_dispatch.dev_ext[200](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt201(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext201(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[201](device); + disp->ext_dispatch.dev_ext[201](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt202(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext202(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[202](device); + disp->ext_dispatch.dev_ext[202](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt203(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext203(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[203](device); + disp->ext_dispatch.dev_ext[203](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt204(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext204(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[204](device); + disp->ext_dispatch.dev_ext[204](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt205(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext205(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[205](device); + disp->ext_dispatch.dev_ext[205](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt206(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext206(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[206](device); + disp->ext_dispatch.dev_ext[206](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt207(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext207(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[207](device); + disp->ext_dispatch.dev_ext[207](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt208(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext208(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[208](device); + disp->ext_dispatch.dev_ext[208](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt209(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext209(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[209](device); + disp->ext_dispatch.dev_ext[209](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt210(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext210(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[210](device); + disp->ext_dispatch.dev_ext[210](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt211(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext211(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[211](device); + disp->ext_dispatch.dev_ext[211](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt212(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext212(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[212](device); + disp->ext_dispatch.dev_ext[212](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt213(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext213(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[213](device); + disp->ext_dispatch.dev_ext[213](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt214(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext214(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[214](device); + disp->ext_dispatch.dev_ext[214](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt215(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext215(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[215](device); + disp->ext_dispatch.dev_ext[215](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt216(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext216(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[216](device); + disp->ext_dispatch.dev_ext[216](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt217(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext217(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[217](device); + disp->ext_dispatch.dev_ext[217](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt218(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext218(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[218](device); + disp->ext_dispatch.dev_ext[218](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt219(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext219(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[219](device); + disp->ext_dispatch.dev_ext[219](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt220(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext220(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[220](device); + disp->ext_dispatch.dev_ext[220](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt221(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext221(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[221](device); + disp->ext_dispatch.dev_ext[221](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt222(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext222(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[222](device); + disp->ext_dispatch.dev_ext[222](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt223(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext223(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[223](device); + disp->ext_dispatch.dev_ext[223](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt224(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext224(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[224](device); + disp->ext_dispatch.dev_ext[224](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt225(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext225(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[225](device); + disp->ext_dispatch.dev_ext[225](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt226(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext226(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[226](device); + disp->ext_dispatch.dev_ext[226](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt227(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext227(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[227](device); + disp->ext_dispatch.dev_ext[227](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt228(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext228(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[228](device); + disp->ext_dispatch.dev_ext[228](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt229(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext229(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[229](device); + disp->ext_dispatch.dev_ext[229](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt230(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext230(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[230](device); + disp->ext_dispatch.dev_ext[230](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt231(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext231(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[231](device); + disp->ext_dispatch.dev_ext[231](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt232(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext232(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[232](device); + disp->ext_dispatch.dev_ext[232](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt233(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext233(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[233](device); + disp->ext_dispatch.dev_ext[233](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt234(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext234(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[234](device); + disp->ext_dispatch.dev_ext[234](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt235(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext235(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[235](device); + disp->ext_dispatch.dev_ext[235](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt236(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext236(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[236](device); + disp->ext_dispatch.dev_ext[236](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt237(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext237(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[237](device); + disp->ext_dispatch.dev_ext[237](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt238(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext238(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[238](device); + disp->ext_dispatch.dev_ext[238](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt239(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext239(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[239](device); + disp->ext_dispatch.dev_ext[239](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt240(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext240(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[240](device); + disp->ext_dispatch.dev_ext[240](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt241(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext241(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[241](device); + disp->ext_dispatch.dev_ext[241](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt242(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext242(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[242](device); + disp->ext_dispatch.dev_ext[242](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt243(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext243(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[243](device); + disp->ext_dispatch.dev_ext[243](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt244(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext244(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[244](device); + disp->ext_dispatch.dev_ext[244](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt245(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext245(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[245](device); + disp->ext_dispatch.dev_ext[245](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt246(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext246(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[246](device); + disp->ext_dispatch.dev_ext[246](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt247(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext247(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[247](device); + disp->ext_dispatch.dev_ext[247](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt248(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext248(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[248](device); + disp->ext_dispatch.dev_ext[248](device); } -VKAPI_ATTR void VKAPI_CALL vkDevExt249(VkDevice device) { +VKAPI_ATTR void VKAPI_CALL vkdev_ext249(VkDevice device) { const struct loader_dev_dispatch_table *disp; disp = loader_get_dev_dispatch(device); - disp->ext_dispatch.DevExt[249](device); + disp->ext_dispatch.dev_ext[249](device); } void *loader_get_dev_ext_trampoline(uint32_t index) { switch (index) { case 0: - return vkDevExt0; + return vkdev_ext0; case 1: - return vkDevExt1; + return vkdev_ext1; case 2: - return vkDevExt2; + return vkdev_ext2; case 3: - return vkDevExt3; + return vkdev_ext3; case 4: - return vkDevExt4; + return vkdev_ext4; case 5: - return vkDevExt5; + return vkdev_ext5; case 6: - return vkDevExt6; + return vkdev_ext6; case 7: - return vkDevExt7; + return vkdev_ext7; case 8: - return vkDevExt8; + return vkdev_ext8; case 9: - return vkDevExt9; + return vkdev_ext9; case 10: - return vkDevExt10; + return vkdev_ext10; case 11: - return vkDevExt11; + return vkdev_ext11; case 12: - return vkDevExt12; + return vkdev_ext12; case 13: - return vkDevExt13; + return vkdev_ext13; case 14: - return vkDevExt14; + return vkdev_ext14; case 15: - return vkDevExt15; + return vkdev_ext15; case 16: - return vkDevExt16; + return vkdev_ext16; case 17: - return vkDevExt17; + return vkdev_ext17; case 18: - return vkDevExt18; + return vkdev_ext18; case 19: - return vkDevExt19; + return vkdev_ext19; case 20: - return vkDevExt20; + return vkdev_ext20; case 21: - return vkDevExt21; + return vkdev_ext21; case 22: - return vkDevExt22; + return vkdev_ext22; case 23: - return vkDevExt23; + return vkdev_ext23; case 24: - return vkDevExt24; + return vkdev_ext24; case 25: - return vkDevExt25; + return vkdev_ext25; case 26: - return vkDevExt26; + return vkdev_ext26; case 27: - return vkDevExt27; + return vkdev_ext27; case 28: - return vkDevExt28; + return vkdev_ext28; case 29: - return vkDevExt29; + return vkdev_ext29; case 30: - return vkDevExt30; + return vkdev_ext30; case 31: - return vkDevExt31; + return vkdev_ext31; case 32: - return vkDevExt32; + return vkdev_ext32; case 33: - return vkDevExt33; + return vkdev_ext33; case 34: - return vkDevExt34; + return vkdev_ext34; case 35: - return vkDevExt35; + return vkdev_ext35; case 36: - return vkDevExt36; + return vkdev_ext36; case 37: - return vkDevExt37; + return vkdev_ext37; case 38: - return vkDevExt38; + return vkdev_ext38; case 39: - return vkDevExt39; + return vkdev_ext39; case 40: - return vkDevExt40; + return vkdev_ext40; case 41: - return vkDevExt41; + return vkdev_ext41; case 42: - return vkDevExt42; + return vkdev_ext42; case 43: - return vkDevExt43; + return vkdev_ext43; case 44: - return vkDevExt44; + return vkdev_ext44; case 45: - return vkDevExt45; + return vkdev_ext45; case 46: - return vkDevExt46; + return vkdev_ext46; case 47: - return vkDevExt47; + return vkdev_ext47; case 48: - return vkDevExt48; + return vkdev_ext48; case 49: - return vkDevExt49; + return vkdev_ext49; case 50: - return vkDevExt50; + return vkdev_ext50; case 51: - return vkDevExt51; + return vkdev_ext51; case 52: - return vkDevExt52; + return vkdev_ext52; case 53: - return vkDevExt53; + return vkdev_ext53; case 54: - return vkDevExt54; + return vkdev_ext54; case 55: - return vkDevExt55; + return vkdev_ext55; case 56: - return vkDevExt56; + return vkdev_ext56; case 57: - return vkDevExt57; + return vkdev_ext57; case 58: - return vkDevExt58; + return vkdev_ext58; case 59: - return vkDevExt59; + return vkdev_ext59; case 60: - return vkDevExt60; + return vkdev_ext60; case 61: - return vkDevExt61; + return vkdev_ext61; case 62: - return vkDevExt62; + return vkdev_ext62; case 63: - return vkDevExt63; + return vkdev_ext63; case 64: - return vkDevExt64; + return vkdev_ext64; case 65: - return vkDevExt65; + return vkdev_ext65; case 66: - return vkDevExt66; + return vkdev_ext66; case 67: - return vkDevExt67; + return vkdev_ext67; case 68: - return vkDevExt68; + return vkdev_ext68; case 69: - return vkDevExt69; + return vkdev_ext69; case 70: - return vkDevExt70; + return vkdev_ext70; case 71: - return vkDevExt71; + return vkdev_ext71; case 72: - return vkDevExt72; + return vkdev_ext72; case 73: - return vkDevExt73; + return vkdev_ext73; case 74: - return vkDevExt74; + return vkdev_ext74; case 75: - return vkDevExt75; + return vkdev_ext75; case 76: - return vkDevExt76; + return vkdev_ext76; case 77: - return vkDevExt77; + return vkdev_ext77; case 78: - return vkDevExt78; + return vkdev_ext78; case 79: - return vkDevExt79; + return vkdev_ext79; case 80: - return vkDevExt80; + return vkdev_ext80; case 81: - return vkDevExt81; + return vkdev_ext81; case 82: - return vkDevExt82; + return vkdev_ext82; case 83: - return vkDevExt83; + return vkdev_ext83; case 84: - return vkDevExt84; + return vkdev_ext84; case 85: - return vkDevExt85; + return vkdev_ext85; case 86: - return vkDevExt86; + return vkdev_ext86; case 87: - return vkDevExt87; + return vkdev_ext87; case 88: - return vkDevExt88; + return vkdev_ext88; case 89: - return vkDevExt89; + return vkdev_ext89; case 90: - return vkDevExt90; + return vkdev_ext90; case 91: - return vkDevExt91; + return vkdev_ext91; case 92: - return vkDevExt92; + return vkdev_ext92; case 93: - return vkDevExt93; + return vkdev_ext93; case 94: - return vkDevExt94; + return vkdev_ext94; case 95: - return vkDevExt95; + return vkdev_ext95; case 96: - return vkDevExt96; + return vkdev_ext96; case 97: - return vkDevExt97; + return vkdev_ext97; case 98: - return vkDevExt98; + return vkdev_ext98; case 99: - return vkDevExt99; + return vkdev_ext99; case 100: - return vkDevExt100; + return vkdev_ext100; case 101: - return vkDevExt101; + return vkdev_ext101; case 102: - return vkDevExt102; + return vkdev_ext102; case 103: - return vkDevExt103; + return vkdev_ext103; case 104: - return vkDevExt104; + return vkdev_ext104; case 105: - return vkDevExt105; + return vkdev_ext105; case 106: - return vkDevExt106; + return vkdev_ext106; case 107: - return vkDevExt107; + return vkdev_ext107; case 108: - return vkDevExt108; + return vkdev_ext108; case 109: - return vkDevExt109; + return vkdev_ext109; case 110: - return vkDevExt110; + return vkdev_ext110; case 111: - return vkDevExt111; + return vkdev_ext111; case 112: - return vkDevExt112; + return vkdev_ext112; case 113: - return vkDevExt113; + return vkdev_ext113; case 114: - return vkDevExt114; + return vkdev_ext114; case 115: - return vkDevExt115; + return vkdev_ext115; case 116: - return vkDevExt116; + return vkdev_ext116; case 117: - return vkDevExt117; + return vkdev_ext117; case 118: - return vkDevExt118; + return vkdev_ext118; case 119: - return vkDevExt119; + return vkdev_ext119; case 120: - return vkDevExt120; + return vkdev_ext120; case 121: - return vkDevExt121; + return vkdev_ext121; case 122: - return vkDevExt122; + return vkdev_ext122; case 123: - return vkDevExt123; + return vkdev_ext123; case 124: - return vkDevExt124; + return vkdev_ext124; case 125: - return vkDevExt125; + return vkdev_ext125; case 126: - return vkDevExt126; + return vkdev_ext126; case 127: - return vkDevExt127; + return vkdev_ext127; case 128: - return vkDevExt128; + return vkdev_ext128; case 129: - return vkDevExt129; + return vkdev_ext129; case 130: - return vkDevExt130; + return vkdev_ext130; case 131: - return vkDevExt131; + return vkdev_ext131; case 132: - return vkDevExt132; + return vkdev_ext132; case 133: - return vkDevExt133; + return vkdev_ext133; case 134: - return vkDevExt134; + return vkdev_ext134; case 135: - return vkDevExt135; + return vkdev_ext135; case 136: - return vkDevExt136; + return vkdev_ext136; case 137: - return vkDevExt137; + return vkdev_ext137; case 138: - return vkDevExt138; + return vkdev_ext138; case 139: - return vkDevExt139; + return vkdev_ext139; case 140: - return vkDevExt140; + return vkdev_ext140; case 141: - return vkDevExt141; + return vkdev_ext141; case 142: - return vkDevExt142; + return vkdev_ext142; case 143: - return vkDevExt143; + return vkdev_ext143; case 144: - return vkDevExt144; + return vkdev_ext144; case 145: - return vkDevExt145; + return vkdev_ext145; case 146: - return vkDevExt146; + return vkdev_ext146; case 147: - return vkDevExt147; + return vkdev_ext147; case 148: - return vkDevExt148; + return vkdev_ext148; case 149: - return vkDevExt149; + return vkdev_ext149; case 150: - return vkDevExt150; + return vkdev_ext150; case 151: - return vkDevExt151; + return vkdev_ext151; case 152: - return vkDevExt152; + return vkdev_ext152; case 153: - return vkDevExt153; + return vkdev_ext153; case 154: - return vkDevExt154; + return vkdev_ext154; case 155: - return vkDevExt155; + return vkdev_ext155; case 156: - return vkDevExt156; + return vkdev_ext156; case 157: - return vkDevExt157; + return vkdev_ext157; case 158: - return vkDevExt158; + return vkdev_ext158; case 159: - return vkDevExt159; + return vkdev_ext159; case 160: - return vkDevExt160; + return vkdev_ext160; case 161: - return vkDevExt161; + return vkdev_ext161; case 162: - return vkDevExt162; + return vkdev_ext162; case 163: - return vkDevExt163; + return vkdev_ext163; case 164: - return vkDevExt164; + return vkdev_ext164; case 165: - return vkDevExt165; + return vkdev_ext165; case 166: - return vkDevExt166; + return vkdev_ext166; case 167: - return vkDevExt167; + return vkdev_ext167; case 168: - return vkDevExt168; + return vkdev_ext168; case 169: - return vkDevExt169; + return vkdev_ext169; case 170: - return vkDevExt170; + return vkdev_ext170; case 171: - return vkDevExt171; + return vkdev_ext171; case 172: - return vkDevExt172; + return vkdev_ext172; case 173: - return vkDevExt173; + return vkdev_ext173; case 174: - return vkDevExt174; + return vkdev_ext174; case 175: - return vkDevExt175; + return vkdev_ext175; case 176: - return vkDevExt176; + return vkdev_ext176; case 177: - return vkDevExt177; + return vkdev_ext177; case 178: - return vkDevExt178; + return vkdev_ext178; case 179: - return vkDevExt179; + return vkdev_ext179; case 180: - return vkDevExt180; + return vkdev_ext180; case 181: - return vkDevExt181; + return vkdev_ext181; case 182: - return vkDevExt182; + return vkdev_ext182; case 183: - return vkDevExt183; + return vkdev_ext183; case 184: - return vkDevExt184; + return vkdev_ext184; case 185: - return vkDevExt185; + return vkdev_ext185; case 186: - return vkDevExt186; + return vkdev_ext186; case 187: - return vkDevExt187; + return vkdev_ext187; case 188: - return vkDevExt188; + return vkdev_ext188; case 189: - return vkDevExt189; + return vkdev_ext189; case 190: - return vkDevExt190; + return vkdev_ext190; case 191: - return vkDevExt191; + return vkdev_ext191; case 192: - return vkDevExt192; + return vkdev_ext192; case 193: - return vkDevExt193; + return vkdev_ext193; case 194: - return vkDevExt194; + return vkdev_ext194; case 195: - return vkDevExt195; + return vkdev_ext195; case 196: - return vkDevExt196; + return vkdev_ext196; case 197: - return vkDevExt197; + return vkdev_ext197; case 198: - return vkDevExt198; + return vkdev_ext198; case 199: - return vkDevExt199; + return vkdev_ext199; case 200: - return vkDevExt200; + return vkdev_ext200; case 201: - return vkDevExt201; + return vkdev_ext201; case 202: - return vkDevExt202; + return vkdev_ext202; case 203: - return vkDevExt203; + return vkdev_ext203; case 204: - return vkDevExt204; + return vkdev_ext204; case 205: - return vkDevExt205; + return vkdev_ext205; case 206: - return vkDevExt206; + return vkdev_ext206; case 207: - return vkDevExt207; + return vkdev_ext207; case 208: - return vkDevExt208; + return vkdev_ext208; case 209: - return vkDevExt209; + return vkdev_ext209; case 210: - return vkDevExt210; + return vkdev_ext210; case 211: - return vkDevExt211; + return vkdev_ext211; case 212: - return vkDevExt212; + return vkdev_ext212; case 213: - return vkDevExt213; + return vkdev_ext213; case 214: - return vkDevExt214; + return vkdev_ext214; case 215: - return vkDevExt215; + return vkdev_ext215; case 216: - return vkDevExt216; + return vkdev_ext216; case 217: - return vkDevExt217; + return vkdev_ext217; case 218: - return vkDevExt218; + return vkdev_ext218; case 219: - return vkDevExt219; + return vkdev_ext219; case 220: - return vkDevExt220; + return vkdev_ext220; case 221: - return vkDevExt221; + return vkdev_ext221; case 222: - return vkDevExt222; + return vkdev_ext222; case 223: - return vkDevExt223; + return vkdev_ext223; case 224: - return vkDevExt224; + return vkdev_ext224; case 225: - return vkDevExt225; + return vkdev_ext225; case 226: - return vkDevExt226; + return vkdev_ext226; case 227: - return vkDevExt227; + return vkdev_ext227; case 228: - return vkDevExt228; + return vkdev_ext228; case 229: - return vkDevExt229; + return vkdev_ext229; case 230: - return vkDevExt230; + return vkdev_ext230; case 231: - return vkDevExt231; + return vkdev_ext231; case 232: - return vkDevExt232; + return vkdev_ext232; case 233: - return vkDevExt233; + return vkdev_ext233; case 234: - return vkDevExt234; + return vkdev_ext234; case 235: - return vkDevExt235; + return vkdev_ext235; case 236: - return vkDevExt236; + return vkdev_ext236; case 237: - return vkDevExt237; + return vkdev_ext237; case 238: - return vkDevExt238; + return vkdev_ext238; case 239: - return vkDevExt239; + return vkdev_ext239; case 240: - return vkDevExt240; + return vkdev_ext240; case 241: - return vkDevExt241; + return vkdev_ext241; case 242: - return vkDevExt242; + return vkdev_ext242; case 243: - return vkDevExt243; + return vkdev_ext243; case 244: - return vkDevExt244; + return vkdev_ext244; case 245: - return vkDevExt245; + return vkdev_ext245; case 246: - return vkDevExt246; + return vkdev_ext246; case 247: - return vkDevExt247; + return vkdev_ext247; case 248: - return vkDevExt248; + return vkdev_ext248; case 249: - return vkDevExt249; + return vkdev_ext249; } return NULL; } diff --git a/third_party/vulkan/loader/dirent_on_windows.c b/third_party/vulkan/loader/dirent_on_windows.c index e408224f3..6f78cf931 100644 --- a/third_party/vulkan/loader/dirent_on_windows.c +++ b/third_party/vulkan/loader/dirent_on_windows.c @@ -36,9 +36,9 @@ DIR *opendir(const char *name) { const char *all = /* search pattern must end with suitable wildcard */ strchr("/\\", name[base_length - 1]) ? "*" : "/*"; - if ((dir = (DIR *)loader_tls_heap_alloc(sizeof *dir)) != 0 && - (dir->name = (char *)loader_tls_heap_alloc(base_length + - strlen(all) + 1)) != 0) { + if ((dir = (DIR *)loader_instance_tls_heap_alloc(sizeof *dir)) != 0 && + (dir->name = (char *)loader_instance_tls_heap_alloc( + base_length + strlen(all) + 1)) != 0) { strcat(strcpy(dir->name, name), all); if ((dir->handle = @@ -46,13 +46,13 @@ DIR *opendir(const char *name) { dir->result.d_name = 0; } else /* rollback */ { - loader_tls_heap_free(dir->name); - loader_tls_heap_free(dir); + loader_instance_tls_heap_free(dir->name); + loader_instance_tls_heap_free(dir); dir = 0; } } else /* rollback */ { - loader_tls_heap_free(dir); + loader_instance_tls_heap_free(dir); dir = 0; errno = ENOMEM; } @@ -71,8 +71,8 @@ int closedir(DIR *dir) { result = _findclose(dir->handle); } - loader_tls_heap_free(dir->name); - loader_tls_heap_free(dir); + loader_instance_tls_heap_free(dir->name); + loader_instance_tls_heap_free(dir); } if (result == -1) /* map all errors to EBADF */ diff --git a/third_party/vulkan/loader/extensions.c b/third_party/vulkan/loader/extensions.c new file mode 100644 index 000000000..0a9f918bb --- /dev/null +++ b/third_party/vulkan/loader/extensions.c @@ -0,0 +1,279 @@ +/* + * Copyright (c) 2015-2016 The Khronos Group Inc. + * Copyright (c) 2015-2016 Valve Corporation + * Copyright (c) 2015-2016 LunarG, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Author: Mark Lobodzinski + */ + +#define _GNU_SOURCE +#include +#include +#include +#include "vk_loader_platform.h" +#include "loader.h" +#include "extensions.h" +#include +#include "wsi.h" + +// Definitions for the VK_EXT_debug_marker extension commands which +// need to have a terminator function + +VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectTagEXT( + VkDevice device, VkDebugMarkerObjectTagInfoEXT *pTagInfo) { + const VkLayerDispatchTable *disp = loader_get_dispatch(device); + // If this is a physical device, we have to replace it with the proper one + // for the next call. + if (pTagInfo->objectType == + VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { + struct loader_physical_device_tramp *phys_dev_tramp = + (struct loader_physical_device_tramp *)(uintptr_t)pTagInfo->object; + pTagInfo->object = (uint64_t)(uintptr_t)phys_dev_tramp->phys_dev; + } + return disp->DebugMarkerSetObjectTagEXT(device, pTagInfo); +} + +VKAPI_ATTR VkResult VKAPI_CALL terminator_DebugMarkerSetObjectTagEXT( + VkDevice device, VkDebugMarkerObjectTagInfoEXT *pTagInfo) { + uint32_t icd_index = 0; + struct loader_device *dev; + struct loader_icd_term *icd_term = + loader_get_icd_and_device(device, &dev, &icd_index); + // If this is a physical device, we have to replace it with the proper one + // for the next call. + if (pTagInfo->objectType == + VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)(uintptr_t)pTagInfo->object; + pTagInfo->object = (uint64_t)(uintptr_t)phys_dev_term->phys_dev; + + // If this is a KHR_surface, and the ICD has created its own, we have to + // replace it with the proper one for the next call. + } else if (pTagInfo->objectType == + VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT) { + if (NULL != icd_term && NULL != icd_term->CreateSwapchainKHR) { + VkIcdSurface *icd_surface = + (VkIcdSurface *)(uintptr_t)pTagInfo->object; + if (NULL != icd_surface->real_icd_surfaces) { + pTagInfo->object = + (uint64_t)icd_surface->real_icd_surfaces[icd_index]; + } + } + } + assert(icd_term != NULL && icd_term->DebugMarkerSetObjectTagEXT && + "loader: null DebugMarkerSetObjectTagEXT ICD pointer"); + return icd_term->DebugMarkerSetObjectTagEXT(device, pTagInfo); +} + +VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectNameEXT( + VkDevice device, VkDebugMarkerObjectNameInfoEXT *pNameInfo) { + const VkLayerDispatchTable *disp = loader_get_dispatch(device); + // If this is a physical device, we have to replace it with the proper one + // for the next call. + if (pNameInfo->objectType == + VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { + struct loader_physical_device_tramp *phys_dev_tramp = + (struct loader_physical_device_tramp *)(uintptr_t)pNameInfo->object; + pNameInfo->object = (uint64_t)(uintptr_t)phys_dev_tramp->phys_dev; + } + return disp->DebugMarkerSetObjectNameEXT(device, pNameInfo); +} + +VKAPI_ATTR VkResult VKAPI_CALL terminator_DebugMarkerSetObjectNameEXT( + VkDevice device, VkDebugMarkerObjectNameInfoEXT *pNameInfo) { + uint32_t icd_index = 0; + struct loader_device *dev; + struct loader_icd_term *icd_term = + loader_get_icd_and_device(device, &dev, &icd_index); + // If this is a physical device, we have to replace it with the proper one + // for the next call. + if (pNameInfo->objectType == + VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT) { + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)(uintptr_t)pNameInfo->object; + pNameInfo->object = (uint64_t)(uintptr_t)phys_dev_term->phys_dev; + + // If this is a KHR_surface, and the ICD has created its own, we have to + // replace it with the proper one for the next call. + } else if (pNameInfo->objectType == + VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT) { + if (NULL != icd_term && NULL != icd_term->CreateSwapchainKHR) { + VkIcdSurface *icd_surface = + (VkIcdSurface *)(uintptr_t)pNameInfo->object; + if (NULL != icd_surface->real_icd_surfaces) { + pNameInfo->object = + (uint64_t)( + uintptr_t)icd_surface->real_icd_surfaces[icd_index]; + } + } + } + assert(icd_term != NULL && icd_term->DebugMarkerSetObjectNameEXT && + "loader: null DebugMarkerSetObjectNameEXT ICD pointer"); + return icd_term->DebugMarkerSetObjectNameEXT(device, pNameInfo); +} + +// Definitions for the VK_NV_external_memory_capabilities extension + +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL +vkGetPhysicalDeviceExternalImageFormatPropertiesNV( + VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, + VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, + VkExternalMemoryHandleTypeFlagsNV externalHandleType, + VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) { + const VkLayerInstanceDispatchTable *disp; + VkPhysicalDevice unwrapped_phys_dev = + loader_unwrap_physical_device(physicalDevice); + disp = loader_get_instance_dispatch(physicalDevice); + + return disp->GetPhysicalDeviceExternalImageFormatPropertiesNV( + unwrapped_phys_dev, format, type, tiling, usage, flags, + externalHandleType, pExternalImageFormatProperties); +} + +VKAPI_ATTR VkResult VKAPI_CALL +terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV( + VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, + VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, + VkExternalMemoryHandleTypeFlagsNV externalHandleType, + VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) { + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; + + if (!icd_term->GetPhysicalDeviceExternalImageFormatPropertiesNV) { + if (externalHandleType) { + return VK_ERROR_FORMAT_NOT_SUPPORTED; + } + + if (!icd_term->GetPhysicalDeviceImageFormatProperties) { + return VK_ERROR_INITIALIZATION_FAILED; + } + + pExternalImageFormatProperties->externalMemoryFeatures = 0; + pExternalImageFormatProperties->exportFromImportedHandleTypes = 0; + pExternalImageFormatProperties->compatibleHandleTypes = 0; + + return icd_term->GetPhysicalDeviceImageFormatProperties( + phys_dev_term->phys_dev, format, type, tiling, usage, flags, + &pExternalImageFormatProperties->imageFormatProperties); + } + + return icd_term->GetPhysicalDeviceExternalImageFormatPropertiesNV( + phys_dev_term->phys_dev, format, type, tiling, usage, flags, + externalHandleType, pExternalImageFormatProperties); +} + +// Definitions for the VK_AMD_draw_indirect_count extension + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectCountAMD( + VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, + VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, + uint32_t stride) { + const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); + disp->CmdDrawIndirectCountAMD(commandBuffer, buffer, offset, countBuffer, + countBufferOffset, maxDrawCount, stride); +} + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCountAMD( + VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, + VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, + uint32_t stride) { + const VkLayerDispatchTable *disp = loader_get_dispatch(commandBuffer); + disp->CmdDrawIndexedIndirectCountAMD(commandBuffer, buffer, offset, + countBuffer, countBufferOffset, + maxDrawCount, stride); +} + +#ifdef VK_USE_PLATFORM_WIN32_KHR + +// Definitions for the VK_NV_external_memory_win32 extension + +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleNV( + VkDevice device, VkDeviceMemory memory, + VkExternalMemoryHandleTypeFlagsNV handleType, HANDLE *pHandle) { + const VkLayerDispatchTable *disp = loader_get_dispatch(device); + return disp->GetMemoryWin32HandleNV(device, memory, handleType, pHandle); +} + +#endif // VK_USE_PLATFORM_WIN32_KHR + +// GPA helpers for non-KHR extensions + +bool extension_instance_gpa(struct loader_instance *ptr_instance, + const char *name, void **addr) { + *addr = NULL; + + // Definitions for the VK_EXT_debug_marker extension commands which + // need to have a terminator function. Since these are device + // commands, we always need to return a valid value for them. + + if (!strcmp("vkDebugMarkerSetObjectTagEXT", name)) { + *addr = (void *)vkDebugMarkerSetObjectTagEXT; + return true; + } + if (!strcmp("vkDebugMarkerSetObjectNameEXT", name)) { + *addr = (void *)vkDebugMarkerSetObjectNameEXT; + return true; + } + + // Functions for the VK_NV_external_memory_capabilities extension + + if (!strcmp("vkGetPhysicalDeviceExternalImageFormatPropertiesNV", name)) { + *addr = (ptr_instance->enabled_known_extensions + .nv_external_memory_capabilities == 1) + ? (void *)vkGetPhysicalDeviceExternalImageFormatPropertiesNV + : NULL; + return true; + } + + // Functions for the VK_AMD_draw_indirect_count extension + + if (!strcmp("vkCmdDrawIndirectCountAMD", name)) { + *addr = (void *)vkCmdDrawIndirectCountAMD; + return true; + } + + if (!strcmp("vkCmdDrawIndexedIndirectCountAMD", name)) { + *addr = (void *)vkCmdDrawIndexedIndirectCountAMD; + return true; + } + +#ifdef VK_USE_PLATFORM_WIN32_KHR + + // Functions for the VK_NV_external_memory_win32 extension + + if (!strcmp("vkGetMemoryWin32HandleNV", name)) { + *addr = (void *)vkGetMemoryWin32HandleNV; + return true; + } + +#endif // VK_USE_PLATFORM_WIN32_KHR + + return false; +} + +void extensions_create_instance(struct loader_instance *ptr_instance, + const VkInstanceCreateInfo *pCreateInfo) { + ptr_instance->enabled_known_extensions.nv_external_memory_capabilities = 0; + + for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { + if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], + VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME) == 0) { + ptr_instance->enabled_known_extensions + .nv_external_memory_capabilities = 1; + return; + } + } +} diff --git a/third_party/vulkan/loader/extensions.h b/third_party/vulkan/loader/extensions.h new file mode 100644 index 000000000..2e922e5af --- /dev/null +++ b/third_party/vulkan/loader/extensions.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2015-2016 The Khronos Group Inc. + * Copyright (c) 2015-2016 Valve Corporation + * Copyright (c) 2015-2016 LunarG, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Author: Mark Lobodzinski + * + */ + +#include "vk_loader_platform.h" +#include "loader.h" + +bool extension_instance_gpa(struct loader_instance *ptr_instance, + const char *name, void **addr); + +void extensions_create_instance(struct loader_instance *ptr_instance, + const VkInstanceCreateInfo *pCreateInfo); + +// Definitions for the VK_EXT_debug_marker extension + + +VKAPI_ATTR VkResult VKAPI_CALL terminator_DebugMarkerSetObjectTagEXT( + VkDevice device, VkDebugMarkerObjectTagInfoEXT *pTagInfo); + +VKAPI_ATTR VkResult VKAPI_CALL terminator_DebugMarkerSetObjectNameEXT( + VkDevice device, VkDebugMarkerObjectNameInfoEXT *pNameInfo); + +// Definitions for the VK_NV_external_memory_capabilities extension + +VKAPI_ATTR VkResult VKAPI_CALL +terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV( + VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, + VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, + VkExternalMemoryHandleTypeFlagsNV externalHandleType, + VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties); diff --git a/third_party/vulkan/loader/gpa_helper.h b/third_party/vulkan/loader/gpa_helper.h index fb9abd779..5089b5922 100644 --- a/third_party/vulkan/loader/gpa_helper.h +++ b/third_party/vulkan/loader/gpa_helper.h @@ -22,6 +22,7 @@ #include #include "debug_report.h" #include "wsi.h" +#include "extensions.h" static inline void *trampolineGetProcAddr(struct loader_instance *inst, const char *funcName) { @@ -304,6 +305,9 @@ static inline void *trampolineGetProcAddr(struct loader_instance *inst, if (wsi_swapchain_instance_gpa(inst, funcName, &addr)) return addr; + if (extension_instance_gpa(inst, funcName, &addr)) + return addr; + addr = loader_dev_ext_gpa(inst, funcName); return addr; } diff --git a/third_party/vulkan/loader/loader.c b/third_party/vulkan/loader/loader.c index 1e74a6d9a..30a3b2d6b 100644 --- a/third_party/vulkan/loader/loader.c +++ b/third_party/vulkan/loader/loader.c @@ -42,6 +42,7 @@ #include "table_ops.h" #include "debug_report.h" #include "wsi.h" +#include "extensions.h" #include "vulkan/vk_icd.h" #include "cJSON.h" #include "murmurhash.h" @@ -61,7 +62,7 @@ static size_t loader_platform_combine_path(char *dest, size_t len, ...); struct loader_phys_dev_per_icd { uint32_t count; VkPhysicalDevice *phys_devs; - struct loader_icd *this_icd; + struct loader_icd_term *this_icd_term; }; enum loader_debug { @@ -117,6 +118,8 @@ const VkLayerInstanceDispatchTable instance_disp = { .CreateDebugReportCallbackEXT = terminator_CreateDebugReportCallback, .DestroyDebugReportCallbackEXT = terminator_DestroyDebugReportCallback, .DebugReportMessageEXT = terminator_DebugReportMessage, + .GetPhysicalDeviceExternalImageFormatPropertiesNV = + terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV, #ifdef VK_USE_PLATFORM_MIR_KHR .CreateMirSurfaceKHR = terminator_CreateMirSurfaceKHR, .GetPhysicalDeviceMirPresentationSupportKHR = @@ -159,66 +162,211 @@ const VkLayerInstanceDispatchTable instance_disp = { LOADER_PLATFORM_THREAD_ONCE_DECLARATION(once_init); -void *loader_heap_alloc(const struct loader_instance *instance, size_t size, - VkSystemAllocationScope alloc_scope) { +void *loader_instance_heap_alloc(const struct loader_instance *instance, + size_t size, + VkSystemAllocationScope alloc_scope) { + void *pMemory = NULL; +#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) + { +#else if (instance && instance->alloc_callbacks.pfnAllocation) { - /* TODO: What should default alignment be? 1, 4, 8, other? */ - return instance->alloc_callbacks.pfnAllocation( - instance->alloc_callbacks.pUserData, size, sizeof(int), + /* These are internal structures, so it's best to align everything to + * the largest unit size which is the size of a uint64_t. + */ + pMemory = instance->alloc_callbacks.pfnAllocation( + instance->alloc_callbacks.pUserData, size, sizeof(uint64_t), alloc_scope); + } else { +#endif + pMemory = malloc(size); } - return malloc(size); + return pMemory; } -void loader_heap_free(const struct loader_instance *instance, void *pMemory) { - if (pMemory == NULL) - return; - if (instance && instance->alloc_callbacks.pfnFree) { - instance->alloc_callbacks.pfnFree(instance->alloc_callbacks.pUserData, - pMemory); - return; - } - free(pMemory); -} - -void *loader_heap_realloc(const struct loader_instance *instance, void *pMemory, - size_t orig_size, size_t size, - VkSystemAllocationScope alloc_scope) { - if (pMemory == NULL || orig_size == 0) - return loader_heap_alloc(instance, size, alloc_scope); - if (size == 0) { - loader_heap_free(instance, pMemory); - return NULL; - } - // TODO use the callback realloc function - if (instance && instance->alloc_callbacks.pfnAllocation) { - if (size <= orig_size) { - memset(((uint8_t *)pMemory) + size, 0, orig_size - size); - return pMemory; +void loader_instance_heap_free(const struct loader_instance *instance, + void *pMemory) { + if (pMemory != NULL) { +#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) + { +#else + if (instance && instance->alloc_callbacks.pfnFree) { + instance->alloc_callbacks.pfnFree( + instance->alloc_callbacks.pUserData, pMemory); + } else { +#endif + free(pMemory); } - /* TODO: What should default alignment be? 1, 4, 8, other? */ - void *new_ptr = instance->alloc_callbacks.pfnAllocation( - instance->alloc_callbacks.pUserData, size, sizeof(int), - alloc_scope); - if (!new_ptr) - return NULL; - memcpy(new_ptr, pMemory, orig_size); - instance->alloc_callbacks.pfnFree(instance->alloc_callbacks.pUserData, - pMemory); - return new_ptr; } - return realloc(pMemory, size); } -void *loader_tls_heap_alloc(size_t size) { - return loader_heap_alloc(tls_instance, size, - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); +void *loader_instance_heap_realloc(const struct loader_instance *instance, + void *pMemory, size_t orig_size, size_t size, + VkSystemAllocationScope alloc_scope) { + void *pNewMem = NULL; + if (pMemory == NULL || orig_size == 0) { + pNewMem = loader_instance_heap_alloc(instance, size, alloc_scope); + } else if (size == 0) { + loader_instance_heap_free(instance, pMemory); +#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) +#else + } else if (instance && instance->alloc_callbacks.pfnReallocation) { + /* These are internal structures, so it's best to align everything to + * the largest unit size which is the size of a uint64_t. + */ + pNewMem = instance->alloc_callbacks.pfnReallocation( + instance->alloc_callbacks.pUserData, pMemory, size, + sizeof(uint64_t), alloc_scope); +#endif + } else { + pNewMem = realloc(pMemory, size); + } + return pNewMem; } -void loader_tls_heap_free(void *pMemory) { - loader_heap_free(tls_instance, pMemory); +void *loader_instance_tls_heap_alloc(size_t size) { + return loader_instance_heap_alloc(tls_instance, size, + VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); } +void loader_instance_tls_heap_free(void *pMemory) { + loader_instance_heap_free(tls_instance, pMemory); +} + +void *loader_device_heap_alloc(const struct loader_device *device, size_t size, + VkSystemAllocationScope alloc_scope) { + void *pMemory = NULL; +#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) + { +#else + if (device && device->alloc_callbacks.pfnAllocation) { + /* These are internal structures, so it's best to align everything to + * the largest unit size which is the size of a uint64_t. + */ + pMemory = device->alloc_callbacks.pfnAllocation( + device->alloc_callbacks.pUserData, size, sizeof(uint64_t), + alloc_scope); + } else { +#endif + pMemory = malloc(size); + } + return pMemory; +} + +void loader_device_heap_free(const struct loader_device *device, + void *pMemory) { + if (pMemory != NULL) { +#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) + { +#else + if (device && device->alloc_callbacks.pfnFree) { + device->alloc_callbacks.pfnFree(device->alloc_callbacks.pUserData, + pMemory); + } else { +#endif + free(pMemory); + } + } +} + +void *loader_device_heap_realloc(const struct loader_device *device, + void *pMemory, size_t orig_size, size_t size, + VkSystemAllocationScope alloc_scope) { + void *pNewMem = NULL; + if (pMemory == NULL || orig_size == 0) { + pNewMem = loader_device_heap_alloc(device, size, alloc_scope); + } else if (size == 0) { + loader_device_heap_free(device, pMemory); +#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) +#else + } else if (device && device->alloc_callbacks.pfnReallocation) { + /* These are internal structures, so it's best to align everything to + * the largest unit size which is the size of a uint64_t. + */ + pNewMem = device->alloc_callbacks.pfnReallocation( + device->alloc_callbacks.pUserData, pMemory, size, sizeof(uint64_t), + alloc_scope); +#endif + } else { + pNewMem = realloc(pMemory, size); + } + return pNewMem; +} + +// Environment variables +#if defined(__linux__) + +static inline char *loader_getenv(const char *name, + const struct loader_instance *inst) { + // No allocation of memory necessary for Linux, but we should at least touch + // the inst pointer to get rid of compiler warnings. + (void)inst; + return getenv(name); +} +static inline void loader_free_getenv(const char *val, + const struct loader_instance *inst) { + // No freeing of memory necessary for Linux, but we should at least touch + // the val and inst pointers to get rid of compiler warnings. + (void)val; + (void)inst; +} + +#elif defined(WIN32) + +static inline char *loader_getenv(const char *name, + const struct loader_instance *inst) { + char *retVal; + DWORD valSize; + + valSize = GetEnvironmentVariableA(name, NULL, 0); + + // valSize DOES include the null terminator, so for any set variable + // will always be at least 1. If it's 0, the variable wasn't set. + if (valSize == 0) + return NULL; + + // Allocate the space necessary for the registry entry + if (NULL != inst && NULL != inst->alloc_callbacks.pfnAllocation) { + retVal = (char *)inst->alloc_callbacks.pfnAllocation( + inst->alloc_callbacks.pUserData, valSize, sizeof(char *), + VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + } else { + retVal = (char *)malloc(valSize); + } + + if (NULL != retVal) { + GetEnvironmentVariableA(name, retVal, valSize); + } + + return retVal; +} + +static inline void loader_free_getenv(char *val, + const struct loader_instance *inst) { + if (NULL != inst && NULL != inst->alloc_callbacks.pfnFree) { + inst->alloc_callbacks.pfnFree(inst->alloc_callbacks.pUserData, val); + } else { + free((void *)val); + } +} + +#else + +static inline char *loader_getenv(const char *name, + const struct loader_instance *inst) { + // stub func + (void)inst; + (void)name; + return NULL; +} +static inline void loader_free_getenv(const char *val, + const struct loader_instance *inst) { + // stub func + (void)val; + (void)inst; +} + +#endif + void loader_log(const struct loader_instance *inst, VkFlags msg_type, int32_t msg_code, const char *format, ...) { char msg[512]; @@ -233,9 +381,9 @@ void loader_log(const struct loader_instance *inst, VkFlags msg_type, va_end(ap); if (inst) { - util_DebugReportMessage(inst, msg_type, - VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, - (uint64_t)inst, 0, msg_code, "loader", msg); + util_DebugReportMessage( + inst, msg_type, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, + (uint64_t)(uintptr_t)inst, 0, msg_code, "loader", msg); } if (!(msg_type & g_loader_log_msgs)) { @@ -250,8 +398,8 @@ void loader_log(const struct loader_instance *inst, VkFlags msg_type, fputc('\n', stderr); } -VKAPI_ATTR VkResult VKAPI_CALL -vkSetInstanceDispatch(VkInstance instance, void *object) { +VKAPI_ATTR VkResult VKAPI_CALL vkSetInstanceDispatch(VkInstance instance, + void *object) { struct loader_instance *inst = loader_get_instance(instance); if (!inst) { @@ -261,12 +409,13 @@ vkSetInstanceDispatch(VkInstance instance, void *object) { return VK_SUCCESS; } -VKAPI_ATTR VkResult VKAPI_CALL -vkSetDeviceDispatch(VkDevice device, void *object) { +VKAPI_ATTR VkResult VKAPI_CALL vkSetDeviceDispatch(VkDevice device, + void *object) { struct loader_device *dev; - struct loader_icd *icd = loader_get_icd_and_device(device, &dev); + struct loader_icd_term *icd_term = + loader_get_icd_and_device(device, &dev, NULL); - if (!icd) { + if (NULL == icd_term) { return VK_ERROR_INITIALIZATION_FAILED; } loader_set_dispatch(object, &dev->loader_dispatch); @@ -322,21 +471,27 @@ static char *loader_get_registry_files(const struct loader_instance *inst, ERROR_SUCCESS) { if (value_size == sizeof(value) && value == 0) { if (out == NULL) { - out = loader_heap_alloc( + out = loader_instance_heap_alloc( inst, total_size, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + if (NULL == out) { + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "Out of memory can't alloc space for " + "registry data"); + return NULL; + } out[0] = '\0'; } else if (strlen(out) + name_size + 1 > total_size) { - out = loader_heap_realloc( + out = loader_instance_heap_realloc( inst, out, total_size, total_size * 2, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + if (NULL == out) { + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "Out of memory can't realloc space for " + "registry data"); + return NULL; + } total_size *= 2; } - if (out == NULL) { - loader_log( - inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "Out of memory, failed loader_get_registry_files"); - return NULL; - } if (strlen(out) == 0) snprintf(out, name_size + 1, "%s", name); else @@ -405,32 +560,26 @@ static size_t loader_platform_combine_path(char *dest, size_t len, ...) { * Given string of three part form "maj.min.pat" convert to a vulkan version * number. */ -static uint32_t loader_make_version(const char *vers_str) { +static uint32_t loader_make_version(char *vers_str) { uint32_t vers = 0, major = 0, minor = 0, patch = 0; - char *minor_str = NULL; - char *patch_str = NULL; - char *cstr; - char *str; + char *vers_tok; - if (!vers_str) + if (!vers_str) { return vers; - cstr = loader_stack_alloc(strlen(vers_str) + 1); - strcpy(cstr, vers_str); - while ((str = strchr(cstr, '.')) != NULL) { - if (minor_str == NULL) { - minor_str = str + 1; - *str = '\0'; - major = atoi(cstr); - } else if (patch_str == NULL) { - patch_str = str + 1; - *str = '\0'; - minor = atoi(minor_str); - } else { - return vers; - } - cstr = str + 1; } - patch = atoi(patch_str); + + vers_tok = strtok(vers_str, ".\"\n\r"); + if (NULL != vers_tok) { + major = (uint16_t)atoi(vers_tok); + vers_tok = strtok(NULL, ".\"\n\r"); + if (NULL != vers_tok) { + minor = (uint16_t)atoi(vers_tok); + vers_tok = strtok(NULL, ".\"\n\r"); + if (NULL != vers_tok) { + patch = (uint16_t)atoi(vers_tok); + } + } + } return VK_MAKE_VERSION(major, minor, patch); } @@ -501,9 +650,9 @@ static struct loader_layer_properties * loader_get_next_layer_property(const struct loader_instance *inst, struct loader_layer_list *layer_list) { if (layer_list->capacity == 0) { - layer_list->list = - loader_heap_alloc(inst, sizeof(struct loader_layer_properties) * 64, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + layer_list->list = loader_instance_heap_alloc( + inst, sizeof(struct loader_layer_properties) * 64, + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (layer_list->list == NULL) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Out of memory can't add any layer properties to list"); @@ -517,12 +666,13 @@ loader_get_next_layer_property(const struct loader_instance *inst, // ensure enough room to add an entry if ((layer_list->count + 1) * sizeof(struct loader_layer_properties) > layer_list->capacity) { - layer_list->list = loader_heap_realloc( + layer_list->list = loader_instance_heap_realloc( inst, layer_list->list, layer_list->capacity, layer_list->capacity * 2, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (layer_list->list == NULL) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "realloc failed for layer list"); + return NULL; } layer_list->capacity *= 2; } @@ -546,12 +696,13 @@ void loader_delete_layer_properties(const struct loader_instance *inst, inst, (struct loader_generic_list *)&layer_list->list[i] .instance_extension_list); dev_ext_list = &layer_list->list[i].device_extension_list; - if (dev_ext_list->capacity > 0 && + if (dev_ext_list->capacity > 0 && NULL != dev_ext_list->list && dev_ext_list->list->entrypoint_count > 0) { for (j = 0; j < dev_ext_list->list->entrypoint_count; j++) { - loader_heap_free(inst, dev_ext_list->list->entrypoints[j]); + loader_instance_heap_free(inst, + dev_ext_list->list->entrypoints[j]); } - loader_heap_free(inst, dev_ext_list->list->entrypoints); + loader_instance_heap_free(inst, dev_ext_list->list->entrypoints); } loader_destroy_generic_list(inst, (struct loader_generic_list *)dev_ext_list); @@ -560,33 +711,33 @@ void loader_delete_layer_properties(const struct loader_instance *inst, if (layer_list->capacity > 0) { layer_list->capacity = 0; - loader_heap_free(inst, layer_list->list); + loader_instance_heap_free(inst, layer_list->list); } } -static void loader_add_instance_extensions( +static VkResult loader_add_instance_extensions( const struct loader_instance *inst, const PFN_vkEnumerateInstanceExtensionProperties fp_get_props, const char *lib_name, struct loader_extension_list *ext_list) { uint32_t i, count = 0; VkExtensionProperties *ext_props; - VkResult res; + VkResult res = VK_SUCCESS; if (!fp_get_props) { /* No EnumerateInstanceExtensionProperties defined */ - return; + goto out; } res = fp_get_props(NULL, &count, NULL); if (res != VK_SUCCESS) { loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "Error getting Instance extension count from %s", lib_name); - return; + goto out; } if (count == 0) { /* No ExtensionProperties to report */ - return; + goto out; } ext_props = loader_stack_alloc(count * sizeof(VkExtensionProperties)); @@ -595,7 +746,7 @@ static void loader_add_instance_extensions( if (res != VK_SUCCESS) { loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "Error getting Instance extensions from %s", lib_name); - return; + goto out; } for (i = 0; i < count; i++) { @@ -611,11 +762,17 @@ static void loader_add_instance_extensions( loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "Instance Extension: %s (%s) version %s", ext_props[i].extensionName, lib_name, spec_version); - loader_add_to_ext_list(inst, ext_list, 1, &ext_props[i]); + res = loader_add_to_ext_list(inst, ext_list, 1, &ext_props[i]); + if (res != VK_SUCCESS) { + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "Failed to add %s to Instance extension list", + lib_name); + goto out; + } } } - - return; +out: + return res; } /* @@ -624,15 +781,16 @@ static void loader_add_instance_extensions( */ static VkResult loader_init_device_extensions(const struct loader_instance *inst, - struct loader_physical_device *phys_dev, + struct loader_physical_device_term *phys_dev_term, uint32_t count, VkExtensionProperties *ext_props, struct loader_extension_list *ext_list) { VkResult res; uint32_t i; - if (!loader_init_generic_list(inst, (struct loader_generic_list *)ext_list, - sizeof(VkExtensionProperties))) { - return VK_ERROR_OUT_OF_HOST_MEMORY; + res = loader_init_generic_list(inst, (struct loader_generic_list *)ext_list, + sizeof(VkExtensionProperties)); + if (VK_SUCCESS != res) { + return res; } for (i = 0; i < count; i++) { @@ -642,10 +800,10 @@ loader_init_device_extensions(const struct loader_instance *inst, VK_MAJOR(ext_props[i].specVersion), VK_MINOR(ext_props[i].specVersion), VK_PATCH(ext_props[i].specVersion)); - loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, - "Device Extension: %s (%s) version %s", - ext_props[i].extensionName, - phys_dev->this_icd->this_icd_lib->lib_name, spec_version); + loader_log( + inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, + "Device Extension: %s (%s) version %s", ext_props[i].extensionName, + phys_dev_term->this_icd_term->scanned_icd->lib_name, spec_version); res = loader_add_to_ext_list(inst, ext_list, 1, &ext_props[i]); if (res != VK_SUCCESS) return res; @@ -668,12 +826,14 @@ VkResult loader_add_device_extensions(const struct loader_instance *inst, NULL); if (res == VK_SUCCESS && count > 0) { ext_props = loader_stack_alloc(count * sizeof(VkExtensionProperties)); - if (!ext_props) + if (!ext_props) { return VK_ERROR_OUT_OF_HOST_MEMORY; + } res = fpEnumerateDeviceExtensionProperties(physical_device, NULL, &count, ext_props); - if (res != VK_SUCCESS) + if (res != VK_SUCCESS) { return res; + } for (i = 0; i < count; i++) { char spec_version[64]; @@ -699,23 +859,25 @@ VkResult loader_add_device_extensions(const struct loader_instance *inst, return VK_SUCCESS; } -bool loader_init_generic_list(const struct loader_instance *inst, - struct loader_generic_list *list_info, - size_t element_size) { - list_info->capacity = 32 * element_size; - list_info->list = loader_heap_alloc(inst, list_info->capacity, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (list_info->list == NULL) { - return false; - } - memset(list_info->list, 0, list_info->capacity); +VkResult loader_init_generic_list(const struct loader_instance *inst, + struct loader_generic_list *list_info, + size_t element_size) { + size_t capacity = 32 * element_size; list_info->count = 0; - return true; + list_info->capacity = 0; + list_info->list = loader_instance_heap_alloc( + inst, capacity, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + if (list_info->list == NULL) { + return VK_ERROR_OUT_OF_HOST_MEMORY; + } + memset(list_info->list, 0, capacity); + list_info->capacity = capacity; + return VK_SUCCESS; } void loader_destroy_generic_list(const struct loader_instance *inst, struct loader_generic_list *list) { - loader_heap_free(inst, list->list); + loader_instance_heap_free(inst, list->list); list->count = 0; list->capacity = 0; } @@ -734,13 +896,14 @@ VkResult loader_add_to_ext_list(const struct loader_instance *inst, const VkExtensionProperties *cur_ext; if (ext_list->list == NULL || ext_list->capacity == 0) { - loader_init_generic_list(inst, (struct loader_generic_list *)ext_list, - sizeof(VkExtensionProperties)); + VkResult res = loader_init_generic_list( + inst, (struct loader_generic_list *)ext_list, + sizeof(VkExtensionProperties)); + if (VK_SUCCESS != res) { + return res; + } } - if (ext_list->list == NULL) - return VK_ERROR_OUT_OF_HOST_MEMORY; - for (i = 0; i < prop_list_count; i++) { cur_ext = &props[i]; @@ -754,7 +917,7 @@ VkResult loader_add_to_ext_list(const struct loader_instance *inst, if (ext_list->count * sizeof(VkExtensionProperties) >= ext_list->capacity) { - ext_list->list = loader_heap_realloc( + ext_list->list = loader_instance_heap_realloc( inst, ext_list->list, ext_list->capacity, ext_list->capacity * 2, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); @@ -785,13 +948,14 @@ loader_add_to_dev_ext_list(const struct loader_instance *inst, uint32_t entry_count, char **entrys) { uint32_t idx; if (ext_list->list == NULL || ext_list->capacity == 0) { - loader_init_generic_list(inst, (struct loader_generic_list *)ext_list, - sizeof(struct loader_dev_ext_props)); + VkResult res = loader_init_generic_list( + inst, (struct loader_generic_list *)ext_list, + sizeof(struct loader_dev_ext_props)); + if (VK_SUCCESS != res) { + return res; + } } - if (ext_list->list == NULL) - return VK_ERROR_OUT_OF_HOST_MEMORY; - // look for duplicates if (has_vk_dev_ext_property(props, ext_list)) { return VK_SUCCESS; @@ -802,7 +966,7 @@ loader_add_to_dev_ext_list(const struct loader_instance *inst, // check for enough capacity if (idx * sizeof(struct loader_dev_ext_props) >= ext_list->capacity) { - ext_list->list = loader_heap_realloc( + ext_list->list = loader_instance_heap_realloc( inst, ext_list->list, ext_list->capacity, ext_list->capacity * 2, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); @@ -817,15 +981,25 @@ loader_add_to_dev_ext_list(const struct loader_instance *inst, sizeof(struct loader_dev_ext_props)); ext_list->list[idx].entrypoint_count = entry_count; ext_list->list[idx].entrypoints = - loader_heap_alloc(inst, sizeof(char *) * entry_count, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (ext_list->list[idx].entrypoints == NULL) + loader_instance_heap_alloc(inst, sizeof(char *) * entry_count, + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + if (ext_list->list[idx].entrypoints == NULL) { + ext_list->list[idx].entrypoint_count = 0; return VK_ERROR_OUT_OF_HOST_MEMORY; + } for (uint32_t i = 0; i < entry_count; i++) { - ext_list->list[idx].entrypoints[i] = loader_heap_alloc( + ext_list->list[idx].entrypoints[i] = loader_instance_heap_alloc( inst, strlen(entrys[i]) + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (ext_list->list[idx].entrypoints[i] == NULL) + if (ext_list->list[idx].entrypoints[i] == NULL) { + for (uint32_t j = 0; j < i; j++) { + loader_instance_heap_free(inst, + ext_list->list[idx].entrypoints[j]); + } + loader_instance_heap_free(inst, ext_list->list[idx].entrypoints); + ext_list->list[idx].entrypoint_count = 0; + ext_list->list[idx].entrypoints = NULL; return VK_ERROR_OUT_OF_HOST_MEMORY; + } strcpy(ext_list->list[idx].entrypoints[i], entrys[i]); } ext_list->count++; @@ -856,7 +1030,7 @@ loader_add_layer_names_to_list(const struct loader_instance *inst, continue; } - loader_add_to_layer_list(inst, output_list, 1, layer_prop); + err = loader_add_to_layer_list(inst, output_list, 1, layer_prop); } return err; @@ -868,8 +1042,8 @@ loader_add_layer_names_to_list(const struct loader_instance *inst, static bool loader_init_layer_list(const struct loader_instance *inst, struct loader_layer_list *list) { list->capacity = 32 * sizeof(struct loader_layer_properties); - list->list = loader_heap_alloc(inst, list->capacity, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + list->list = loader_instance_heap_alloc( + inst, list->capacity, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (list->list == NULL) { return false; } @@ -879,8 +1053,13 @@ static bool loader_init_layer_list(const struct loader_instance *inst, } void loader_destroy_layer_list(const struct loader_instance *inst, + struct loader_device *device, struct loader_layer_list *layer_list) { - loader_heap_free(inst, layer_list->list); + if (device) { + loader_device_heap_free(device, layer_list->list); + } else { + loader_instance_heap_free(inst, layer_list->list); + } layer_list->count = 0; layer_list->capacity = 0; } @@ -914,10 +1093,10 @@ bool has_layer_name(const char *name, const struct loader_layer_list *list) { * Append non-duplicate layer properties defined in prop_list * to the given layer_info list */ -void loader_add_to_layer_list(const struct loader_instance *inst, - struct loader_layer_list *list, - uint32_t prop_list_count, - const struct loader_layer_properties *props) { +VkResult loader_add_to_layer_list(const struct loader_instance *inst, + struct loader_layer_list *list, + uint32_t prop_list_count, + const struct loader_layer_properties *props) { uint32_t i; struct loader_layer_properties *layer; @@ -926,7 +1105,7 @@ void loader_add_to_layer_list(const struct loader_instance *inst, } if (list->list == NULL) - return; + return VK_SUCCESS; for (i = 0; i < prop_list_count; i++) { layer = (struct loader_layer_properties *)&props[i]; @@ -941,9 +1120,15 @@ void loader_add_to_layer_list(const struct loader_instance *inst, if (list->count * sizeof(struct loader_layer_properties) >= list->capacity) { - list->list = loader_heap_realloc( + list->list = loader_instance_heap_realloc( inst, list->list, list->capacity, list->capacity * 2, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + if (NULL == list->list) { + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "realloc failed for layer list when attempting to " + "add new layer"); + return VK_ERROR_OUT_OF_HOST_MEMORY; + } // double capacity list->capacity *= 2; } @@ -952,6 +1137,8 @@ void loader_add_to_layer_list(const struct loader_instance *inst, sizeof(struct loader_layer_properties)); list->count++; } + + return VK_SUCCESS; } /** @@ -971,8 +1158,10 @@ void loader_find_layer_name_add_list( if (0 == strcmp(layer_prop->info.layerName, name) && (layer_prop->type & type)) { /* Found a layer with the same name, add to found_list */ - loader_add_to_layer_list(inst, found_list, 1, layer_prop); - found = true; + if (VK_SUCCESS == + loader_add_to_layer_list(inst, found_list, 1, layer_prop)) { + found = true; + } } } if (!found) { @@ -1001,7 +1190,6 @@ get_dev_extension_property(const char *name, return NULL; } - /* * For Instance extensions implemented within the loader (i.e. DEBUG_REPORT * the extension must provide two entry points for the loader to use: @@ -1022,61 +1210,103 @@ get_dev_extension_property(const char *name, * linked directly with the loader. */ -void loader_get_icd_loader_instance_extensions( - const struct loader_instance *inst, struct loader_icd_libs *icd_libs, +VkResult loader_get_icd_loader_instance_extensions( + const struct loader_instance *inst, + struct loader_icd_tramp_list *icd_tramp_list, struct loader_extension_list *inst_exts) { struct loader_extension_list icd_exts; + VkResult res = VK_SUCCESS; + loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "Build ICD instance extension list"); + // traverse scanned icd list adding non-duplicate extensions to the list - for (uint32_t i = 0; i < icd_libs->count; i++) { - loader_init_generic_list(inst, (struct loader_generic_list *)&icd_exts, - sizeof(VkExtensionProperties)); - loader_add_instance_extensions( - inst, icd_libs->list[i].EnumerateInstanceExtensionProperties, - icd_libs->list[i].lib_name, &icd_exts); - loader_add_to_ext_list(inst, inst_exts, icd_exts.count, icd_exts.list); + for (uint32_t i = 0; i < icd_tramp_list->count; i++) { + res = loader_init_generic_list(inst, + (struct loader_generic_list *)&icd_exts, + sizeof(VkExtensionProperties)); + if (VK_SUCCESS != res) { + goto out; + } + res = loader_add_instance_extensions( + inst, icd_tramp_list->scanned_list[i] + .EnumerateInstanceExtensionProperties, + icd_tramp_list->scanned_list[i].lib_name, &icd_exts); + if (VK_SUCCESS == res) { + res = loader_add_to_ext_list(inst, inst_exts, icd_exts.count, + icd_exts.list); + } loader_destroy_generic_list(inst, (struct loader_generic_list *)&icd_exts); + if (VK_SUCCESS != res) { + goto out; + } }; // Traverse loader's extensions, adding non-duplicate extensions to the list debug_report_add_instance_extensions(inst, inst_exts); + +out: + return res; } -struct loader_icd *loader_get_icd_and_device(const VkDevice device, - struct loader_device **found_dev) { +struct loader_icd_term * +loader_get_icd_and_device(const VkDevice device, + struct loader_device **found_dev, + uint32_t *icd_index) { *found_dev = NULL; + uint32_t index = 0; for (struct loader_instance *inst = loader.instances; inst; inst = inst->next) { - for (struct loader_icd *icd = inst->icds; icd; icd = icd->next) { - for (struct loader_device *dev = icd->logical_device_list; dev; + for (struct loader_icd_term *icd_term = inst->icd_terms; icd_term; + icd_term = icd_term->next) { + for (struct loader_device *dev = icd_term->logical_device_list; dev; dev = dev->next) - /* Value comparison of device prevents object wrapping by layers - */ - if (loader_get_dispatch(dev->device) == + // Value comparison of device prevents object wrapping by layers + if (loader_get_dispatch(dev->icd_device) == + loader_get_dispatch(device) || + loader_get_dispatch(dev->chain_device) == loader_get_dispatch(device)) { *found_dev = dev; - return icd; + if (NULL != icd_index) { + *icd_index = index; + } + return icd_term; } + index++; } } return NULL; } -static void loader_destroy_logical_device(const struct loader_instance *inst, - struct loader_device *dev) { - loader_heap_free(inst, dev->app_extension_props); - loader_deactivate_layers(inst, &dev->activated_layer_list); - loader_heap_free(inst, dev); +void loader_destroy_logical_device(const struct loader_instance *inst, + struct loader_device *dev, + const VkAllocationCallbacks *pAllocator) { + if (pAllocator) { + dev->alloc_callbacks = *pAllocator; + } + if (NULL != dev->activated_layer_list.list) { + loader_deactivate_layers(inst, dev, &dev->activated_layer_list); + } + loader_device_heap_free(dev, dev); } struct loader_device * -loader_create_logical_device(const struct loader_instance *inst) { +loader_create_logical_device(const struct loader_instance *inst, + const VkAllocationCallbacks *pAllocator) { struct loader_device *new_dev; +#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) + { +#else + if (pAllocator) { + new_dev = (struct loader_device *)pAllocator->pfnAllocation( + pAllocator->pUserData, sizeof(struct loader_device), sizeof(int *), + VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); + } else { +#endif + new_dev = (struct loader_device *)malloc(sizeof(struct loader_device)); + } - new_dev = loader_heap_alloc(inst, sizeof(struct loader_device), - VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); if (!new_dev) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Failed to alloc struct loader-device"); @@ -1084,27 +1314,31 @@ loader_create_logical_device(const struct loader_instance *inst) { } memset(new_dev, 0, sizeof(struct loader_device)); + if (pAllocator) { + new_dev->alloc_callbacks = *pAllocator; + } return new_dev; } void loader_add_logical_device(const struct loader_instance *inst, - struct loader_icd *icd, + struct loader_icd_term *icd_term, struct loader_device *dev) { - dev->next = icd->logical_device_list; - icd->logical_device_list = dev; + dev->next = icd_term->logical_device_list; + icd_term->logical_device_list = dev; } void loader_remove_logical_device(const struct loader_instance *inst, - struct loader_icd *icd, - struct loader_device *found_dev) { + struct loader_icd_term *icd_term, + struct loader_device *found_dev, + const VkAllocationCallbacks *pAllocator) { struct loader_device *dev, *prev_dev; - if (!icd || !found_dev) + if (!icd_term || !found_dev) return; prev_dev = NULL; - dev = icd->logical_device_list; + dev = icd_term->logical_device_list; while (dev && dev != found_dev) { prev_dev = dev; dev = dev->next; @@ -1113,55 +1347,59 @@ void loader_remove_logical_device(const struct loader_instance *inst, if (prev_dev) prev_dev->next = found_dev->next; else - icd->logical_device_list = found_dev->next; - loader_destroy_logical_device(inst, found_dev); + icd_term->logical_device_list = found_dev->next; + loader_destroy_logical_device(inst, found_dev, pAllocator); } static void loader_icd_destroy(struct loader_instance *ptr_inst, - struct loader_icd *icd) { + struct loader_icd_term *icd_term, + const VkAllocationCallbacks *pAllocator) { ptr_inst->total_icd_count--; - for (struct loader_device *dev = icd->logical_device_list; dev;) { + for (struct loader_device *dev = icd_term->logical_device_list; dev;) { struct loader_device *next_dev = dev->next; - loader_destroy_logical_device(ptr_inst, dev); + loader_destroy_logical_device(ptr_inst, dev, pAllocator); dev = next_dev; } - loader_heap_free(ptr_inst, icd); + loader_instance_heap_free(ptr_inst, icd_term); } -static struct loader_icd * +static struct loader_icd_term * loader_icd_create(const struct loader_instance *inst) { - struct loader_icd *icd; + struct loader_icd_term *icd_term; - icd = loader_heap_alloc(inst, sizeof(*icd), - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (!icd) + icd_term = loader_instance_heap_alloc(inst, sizeof(struct loader_icd_term), + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + if (!icd_term) { return NULL; + } - memset(icd, 0, sizeof(*icd)); + memset(icd_term, 0, sizeof(struct loader_icd_term)); - return icd; + return icd_term; } -static struct loader_icd * +static struct loader_icd_term * loader_icd_add(struct loader_instance *ptr_inst, - const struct loader_scanned_icds *icd_lib) { - struct loader_icd *icd; + const struct loader_scanned_icd *scanned_icd) { + struct loader_icd_term *icd_term; - icd = loader_icd_create(ptr_inst); - if (!icd) + icd_term = loader_icd_create(ptr_inst); + if (!icd_term) { return NULL; + } - icd->this_icd_lib = icd_lib; - icd->this_instance = ptr_inst; + icd_term->scanned_icd = scanned_icd; + icd_term->this_instance = ptr_inst; /* prepend to the list */ - icd->next = ptr_inst->icds; - ptr_inst->icds = icd; + icd_term->next = ptr_inst->icd_terms; + ptr_inst->icd_terms = icd_term; ptr_inst->total_icd_count++; - return icd; + return icd_term; } + /** * Determine the ICD interface version to use. * @param icd @@ -1175,8 +1413,8 @@ loader_icd_add(struct loader_instance *ptr_inst, * version 2 supports vk_icdNegotiateLoaderICDInterfaceVersion */ bool loader_get_icd_interface_version( - PFN_vkNegotiateLoaderICDInterfaceVersion fp_negotiate_icd_version, - uint32_t *pVersion) { + PFN_vkNegotiateLoaderICDInterfaceVersion fp_negotiate_icd_version, + uint32_t *pVersion) { if (fp_negotiate_icd_version == NULL) { // ICD does not support the negotiation API, it supports version 0 or 1 @@ -1206,37 +1444,49 @@ bool loader_get_icd_interface_version( } void loader_scanned_icd_clear(const struct loader_instance *inst, - struct loader_icd_libs *icd_libs) { - if (icd_libs->capacity == 0) + struct loader_icd_tramp_list *icd_tramp_list) { + if (icd_tramp_list->capacity == 0) return; - for (uint32_t i = 0; i < icd_libs->count; i++) { - loader_platform_close_library(icd_libs->list[i].handle); - loader_heap_free(inst, icd_libs->list[i].lib_name); + for (uint32_t i = 0; i < icd_tramp_list->count; i++) { + loader_platform_close_library(icd_tramp_list->scanned_list[i].handle); + loader_instance_heap_free(inst, + icd_tramp_list->scanned_list[i].lib_name); } - loader_heap_free(inst, icd_libs->list); - icd_libs->capacity = 0; - icd_libs->count = 0; - icd_libs->list = NULL; + loader_instance_heap_free(inst, icd_tramp_list->scanned_list); + icd_tramp_list->capacity = 0; + icd_tramp_list->count = 0; + icd_tramp_list->scanned_list = NULL; } -static void loader_scanned_icd_init(const struct loader_instance *inst, - struct loader_icd_libs *icd_libs) { - loader_scanned_icd_clear(inst, icd_libs); - icd_libs->capacity = 8 * sizeof(struct loader_scanned_icds); - icd_libs->list = loader_heap_alloc(inst, icd_libs->capacity, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); +static VkResult +loader_scanned_icd_init(const struct loader_instance *inst, + struct loader_icd_tramp_list *icd_tramp_list) { + VkResult err = VK_SUCCESS; + loader_scanned_icd_clear(inst, icd_tramp_list); + icd_tramp_list->capacity = 8 * sizeof(struct loader_scanned_icd); + icd_tramp_list->scanned_list = loader_instance_heap_alloc( + inst, icd_tramp_list->capacity, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + if (NULL == icd_tramp_list->scanned_list) { + loader_log( + inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "realloc failed for layer list when attempting to add new layer"); + err = VK_ERROR_OUT_OF_HOST_MEMORY; + } + return err; } -static void loader_scanned_icd_add(const struct loader_instance *inst, - struct loader_icd_libs *icd_libs, - const char *filename, uint32_t api_version) { +static VkResult +loader_scanned_icd_add(const struct loader_instance *inst, + struct loader_icd_tramp_list *icd_tramp_list, + const char *filename, uint32_t api_version) { loader_platform_dl_handle handle; PFN_vkCreateInstance fp_create_inst; PFN_vkEnumerateInstanceExtensionProperties fp_get_inst_ext_props; PFN_vkGetInstanceProcAddr fp_get_proc_addr; PFN_vkNegotiateLoaderICDInterfaceVersion fp_negotiate_icd_version; - struct loader_scanned_icds *new_node; + struct loader_scanned_icd *new_scanned_icd; uint32_t interface_vers; + VkResult res = VK_SUCCESS; /* TODO implement smarter opening/closing of libraries. For now this * function leaves libraries open and the scanned_icd_clear closes them */ @@ -1244,19 +1494,20 @@ static void loader_scanned_icd_add(const struct loader_instance *inst, if (!handle) { loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, loader_platform_open_library_error(filename)); - return; + goto out; } // Get and settle on an ICD interface version - fp_negotiate_icd_version = - loader_platform_get_proc_address(handle, "vk_icdNegotiateLoaderICDInterfaceVersion"); + fp_negotiate_icd_version = loader_platform_get_proc_address( + handle, "vk_icdNegotiateLoaderICDInterfaceVersion"); if (!loader_get_icd_interface_version(fp_negotiate_icd_version, - &interface_vers)) { - loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD (%s) doesn't support interface version compatible" - "with loader, skip this ICD %s", filename); - return; + &interface_vers)) { + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "ICD (%s) doesn't support interface version compatible" + "with loader, skip this ICD %s", + filename); + goto out; } fp_get_proc_addr = @@ -1270,29 +1521,31 @@ static void loader_scanned_icd_add(const struct loader_instance *inst, loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, loader_platform_get_proc_address_error( "vk_icdGetInstanceProcAddr")); - return; + goto out; } else { loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "Using deprecated ICD interface of " "vkGetInstanceProcAddr instead of " - "vk_icdGetInstanceProcAddr for ICD %s", filename); + "vk_icdGetInstanceProcAddr for ICD %s", + filename); } fp_create_inst = loader_platform_get_proc_address(handle, "vkCreateInstance"); if (!fp_create_inst) { - loader_log( - inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "Couldn't get vkCreateInstance via dlsym/loadlibrary for ICD %s", - filename); - return; + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "Couldn't get vkCreateInstance via dlsym/loadlibrary " + "for ICD %s", + filename); + goto out; } fp_get_inst_ext_props = loader_platform_get_proc_address( handle, "vkEnumerateInstanceExtensionProperties"); if (!fp_get_inst_ext_props) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Couldn't get vkEnumerateInstanceExtensionProperties " - "via dlsym/loadlibrary for ICD %s", filename); - return; + "via dlsym/loadlibrary for ICD %s", + filename); + goto out; } } else { // Use newer interface version 1 or later @@ -1304,8 +1557,9 @@ static void loader_scanned_icd_add(const struct loader_instance *inst, if (!fp_create_inst) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Couldn't get vkCreateInstance via " - "vk_icdGetInstanceProcAddr for ICD %s", filename); - return; + "vk_icdGetInstanceProcAddr for ICD %s", + filename); + goto out; } fp_get_inst_ext_props = (PFN_vkEnumerateInstanceExtensionProperties)fp_get_proc_addr( @@ -1313,49 +1567,63 @@ static void loader_scanned_icd_add(const struct loader_instance *inst, if (!fp_get_inst_ext_props) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Couldn't get vkEnumerateInstanceExtensionProperties " - "via vk_icdGetInstanceProcAddr for ICD %s", filename); - return; + "via vk_icdGetInstanceProcAddr for ICD %s", + filename); + goto out; } } // check for enough capacity - if ((icd_libs->count * sizeof(struct loader_scanned_icds)) >= - icd_libs->capacity) { + if ((icd_tramp_list->count * sizeof(struct loader_scanned_icd)) >= + icd_tramp_list->capacity) { - icd_libs->list = loader_heap_realloc( - inst, icd_libs->list, icd_libs->capacity, icd_libs->capacity * 2, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + icd_tramp_list->scanned_list = loader_instance_heap_realloc( + inst, icd_tramp_list->scanned_list, icd_tramp_list->capacity, + icd_tramp_list->capacity * 2, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + if (NULL == icd_tramp_list->scanned_list) { + res = VK_ERROR_OUT_OF_HOST_MEMORY; + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "realloc failed on icd library list"); + goto out; + } // double capacity - icd_libs->capacity *= 2; + icd_tramp_list->capacity *= 2; } - new_node = &(icd_libs->list[icd_libs->count]); + new_scanned_icd = &(icd_tramp_list->scanned_list[icd_tramp_list->count]); - new_node->handle = handle; - new_node->api_version = api_version; - new_node->GetInstanceProcAddr = fp_get_proc_addr; - new_node->EnumerateInstanceExtensionProperties = fp_get_inst_ext_props; - new_node->CreateInstance = fp_create_inst; - new_node->interface_version = interface_vers; + new_scanned_icd->handle = handle; + new_scanned_icd->api_version = api_version; + new_scanned_icd->GetInstanceProcAddr = fp_get_proc_addr; + new_scanned_icd->EnumerateInstanceExtensionProperties = + fp_get_inst_ext_props; + new_scanned_icd->CreateInstance = fp_create_inst; + new_scanned_icd->interface_version = interface_vers; - new_node->lib_name = (char *)loader_heap_alloc( + new_scanned_icd->lib_name = (char *)loader_instance_heap_alloc( inst, strlen(filename) + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (!new_node->lib_name) { + if (NULL == new_scanned_icd->lib_name) { + res = VK_ERROR_OUT_OF_HOST_MEMORY; loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "Out of memory can't add icd"); - return; + goto out; } - strcpy(new_node->lib_name, filename); - icd_libs->count++; + strcpy(new_scanned_icd->lib_name, filename); + icd_tramp_list->count++; + +out: + + return res; } -static bool loader_icd_init_entrys(struct loader_icd *icd, VkInstance inst, +static bool loader_icd_init_entrys(struct loader_icd_term *icd_term, + VkInstance inst, const PFN_vkGetInstanceProcAddr fp_gipa) { /* initialize entrypoint function pointers */ #define LOOKUP_GIPA(func, required) \ do { \ - icd->func = (PFN_vk##func)fp_gipa(inst, "vk" #func); \ - if (!icd->func && required) { \ + icd_term->func = (PFN_vk##func)fp_gipa(inst, "vk" #func); \ + if (!icd_term->func && required) { \ loader_log((struct loader_instance *)inst, \ VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, \ loader_platform_get_proc_address_error("vk" #func)); \ @@ -1377,6 +1645,8 @@ static bool loader_icd_init_entrys(struct loader_icd *icd, VkInstance inst, LOOKUP_GIPA(GetPhysicalDeviceSparseImageFormatProperties, true); LOOKUP_GIPA(CreateDebugReportCallbackEXT, false); LOOKUP_GIPA(DestroyDebugReportCallbackEXT, false); + LOOKUP_GIPA(DebugMarkerSetObjectTagEXT, false); + LOOKUP_GIPA(DebugMarkerSetObjectNameEXT, false); LOOKUP_GIPA(GetPhysicalDeviceSurfaceSupportKHR, false); LOOKUP_GIPA(GetPhysicalDeviceSurfaceCapabilitiesKHR, false); LOOKUP_GIPA(GetPhysicalDeviceSurfaceFormatsKHR, false); @@ -1389,18 +1659,28 @@ static bool loader_icd_init_entrys(struct loader_icd *icd, VkInstance inst, LOOKUP_GIPA(CreateDisplayModeKHR, false); LOOKUP_GIPA(GetDisplayPlaneCapabilitiesKHR, false); LOOKUP_GIPA(DestroySurfaceKHR, false); + LOOKUP_GIPA(CreateSwapchainKHR, false); #ifdef VK_USE_PLATFORM_WIN32_KHR + LOOKUP_GIPA(CreateWin32SurfaceKHR, false); LOOKUP_GIPA(GetPhysicalDeviceWin32PresentationSupportKHR, false); #endif #ifdef VK_USE_PLATFORM_XCB_KHR + LOOKUP_GIPA(CreateXcbSurfaceKHR, false); LOOKUP_GIPA(GetPhysicalDeviceXcbPresentationSupportKHR, false); #endif #ifdef VK_USE_PLATFORM_XLIB_KHR + LOOKUP_GIPA(CreateXlibSurfaceKHR, false); LOOKUP_GIPA(GetPhysicalDeviceXlibPresentationSupportKHR, false); #endif +#ifdef VK_USE_PLATFORM_MIR_KHR + LOOKUP_GIPA(CreateMirSurfaceKHR, false); + LOOKUP_GIPA(GetPhysicalDeviceMirPresentationSupportKHR, false); +#endif #ifdef VK_USE_PLATFORM_WAYLAND_KHR + LOOKUP_GIPA(CreateWaylandSurfaceKHR, false); LOOKUP_GIPA(GetPhysicalDeviceWaylandPresentationSupportKHR, false); #endif + LOOKUP_GIPA(GetPhysicalDeviceExternalImageFormatPropertiesNV, false); #undef LOOKUP_GIPA @@ -1408,7 +1688,7 @@ static bool loader_icd_init_entrys(struct loader_icd *icd, VkInstance inst, } static void loader_debug_init(void) { - const char *env, *orig; + char *env, *orig; if (g_loader_debug > 0) return; @@ -1416,9 +1696,9 @@ static void loader_debug_init(void) { g_loader_debug = 0; /* parse comma-separated debug options */ - orig = env = loader_getenv("VK_LOADER_DEBUG"); + orig = env = loader_getenv("VK_LOADER_DEBUG", NULL); while (env) { - const char *p = strchr(env, ','); + char *p = strchr(env, ','); size_t len; if (p) @@ -1455,7 +1735,7 @@ static void loader_debug_init(void) { env = p + 1; } - loader_free_getenv(orig); + loader_free_getenv(orig, NULL); } void loader_initialize(void) { @@ -1468,7 +1748,8 @@ void loader_initialize(void) { // initial cJSON to use alloc callbacks cJSON_Hooks alloc_fns = { - .malloc_fn = loader_tls_heap_alloc, .free_fn = loader_tls_heap_free, + .malloc_fn = loader_instance_tls_heap_alloc, + .free_fn = loader_instance_tls_heap_free, }; cJSON_InitHooks(&alloc_fns); } @@ -1559,65 +1840,95 @@ static void loader_get_fullpath(const char *file, const char *dirs, * A pointer to a cJSON object representing the JSON parse tree. * This returned buffer should be freed by caller. */ -static cJSON *loader_get_json(const struct loader_instance *inst, - const char *filename) { - FILE *file; +static VkResult loader_get_json(const struct loader_instance *inst, + const char *filename, cJSON **json) { + FILE *file = NULL; char *json_buf; - cJSON *json; size_t len; + VkResult res = VK_SUCCESS; + + if (NULL == json) { + res = VK_ERROR_INITIALIZATION_FAILED; + goto out; + } + + *json = NULL; + file = fopen(filename, "rb"); if (!file) { + res = VK_ERROR_INITIALIZATION_FAILED; loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Couldn't open JSON file %s", filename); - return NULL; + goto out; } fseek(file, 0, SEEK_END); len = ftell(file); fseek(file, 0, SEEK_SET); json_buf = (char *)loader_stack_alloc(len + 1); if (json_buf == NULL) { + res = VK_ERROR_OUT_OF_HOST_MEMORY; loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Out of memory can't get JSON file"); - fclose(file); - return NULL; + goto out; } if (fread(json_buf, sizeof(char), len, file) != len) { + res = VK_ERROR_INITIALIZATION_FAILED; loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "fread failed can't get JSON file"); - fclose(file); - return NULL; + goto out; } - fclose(file); json_buf[len] = '\0'; // parse text from file - json = cJSON_Parse(json_buf); - if (json == NULL) + *json = cJSON_Parse(json_buf); + if (*json == NULL) { + res = VK_ERROR_OUT_OF_HOST_MEMORY; loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Can't parse JSON file %s", filename); - return json; + goto out; + } + +out: + if (NULL != file) { + fclose(file); + } + + return res; } /** * Do a deep copy of the loader_layer_properties structure. */ -void loader_copy_layer_properties(const struct loader_instance *inst, - struct loader_layer_properties *dst, - struct loader_layer_properties *src) { +VkResult loader_copy_layer_properties(const struct loader_instance *inst, + struct loader_layer_properties *dst, + struct loader_layer_properties *src) { uint32_t cnt, i; memcpy(dst, src, sizeof(*src)); dst->instance_extension_list.list = - loader_heap_alloc(inst, sizeof(VkExtensionProperties) * - src->instance_extension_list.count, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + loader_instance_heap_alloc(inst, sizeof(VkExtensionProperties) * + src->instance_extension_list.count, + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + if (NULL == dst->instance_extension_list.list) { + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "alloc failed for instance extension list"); + return VK_ERROR_OUT_OF_HOST_MEMORY; + } dst->instance_extension_list.capacity = sizeof(VkExtensionProperties) * src->instance_extension_list.count; memcpy(dst->instance_extension_list.list, src->instance_extension_list.list, dst->instance_extension_list.capacity); dst->device_extension_list.list = - loader_heap_alloc(inst, sizeof(struct loader_dev_ext_props) * - src->device_extension_list.count, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + loader_instance_heap_alloc(inst, sizeof(struct loader_dev_ext_props) * + src->device_extension_list.count, + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + if (NULL == dst->device_extension_list.list) { + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "alloc failed for device extension list"); + return VK_ERROR_OUT_OF_HOST_MEMORY; + } + memset(dst->device_extension_list.list, 0, + sizeof(struct loader_dev_ext_props) * + src->device_extension_list.count); dst->device_extension_list.capacity = sizeof(struct loader_dev_ext_props) * src->device_extension_list.count; @@ -1626,17 +1937,36 @@ void loader_copy_layer_properties(const struct loader_instance *inst, if (src->device_extension_list.count > 0 && src->device_extension_list.list->entrypoint_count > 0) { cnt = src->device_extension_list.list->entrypoint_count; - dst->device_extension_list.list->entrypoints = loader_heap_alloc( - inst, sizeof(char *) * cnt, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + dst->device_extension_list.list->entrypoints = + loader_instance_heap_alloc(inst, sizeof(char *) * cnt, + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + if (NULL == dst->device_extension_list.list->entrypoints) { + loader_log( + inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "alloc failed for device extension list entrypoint array"); + return VK_ERROR_OUT_OF_HOST_MEMORY; + } + memset(dst->device_extension_list.list->entrypoints, 0, + sizeof(char *) * cnt); + for (i = 0; i < cnt; i++) { - dst->device_extension_list.list->entrypoints[i] = loader_heap_alloc( - inst, - strlen(src->device_extension_list.list->entrypoints[i]) + 1, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + dst->device_extension_list.list->entrypoints[i] = + loader_instance_heap_alloc( + inst, + strlen(src->device_extension_list.list->entrypoints[i]) + 1, + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + if (NULL == dst->device_extension_list.list->entrypoints[i]) { + loader_log( + inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "alloc failed for device extension list entrypoint %d", i); + return VK_ERROR_OUT_OF_HOST_MEMORY; + } strcpy(dst->device_extension_list.list->entrypoints[i], src->device_extension_list.list->entrypoints[i]); } } + + return VK_SUCCESS; } static bool @@ -1683,9 +2013,8 @@ bool loader_find_layer_name_array( * @param layer_count * @param ppp_layer_names */ -void loader_expand_layer_names( - struct loader_instance *inst, const char *key_name, - uint32_t expand_count, +VkResult loader_expand_layer_names( + struct loader_instance *inst, const char *key_name, uint32_t expand_count, const char expand_names[][VK_MAX_EXTENSION_NAME_SIZE], uint32_t *layer_count, char const *const **ppp_layer_names) { @@ -1694,7 +2023,7 @@ void loader_expand_layer_names( if (!loader_find_layer_name(key_name, *layer_count, (char const **)pp_src_layers)) { inst->activated_layers_are_std_val = false; - return; // didn't find the key_name in the list. + return VK_SUCCESS; // didn't find the key_name in the list. } loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, @@ -1702,9 +2031,14 @@ void loader_expand_layer_names( key_name); inst->activated_layers_are_std_val = true; - char const **pp_dst_layers = loader_heap_alloc( + char const **pp_dst_layers = loader_instance_heap_alloc( inst, (expand_count + *layer_count - 1) * sizeof(char const *), VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + if (NULL == pp_dst_layers) { + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "alloc failed for dst layer array"); + return VK_ERROR_OUT_OF_HOST_MEMORY; + } // copy layers from src to dst, stripping key_name and anything in // expand_names. @@ -1730,6 +2064,8 @@ void loader_expand_layer_names( *ppp_layer_names = pp_dst_layers; *layer_count = dst_index; + + return VK_SUCCESS; } void loader_delete_shadow_inst_layer_names(const struct loader_instance *inst, @@ -1737,7 +2073,7 @@ void loader_delete_shadow_inst_layer_names(const struct loader_instance *inst, VkInstanceCreateInfo *ours) { /* Free the layer names array iff we had to reallocate it */ if (orig->ppEnabledLayerNames != ours->ppEnabledLayerNames) { - loader_heap_free(inst, (void *)ours->ppEnabledLayerNames); + loader_instance_heap_free(inst, (void *)ours->ppEnabledLayerNames); } } @@ -1745,10 +2081,10 @@ void loader_init_std_validation_props(struct loader_layer_properties *props) { memset(props, 0, sizeof(struct loader_layer_properties)); props->type = VK_LAYER_TYPE_META_EXPLICT; strncpy(props->info.description, "LunarG Standard Validation Layer", - sizeof (props->info.description)); + sizeof(props->info.description)); props->info.implementationVersion = 1; strncpy(props->info.layerName, std_validation_str, - sizeof (props->info.layerName)); + sizeof(props->info.layerName)); // TODO what about specVersion? for now insert loader's built version props->info.specVersion = VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION); } @@ -1776,7 +2112,6 @@ static void loader_add_layer_property_meta( if (layer_instance_list && (layer_count > layer_instance_list->count)) return; - layer_list = layer_instance_list; found = true; @@ -1792,10 +2127,12 @@ static void loader_add_layer_property_meta( struct loader_layer_properties *props; if (found) { props = loader_get_next_layer_property(inst, layer_list); + if (NULL == props) { + // Error already triggered in loader_get_next_layer_property. + return; + } loader_init_std_validation_props(props); - } - } static void loader_read_json_layer( @@ -1808,16 +2145,16 @@ static void loader_read_json_layer( cJSON *ext_item; VkExtensionProperties ext_prop; - /* - * The following are required in the "layer" object: - * (required) "name" - * (required) "type" - * (required) “library_path” - * (required) “api_version” - * (required) “implementation_version” - * (required) “description” - * (required for implicit layers) “disable_environment” - */ +/* + * The following are required in the "layer" object: + * (required) "name" + * (required) "type" + * (required) “library_path” + * (required) “api_version” + * (required) “implementation_version” + * (required) “description” + * (required for implicit layers) “disable_environment” + */ #define GET_JSON_OBJECT(node, var) \ { \ @@ -1843,10 +2180,18 @@ static void loader_read_json_layer( return; \ } \ temp = cJSON_Print(item); \ + if (temp == NULL) { \ + layer_node = layer_node->next; \ + loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, \ + "Problem accessing layer value %s in manifest JSON " \ + "file, skipping this layer", \ + #var); \ + return; \ + } \ temp[strlen(temp) - 1] = '\0'; \ var = loader_stack_alloc(strlen(temp) + 1); \ strcpy(var, &temp[1]); \ - loader_tls_heap_free(temp); \ + cJSON_Free(temp); \ } GET_JSON_ITEM(layer_node, name) GET_JSON_ITEM(layer_node, type) @@ -1876,6 +2221,10 @@ static void loader_read_json_layer( return; } props = loader_get_next_layer_property(inst, layer_instance_list); + if (NULL == props) { + // Error already triggered in loader_get_next_layer_property. + return; + } props->type = (is_implicit) ? VK_LAYER_TYPE_INSTANCE_IMPLICIT : VK_LAYER_TYPE_INSTANCE_EXPLICIT; } @@ -1940,10 +2289,12 @@ static void loader_read_json_layer( item = cJSON_GetObjectItem(node, #var); \ if (item != NULL) { \ temp = cJSON_Print(item); \ - temp[strlen(temp) - 1] = '\0'; \ - var = loader_stack_alloc(strlen(temp) + 1); \ - strcpy(var, &temp[1]); \ - loader_tls_heap_free(temp); \ + if (temp != NULL) { \ + temp[strlen(temp) - 1] = '\0'; \ + var = loader_stack_alloc(strlen(temp) + 1); \ + strcpy(var, &temp[1]); \ + cJSON_Free(temp); \ + } \ } \ } @@ -1989,14 +2340,18 @@ static void loader_read_json_layer( for (i = 0; i < count; i++) { ext_item = cJSON_GetArrayItem(instance_extensions, i); GET_JSON_ITEM(ext_item, name) - GET_JSON_ITEM(ext_item, spec_version) if (name != NULL) { strncpy(ext_prop.extensionName, name, sizeof(ext_prop.extensionName)); ext_prop.extensionName[sizeof(ext_prop.extensionName) - 1] = '\0'; } - ext_prop.specVersion = atoi(spec_version); + GET_JSON_ITEM(ext_item, spec_version) + if (NULL != spec_version) { + ext_prop.specVersion = atoi(spec_version); + } else { + ext_prop.specVersion = 0; + } bool ext_unsupported = wsi_unsupported_instance_extension(&ext_prop); if (!ext_unsupported) { @@ -2025,7 +2380,11 @@ static void loader_read_json_layer( ext_prop.extensionName[sizeof(ext_prop.extensionName) - 1] = '\0'; } - ext_prop.specVersion = atoi(spec_version); + if (NULL != spec_version) { + ext_prop.specVersion = atoi(spec_version); + } else { + ext_prop.specVersion = 0; + } // entrypoints = cJSON_GetObjectItem(ext_item, "entrypoints"); GET_JSON_OBJECT(ext_item, entrypoints) int entry_count; @@ -2035,17 +2394,22 @@ static void loader_read_json_layer( continue; } entry_count = cJSON_GetArraySize(entrypoints); - if (entry_count) + if (entry_count) { entry_array = (char **)loader_stack_alloc(sizeof(char *) * entry_count); + } for (j = 0; j < entry_count; j++) { ext_item = cJSON_GetArrayItem(entrypoints, j); if (ext_item != NULL) { temp = cJSON_Print(ext_item); + if (NULL == temp) { + entry_array[j] = NULL; + continue; + } temp[strlen(temp) - 1] = '\0'; entry_array[j] = loader_stack_alloc(strlen(temp) + 1); strcpy(entry_array[j], &temp[1]); - loader_tls_heap_free(temp); + cJSON_Free(temp); } } loader_add_to_dev_ext_list(inst, &props->device_extension_list, @@ -2091,7 +2455,8 @@ loader_add_layer_properties(const struct loader_instance *inst, /* Fields in layer manifest file that are required: * (required) “file_format_version” * - * If more than one "layer" object are to be used, use the "layers" array instead. + * If more than one "layer" object are to be used, use the "layers" array + * instead. * * First get all required items and if any missing abort */ @@ -2107,18 +2472,21 @@ loader_add_layer_properties(const struct loader_instance *inst, return; } char *file_vers = cJSON_PrintUnformatted(item); + if (NULL == file_vers) { + return; + } loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, "Found manifest file %s, version %s", filename, file_vers); // Get the major/minor/and patch as integers for easier comparison vers_tok = strtok(file_vers, ".\"\n\r"); if (NULL != vers_tok) { - file_major_vers = atoi(vers_tok); + file_major_vers = (uint16_t)atoi(vers_tok); vers_tok = strtok(NULL, ".\"\n\r"); if (NULL != vers_tok) { - file_minor_vers = atoi(vers_tok); + file_minor_vers = (uint16_t)atoi(vers_tok); vers_tok = strtok(NULL, ".\"\n\r"); if (NULL != vers_tok) { - file_patch_vers = atoi(vers_tok); + file_patch_vers = (uint16_t)atoi(vers_tok); } } } @@ -2128,7 +2496,7 @@ loader_add_layer_properties(const struct loader_instance *inst, "1.0.1), may cause errors", filename); } - loader_tls_heap_free(file_vers); + cJSON_Free(file_vers); // If "layers" is present, read in the array of layer objects layers_node = cJSON_GetObjectItem(json, "layers"); if (layers_node != NULL) { @@ -2204,10 +2572,12 @@ loader_add_layer_properties(const struct loader_instance *inst, * location is used to look for manifest files. The location * is interpreted as Registry path on Windows and a directory path(s) * on Linux. "home_location" is an additional directory in the users home - * directory to look at. It is exapanded into the dir path $HOME/home_location. - * This "home_location" is only used on Linux. + * directory to look at. It is expanded into the dir path + * $XDG_DATA_HOME/home_location or $HOME/.local/share/home_location depending + * on environment variables. This "home_location" is only used on Linux. * * \returns + * VKResult * A string list of manifest files to be opened in out_files param. * List has a pointer to string for each manifest filename. * When done using the list in out_files, pointers should be freed. @@ -2220,31 +2590,34 @@ loader_add_layer_properties(const struct loader_instance *inst, * Linux ICD | dirs | files * Linux Layer| dirs | dirs */ -static void loader_get_manifest_files(const struct loader_instance *inst, - const char *env_override, - const char *source_override, bool is_layer, - const char *location, - const char *home_location, - struct loader_manifest_files *out_files) { - const char *override = NULL; - char *loc; +static VkResult +loader_get_manifest_files(const struct loader_instance *inst, + const char *env_override, char *source_override, + bool is_layer, bool warn_if_not_present, + const char *location, const char *home_location, + struct loader_manifest_files *out_files) { + char * override = NULL; + char *loc, *orig_loc = NULL; + char *reg = NULL; char *file, *next_file, *name; size_t alloced_count = 64; char full_path[2048]; DIR *sysdir = NULL; bool list_is_dirs = false; struct dirent *dent; + VkResult res = VK_SUCCESS; out_files->count = 0; out_files->filename_list = NULL; if (source_override != NULL) { override = source_override; - } else if (env_override != NULL && (override = loader_getenv(env_override))) { + } else if (env_override != NULL && + (override = loader_getenv(env_override, inst))) { #if !defined(_WIN32) if (geteuid() != getuid() || getegid() != getgid()) { /* Don't allow setuid apps to use the env var: */ - loader_free_getenv(override); + loader_free_getenv(override, inst); override = NULL; } #endif @@ -2260,7 +2633,8 @@ static void loader_get_manifest_files(const struct loader_instance *inst, inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Can't get manifest files with NULL location, env_override=%s", env_override); - return; + res = VK_ERROR_INITIALIZATION_FAILED; + goto out; } #if defined(_WIN32) @@ -2275,35 +2649,47 @@ static void loader_get_manifest_files(const struct loader_instance *inst, if (loc == NULL) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Out of memory can't get manifest files"); - return; + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } strcpy(loc, location); #if defined(_WIN32) - loc = loader_get_registry_files(inst, loc); - if (loc == NULL) { + reg = loader_get_registry_files(inst, loc); + if (reg == NULL) { if (!is_layer) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Registry lookup failed can't get ICD manifest " "files, do you have a Vulkan driver installed"); + // This typically only fails when out of memory, which is + // critical + // if this is for the loader. + res = VK_ERROR_OUT_OF_HOST_MEMORY; } else { - // warning only for layers - loader_log( - inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "Registry lookup failed can't get layer manifest files"); + if (warn_if_not_present) { + // warning only for layers + loader_log( + inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "Registry lookup failed can't get layer manifest files"); + } + // Return success for now since it's not critical for layers + res = VK_SUCCESS; } - return; + goto out; } + orig_loc = loc; + loc = reg; #endif } else { loc = loader_stack_alloc(strlen(override) + 1); if (loc == NULL) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Out of memory can't get manifest files"); - return; + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } strcpy(loc, override); if (source_override == NULL) { - loader_free_getenv(override); + loader_free_getenv(override, inst); } } @@ -2336,7 +2722,7 @@ static void loader_get_manifest_files(const struct loader_instance *inst, if (dir == NULL) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Out of memory can't get manifest files"); - return; + goto out; } strcpy(dir, loc); @@ -2351,28 +2737,32 @@ static void loader_get_manifest_files(const struct loader_instance *inst, const char *suf = name + nlen - 5; if ((nlen > 5) && !strncmp(suf, ".json", 5)) { if (out_files->count == 0) { - out_files->filename_list = - loader_heap_alloc(inst, alloced_count * sizeof(char *), - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + out_files->filename_list = loader_instance_heap_alloc( + inst, alloced_count * sizeof(char *), + VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); } else if (out_files->count == alloced_count) { - out_files->filename_list = - loader_heap_realloc(inst, out_files->filename_list, - alloced_count * sizeof(char *), - alloced_count * sizeof(char *) * 2, - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + out_files->filename_list = loader_instance_heap_realloc( + inst, out_files->filename_list, + alloced_count * sizeof(char *), + alloced_count * sizeof(char *) * 2, + VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); alloced_count *= 2; } if (out_files->filename_list == NULL) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Out of memory can't alloc manifest file list"); - return; + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } - out_files->filename_list[out_files->count] = loader_heap_alloc( - inst, strlen(name) + 1, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); + out_files->filename_list[out_files->count] = + loader_instance_heap_alloc( + inst, strlen(name) + 1, + VK_SYSTEM_ALLOCATION_SCOPE_COMMAND); if (out_files->filename_list[out_files->count] == NULL) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Out of memory can't get manifest files"); - return; + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } strcpy(out_files->filename_list[out_files->count], name); out_files->count++; @@ -2384,8 +2774,9 @@ static void loader_get_manifest_files(const struct loader_instance *inst, } if (list_is_dirs) { dent = readdir(sysdir); - if (dent == NULL) + if (dent == NULL) { break; + } name = &(dent->d_name[0]); loader_get_fullpath(name, file, sizeof(full_path), full_path); name = full_path; @@ -2393,23 +2784,27 @@ static void loader_get_manifest_files(const struct loader_instance *inst, break; } } - if (sysdir) + if (sysdir) { closedir(sysdir); + sysdir = NULL; + } file = next_file; #if !defined(_WIN32) if (home_location != NULL && (next_file == NULL || *next_file == '\0') && override == NULL) { - char *home = secure_getenv("HOME"); - if (home != NULL) { - size_t len; - char *home_loc = loader_stack_alloc(strlen(home) + 2 + + char *xdgdatahome = secure_getenv("XDG_DATA_HOME"); + size_t len; + if (xdgdatahome != NULL) { + + char *home_loc = loader_stack_alloc(strlen(xdgdatahome) + 2 + strlen(home_location)); if (home_loc == NULL) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Out of memory can't get manifest files"); - return; + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } - strcpy(home_loc, home); + strcpy(home_loc, xdgdatahome); // Add directory separator if needed if (home_location[0] != DIRECTORY_SYMBOL) { len = strlen(home_loc); @@ -2423,14 +2818,72 @@ static void loader_get_manifest_files(const struct loader_instance *inst, loader_log( inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, - "Searching the following paths for manifest files: %s\n", + "Searching the following path for manifest files: %s\n", home_loc); list_is_dirs = true; + + } else { + + char *home = secure_getenv("HOME"); + if (home != NULL) { + char *home_loc = loader_stack_alloc(strlen(home) + 16 + + strlen(home_location)); + if (home_loc == NULL) { + loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "Out of memory can't get manifest files"); + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; + } + strcpy(home_loc, home); + + len = strlen(home); + if (home[len] != DIRECTORY_SYMBOL) { + home_loc[len] = DIRECTORY_SYMBOL; + home_loc[len + 1] = '\0'; + } + strcat(home_loc, ".local/share"); + + if (home_location[0] != DIRECTORY_SYMBOL) { + len = strlen(home_loc); + home_loc[len] = DIRECTORY_SYMBOL; + home_loc[len + 1] = '\0'; + } + strcat(home_loc, home_location); + file = home_loc; + next_file = loader_get_next_path(file); + home_location = NULL; + + loader_log( + inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, + "Searching the following path for manifest files: %s\n", + home_loc); + list_is_dirs = true; + } else { + // without knowing HOME, we just.. give up + } } } #endif } - return; + +out: + if (VK_SUCCESS != res && NULL != out_files->filename_list) { + for (uint32_t remove = 0; remove < out_files->count; remove++) { + loader_instance_heap_free(inst, out_files->filename_list[remove]); + } + loader_instance_heap_free(inst, out_files->filename_list); + out_files->count = 0; + out_files->filename_list = NULL; + } + + if (NULL != sysdir) { + closedir(sysdir); + } + + if (NULL != reg && reg != orig_loc) { + loader_instance_heap_free(inst, reg); + } + return res; } void loader_init_icd_lib_list() {} @@ -2445,61 +2898,93 @@ void loader_destroy_icd_lib_list() {} * manifest files it finds the ICD libraries. * * \returns - * a list of icds that were discovered + * Vulkan result + * (on result == VK_SUCCESS) a list of icds that were discovered */ -void loader_icd_scan(const struct loader_instance *inst, - struct loader_icd_libs *icds) { +VkResult loader_icd_scan(const struct loader_instance *inst, + struct loader_icd_tramp_list *icd_tramp_list) { char *file_str; uint16_t file_major_vers = 0; uint16_t file_minor_vers = 0; uint16_t file_patch_vers = 0; char *vers_tok; struct loader_manifest_files manifest_files; + VkResult res = VK_SUCCESS; + bool lockedMutex = false; + cJSON *json = NULL; + uint32_t num_good_icds = 0; + + memset(&manifest_files, 0, sizeof(struct loader_manifest_files)); + + res = loader_scanned_icd_init(inst, icd_tramp_list); + if (VK_SUCCESS != res) { + goto out; + } - loader_scanned_icd_init(inst, icds); // Get a list of manifest files for ICDs - loader_get_manifest_files(inst, "VK_ICD_FILENAMES", NULL, false, - DEFAULT_VK_DRIVERS_INFO, HOME_VK_DRIVERS_INFO, - &manifest_files); - if (manifest_files.count == 0) - return; + res = loader_get_manifest_files(inst, "VK_ICD_FILENAMES", NULL, false, + true, DEFAULT_VK_DRIVERS_INFO, + HOME_VK_DRIVERS_INFO, &manifest_files); + if (VK_SUCCESS != res || manifest_files.count == 0) { + goto out; + } loader_platform_thread_lock_mutex(&loader_json_lock); + lockedMutex = true; for (uint32_t i = 0; i < manifest_files.count; i++) { file_str = manifest_files.filename_list[i]; - if (file_str == NULL) + if (file_str == NULL) { continue; + } - cJSON *json; - json = loader_get_json(inst, file_str); - if (!json) + res = loader_get_json(inst, file_str, &json); + if (VK_ERROR_OUT_OF_HOST_MEMORY == res) { + break; + } else if (VK_SUCCESS != res || NULL == json) { continue; + } + cJSON *item, *itemICD; item = cJSON_GetObjectItem(json, "file_format_version"); if (item == NULL) { - loader_platform_thread_unlock_mutex(&loader_json_lock); - return; + if (num_good_icds == 0) { + res = VK_ERROR_INITIALIZATION_FAILED; + } + cJSON_Delete(json); + json = NULL; + continue; } char *file_vers = cJSON_Print(item); - // Get the major/minor/and patch as integers for easier comparison - vers_tok = strtok(file_vers, ".\"\n\r"); - if (NULL != vers_tok) { - file_major_vers = atoi(vers_tok); - vers_tok = strtok(NULL, ".\"\n\r"); - if (NULL != vers_tok) { - file_minor_vers = atoi(vers_tok); - vers_tok = strtok(NULL, ".\"\n\r"); - if (NULL != vers_tok) { - file_patch_vers = atoi(vers_tok); - } + if (NULL == file_vers) { + // Only reason the print can fail is if there was an allocation + // issue + if (num_good_icds == 0) { + res = VK_ERROR_OUT_OF_HOST_MEMORY; } + cJSON_Delete(json); + json = NULL; + continue; } loader_log(inst, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, 0, "Found manifest file %s, version %s", file_str, file_vers); + // Get the major/minor/and patch as integers for easier comparison + vers_tok = strtok(file_vers, ".\"\n\r"); + if (NULL != vers_tok) { + file_major_vers = (uint16_t)atoi(vers_tok); + vers_tok = strtok(NULL, ".\"\n\r"); + if (NULL != vers_tok) { + file_minor_vers = (uint16_t)atoi(vers_tok); + vers_tok = strtok(NULL, ".\"\n\r"); + if (NULL != vers_tok) { + file_patch_vers = (uint16_t)atoi(vers_tok); + } + } + } if (file_major_vers != 1 || file_minor_vers != 0 || file_patch_vers > 1) loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, - "Unexpected manifest file version (expected 1.0.0 or 1.0.1), may " + "Unexpected manifest file version (expected 1.0.0 or " + "1.0.1), may " "cause errors"); - loader_tls_heap_free(file_vers); + cJSON_Free(file_vers); itemICD = cJSON_GetObjectItem(json, "ICD"); if (itemICD != NULL) { item = cJSON_GetObjectItem(itemICD, "library_path"); @@ -2510,23 +2995,38 @@ void loader_icd_scan(const struct loader_instance *inst, "Can't find \"library_path\" in ICD JSON file " "%s, skipping", file_str); - loader_tls_heap_free(temp); - loader_heap_free(inst, file_str); + if (num_good_icds == 0) { + res = VK_ERROR_OUT_OF_HOST_MEMORY; + } + cJSON_Free(temp); cJSON_Delete(json); + json = NULL; continue; } // strip out extra quotes temp[strlen(temp) - 1] = '\0'; char *library_path = loader_stack_alloc(strlen(temp) + 1); + if (NULL == library_path) { + loader_log( + inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "Can't allocate space for \"library_path\" in ICD " + "JSON file %s, skipping", + file_str); + res = VK_ERROR_OUT_OF_HOST_MEMORY; + cJSON_Free(temp); + cJSON_Delete(json); + json = NULL; + goto out; + } strcpy(library_path, &temp[1]); - loader_tls_heap_free(temp); - if (!library_path || strlen(library_path) == 0) { + cJSON_Free(temp); + if (strlen(library_path) == 0) { loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "Can't find \"library_path\" in ICD JSON file " "%s, skipping", file_str); - loader_heap_free(inst, file_str); cJSON_Delete(json); + json = NULL; continue; } char fullpath[MAX_STRING_SIZE]; @@ -2553,26 +3053,55 @@ void loader_icd_scan(const struct loader_instance *inst, item = cJSON_GetObjectItem(itemICD, "api_version"); if (item != NULL) { temp = cJSON_Print(item); + if (NULL == temp) { + // Only reason the print can fail is if there was an + // allocation issue + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; + } vers = loader_make_version(temp); - loader_tls_heap_free(temp); + cJSON_Free(temp); } - loader_scanned_icd_add(inst, icds, fullpath, vers); - } else + res = loader_scanned_icd_add(inst, icd_tramp_list, fullpath, + vers); + if (VK_SUCCESS != res) { + goto out; + } + num_good_icds++; + } else { loader_log(inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "Can't find \"library_path\" object in ICD JSON " "file %s, skipping", file_str); - } else + } + } else { loader_log( inst, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, "Can't find \"ICD\" object in ICD JSON file %s, skipping", file_str); + } - loader_heap_free(inst, file_str); + cJSON_Delete(json); + json = NULL; + } + +out: + if (NULL != json) { cJSON_Delete(json); } - loader_heap_free(inst, manifest_files.filename_list); - loader_platform_thread_unlock_mutex(&loader_json_lock); + if (NULL != manifest_files.filename_list) { + for (uint32_t i = 0; i < manifest_files.count; i++) { + if (NULL != manifest_files.filename_list[i]) { + loader_instance_heap_free(inst, + manifest_files.filename_list[i]); + } + } + loader_instance_heap_free(inst, manifest_files.filename_list); + } + if (lockedMutex) { + loader_platform_thread_unlock_mutex(&loader_json_lock); + } + return res; } void loader_layer_scan(const struct loader_instance *inst, @@ -2581,55 +3110,81 @@ void loader_layer_scan(const struct loader_instance *inst, struct loader_manifest_files manifest_files[2]; // [0] = explicit, [1] = implicit cJSON *json; - uint32_t i; uint32_t implicit; + bool lockedMutex = false; - // Get a list of manifest files for explicit layers - loader_get_manifest_files(inst, LAYERS_PATH_ENV, LAYERS_SOURCE_PATH, true, - DEFAULT_VK_ELAYERS_INFO, HOME_VK_ELAYERS_INFO, - &manifest_files[0]); + memset(manifest_files, 0, sizeof(struct loader_manifest_files) * 2); + + // Get a list of manifest files for explicit layers + if (VK_SUCCESS != + loader_get_manifest_files(inst, LAYERS_PATH_ENV, LAYERS_SOURCE_PATH, + true, true, DEFAULT_VK_ELAYERS_INFO, + HOME_VK_ELAYERS_INFO, &manifest_files[0])) { + goto out; + } + + // Get a list of manifest files for any implicit layers // Pass NULL for environment variable override - implicit layers are not // overridden by LAYERS_PATH_ENV - loader_get_manifest_files(inst, NULL, NULL, true, DEFAULT_VK_ILAYERS_INFO, - HOME_VK_ILAYERS_INFO, &manifest_files[1]); - if (manifest_files[0].count == 0 && manifest_files[1].count == 0) - return; + if (VK_SUCCESS != loader_get_manifest_files(inst, NULL, NULL, true, false, + DEFAULT_VK_ILAYERS_INFO, + HOME_VK_ILAYERS_INFO, + &manifest_files[1])) { + goto out; + } - /* cleanup any previously scanned libraries */ + // Make sure we have at least one layer, if not, go ahead and return + if (manifest_files[0].count == 0 && manifest_files[1].count == 0) { + goto out; + } + + // cleanup any previously scanned libraries loader_delete_layer_properties(inst, instance_layers); loader_platform_thread_lock_mutex(&loader_json_lock); + lockedMutex = true; for (implicit = 0; implicit < 2; implicit++) { - for (i = 0; i < manifest_files[implicit].count; i++) { + for (uint32_t i = 0; i < manifest_files[implicit].count; i++) { file_str = manifest_files[implicit].filename_list[i]; if (file_str == NULL) continue; // parse file into JSON struct - json = loader_get_json(inst, file_str); - if (!json) { + VkResult res = loader_get_json(inst, file_str, &json); + if (VK_ERROR_OUT_OF_HOST_MEMORY == res) { + break; + } else if (VK_SUCCESS != res || NULL == json) { continue; } loader_add_layer_properties(inst, instance_layers, json, (implicit == 1), file_str); - - loader_heap_free(inst, file_str); cJSON_Delete(json); } } - if (manifest_files[0].count != 0) - loader_heap_free(inst, manifest_files[0].filename_list); - - if (manifest_files[1].count != 0) - loader_heap_free(inst, manifest_files[1].filename_list); // add a meta layer for validation if the validation layers are all present - loader_add_layer_property_meta( - inst, sizeof(std_validation_names) / sizeof(std_validation_names[0]), - std_validation_names, instance_layers); + loader_add_layer_property_meta(inst, sizeof(std_validation_names) / + sizeof(std_validation_names[0]), + std_validation_names, instance_layers); - loader_platform_thread_unlock_mutex(&loader_json_lock); +out: + + for (uint32_t manFile = 0; manFile < 2; manFile++) { + if (NULL != manifest_files[manFile].filename_list) { + for (uint32_t i = 0; i < manifest_files[manFile].count; i++) { + if (NULL != manifest_files[manFile].filename_list[i]) { + loader_instance_heap_free( + inst, manifest_files[manFile].filename_list[i]); + } + } + loader_instance_heap_free(inst, + manifest_files[manFile].filename_list); + } + } + if (lockedMutex) { + loader_platform_thread_unlock_mutex(&loader_json_lock); + } } void loader_implicit_layer_scan(const struct loader_instance *inst, @@ -2641,9 +3196,10 @@ void loader_implicit_layer_scan(const struct loader_instance *inst, // Pass NULL for environment variable override - implicit layers are not // overridden by LAYERS_PATH_ENV - loader_get_manifest_files(inst, NULL, NULL, true, DEFAULT_VK_ILAYERS_INFO, - HOME_VK_ILAYERS_INFO, &manifest_files); - if (manifest_files.count == 0) { + VkResult res = loader_get_manifest_files( + inst, NULL, NULL, true, false, DEFAULT_VK_ILAYERS_INFO, + HOME_VK_ILAYERS_INFO, &manifest_files); + if (VK_SUCCESS != res || manifest_files.count == 0) { return; } @@ -2659,26 +3215,25 @@ void loader_implicit_layer_scan(const struct loader_instance *inst, } // parse file into JSON struct - json = loader_get_json(inst, file_str); - if (!json) { + res = loader_get_json(inst, file_str, &json); + if (VK_ERROR_OUT_OF_HOST_MEMORY == res) { + break; + } else if (VK_SUCCESS != res || NULL == json) { continue; } - loader_add_layer_properties(inst, instance_layers, json, - true, file_str); + loader_add_layer_properties(inst, instance_layers, json, true, + file_str); - loader_heap_free(inst, file_str); + loader_instance_heap_free(inst, file_str); cJSON_Delete(json); } - - if (manifest_files.count != 0) { - loader_heap_free(inst, manifest_files.filename_list); - } + loader_instance_heap_free(inst, manifest_files.filename_list); // add a meta layer for validation if the validation layers are all present - loader_add_layer_property_meta( - inst, sizeof(std_validation_names) / sizeof(std_validation_names[0]), - std_validation_names, instance_layers); + loader_add_layer_property_meta(inst, sizeof(std_validation_names) / + sizeof(std_validation_names[0]), + std_validation_names, instance_layers); loader_platform_thread_unlock_mutex(&loader_json_lock); } @@ -2716,11 +3271,31 @@ loader_gpa_instance_internal(VkInstance inst, const char *pName) { return NULL; } -static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL +VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL loader_gpa_device_internal(VkDevice device, const char *pName) { struct loader_device *dev; - struct loader_icd *icd = loader_get_icd_and_device(device, &dev); - return icd->GetDeviceProcAddr(device, pName); + struct loader_icd_term *icd_term = + loader_get_icd_and_device(device, &dev, NULL); + + // NOTE: Device Funcs needing Trampoline/Terminator. + // Overrides for device functions needing a trampoline and + // a terminator because certain device entry-points still need to go + // through a terminator before hitting the ICD. This could be for + // several reasons, but the main one is currently unwrapping an + // object before passing the appropriate info along to the ICD. + // This is why we also have to override the direct ICD call to + // vkGetDeviceProcAddr to intercept those calls. + if (!strcmp(pName, "vkGetDeviceProcAddr")) { + return (PFN_vkVoidFunction)loader_gpa_device_internal; + } else if (!strcmp(pName, "vkCreateSwapchainKHR")) { + return (PFN_vkVoidFunction)terminator_vkCreateSwapchainKHR; + } else if (!strcmp(pName, "vkDebugMarkerSetObjectTagEXT")) { + return (PFN_vkVoidFunction)terminator_DebugMarkerSetObjectTagEXT; + } else if (!strcmp(pName, "vkDebugMarkerSetObjectNameEXT")) { + return (PFN_vkVoidFunction)terminator_DebugMarkerSetObjectNameEXT; + } + + return icd_term->GetDeviceProcAddr(device, pName); } /** @@ -2741,20 +3316,20 @@ static void loader_init_dispatch_dev_ext_entry(struct loader_instance *inst, void *gdpa_value; if (dev != NULL) { gdpa_value = dev->loader_dispatch.core_dispatch.GetDeviceProcAddr( - dev->device, funcName); + dev->chain_device, funcName); if (gdpa_value != NULL) - dev->loader_dispatch.ext_dispatch.DevExt[idx] = + dev->loader_dispatch.ext_dispatch.dev_ext[idx] = (PFN_vkDevExt)gdpa_value; } else { - for (uint32_t i = 0; i < inst->total_icd_count; i++) { - struct loader_icd *icd = &inst->icds[i]; - struct loader_device *ldev = icd->logical_device_list; + for (struct loader_icd_term *icd_term = inst->icd_terms; + icd_term != NULL; icd_term = icd_term->next) { + struct loader_device *ldev = icd_term->logical_device_list; while (ldev) { gdpa_value = ldev->loader_dispatch.core_dispatch.GetDeviceProcAddr( - ldev->device, funcName); + ldev->chain_device, funcName); if (gdpa_value != NULL) - ldev->loader_dispatch.ext_dispatch.DevExt[idx] = + ldev->loader_dispatch.ext_dispatch.dev_ext[idx] = (PFN_vkDevExt)gdpa_value; ldev = ldev->next; } @@ -2778,13 +3353,14 @@ void loader_init_dispatch_dev_ext(struct loader_instance *inst, static bool loader_check_icds_for_address(struct loader_instance *inst, const char *funcName) { - struct loader_icd *icd; - icd = inst->icds; - while (icd) { - if (icd->this_icd_lib->GetInstanceProcAddr(icd->instance, funcName)) + struct loader_icd_term *icd_term; + icd_term = inst->icd_terms; + while (NULL != icd_term) { + if (icd_term->scanned_icd->GetInstanceProcAddr(icd_term->instance, + funcName)) // this icd supports funcName return true; - icd = icd->next; + icd_term = icd_term->next; } return false; @@ -2814,21 +3390,10 @@ static bool loader_check_layer_list_for_address( return false; } -static bool -loader_check_layers_for_address(const struct loader_instance *const inst, - const char *funcName) { - if (loader_check_layer_list_for_address(&inst->instance_layer_list, - funcName)) { - return true; - } - - return false; -} - static void loader_free_dev_ext_table(struct loader_instance *inst) { for (uint32_t i = 0; i < MAX_NUM_DEV_EXTS; i++) { - loader_heap_free(inst, inst->disp_hash[i].func_name); - loader_heap_free(inst, inst->disp_hash[i].list.index); + loader_instance_heap_free(inst, inst->disp_hash[i].func_name); + loader_instance_heap_free(inst, inst->disp_hash[i].list.index); } memset(inst->disp_hash, 0, sizeof(inst->disp_hash)); } @@ -2842,7 +3407,7 @@ static bool loader_add_dev_ext_table(struct loader_instance *inst, if (!inst->disp_hash[idx].func_name) { // no entry here at this idx, so use it assert(list->capacity == 0); - inst->disp_hash[idx].func_name = (char *)loader_heap_alloc( + inst->disp_hash[idx].func_name = (char *)loader_instance_heap_alloc( inst, strlen(funcName) + 1, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (inst->disp_hash[idx].func_name == NULL) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, @@ -2856,8 +3421,9 @@ static bool loader_add_dev_ext_table(struct loader_instance *inst, // check for enough capacity if (list->capacity == 0) { - list->index = loader_heap_alloc(inst, 8 * sizeof(*(list->index)), - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + list->index = + loader_instance_heap_alloc(inst, 8 * sizeof(*(list->index)), + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (list->index == NULL) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_dev_ext_table() can't allocate list memory"); @@ -2865,9 +3431,9 @@ static bool loader_add_dev_ext_table(struct loader_instance *inst, } list->capacity = 8 * sizeof(*(list->index)); } else if (list->capacity < (list->count + 1) * sizeof(*(list->index))) { - list->index = loader_heap_realloc(inst, list->index, list->capacity, - list->capacity * 2, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + list->index = loader_instance_heap_realloc( + inst, list->index, list->capacity, list->capacity * 2, + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (list->index == NULL) { loader_log( inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, @@ -2882,9 +3448,9 @@ static bool loader_add_dev_ext_table(struct loader_instance *inst, do { if (!inst->disp_hash[i].func_name) { assert(inst->disp_hash[i].list.capacity == 0); - inst->disp_hash[i].func_name = - (char *)loader_heap_alloc(inst, strlen(funcName) + 1, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + inst->disp_hash[i].func_name = (char *)loader_instance_heap_alloc( + inst, strlen(funcName) + 1, + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (inst->disp_hash[i].func_name == NULL) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "loader_add_dev_ext_table() can't rallocate " @@ -2957,7 +3523,8 @@ void *loader_dev_ext_gpa(struct loader_instance *inst, const char *funcName) { // Check if funcName is supported in either ICDs or a layer library if (!loader_check_icds_for_address(inst, funcName) && - !loader_check_layers_for_address(inst, funcName)) { + !loader_check_layer_list_for_address(&inst->instance_layer_list, + funcName)) { // if support found in layers continue on return NULL; } @@ -2991,8 +3558,9 @@ struct loader_instance *loader_get_instance(const VkInstance instance) { } static loader_platform_dl_handle -loader_open_layer_lib(const struct loader_instance *inst, const char *chain_type, - struct loader_layer_properties *prop) { +loader_open_layer_lib(const struct loader_instance *inst, + const char *chain_type, + struct loader_layer_properties *prop) { if ((prop->lib_handle = loader_platform_open_library(prop->lib_name)) == NULL) { @@ -3007,9 +3575,8 @@ loader_open_layer_lib(const struct loader_instance *inst, const char *chain_type return prop->lib_handle; } -static void -loader_close_layer_lib(const struct loader_instance *inst, - struct loader_layer_properties *prop) { +static void loader_close_layer_lib(const struct loader_instance *inst, + struct loader_layer_properties *prop) { if (prop->lib_handle) { loader_platform_close_library(prop->lib_handle); @@ -3020,6 +3587,7 @@ loader_close_layer_lib(const struct loader_instance *inst, } void loader_deactivate_layers(const struct loader_instance *instance, + struct loader_device *device, struct loader_layer_list *list) { /* delete instance list of enabled layers and close any layer libraries */ for (uint32_t i = 0; i < list->count; i++) { @@ -3027,7 +3595,7 @@ void loader_deactivate_layers(const struct loader_instance *instance, loader_close_layer_lib(instance, layer_prop); } - loader_destroy_layer_list(instance, list); + loader_destroy_layer_list(instance, device, list); } /** @@ -3054,23 +3622,25 @@ loader_add_layer_implicit(const struct loader_instance *inst, if (prop->enable_env_var.name[0] == 0) { enable = true; } else { - env_value = loader_getenv(prop->enable_env_var.name); + env_value = loader_getenv(prop->enable_env_var.name, inst); if (env_value && !strcmp(prop->enable_env_var.value, env_value)) enable = true; - loader_free_getenv(env_value); + loader_free_getenv(env_value, inst); } // disable_environment has priority, i.e. if both enable and disable // environment variables are set, the layer is disabled. Implicit // layers // are required to have a disable_environment variables - env_value = loader_getenv(prop->disable_env_var.name); - if (env_value) + env_value = loader_getenv(prop->disable_env_var.name, inst); + if (env_value) { enable = false; - loader_free_getenv(env_value); + } + loader_free_getenv(env_value, inst); - if (enable) + if (enable) { loader_add_to_layer_list(inst, list, 1, prop); + } } } } @@ -3088,7 +3658,7 @@ static void loader_add_layer_env(struct loader_instance *inst, char *layerEnv; char *next, *name; - layerEnv = loader_getenv(env_name); + layerEnv = loader_getenv(env_name, inst); if (layerEnv == NULL) { return; } @@ -3098,7 +3668,7 @@ static void loader_add_layer_env(struct loader_instance *inst, } strcpy(name, layerEnv); - loader_free_getenv(layerEnv); + loader_free_getenv(layerEnv, inst); while (name && *name) { next = loader_get_next_path(name); @@ -3407,15 +3977,15 @@ loader_create_device_chain(const struct loader_physical_device_tramp *pd, if (res != VK_SUCCESS) { return res; } - dev->device = created_device; + dev->chain_device = created_device; } else { // Couldn't find CreateDevice function! return VK_ERROR_INITIALIZATION_FAILED; } - /* Initialize device dispatch table */ + // Initialize device dispatch table loader_init_device_dispatch_table(&dev->loader_dispatch, nextGDPA, - dev->device); + dev->chain_device); return res; } @@ -3475,7 +4045,7 @@ VkResult loader_validate_instance_extensions( /* Not in global list, search layer extension lists */ for (uint32_t j = 0; j < pCreateInfo->enabledLayerCount; j++) { layer_prop = loader_get_layer_property( - pCreateInfo->ppEnabledLayerNames[i], instance_layer); + pCreateInfo->ppEnabledLayerNames[j], instance_layer); if (!layer_prop) { /* Should NOT get here, loader_validate_layers * should have already filtered this case out. @@ -3554,16 +4124,15 @@ VkResult loader_validate_device_extensions( * Terminator functions for the Instance chain * All named terminator_ */ -VKAPI_ATTR VkResult VKAPI_CALL -terminator_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkInstance *pInstance) { - struct loader_icd *icd; +VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateInstance( + const VkInstanceCreateInfo *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkInstance *pInstance) { + struct loader_icd_term *icd_term; VkExtensionProperties *prop; char **filtered_extension_names = NULL; VkInstanceCreateInfo icd_create_info; VkResult res = VK_SUCCESS; - bool success = false; + bool one_icd_successful = false; struct loader_instance *ptr_instance = (struct loader_instance *)*pInstance; memcpy(&icd_create_info, pCreateInfo, sizeof(icd_create_info)); @@ -3581,82 +4150,133 @@ terminator_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, filtered_extension_names = loader_stack_alloc(pCreateInfo->enabledExtensionCount * sizeof(char *)); if (!filtered_extension_names) { - return VK_ERROR_OUT_OF_HOST_MEMORY; + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } icd_create_info.ppEnabledExtensionNames = (const char *const *)filtered_extension_names; - for (uint32_t i = 0; i < ptr_instance->icd_libs.count; i++) { - icd = loader_icd_add(ptr_instance, &ptr_instance->icd_libs.list[i]); - if (icd) { - icd_create_info.enabledExtensionCount = 0; - struct loader_extension_list icd_exts; + for (uint32_t i = 0; i < ptr_instance->icd_tramp_list.count; i++) { + icd_term = loader_icd_add( + ptr_instance, &ptr_instance->icd_tramp_list.scanned_list[i]); + if (NULL == icd_term) { + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; + } + icd_create_info.enabledExtensionCount = 0; + struct loader_extension_list icd_exts; - loader_log(ptr_instance, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, - "Build ICD instance extension list"); - // traverse scanned icd list adding non-duplicate extensions to the - // list - loader_init_generic_list(ptr_instance, - (struct loader_generic_list *)&icd_exts, - sizeof(VkExtensionProperties)); - loader_add_instance_extensions( - ptr_instance, - icd->this_icd_lib->EnumerateInstanceExtensionProperties, - icd->this_icd_lib->lib_name, &icd_exts); - - for (uint32_t j = 0; j < pCreateInfo->enabledExtensionCount; j++) { - prop = get_extension_property( - pCreateInfo->ppEnabledExtensionNames[j], &icd_exts); - if (prop) { - filtered_extension_names[icd_create_info - .enabledExtensionCount] = - (char *)pCreateInfo->ppEnabledExtensionNames[j]; - icd_create_info.enabledExtensionCount++; - } - } + loader_log(ptr_instance, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, + "Build ICD instance extension list"); + // traverse scanned icd list adding non-duplicate extensions to the + // list + res = loader_init_generic_list(ptr_instance, + (struct loader_generic_list *)&icd_exts, + sizeof(VkExtensionProperties)); + if (VK_ERROR_OUT_OF_HOST_MEMORY == res) { + // If out of memory, bail immediately. + goto out; + } else if (VK_SUCCESS != res) { + // Something bad happened with this ICD, so free it and try the + // next. + ptr_instance->icd_terms = icd_term->next; + icd_term->next = NULL; + loader_icd_destroy(ptr_instance, icd_term, pAllocator); + continue; + } + res = loader_add_instance_extensions( + ptr_instance, + icd_term->scanned_icd->EnumerateInstanceExtensionProperties, + icd_term->scanned_icd->lib_name, &icd_exts); + if (VK_SUCCESS != res) { loader_destroy_generic_list( ptr_instance, (struct loader_generic_list *)&icd_exts); - - res = ptr_instance->icd_libs.list[i].CreateInstance( - &icd_create_info, pAllocator, &(icd->instance)); - if (res == VK_SUCCESS) - success = loader_icd_init_entrys( - icd, icd->instance, - ptr_instance->icd_libs.list[i].GetInstanceProcAddr); - - if (res != VK_SUCCESS || !success) { - ptr_instance->icds = ptr_instance->icds->next; - loader_icd_destroy(ptr_instance, icd); - loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, - "ICD ignored: failed to CreateInstance and find " - "entrypoints with ICD"); + if (VK_ERROR_OUT_OF_HOST_MEMORY == res) { + // If out of memory, bail immediately. + goto out; + } else { + // Something bad happened with this ICD, so free it and try + // the next. + ptr_instance->icd_terms = icd_term->next; + icd_term->next = NULL; + loader_icd_destroy(ptr_instance, icd_term, pAllocator); + continue; } } + + for (uint32_t j = 0; j < pCreateInfo->enabledExtensionCount; j++) { + prop = get_extension_property( + pCreateInfo->ppEnabledExtensionNames[j], &icd_exts); + if (prop) { + filtered_extension_names[icd_create_info + .enabledExtensionCount] = + (char *)pCreateInfo->ppEnabledExtensionNames[j]; + icd_create_info.enabledExtensionCount++; + } + } + + loader_destroy_generic_list(ptr_instance, + (struct loader_generic_list *)&icd_exts); + + VkResult icd_result = + ptr_instance->icd_tramp_list.scanned_list[i].CreateInstance( + &icd_create_info, pAllocator, &(icd_term->instance)); + if (VK_ERROR_OUT_OF_HOST_MEMORY == icd_result) { + // If out of memory, bail immediately. + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; + } else if (VK_SUCCESS != icd_result) { + loader_log(ptr_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "ICD ignored: failed to CreateInstance in ICD %d", i); + ptr_instance->icd_terms = icd_term->next; + icd_term->next = NULL; + loader_icd_destroy(ptr_instance, icd_term, pAllocator); + continue; + } + + if (!loader_icd_init_entrys(icd_term, icd_term->instance, + ptr_instance->icd_tramp_list.scanned_list[i] + .GetInstanceProcAddr)) { + loader_log(ptr_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, 0, + "ICD ignored: failed to CreateInstance and find " + "entrypoints with ICD"); + continue; + } + + // If we made it this far, at least one ICD was successful + one_icd_successful = true; } - /* - * If no ICDs were added to instance list and res is unchanged - * from it's initial value, the loader was unable to find - * a suitable ICD. - */ - if (ptr_instance->icds == NULL) { - if (res == VK_SUCCESS) { - return VK_ERROR_INCOMPATIBLE_DRIVER; - } else { - return res; + // If no ICDs were added to instance list and res is unchanged + // from it's initial value, the loader was unable to find + // a suitable ICD. + if (VK_SUCCESS == res && + (ptr_instance->icd_terms == NULL || !one_icd_successful)) { + res = VK_ERROR_INCOMPATIBLE_DRIVER; + } + +out: + + if (VK_SUCCESS != res) { + while (NULL != ptr_instance->icd_terms) { + icd_term = ptr_instance->icd_terms; + ptr_instance->icd_terms = icd_term->next; + if (NULL != icd_term->instance) { + icd_term->DestroyInstance(icd_term->instance, pAllocator); + } + loader_icd_destroy(ptr_instance, icd_term, pAllocator); } } - return VK_SUCCESS; + return res; } -VKAPI_ATTR void VKAPI_CALL -terminator_DestroyInstance(VkInstance instance, - const VkAllocationCallbacks *pAllocator) { +VKAPI_ATTR void VKAPI_CALL terminator_DestroyInstance( + VkInstance instance, const VkAllocationCallbacks *pAllocator) { struct loader_instance *ptr_instance = loader_instance(instance); - struct loader_icd *icds = ptr_instance->icds; - struct loader_icd *next_icd; + struct loader_icd_term *icd_terms = ptr_instance->icd_terms; + struct loader_icd_term *next_icd_term; // Remove this instance from the list of instances: struct loader_instance *prev = NULL; @@ -3674,40 +4294,49 @@ terminator_DestroyInstance(VkInstance instance, next = next->next; } - while (icds) { - if (icds->instance) { - icds->DestroyInstance(icds->instance, pAllocator); + while (NULL != icd_terms) { + if (icd_terms->instance) { + icd_terms->DestroyInstance(icd_terms->instance, pAllocator); } - next_icd = icds->next; - icds->instance = VK_NULL_HANDLE; - loader_icd_destroy(ptr_instance, icds); + next_icd_term = icd_terms->next; + icd_terms->instance = VK_NULL_HANDLE; + loader_icd_destroy(ptr_instance, icd_terms, pAllocator); - icds = next_icd; + icd_terms = next_icd_term; } loader_delete_layer_properties(ptr_instance, &ptr_instance->instance_layer_list); - loader_scanned_icd_clear(ptr_instance, &ptr_instance->icd_libs); + loader_scanned_icd_clear(ptr_instance, &ptr_instance->icd_tramp_list); loader_destroy_generic_list( ptr_instance, (struct loader_generic_list *)&ptr_instance->ext_list); if (ptr_instance->phys_devs_term) - loader_heap_free(ptr_instance, ptr_instance->phys_devs_term); + loader_instance_heap_free(ptr_instance, ptr_instance->phys_devs_term); loader_free_dev_ext_table(ptr_instance); } -VKAPI_ATTR VkResult VKAPI_CALL -terminator_CreateDevice(VkPhysicalDevice physicalDevice, - const VkDeviceCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkDevice *pDevice) { - struct loader_physical_device *phys_dev; - phys_dev = (struct loader_physical_device *)physicalDevice; +VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice( + VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) { + VkResult res = VK_SUCCESS; + struct loader_physical_device_term *phys_dev_term; + phys_dev_term = (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_device *dev = (struct loader_device *)*pDevice; - PFN_vkCreateDevice fpCreateDevice = phys_dev->this_icd->CreateDevice; + PFN_vkCreateDevice fpCreateDevice = icd_term->CreateDevice; + struct loader_extension_list icd_exts; + + dev->phys_dev_term = phys_dev_term; + + icd_exts.list = NULL; if (fpCreateDevice == NULL) { - return VK_ERROR_INITIALIZATION_FAILED; + loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "No vkCreateDevice command exposed by ICD %s", + icd_term->scanned_icd->lib_name); + res = VK_ERROR_INITIALIZATION_FAILED; + goto out; } VkDeviceCreateInfo localCreateInfo; @@ -3735,21 +4364,18 @@ terminator_CreateDevice(VkPhysicalDevice physicalDevice, (const char *const *)filtered_extension_names; /* Get the physical device (ICD) extensions */ - struct loader_extension_list icd_exts; - VkResult res; - if (!loader_init_generic_list(phys_dev->this_icd->this_instance, - (struct loader_generic_list *)&icd_exts, - sizeof(VkExtensionProperties))) { - return VK_ERROR_OUT_OF_HOST_MEMORY; + res = loader_init_generic_list(icd_term->this_instance, + (struct loader_generic_list *)&icd_exts, + sizeof(VkExtensionProperties)); + if (VK_SUCCESS != res) { + goto out; } res = loader_add_device_extensions( - phys_dev->this_icd->this_instance, - phys_dev->this_icd->EnumerateDeviceExtensionProperties, - phys_dev->phys_dev, phys_dev->this_icd->this_icd_lib->lib_name, - &icd_exts); + icd_term->this_instance, icd_term->EnumerateDeviceExtensionProperties, + phys_dev_term->phys_dev, icd_term->scanned_icd->lib_name, &icd_exts); if (res != VK_SUCCESS) { - return res; + goto out; } for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { @@ -3760,39 +4386,46 @@ terminator_CreateDevice(VkPhysicalDevice physicalDevice, filtered_extension_names[localCreateInfo.enabledExtensionCount] = (char *)extension_name; localCreateInfo.enabledExtensionCount++; + } else { + loader_log(icd_term->this_instance, VK_DEBUG_REPORT_WARNING_BIT_EXT, + 0, "vkCreateDevice extension %s not available for " + "devices associated with ICD %s", + extension_name, icd_term->scanned_icd->lib_name); } } - // TODO: Why does fpCreateDevice behave differently than - // this_icd->CreateDevice? - // VkResult res = fpCreateDevice(phys_dev->phys_dev, &localCreateInfo, - // pAllocator, &localDevice); - res = phys_dev->this_icd->CreateDevice(phys_dev->phys_dev, &localCreateInfo, - pAllocator, &dev->device); - + res = fpCreateDevice(phys_dev_term->phys_dev, &localCreateInfo, pAllocator, + &dev->icd_device); if (res != VK_SUCCESS) { - return res; + loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + "vkCreateDevice call failed in ICD %s", + icd_term->scanned_icd->lib_name); + goto out; } - *pDevice = dev->device; - loader_add_logical_device(phys_dev->this_icd->this_instance, - phys_dev->this_icd, dev); + *pDevice = dev->icd_device; + loader_add_logical_device(icd_term->this_instance, icd_term, dev); /* Init dispatch pointer in new device object */ loader_init_dispatch(*pDevice, &dev->loader_dispatch); +out: + if (NULL != icd_exts.list) { + loader_destroy_generic_list(icd_term->this_instance, + (struct loader_generic_list *)&icd_exts); + } + return res; } -VKAPI_ATTR VkResult VKAPI_CALL -terminator_EnumeratePhysicalDevices(VkInstance instance, - uint32_t *pPhysicalDeviceCount, - VkPhysicalDevice *pPhysicalDevices) { +VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumeratePhysicalDevices( + VkInstance instance, uint32_t *pPhysicalDeviceCount, + VkPhysicalDevice *pPhysicalDevices) { uint32_t i; struct loader_instance *inst = (struct loader_instance *)instance; VkResult res = VK_SUCCESS; - struct loader_icd *icd; + struct loader_icd_term *icd_term; struct loader_phys_dev_per_icd *phys_devs; inst->total_gpu_count = 0; @@ -3801,135 +4434,144 @@ terminator_EnumeratePhysicalDevices(VkInstance instance, if (!phys_devs) return VK_ERROR_OUT_OF_HOST_MEMORY; - icd = inst->icds; + icd_term = inst->icd_terms; for (i = 0; i < inst->total_icd_count; i++) { - assert(icd); - res = icd->EnumeratePhysicalDevices(icd->instance, &phys_devs[i].count, - NULL); + assert(icd_term); + res = icd_term->EnumeratePhysicalDevices(icd_term->instance, + &phys_devs[i].count, NULL); if (res != VK_SUCCESS) return res; - icd = icd->next; + icd_term = icd_term->next; } - icd = inst->icds; + icd_term = inst->icd_terms; for (i = 0; i < inst->total_icd_count; i++) { - assert(icd); + assert(icd_term); phys_devs[i].phys_devs = (VkPhysicalDevice *)loader_stack_alloc( phys_devs[i].count * sizeof(VkPhysicalDevice)); if (!phys_devs[i].phys_devs) { return VK_ERROR_OUT_OF_HOST_MEMORY; } - res = icd->EnumeratePhysicalDevices( - icd->instance, &(phys_devs[i].count), phys_devs[i].phys_devs); + res = icd_term->EnumeratePhysicalDevices( + icd_term->instance, &(phys_devs[i].count), phys_devs[i].phys_devs); if ((res == VK_SUCCESS)) { inst->total_gpu_count += phys_devs[i].count; } else { return res; } - phys_devs[i].this_icd = icd; - icd = icd->next; + phys_devs[i].this_icd_term = icd_term; + icd_term = icd_term->next; + } + if (inst->total_gpu_count == 0) { + return VK_ERROR_INITIALIZATION_FAILED; } - *pPhysicalDeviceCount = inst->total_gpu_count; - if (!pPhysicalDevices) { - return res; - } + uint32_t copy_count = inst->total_gpu_count; - /* Initialize the output pPhysicalDevices with wrapped loader terminator - * physicalDevice objects; save this list of wrapped objects in instance - * struct for later cleanup and use by trampoline code */ - uint32_t j, idx = 0; - uint32_t copy_count = 0; + if (NULL != pPhysicalDevices) { + // Initialize the output pPhysicalDevices with wrapped loader + // terminator physicalDevice objects; save this list of + // wrapped objects in instance struct for later cleanup and + // use by trampoline code + uint32_t j, idx = 0; - copy_count = (inst->total_gpu_count < *pPhysicalDeviceCount) - ? inst->total_gpu_count - : *pPhysicalDeviceCount; + if (copy_count > *pPhysicalDeviceCount) { + copy_count = *pPhysicalDeviceCount; + } - if (inst->phys_devs_term) - loader_heap_free(inst, inst->phys_devs_term); - inst->phys_devs_term = loader_heap_alloc( - inst, sizeof(struct loader_physical_device) * copy_count, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); - if (!inst->phys_devs_term) - return VK_ERROR_OUT_OF_HOST_MEMORY; + if (NULL == inst->phys_devs_term) { + inst->phys_devs_term = loader_instance_heap_alloc( + inst, sizeof(struct loader_physical_device_term) * + inst->total_gpu_count, + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + if (NULL == inst->phys_devs_term) { + return VK_ERROR_OUT_OF_HOST_MEMORY; + } + } - for (i = 0; idx < copy_count && i < inst->total_icd_count; i++) { + for (i = 0; idx < inst->total_gpu_count && i < inst->total_icd_count; + i++) { + for (j = 0; j < phys_devs[i].count && idx < inst->total_gpu_count; + j++) { + loader_set_dispatch((void *)&inst->phys_devs_term[idx], + inst->disp); + inst->phys_devs_term[idx].this_icd_term = + phys_devs[i].this_icd_term; + inst->phys_devs_term[idx].icd_index = (uint8_t)(i); + inst->phys_devs_term[idx].phys_dev = phys_devs[i].phys_devs[j]; + if (idx < copy_count) { + pPhysicalDevices[idx] = + (VkPhysicalDevice)&inst->phys_devs_term[idx]; + } + idx++; + } + } - for (j = 0; j < phys_devs[i].count && idx < copy_count; j++) { - loader_set_dispatch((void *)&inst->phys_devs_term[idx], inst->disp); - inst->phys_devs_term[idx].this_icd = phys_devs[i].this_icd; - inst->phys_devs_term[idx].phys_dev = phys_devs[i].phys_devs[j]; - pPhysicalDevices[idx] = - (VkPhysicalDevice)&inst->phys_devs_term[idx]; - idx++; + if (copy_count < inst->total_gpu_count) { + res = VK_INCOMPLETE; } } + *pPhysicalDeviceCount = copy_count; - // TODO: Is phys_devs being leaked? - - if (copy_count < inst->total_gpu_count) { - inst->total_gpu_count = copy_count; - return VK_INCOMPLETE; - } return res; } VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceProperties( VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties *pProperties) { - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; - struct loader_icd *icd = phys_dev->this_icd; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (icd->GetPhysicalDeviceProperties) - icd->GetPhysicalDeviceProperties(phys_dev->phys_dev, pProperties); + if (icd_term->GetPhysicalDeviceProperties) + icd_term->GetPhysicalDeviceProperties(phys_dev_term->phys_dev, + pProperties); } VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceQueueFamilyProperties( VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties *pProperties) { - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; - struct loader_icd *icd = phys_dev->this_icd; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (icd->GetPhysicalDeviceQueueFamilyProperties) - icd->GetPhysicalDeviceQueueFamilyProperties( - phys_dev->phys_dev, pQueueFamilyPropertyCount, pProperties); + if (icd_term->GetPhysicalDeviceQueueFamilyProperties) + icd_term->GetPhysicalDeviceQueueFamilyProperties( + phys_dev_term->phys_dev, pQueueFamilyPropertyCount, pProperties); } VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceMemoryProperties( VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties *pProperties) { - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; - struct loader_icd *icd = phys_dev->this_icd; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (icd->GetPhysicalDeviceMemoryProperties) - icd->GetPhysicalDeviceMemoryProperties(phys_dev->phys_dev, pProperties); + if (icd_term->GetPhysicalDeviceMemoryProperties) + icd_term->GetPhysicalDeviceMemoryProperties(phys_dev_term->phys_dev, + pProperties); } -VKAPI_ATTR void VKAPI_CALL -terminator_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceFeatures *pFeatures) { - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; - struct loader_icd *icd = phys_dev->this_icd; +VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFeatures( + VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures *pFeatures) { + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (icd->GetPhysicalDeviceFeatures) - icd->GetPhysicalDeviceFeatures(phys_dev->phys_dev, pFeatures); + if (icd_term->GetPhysicalDeviceFeatures) + icd_term->GetPhysicalDeviceFeatures(phys_dev_term->phys_dev, pFeatures); } -VKAPI_ATTR void VKAPI_CALL -terminator_GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, - VkFormat format, - VkFormatProperties *pFormatInfo) { - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; - struct loader_icd *icd = phys_dev->this_icd; +VKAPI_ATTR void VKAPI_CALL terminator_GetPhysicalDeviceFormatProperties( + VkPhysicalDevice physicalDevice, VkFormat format, + VkFormatProperties *pFormatInfo) { + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (icd->GetPhysicalDeviceFormatProperties) - icd->GetPhysicalDeviceFormatProperties(phys_dev->phys_dev, format, - pFormatInfo); + if (icd_term->GetPhysicalDeviceFormatProperties) + icd_term->GetPhysicalDeviceFormatProperties(phys_dev_term->phys_dev, + format, pFormatInfo); } VKAPI_ATTR VkResult VKAPI_CALL @@ -3937,15 +4579,15 @@ terminator_GetPhysicalDeviceImageFormatProperties( VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) { - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; - struct loader_icd *icd = phys_dev->this_icd; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (!icd->GetPhysicalDeviceImageFormatProperties) + if (!icd_term->GetPhysicalDeviceImageFormatProperties) return VK_ERROR_INITIALIZATION_FAILED; - return icd->GetPhysicalDeviceImageFormatProperties( - phys_dev->phys_dev, format, type, tiling, usage, flags, + return icd_term->GetPhysicalDeviceImageFormatProperties( + phys_dev_term->phys_dev, format, type, tiling, usage, flags, pImageFormatProperties); } @@ -3955,82 +4597,94 @@ terminator_GetPhysicalDeviceSparseImageFormatProperties( VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t *pNumProperties, VkSparseImageFormatProperties *pProperties) { - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; - struct loader_icd *icd = phys_dev->this_icd; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; - if (icd->GetPhysicalDeviceSparseImageFormatProperties) - icd->GetPhysicalDeviceSparseImageFormatProperties( - phys_dev->phys_dev, format, type, samples, usage, tiling, + if (icd_term->GetPhysicalDeviceSparseImageFormatProperties) + icd_term->GetPhysicalDeviceSparseImageFormatProperties( + phys_dev_term->phys_dev, format, type, samples, usage, tiling, pNumProperties, pProperties); } VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceExtensionProperties( VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties) { - struct loader_physical_device *phys_dev; + struct loader_physical_device_term *phys_dev_term; - struct loader_layer_list implicit_layer_list; + struct loader_layer_list implicit_layer_list = {0}; + struct loader_extension_list all_exts = {0}; + struct loader_extension_list icd_exts = {0}; assert(pLayerName == NULL || strlen(pLayerName) == 0); /* Any layer or trampoline wrapping should be removed at this point in time * can just cast to the expected type for VkPhysicalDevice. */ - phys_dev = (struct loader_physical_device *)physicalDevice; + phys_dev_term = (struct loader_physical_device_term *)physicalDevice; /* this case is during the call down the instance chain with pLayerName * == NULL*/ - struct loader_icd *icd = phys_dev->this_icd; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; uint32_t icd_ext_count = *pPropertyCount; VkResult res; /* get device extensions */ - res = icd->EnumerateDeviceExtensionProperties(phys_dev->phys_dev, NULL, - &icd_ext_count, pProperties); - if (res != VK_SUCCESS) - return res; + res = icd_term->EnumerateDeviceExtensionProperties( + phys_dev_term->phys_dev, NULL, &icd_ext_count, pProperties); + if (res != VK_SUCCESS) { + goto out; + } - loader_init_layer_list(icd->this_instance, &implicit_layer_list); + if (!loader_init_layer_list(icd_term->this_instance, + &implicit_layer_list)) { + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; + } loader_add_layer_implicit( - icd->this_instance, VK_LAYER_TYPE_INSTANCE_IMPLICIT, - &implicit_layer_list, &icd->this_instance->instance_layer_list); + icd_term->this_instance, VK_LAYER_TYPE_INSTANCE_IMPLICIT, + &implicit_layer_list, &icd_term->this_instance->instance_layer_list); /* we need to determine which implicit layers are active, * and then add their extensions. This can't be cached as * it depends on results of environment variables (which can change). */ if (pProperties != NULL) { - struct loader_extension_list icd_exts; /* initialize dev_extension list within the physicalDevice object */ - res = loader_init_device_extensions(icd->this_instance, phys_dev, - icd_ext_count, pProperties, - &icd_exts); - if (res != VK_SUCCESS) - return res; + res = loader_init_device_extensions(icd_term->this_instance, + phys_dev_term, icd_ext_count, + pProperties, &icd_exts); + if (res != VK_SUCCESS) { + goto out; + } /* we need to determine which implicit layers are active, * and then add their extensions. This can't be cached as * it depends on results of environment variables (which can * change). */ - struct loader_extension_list all_exts = {0}; - loader_add_to_ext_list(icd->this_instance, &all_exts, icd_exts.count, - icd_exts.list); - - loader_init_layer_list(icd->this_instance, &implicit_layer_list); + res = loader_add_to_ext_list(icd_term->this_instance, &all_exts, + icd_exts.count, icd_exts.list); + if (res != VK_SUCCESS) { + goto out; + } loader_add_layer_implicit( - icd->this_instance, VK_LAYER_TYPE_INSTANCE_IMPLICIT, - &implicit_layer_list, &icd->this_instance->instance_layer_list); + icd_term->this_instance, VK_LAYER_TYPE_INSTANCE_IMPLICIT, + &implicit_layer_list, + &icd_term->this_instance->instance_layer_list); for (uint32_t i = 0; i < implicit_layer_list.count; i++) { for (uint32_t j = 0; j < implicit_layer_list.list[i].device_extension_list.count; j++) { - loader_add_to_ext_list(icd->this_instance, &all_exts, 1, - &implicit_layer_list.list[i] - .device_extension_list.list[j] - .props); + res = loader_add_to_ext_list(icd_term->this_instance, &all_exts, + 1, + &implicit_layer_list.list[i] + .device_extension_list.list[j] + .props); + if (res != VK_SUCCESS) { + goto out; + } } } uint32_t capacity = *pPropertyCount; @@ -4046,8 +4700,6 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceExtensionProperties( } else { *pPropertyCount = all_exts.count; } - loader_destroy_generic_list(icd->this_instance, - (struct loader_generic_list *)&all_exts); } else { /* just return the count; need to add in the count of implicit layer * extensions @@ -4061,15 +4713,28 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceExtensionProperties( res = VK_SUCCESS; } - loader_destroy_generic_list( - icd->this_instance, (struct loader_generic_list *)&implicit_layer_list); +out: + + if (NULL != implicit_layer_list.list) { + loader_destroy_generic_list( + icd_term->this_instance, + (struct loader_generic_list *)&implicit_layer_list); + } + if (NULL != all_exts.list) { + loader_destroy_generic_list(icd_term->this_instance, + (struct loader_generic_list *)&all_exts); + } + if (NULL != icd_exts.list) { + loader_destroy_generic_list(icd_term->this_instance, + (struct loader_generic_list *)&icd_exts); + } + return res; } -VKAPI_ATTR VkResult VKAPI_CALL -terminator_EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, - uint32_t *pPropertyCount, - VkLayerProperties *pProperties) { +VKAPI_ATTR VkResult VKAPI_CALL terminator_EnumerateDeviceLayerProperties( + VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, + VkLayerProperties *pProperties) { // should never get here this call isn't dispatched down the chain return VK_ERROR_INITIALIZATION_FAILED; diff --git a/third_party/vulkan/loader/loader.h b/third_party/vulkan/loader/loader.h index ecc945edc..fc035ed3b 100644 --- a/third_party/vulkan/loader/loader.h +++ b/third_party/vulkan/loader/loader.h @@ -44,6 +44,9 @@ #define LOADER_EXPORT #endif +// A debug option to disable allocators at compile time to investigate future issues. +#define DEBUG_DISABLE_APP_ALLOCATORS 0 + #define MAX_STRING_SIZE 1024 #define VK_MAJOR(version) (version >> 22) #define VK_MINOR(version) ((version >> 12) & 0x3ff) @@ -72,11 +75,11 @@ static const char UTF8_THREE_BYTE_MASK = 0xF8; static const char UTF8_DATA_BYTE_CODE = 0x80; static const char UTF8_DATA_BYTE_MASK = 0xC0; -static const char std_validation_names[8][VK_MAX_EXTENSION_NAME_SIZE] = { - "VK_LAYER_GOOGLE_threading", "VK_LAYER_LUNARG_parameter_validation", - "VK_LAYER_LUNARG_device_limits", "VK_LAYER_LUNARG_object_tracker", - "VK_LAYER_LUNARG_image", "VK_LAYER_LUNARG_core_validation", - "VK_LAYER_LUNARG_swapchain", "VK_LAYER_GOOGLE_unique_objects"}; +static const char std_validation_names[7][VK_MAX_EXTENSION_NAME_SIZE] = { + "VK_LAYER_GOOGLE_threading", "VK_LAYER_LUNARG_parameter_validation", + "VK_LAYER_LUNARG_object_tracker", "VK_LAYER_LUNARG_image", + "VK_LAYER_LUNARG_core_validation", "VK_LAYER_LUNARG_swapchain", + "VK_LAYER_GOOGLE_unique_objects"}; // form of all dynamic lists/arrays // only the list element should be changed @@ -141,9 +144,9 @@ struct loader_dispatch_hash_list { }; #define MAX_NUM_DEV_EXTS 250 -// loader_dispatch_hash_entry and loader_dev_ext_dispatch_table.DevExt have one -// to one -// correspondence; one loader_dispatch_hash_entry for one DevExt dispatch entry. +// loader_dispatch_hash_entry and loader_dev_ext_dispatch_table.dev_ext have +// one to one correspondence; one loader_dispatch_hash_entry for one dev_ext +// dispatch entry. // Also have a one to one correspondence with functions in dev_ext_trampoline.c struct loader_dispatch_hash_entry { char *func_name; @@ -152,7 +155,7 @@ struct loader_dispatch_hash_entry { typedef void(VKAPI_PTR *PFN_vkDevExt)(VkDevice device); struct loader_dev_ext_dispatch_table { - PFN_vkDevExt DevExt[MAX_NUM_DEV_EXTS]; + PFN_vkDevExt dev_ext[MAX_NUM_DEV_EXTS]; }; struct loader_dev_dispatch_table { @@ -160,23 +163,24 @@ struct loader_dev_dispatch_table { struct loader_dev_ext_dispatch_table ext_dispatch; }; -/* per CreateDevice structure */ +// per CreateDevice structure struct loader_device { struct loader_dev_dispatch_table loader_dispatch; - VkDevice device; // device object from the icd - - uint32_t app_extension_count; - VkExtensionProperties *app_extension_props; + VkDevice chain_device; // device object from the dispatch chain + VkDevice icd_device; // device object from the icd + struct loader_physical_device_term *phys_dev_term; struct loader_layer_list activated_layer_list; + VkAllocationCallbacks alloc_callbacks; + struct loader_device *next; }; /* per ICD structure */ -struct loader_icd { +struct loader_icd_term { // pointers to find other structs - const struct loader_scanned_icds *this_icd_lib; + const struct loader_scanned_icd *scanned_icd; const struct loader_instance *this_instance; struct loader_device *logical_device_list; VkInstance instance; // instance object from the icd @@ -198,29 +202,38 @@ struct loader_icd { PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallbackEXT; PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallbackEXT; PFN_vkDebugReportMessageEXT DebugReportMessageEXT; + PFN_vkDebugMarkerSetObjectTagEXT DebugMarkerSetObjectTagEXT; + PFN_vkDebugMarkerSetObjectNameEXT DebugMarkerSetObjectNameEXT; PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR; PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR GetPhysicalDeviceSurfaceCapabilitiesKHR; PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR; PFN_vkGetPhysicalDeviceSurfacePresentModesKHR GetPhysicalDeviceSurfacePresentModesKHR; + PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV + GetPhysicalDeviceExternalImageFormatPropertiesNV; #ifdef VK_USE_PLATFORM_WIN32_KHR + PFN_vkCreateWin32SurfaceKHR CreateWin32SurfaceKHR; PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR GetPhysicalDeviceWin32PresentationSupportKHR; #endif #ifdef VK_USE_PLATFORM_MIR_KHR + PFN_vkCreateMirSurfaceKHR CreateMirSurfaceKHR; PFN_vkGetPhysicalDeviceMirPresentationSupportKHR - GetPhysicalDeviceMirPresentvationSupportKHR; + GetPhysicalDeviceMirPresentationSupportKHR; #endif #ifdef VK_USE_PLATFORM_WAYLAND_KHR + PFN_vkCreateWaylandSurfaceKHR CreateWaylandSurfaceKHR; PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR GetPhysicalDeviceWaylandPresentationSupportKHR; #endif #ifdef VK_USE_PLATFORM_XCB_KHR + PFN_vkCreateXcbSurfaceKHR CreateXcbSurfaceKHR; PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR GetPhysicalDeviceXcbPresentationSupportKHR; #endif #ifdef VK_USE_PLATFORM_XLIB_KHR + PFN_vkCreateXlibSurfaceKHR CreateXlibSurfaceKHR; PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR GetPhysicalDeviceXlibPresentationSupportKHR; #endif @@ -235,39 +248,51 @@ struct loader_icd { PFN_vkGetDisplayPlaneCapabilitiesKHR GetDisplayPlaneCapabilitiesKHR; PFN_vkCreateDisplayPlaneSurfaceKHR CreateDisplayPlaneSurfaceKHR; PFN_vkDestroySurfaceKHR DestroySurfaceKHR; - struct loader_icd *next; + PFN_vkCreateSwapchainKHR CreateSwapchainKHR; + struct loader_icd_term *next; }; -/* per ICD library structure */ -struct loader_icd_libs { +// per ICD library structure +struct loader_icd_tramp_list { size_t capacity; uint32_t count; - struct loader_scanned_icds *list; + struct loader_scanned_icd *scanned_list; }; -/* per instance structure */ +union loader_instance_extension_enables { + struct { + uint8_t ext_debug_report : 1; + uint8_t nv_external_memory_capabilities : 1; + }; + uint64_t padding[4]; +}; + +// per instance structure struct loader_instance { VkLayerInstanceDispatchTable *disp; // must be first entry in structure - uint32_t total_gpu_count; // count of the next two arrays - struct loader_physical_device *phys_devs_term; - struct loader_physical_device_tramp * - phys_devs; // tramp wrapped physDev obj list - uint32_t total_icd_count; - struct loader_icd *icds; + uint32_t total_gpu_count; + struct loader_physical_device_term *phys_devs_term; + struct loader_physical_device_tramp *phys_devs_tramp; + struct loader_instance *next; - struct loader_extension_list ext_list; // icds and loaders extensions - struct loader_icd_libs icd_libs; - struct loader_layer_list instance_layer_list; + + uint32_t total_icd_count; + struct loader_icd_term *icd_terms; + struct loader_icd_tramp_list icd_tramp_list; + struct loader_dispatch_hash_entry disp_hash[MAX_NUM_DEV_EXTS]; struct loader_msg_callback_map_entry *icd_msg_callback_map; + struct loader_layer_list instance_layer_list; struct loader_layer_list activated_layer_list; bool activated_layers_are_std_val; VkInstance instance; // layers/ICD instance returned to trampoline - bool debug_report_enabled; + struct loader_extension_list ext_list; // icds and loaders extensions + union loader_instance_extension_enables enabled_known_extensions; + VkLayerDbgFunctionNode *DbgFunctionHead; uint32_t num_tmp_callbacks; VkDebugReportCallbackCreateInfoEXT *tmp_dbg_create_infos; @@ -298,7 +323,7 @@ struct loader_instance { }; /* VkPhysicalDevice requires special treatment by loader. Firstly, terminator - * code must be able to get the struct loader_icd to call into the proper + * code must be able to get the struct loader_icd_term to call into the proper * driver (multiple ICD/gpu case). This can be accomplished by wrapping the * created VkPhysicalDevice in loader terminate_EnumeratePhysicalDevices(). * Secondly, the loader must be able to handle wrapped by layer VkPhysicalDevice @@ -318,9 +343,10 @@ struct loader_physical_device_tramp { }; /* per enumerated PhysicalDevice structure, used to wrap in terminator code */ -struct loader_physical_device { +struct loader_physical_device_term { VkLayerInstanceDispatchTable *disp; // must be first entry in structure - struct loader_icd *this_icd; + struct loader_icd_term *this_icd_term; + uint8_t icd_index; VkPhysicalDevice phys_dev; // object from ICD }; @@ -328,7 +354,7 @@ struct loader_struct { struct loader_instance *instances; }; -struct loader_scanned_icds { +struct loader_scanned_icd { char *lib_name; loader_platform_dl_handle handle; uint32_t api_version; @@ -393,14 +419,22 @@ struct loader_msg_callback_map_entry { }; /* helper function definitions */ -void *loader_heap_alloc(const struct loader_instance *instance, size_t size, - VkSystemAllocationScope allocationScope); - -void loader_heap_free(const struct loader_instance *instance, void *pMemory); - -void *loader_tls_heap_alloc(size_t size); - -void loader_tls_heap_free(void *pMemory); +void *loader_instance_heap_alloc(const struct loader_instance *instance, + size_t size, + VkSystemAllocationScope allocationScope); +void loader_instance_heap_free(const struct loader_instance *instance, + void *pMemory); +void *loader_instance_heap_realloc(const struct loader_instance *instance, + void *pMemory, size_t orig_size, size_t size, + VkSystemAllocationScope alloc_scope); +void *loader_instance_tls_heap_alloc(size_t size); +void loader_instance_tls_heap_free(void *pMemory); +void *loader_device_heap_alloc(const struct loader_device *device, size_t size, + VkSystemAllocationScope allocationScope); +void loader_device_heap_free(const struct loader_device *device, void *pMemory); +void *loader_device_heap_realloc(const struct loader_device *device, + void *pMemory, size_t orig_size, size_t size, + VkSystemAllocationScope alloc_scope); void loader_log(const struct loader_instance *inst, VkFlags msg_type, int32_t msg_code, const char *format, ...); @@ -420,9 +454,9 @@ VkResult loader_validate_instance_extensions( const VkInstanceCreateInfo *pCreateInfo); void loader_initialize(void); -void loader_copy_layer_properties(const struct loader_instance *inst, - struct loader_layer_properties *dst, - struct loader_layer_properties *src); +VkResult loader_copy_layer_properties(const struct loader_instance *inst, + struct loader_layer_properties *dst, + struct loader_layer_properties *src); bool has_vk_extension_property_array(const VkExtensionProperties *vk_ext_prop, const uint32_t count, const VkExtensionProperties *ext_array); @@ -444,20 +478,21 @@ VkResult loader_add_device_extensions(const struct loader_instance *inst, VkPhysicalDevice physical_device, const char *lib_name, struct loader_extension_list *ext_list); -bool loader_init_generic_list(const struct loader_instance *inst, - struct loader_generic_list *list_info, - size_t element_size); +VkResult loader_init_generic_list(const struct loader_instance *inst, + struct loader_generic_list *list_info, + size_t element_size); void loader_destroy_generic_list(const struct loader_instance *inst, struct loader_generic_list *list); void loader_destroy_layer_list(const struct loader_instance *inst, + struct loader_device *device, struct loader_layer_list *layer_list); void loader_delete_layer_properties(const struct loader_instance *inst, struct loader_layer_list *layer_list); -bool loader_find_layer_name_array(const char *name, uint32_t layer_count, - const char layer_list[][VK_MAX_EXTENSION_NAME_SIZE]); -void loader_expand_layer_names( - struct loader_instance *inst, const char *key_name, - uint32_t expand_count, +bool loader_find_layer_name_array( + const char *name, uint32_t layer_count, + const char layer_list[][VK_MAX_EXTENSION_NAME_SIZE]); +VkResult loader_expand_layer_names( + struct loader_instance *inst, const char *key_name, uint32_t expand_count, const char expand_names[][VK_MAX_EXTENSION_NAME_SIZE], uint32_t *layer_count, char const *const **ppp_layer_names); void loader_init_std_validation_props(struct loader_layer_properties *props); @@ -467,42 +502,55 @@ void loader_delete_shadow_dev_layer_names(const struct loader_instance *inst, void loader_delete_shadow_inst_layer_names(const struct loader_instance *inst, const VkInstanceCreateInfo *orig, VkInstanceCreateInfo *ours); -void loader_add_to_layer_list(const struct loader_instance *inst, - struct loader_layer_list *list, - uint32_t prop_list_count, - const struct loader_layer_properties *props); +VkResult loader_add_to_layer_list(const struct loader_instance *inst, + struct loader_layer_list *list, + uint32_t prop_list_count, + const struct loader_layer_properties *props); void loader_find_layer_name_add_list( const struct loader_instance *inst, const char *name, const enum layer_type type, const struct loader_layer_list *search_list, struct loader_layer_list *found_list); void loader_scanned_icd_clear(const struct loader_instance *inst, - struct loader_icd_libs *icd_libs); -void loader_icd_scan(const struct loader_instance *inst, - struct loader_icd_libs *icds); + struct loader_icd_tramp_list *icd_tramp_list); +VkResult loader_icd_scan(const struct loader_instance *inst, + struct loader_icd_tramp_list *icd_tramp_list); void loader_layer_scan(const struct loader_instance *inst, struct loader_layer_list *instance_layers); void loader_implicit_layer_scan(const struct loader_instance *inst, struct loader_layer_list *instance_layers); -void loader_get_icd_loader_instance_extensions( - const struct loader_instance *inst, struct loader_icd_libs *icd_libs, +VkResult loader_get_icd_loader_instance_extensions( + const struct loader_instance *inst, + struct loader_icd_tramp_list *icd_tramp_list, struct loader_extension_list *inst_exts); -struct loader_icd *loader_get_icd_and_device(const VkDevice device, - struct loader_device **found_dev); +struct loader_icd_term * +loader_get_icd_and_device(const VkDevice device, + struct loader_device **found_dev, + uint32_t *icd_index); void loader_init_dispatch_dev_ext(struct loader_instance *inst, struct loader_device *dev); void *loader_dev_ext_gpa(struct loader_instance *inst, const char *funcName); void *loader_get_dev_ext_trampoline(uint32_t index); +void loader_override_terminating_device_proc(struct loader_device *dev); struct loader_instance *loader_get_instance(const VkInstance instance); void loader_deactivate_layers(const struct loader_instance *instance, + struct loader_device *device, struct loader_layer_list *list); struct loader_device * -loader_create_logical_device(const struct loader_instance *inst); +loader_create_logical_device(const struct loader_instance *inst, + const VkAllocationCallbacks *pAllocator); void loader_add_logical_device(const struct loader_instance *inst, - struct loader_icd *icd, + struct loader_icd_term *icd_term, struct loader_device *found_dev); void loader_remove_logical_device(const struct loader_instance *inst, - struct loader_icd *icd, - struct loader_device *found_dev); + struct loader_icd_term *icd_term, + struct loader_device *found_dev, + const VkAllocationCallbacks *pAllocator); +// NOTE: Outside of loader, this entry-point is only proivided for error +// cleanup. +void loader_destroy_logical_device(const struct loader_instance *inst, + struct loader_device *dev, + const VkAllocationCallbacks *pAllocator); + VkResult loader_enable_instance_layers(struct loader_instance *inst, const VkInstanceCreateInfo *pCreateInfo, diff --git a/third_party/vulkan/loader/premake5.lua b/third_party/vulkan/loader/premake5.lua index 35675f232..f38c9923e 100644 --- a/third_party/vulkan/loader/premake5.lua +++ b/third_party/vulkan/loader/premake5.lua @@ -6,6 +6,7 @@ project("vulkan-loader") defines({ "_LIB", + "API_NAME=\"vulkan\"", }) removedefines({ "_UNICODE", diff --git a/third_party/vulkan/loader/table_ops.h b/third_party/vulkan/loader/table_ops.h index 8a5f8df33..0e42d0ca8 100644 --- a/third_party/vulkan/loader/table_ops.h +++ b/third_party/vulkan/loader/table_ops.h @@ -31,10 +31,12 @@ static VkResult vkDevExtError(VkDevice dev) { struct loader_device *found_dev; - struct loader_icd *icd = loader_get_icd_and_device(dev, &found_dev); + // The device going in is a trampoline device + struct loader_icd_term *icd_term = + loader_get_icd_and_device(dev, &found_dev, NULL); - if (icd) - loader_log(icd->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, + if (icd_term) + loader_log(icd_term->this_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "Bad destination in loader trampoline dispatch," "Are layers and extensions that you are calling enabled?"); return VK_ERROR_EXTENSION_NOT_PRESENT; @@ -45,7 +47,7 @@ loader_init_device_dispatch_table(struct loader_dev_dispatch_table *dev_table, PFN_vkGetDeviceProcAddr gpa, VkDevice dev) { VkLayerDispatchTable *table = &dev_table->core_dispatch; for (uint32_t i = 0; i < MAX_NUM_DEV_EXTS; i++) - dev_table->ext_dispatch.DevExt[i] = (PFN_vkDevExt)vkDevExtError; + dev_table->ext_dispatch.dev_ext[i] = (PFN_vkDevExt)vkDevExtError; table->GetDeviceProcAddr = (PFN_vkGetDeviceProcAddr)gpa(dev, "vkGetDeviceProcAddr"); @@ -267,6 +269,27 @@ static inline void loader_init_device_extension_dispatch_table( (PFN_vkGetSwapchainImagesKHR)gpa(dev, "vkGetSwapchainImagesKHR"); table->QueuePresentKHR = (PFN_vkQueuePresentKHR)gpa(dev, "vkQueuePresentKHR"); + table->CmdDrawIndirectCountAMD = + (PFN_vkCmdDrawIndirectCountAMD)gpa(dev, "vkCmdDrawIndirectCountAMD"); + table->CmdDrawIndexedIndirectCountAMD = + (PFN_vkCmdDrawIndexedIndirectCountAMD)gpa( + dev, "vkCmdDrawIndexedIndirectCountAMD"); +#ifdef VK_USE_PLATFORM_WIN32_KHR + table->GetMemoryWin32HandleNV = + (PFN_vkGetMemoryWin32HandleNV)gpa(dev, "vkGetMemoryWin32HandleNV"); +#endif // VK_USE_PLATFORM_WIN32_KHR + table->CreateSharedSwapchainsKHR = + (PFN_vkCreateSharedSwapchainsKHR)gpa(dev, "vkCreateSharedSwapchainsKHR"); + table->DebugMarkerSetObjectTagEXT = + (PFN_vkDebugMarkerSetObjectTagEXT)gpa(dev, "vkDebugMarkerSetObjectTagEXT"); + table->DebugMarkerSetObjectNameEXT = + (PFN_vkDebugMarkerSetObjectNameEXT)gpa(dev, "vkDebugMarkerSetObjectNameEXT"); + table->CmdDebugMarkerBeginEXT = + (PFN_vkCmdDebugMarkerBeginEXT)gpa(dev, "vkCmdDebugMarkerBeginEXT"); + table->CmdDebugMarkerEndEXT = + (PFN_vkCmdDebugMarkerEndEXT)gpa(dev, "vkCmdDebugMarkerEndEXT"); + table->CmdDebugMarkerInsertEXT = + (PFN_vkCmdDebugMarkerInsertEXT)gpa(dev, "vkCmdDebugMarkerInsertEXT"); } static inline void * @@ -519,6 +542,29 @@ loader_lookup_device_dispatch_table(const VkLayerDispatchTable *table, if (!strcmp(name, "CmdExecuteCommands")) return (void *)table->CmdExecuteCommands; + if (!strcmp(name, "DestroySwapchainKHR")) + return (void *)table->DestroySwapchainKHR; + if (!strcmp(name, "GetSwapchainImagesKHR")) + return (void *)table->GetSwapchainImagesKHR; + if (!strcmp(name, "AcquireNextImageKHR")) + return (void *)table->AcquireNextImageKHR; + if (!strcmp(name, "QueuePresentKHR")) + return (void *)table->QueuePresentKHR; + + // NOTE: Device Funcs needing Trampoline/Terminator. + // Overrides for device functions needing a trampoline and + // a terminator because certain device entry-points still need to go + // through a terminator before hitting the ICD. This could be for + // several reasons, but the main one is currently unwrapping an + // object before passing the appropriate info along to the ICD. + if (!strcmp(name, "CreateSwapchainKHR")) { + return (void *)vkCreateSwapchainKHR; + } else if (!strcmp(name, "DebugMarkerSetObjectTagEXT")) { + return (void *)vkDebugMarkerSetObjectTagEXT; + } else if (!strcmp(name, "DebugMarkerSetObjectNameEXT")) { + return (void *)vkDebugMarkerSetObjectNameEXT; + } + return NULL; } @@ -584,6 +630,9 @@ static inline void loader_init_instance_extension_dispatch_table( table->GetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)gpa( inst, "vkGetPhysicalDeviceSurfacePresentModesKHR"); + table->GetPhysicalDeviceExternalImageFormatPropertiesNV = + (PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV)gpa( + inst, "vkGetPhysicalDeviceExternalImageFormatPropertiesNV"); #ifdef VK_USE_PLATFORM_MIR_KHR table->CreateMirSurfaceKHR = (PFN_vkCreateMirSurfaceKHR)gpa(inst, "vkCreateMirSurfaceKHR"); @@ -684,6 +733,8 @@ loader_lookup_instance_dispatch_table(const VkLayerInstanceDispatchTable *table, return (void *)table->GetPhysicalDeviceSurfaceFormatsKHR; if (!strcmp(name, "GetPhysicalDeviceSurfacePresentModesKHR")) return (void *)table->GetPhysicalDeviceSurfacePresentModesKHR; + if (!strcmp(name, "GetPhysicalDeviceExternalImageFormatPropertiesNV")) + return (void *)table->GetPhysicalDeviceExternalImageFormatPropertiesNV; #ifdef VK_USE_PLATFORM_MIR_KHR if (!strcmp(name, "CreateMirSurfaceKHR")) return (void *)table->CreateMirSurfaceKHR; diff --git a/third_party/vulkan/loader/trampoline.c b/third_party/vulkan/loader/trampoline.c index 8b1117d09..91da1e426 100644 --- a/third_party/vulkan/loader/trampoline.c +++ b/third_party/vulkan/loader/trampoline.c @@ -30,6 +30,7 @@ #include "loader.h" #include "debug_report.h" #include "wsi.h" +#include "extensions.h" #include "gpa_helper.h" #include "table_ops.h" @@ -120,8 +121,9 @@ vkEnumerateInstanceExtensionProperties(const char *pLayerName, struct loader_extension_list *global_ext_list = NULL; struct loader_layer_list instance_layers; struct loader_extension_list local_ext_list; - struct loader_icd_libs icd_libs; + struct loader_icd_tramp_list icd_tramp_list; uint32_t copy_size; + VkResult res = VK_SUCCESS; tls_instance = NULL; memset(&local_ext_list, 0, sizeof(local_ext_list)); @@ -134,7 +136,8 @@ vkEnumerateInstanceExtensionProperties(const char *pLayerName, VK_STRING_ERROR_NONE) { assert(VK_FALSE && "vkEnumerateInstanceExtensionProperties: " "pLayerName is too long or is badly formed"); - return VK_ERROR_EXTENSION_NOT_PRESENT; + res = VK_ERROR_EXTENSION_NOT_PRESENT; + goto out; } loader_layer_scan(NULL, &instance_layers); @@ -154,7 +157,7 @@ vkEnumerateInstanceExtensionProperties(const char *pLayerName, loader_add_to_ext_list(NULL, &local_ext_list, ext_list->count, ext_list->list); } - loader_destroy_layer_list(NULL, &local_list); + loader_destroy_layer_list(NULL, NULL, &local_list); global_ext_list = &local_ext_list; } else { @@ -169,12 +172,18 @@ vkEnumerateInstanceExtensionProperties(const char *pLayerName, } } else { /* Scan/discover all ICD libraries */ - memset(&icd_libs, 0, sizeof(struct loader_icd_libs)); - loader_icd_scan(NULL, &icd_libs); + memset(&icd_tramp_list, 0, sizeof(struct loader_icd_tramp_list)); + res = loader_icd_scan(NULL, &icd_tramp_list); + if (VK_SUCCESS != res) { + goto out; + } /* get extensions from all ICD's, merge so no duplicates */ - loader_get_icd_loader_instance_extensions(NULL, &icd_libs, - &local_ext_list); - loader_scanned_icd_clear(NULL, &icd_libs); + res = loader_get_icd_loader_instance_extensions(NULL, &icd_tramp_list, + &local_ext_list); + if (VK_SUCCESS != res) { + goto out; + } + loader_scanned_icd_clear(NULL, &icd_tramp_list); // Append implicit layers. loader_implicit_layer_scan(NULL, &instance_layers); @@ -189,16 +198,13 @@ vkEnumerateInstanceExtensionProperties(const char *pLayerName, } if (global_ext_list == NULL) { - loader_destroy_layer_list(NULL, &instance_layers); - return VK_ERROR_LAYER_NOT_PRESENT; + res = VK_ERROR_LAYER_NOT_PRESENT; + goto out; } if (pProperties == NULL) { *pPropertyCount = global_ext_list->count; - loader_destroy_layer_list(NULL, &instance_layers); - loader_destroy_generic_list( - NULL, (struct loader_generic_list *)&local_ext_list); - return VK_SUCCESS; + goto out; } copy_size = *pPropertyCount < global_ext_list->count @@ -209,21 +215,21 @@ vkEnumerateInstanceExtensionProperties(const char *pLayerName, sizeof(VkExtensionProperties)); } *pPropertyCount = copy_size; - loader_destroy_generic_list(NULL, - (struct loader_generic_list *)&local_ext_list); if (copy_size < global_ext_list->count) { - loader_destroy_layer_list(NULL, &instance_layers); - return VK_INCOMPLETE; + res = VK_INCOMPLETE; + goto out; } - loader_destroy_layer_list(NULL, &instance_layers); - return VK_SUCCESS; +out: + loader_destroy_generic_list(NULL, + (struct loader_generic_list *)&local_ext_list); + loader_delete_layer_properties(NULL, &instance_layers); + return res; } -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL -vkEnumerateInstanceLayerProperties(uint32_t *pPropertyCount, - VkLayerProperties *pProperties) { +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties( + uint32_t *pPropertyCount, VkLayerProperties *pProperties) { struct loader_layer_list instance_layer_list; tls_instance = NULL; @@ -238,7 +244,7 @@ vkEnumerateInstanceLayerProperties(uint32_t *pPropertyCount, if (pProperties == NULL) { *pPropertyCount = instance_layer_list.count; - loader_destroy_layer_list(NULL, &instance_layer_list); + loader_destroy_layer_list(NULL, NULL, &instance_layer_list); return VK_SUCCESS; } @@ -251,50 +257,54 @@ vkEnumerateInstanceLayerProperties(uint32_t *pPropertyCount, } *pPropertyCount = copy_size; - loader_destroy_layer_list(NULL, &instance_layer_list); if (copy_size < instance_layer_list.count) { + loader_destroy_layer_list(NULL, NULL, &instance_layer_list); return VK_INCOMPLETE; } + loader_destroy_layer_list(NULL, NULL, &instance_layer_list); + return VK_SUCCESS; } -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL -vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkInstance *pInstance) { +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance( + const VkInstanceCreateInfo *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkInstance *pInstance) { struct loader_instance *ptr_instance = NULL; VkInstance created_instance = VK_NULL_HANDLE; + bool loaderLocked = false; VkResult res = VK_ERROR_INITIALIZATION_FAILED; loader_platform_thread_once(&once_init, loader_initialize); - //TODO start handling the pAllocators again -#if 0 - if (pAllocator) { - ptr_instance = (struct loader_instance *) pAllocator->pfnAllocation( - pAllocator->pUserData, - sizeof(struct loader_instance), - sizeof(int *), - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); +#if (DEBUG_DISABLE_APP_ALLOCATORS == 1) + { +#else + if (pAllocator) { + ptr_instance = (struct loader_instance *)pAllocator->pfnAllocation( + pAllocator->pUserData, sizeof(struct loader_instance), + sizeof(int *), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); } else { #endif - ptr_instance = - (struct loader_instance *)malloc(sizeof(struct loader_instance)); - //} + ptr_instance = + (struct loader_instance *)malloc(sizeof(struct loader_instance)); + } + + VkInstanceCreateInfo ici = *pCreateInfo; + if (ptr_instance == NULL) { - return VK_ERROR_OUT_OF_HOST_MEMORY; + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } tls_instance = ptr_instance; loader_platform_thread_lock_mutex(&loader_lock); + loaderLocked = true; memset(ptr_instance, 0, sizeof(struct loader_instance)); -#if 0 if (pAllocator) { ptr_instance->alloc_callbacks = *pAllocator; } -#endif /* * Look for one or more debug report create info structures @@ -309,9 +319,8 @@ vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, &ptr_instance->tmp_callbacks)) { // One or more were found, but allocation failed. Therefore, clean up // and fail this function: - loader_heap_free(ptr_instance, ptr_instance); - loader_platform_thread_unlock_mutex(&loader_lock); - return VK_ERROR_OUT_OF_HOST_MEMORY; + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } else if (ptr_instance->num_tmp_callbacks > 0) { // Setup the temporary callback(s) here to catch early issues: if (util_CreateDebugReportCallbacks(ptr_instance, pAllocator, @@ -320,12 +329,8 @@ vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, ptr_instance->tmp_callbacks)) { // Failure of setting up one or more of the callback. Therefore, // clean up and fail this function: - util_FreeDebugReportCreateInfos(pAllocator, - ptr_instance->tmp_dbg_create_infos, - ptr_instance->tmp_callbacks); - loader_heap_free(ptr_instance, ptr_instance); - loader_platform_thread_unlock_mutex(&loader_lock); - return VK_ERROR_OUT_OF_HOST_MEMORY; + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } } @@ -343,75 +348,47 @@ vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, pCreateInfo->ppEnabledLayerNames, &ptr_instance->instance_layer_list); if (res != VK_SUCCESS) { - util_DestroyDebugReportCallbacks(ptr_instance, pAllocator, - ptr_instance->num_tmp_callbacks, - ptr_instance->tmp_callbacks); - util_FreeDebugReportCreateInfos(pAllocator, - ptr_instance->tmp_dbg_create_infos, - ptr_instance->tmp_callbacks); - loader_heap_free(ptr_instance, ptr_instance); - loader_platform_thread_unlock_mutex(&loader_lock); - return res; + goto out; } } /* convert any meta layers to the actual layers makes a copy of layer name*/ - VkInstanceCreateInfo ici = *pCreateInfo; - loader_expand_layer_names( + VkResult layerErr = loader_expand_layer_names( ptr_instance, std_validation_str, sizeof(std_validation_names) / sizeof(std_validation_names[0]), std_validation_names, &ici.enabledLayerCount, &ici.ppEnabledLayerNames); + if (VK_SUCCESS != layerErr) { + res = layerErr; + goto out; + } /* Scan/discover all ICD libraries */ - memset(&ptr_instance->icd_libs, 0, sizeof(ptr_instance->icd_libs)); - loader_icd_scan(ptr_instance, &ptr_instance->icd_libs); + memset(&ptr_instance->icd_tramp_list, 0, + sizeof(ptr_instance->icd_tramp_list)); + res = loader_icd_scan(ptr_instance, &ptr_instance->icd_tramp_list); + if (res != VK_SUCCESS) { + goto out; + } /* get extensions from all ICD's, merge so no duplicates, then validate */ - loader_get_icd_loader_instance_extensions( - ptr_instance, &ptr_instance->icd_libs, &ptr_instance->ext_list); + res = loader_get_icd_loader_instance_extensions( + ptr_instance, &ptr_instance->icd_tramp_list, &ptr_instance->ext_list); + if (res != VK_SUCCESS) { + goto out; + } res = loader_validate_instance_extensions( ptr_instance, &ptr_instance->ext_list, &ptr_instance->instance_layer_list, &ici); if (res != VK_SUCCESS) { - loader_delete_shadow_inst_layer_names(ptr_instance, pCreateInfo, &ici); - loader_delete_layer_properties(ptr_instance, - &ptr_instance->instance_layer_list); - loader_scanned_icd_clear(ptr_instance, &ptr_instance->icd_libs); - loader_destroy_generic_list( - ptr_instance, - (struct loader_generic_list *)&ptr_instance->ext_list); - util_DestroyDebugReportCallbacks(ptr_instance, pAllocator, - ptr_instance->num_tmp_callbacks, - ptr_instance->tmp_callbacks); - util_FreeDebugReportCreateInfos(pAllocator, - ptr_instance->tmp_dbg_create_infos, - ptr_instance->tmp_callbacks); - loader_platform_thread_unlock_mutex(&loader_lock); - loader_heap_free(ptr_instance, ptr_instance); - return res; + goto out; } - ptr_instance->disp = - loader_heap_alloc(ptr_instance, sizeof(VkLayerInstanceDispatchTable), - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + ptr_instance->disp = loader_instance_heap_alloc( + ptr_instance, sizeof(VkLayerInstanceDispatchTable), + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (ptr_instance->disp == NULL) { - loader_delete_shadow_inst_layer_names(ptr_instance, pCreateInfo, &ici); - - loader_delete_layer_properties(ptr_instance, - &ptr_instance->instance_layer_list); - loader_scanned_icd_clear(ptr_instance, &ptr_instance->icd_libs); - loader_destroy_generic_list( - ptr_instance, - (struct loader_generic_list *)&ptr_instance->ext_list); - util_DestroyDebugReportCallbacks(ptr_instance, pAllocator, - ptr_instance->num_tmp_callbacks, - ptr_instance->tmp_callbacks); - util_FreeDebugReportCreateInfos(pAllocator, - ptr_instance->tmp_dbg_create_infos, - ptr_instance->tmp_callbacks); - loader_platform_thread_unlock_mutex(&loader_lock); - loader_heap_free(ptr_instance, ptr_instance); - return VK_ERROR_OUT_OF_HOST_MEMORY; + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } memcpy(ptr_instance->disp, &instance_disp, sizeof(instance_disp)); ptr_instance->next = loader.instances; @@ -421,24 +398,7 @@ vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, res = loader_enable_instance_layers(ptr_instance, &ici, &ptr_instance->instance_layer_list); if (res != VK_SUCCESS) { - loader_delete_shadow_inst_layer_names(ptr_instance, pCreateInfo, &ici); - loader_delete_layer_properties(ptr_instance, - &ptr_instance->instance_layer_list); - loader_scanned_icd_clear(ptr_instance, &ptr_instance->icd_libs); - loader_destroy_generic_list( - ptr_instance, - (struct loader_generic_list *)&ptr_instance->ext_list); - loader.instances = ptr_instance->next; - util_DestroyDebugReportCallbacks(ptr_instance, pAllocator, - ptr_instance->num_tmp_callbacks, - ptr_instance->tmp_callbacks); - util_FreeDebugReportCreateInfos(pAllocator, - ptr_instance->tmp_dbg_create_infos, - ptr_instance->tmp_callbacks); - loader_platform_thread_unlock_mutex(&loader_lock); - loader_heap_free(ptr_instance, ptr_instance->disp); - loader_heap_free(ptr_instance, ptr_instance); - return res; + goto out; } created_instance = (VkInstance)ptr_instance; @@ -448,6 +408,7 @@ vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, if (res == VK_SUCCESS) { wsi_create_instance(ptr_instance, &ici); debug_report_create_instance(ptr_instance, &ici); + extensions_create_instance(ptr_instance, &ici); *pInstance = created_instance; @@ -458,22 +419,60 @@ vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, * if enabled. */ loader_activate_instance_layer_extensions(ptr_instance, *pInstance); - } else { - // TODO: cleanup here. } - /* Remove temporary debug_report callback */ - util_DestroyDebugReportCallbacks(ptr_instance, pAllocator, - ptr_instance->num_tmp_callbacks, - ptr_instance->tmp_callbacks); - loader_delete_shadow_inst_layer_names(ptr_instance, pCreateInfo, &ici); - loader_platform_thread_unlock_mutex(&loader_lock); +out: + + if (NULL != ptr_instance) { + if (res != VK_SUCCESS) { + if (NULL != ptr_instance->next) { + loader.instances = ptr_instance->next; + } + if (NULL != ptr_instance->disp) { + loader_instance_heap_free(ptr_instance, ptr_instance->disp); + } + if (ptr_instance->num_tmp_callbacks > 0) { + util_DestroyDebugReportCallbacks( + ptr_instance, pAllocator, ptr_instance->num_tmp_callbacks, + ptr_instance->tmp_callbacks); + util_FreeDebugReportCreateInfos( + pAllocator, ptr_instance->tmp_dbg_create_infos, + ptr_instance->tmp_callbacks); + } + + loader_deactivate_layers(ptr_instance, NULL, + &ptr_instance->activated_layer_list); + + loader_delete_shadow_inst_layer_names(ptr_instance, pCreateInfo, + &ici); + loader_delete_layer_properties(ptr_instance, + &ptr_instance->instance_layer_list); + loader_scanned_icd_clear(ptr_instance, + &ptr_instance->icd_tramp_list); + loader_destroy_generic_list( + ptr_instance, + (struct loader_generic_list *)&ptr_instance->ext_list); + + loader_instance_heap_free(ptr_instance, ptr_instance); + } else { + /* Remove temporary debug_report callback */ + util_DestroyDebugReportCallbacks(ptr_instance, pAllocator, + ptr_instance->num_tmp_callbacks, + ptr_instance->tmp_callbacks); + loader_delete_shadow_inst_layer_names(ptr_instance, pCreateInfo, + &ici); + } + + if (loaderLocked) { + loader_platform_thread_unlock_mutex(&loader_lock); + } + } + return res; } -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL -vkDestroyInstance(VkInstance instance, - const VkAllocationCallbacks *pAllocator) { +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyInstance( + VkInstance instance, const VkAllocationCallbacks *pAllocator) { const VkLayerInstanceDispatchTable *disp; struct loader_instance *ptr_instance = NULL; bool callback_setup = false; @@ -488,6 +487,10 @@ vkDestroyInstance(VkInstance instance, ptr_instance = loader_get_instance(instance); + if (pAllocator) { + ptr_instance->alloc_callbacks = *pAllocator; + } + if (ptr_instance->num_tmp_callbacks > 0) { // Setup the temporary callback(s) here to catch cleanup issues: if (!util_CreateDebugReportCallbacks(ptr_instance, pAllocator, @@ -500,9 +503,11 @@ vkDestroyInstance(VkInstance instance, disp->DestroyInstance(instance, pAllocator); - loader_deactivate_layers(ptr_instance, &ptr_instance->activated_layer_list); - if (ptr_instance->phys_devs) - loader_heap_free(ptr_instance, ptr_instance->phys_devs); + loader_deactivate_layers(ptr_instance, NULL, + &ptr_instance->activated_layer_list); + if (ptr_instance->phys_devs_tramp) { + loader_instance_heap_free(ptr_instance, ptr_instance->phys_devs_tramp); + } if (callback_setup) { util_DestroyDebugReportCallbacks(ptr_instance, pAllocator, ptr_instance->num_tmp_callbacks, @@ -511,8 +516,8 @@ vkDestroyInstance(VkInstance instance, ptr_instance->tmp_dbg_create_infos, ptr_instance->tmp_callbacks); } - loader_heap_free(ptr_instance, ptr_instance->disp); - loader_heap_free(ptr_instance, ptr_instance); + loader_instance_heap_free(ptr_instance, ptr_instance->disp); + loader_instance_heap_free(ptr_instance, ptr_instance); loader_platform_thread_unlock_mutex(&loader_lock); } @@ -549,14 +554,14 @@ vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, ? inst->total_gpu_count : *pPhysicalDeviceCount; *pPhysicalDeviceCount = count; - if (!inst->phys_devs) { - inst->phys_devs = - (struct loader_physical_device_tramp *)loader_heap_alloc( + if (NULL == inst->phys_devs_tramp) { + inst->phys_devs_tramp = + (struct loader_physical_device_tramp *)loader_instance_heap_alloc( inst, inst->total_gpu_count * sizeof(struct loader_physical_device_tramp), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); } - if (!inst->phys_devs) { + if (NULL == inst->phys_devs_tramp) { loader_platform_thread_unlock_mutex(&loader_lock); return VK_ERROR_OUT_OF_HOST_MEMORY; } @@ -564,20 +569,19 @@ vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, for (i = 0; i < count; i++) { // initialize the loader's physicalDevice object - loader_set_dispatch((void *)&inst->phys_devs[i], inst->disp); - inst->phys_devs[i].this_instance = inst; - inst->phys_devs[i].phys_dev = pPhysicalDevices[i]; + loader_set_dispatch((void *)&inst->phys_devs_tramp[i], inst->disp); + inst->phys_devs_tramp[i].this_instance = inst; + inst->phys_devs_tramp[i].phys_dev = pPhysicalDevices[i]; // copy wrapped object into Application provided array - pPhysicalDevices[i] = (VkPhysicalDevice)&inst->phys_devs[i]; + pPhysicalDevices[i] = (VkPhysicalDevice)&inst->phys_devs_tramp[i]; } loader_platform_thread_unlock_mutex(&loader_lock); return res; } -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL -vkGetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceFeatures *pFeatures) { +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures( + VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures *pFeatures) { const VkLayerInstanceDispatchTable *disp; VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); @@ -585,10 +589,9 @@ vkGetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, disp->GetPhysicalDeviceFeatures(unwrapped_phys_dev, pFeatures); } -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL -vkGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, - VkFormat format, - VkFormatProperties *pFormatInfo) { +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties( + VkPhysicalDevice physicalDevice, VkFormat format, + VkFormatProperties *pFormatInfo) { const VkLayerInstanceDispatchTable *disp; VkPhysicalDevice unwrapped_pd = loader_unwrap_physical_device(physicalDevice); @@ -610,9 +613,8 @@ vkGetPhysicalDeviceImageFormatProperties( pImageFormatProperties); } -LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL -vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, - VkPhysicalDeviceProperties *pProperties) { +LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties( + VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties *pProperties) { const VkLayerInstanceDispatchTable *disp; VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); @@ -643,14 +645,13 @@ LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties( pMemoryProperties); } -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL -vkCreateDevice(VkPhysicalDevice physicalDevice, - const VkDeviceCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) { +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice( + VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) { VkResult res; - struct loader_physical_device_tramp *phys_dev; - struct loader_device *dev; - struct loader_instance *inst; + struct loader_physical_device_tramp *phys_dev = NULL; + struct loader_device *dev = NULL; + struct loader_instance *inst = NULL; assert(pCreateInfo->queueCreateInfoCount >= 1); @@ -661,66 +662,78 @@ vkCreateDevice(VkPhysicalDevice physicalDevice, /* Get the physical device (ICD) extensions */ struct loader_extension_list icd_exts; - if (!loader_init_generic_list(inst, (struct loader_generic_list *)&icd_exts, - sizeof(VkExtensionProperties))) { - loader_platform_thread_unlock_mutex(&loader_lock); - return VK_ERROR_OUT_OF_HOST_MEMORY; + icd_exts.list = NULL; + res = + loader_init_generic_list(inst, (struct loader_generic_list *)&icd_exts, + sizeof(VkExtensionProperties)); + if (VK_SUCCESS != res) { + goto out; } res = loader_add_device_extensions( inst, inst->disp->EnumerateDeviceExtensionProperties, phys_dev->phys_dev, "Unknown", &icd_exts); if (res != VK_SUCCESS) { - loader_platform_thread_unlock_mutex(&loader_lock); - return res; + goto out; } /* make sure requested extensions to be enabled are supported */ - res = loader_validate_device_extensions(phys_dev, &inst->activated_layer_list, - &icd_exts, pCreateInfo); + res = loader_validate_device_extensions( + phys_dev, &inst->activated_layer_list, &icd_exts, pCreateInfo); if (res != VK_SUCCESS) { - loader_platform_thread_unlock_mutex(&loader_lock); - return res; + goto out; } - dev = loader_create_logical_device(inst); + dev = loader_create_logical_device(inst, pAllocator); if (dev == NULL) { - loader_platform_thread_unlock_mutex(&loader_lock); - return VK_ERROR_OUT_OF_HOST_MEMORY; + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } /* copy the instance layer list into the device */ dev->activated_layer_list.capacity = inst->activated_layer_list.capacity; dev->activated_layer_list.count = inst->activated_layer_list.count; - dev->activated_layer_list.list = loader_heap_alloc(inst, - inst->activated_layer_list.capacity, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + dev->activated_layer_list.list = + loader_device_heap_alloc(dev, inst->activated_layer_list.capacity, + VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); if (dev->activated_layer_list.list == NULL) { - loader_platform_thread_unlock_mutex(&loader_lock); - return VK_ERROR_OUT_OF_HOST_MEMORY; + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } memcpy(dev->activated_layer_list.list, inst->activated_layer_list.list, - sizeof(*dev->activated_layer_list.list) * dev->activated_layer_list.count); + sizeof(*dev->activated_layer_list.list) * + dev->activated_layer_list.count); - - res = loader_create_device_chain(phys_dev, pCreateInfo, pAllocator, inst, dev); + res = loader_create_device_chain(phys_dev, pCreateInfo, pAllocator, inst, + dev); if (res != VK_SUCCESS) { - loader_platform_thread_unlock_mutex(&loader_lock); - return res; + goto out; } - *pDevice = dev->device; + *pDevice = dev->chain_device; - /* initialize any device extension dispatch entry's from the instance list*/ + // Initialize any device extension dispatch entry's from the instance list loader_init_dispatch_dev_ext(inst, dev); - /* initialize WSI device extensions as part of core dispatch since loader - * has - * dedicated trampoline code for these*/ + // Initialize WSI device extensions as part of core dispatch since loader + // has dedicated trampoline code for these*/ loader_init_device_extension_dispatch_table( &dev->loader_dispatch, dev->loader_dispatch.core_dispatch.GetDeviceProcAddr, *pDevice); +out: + + // Failure cleanup + if (VK_SUCCESS != res) { + if (NULL != dev) { + loader_destroy_logical_device(inst, dev, pAllocator); + } + } + + if (NULL != icd_exts.list) { + loader_destroy_generic_list(inst, + (struct loader_generic_list *)&icd_exts); + } loader_platform_thread_unlock_mutex(&loader_lock); return res; } @@ -736,13 +749,15 @@ vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { loader_platform_thread_lock_mutex(&loader_lock); - struct loader_icd *icd = loader_get_icd_and_device(device, &dev); - const struct loader_instance *inst = icd->this_instance; + struct loader_icd_term *icd_term = + loader_get_icd_and_device(device, &dev, NULL); + const struct loader_instance *inst = icd_term->this_instance; disp = loader_get_dispatch(device); disp->DestroyDevice(device, pAllocator); - dev->device = NULL; - loader_remove_logical_device(inst, icd, dev); + dev->chain_device = NULL; + dev->icd_device = NULL; + loader_remove_logical_device(inst, icd_term, dev, pAllocator); loader_platform_thread_unlock_mutex(&loader_lock); } @@ -786,8 +801,8 @@ vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, i++) { loader_find_layer_name_add_list( NULL, std_validation_names[i], - VK_LAYER_TYPE_INSTANCE_EXPLICIT, &inst->instance_layer_list, - &local_list); + VK_LAYER_TYPE_INSTANCE_EXPLICIT, + &inst->instance_layer_list, &local_list); } for (uint32_t i = 0; i < local_list.count; i++) { struct loader_device_extension_list *ext_list = @@ -880,7 +895,7 @@ vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, enabled_layers->count = count; enabled_layers->capacity = enabled_layers->count * sizeof(struct loader_layer_properties); - enabled_layers->list = loader_heap_alloc(inst, enabled_layers->capacity, + enabled_layers->list = loader_instance_heap_alloc(inst, enabled_layers->capacity, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (!enabled_layers->list) return VK_ERROR_OUT_OF_HOST_MEMORY; @@ -893,14 +908,21 @@ vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, std_val_count, std_validation_names)) { struct loader_layer_properties props; loader_init_std_validation_props(&props); - loader_copy_layer_properties(inst, - &enabled_layers->list[j], &props); + VkResult err = loader_copy_layer_properties(inst, + &enabled_layers->list[j], + &props); + if (err != VK_SUCCESS) { + return err; + } i += std_val_count; } else { - loader_copy_layer_properties(inst, - &enabled_layers->list[j], - &inst->activated_layer_list.list[i++]); + VkResult err = loader_copy_layer_properties(inst, + &enabled_layers->list[j], + &inst->activated_layer_list.list[i++]); + if (err != VK_SUCCESS) { + return err; + } } } } @@ -916,8 +938,9 @@ vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, } *pPropertyCount = copy_size; - if (inst->activated_layers_are_std_val) + if (inst->activated_layers_are_std_val) { loader_delete_layer_properties(inst, enabled_layers); + } if (copy_size < count) { loader_platform_thread_unlock_mutex(&loader_lock); return VK_INCOMPLETE; @@ -2014,7 +2037,7 @@ vkCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, - const uint32_t *pData) { + const void *pData) { const VkLayerDispatchTable *disp; disp = loader_get_dispatch(commandBuffer); diff --git a/third_party/vulkan/loader/vk_loader_platform.h b/third_party/vulkan/loader/vk_loader_platform.h index c94e33c0d..0ffc92384 100644 --- a/third_party/vulkan/loader/vk_loader_platform.h +++ b/third_party/vulkan/loader/vk_loader_platform.h @@ -50,69 +50,66 @@ #define PATH_SEPERATOR ':' #define DIRECTORY_SYMBOL '/' -#define VULKAN_ICDCONF_DIR \ - "/" \ - "vulkan" \ - "/" \ - "icd.d" -#define VULKAN_ICD_DIR \ - "/" \ - "vulkan" \ - "/" \ - "icd" -#define VULKAN_ELAYERCONF_DIR \ - "/" \ - "vulkan" \ - "/" \ - "explicit_layer.d" -#define VULKAN_ILAYERCONF_DIR \ - "/" \ - "vulkan" \ - "/" \ - "implicit_layer.d" -#define VULKAN_LAYER_DIR \ - "/" \ - "vulkan" \ - "/" \ - "layer" +#define VULKAN_DIR "/vulkan/" +#define VULKAN_ICDCONF_DIR "icd.d" +#define VULKAN_ICD_DIR "icd" +#define VULKAN_ELAYERCONF_DIR "explicit_layer.d" +#define VULKAN_ILAYERCONF_DIR "implicit_layer.d" +#define VULKAN_LAYER_DIR "layer" -#if defined(LOCALPREFIX) -#define LOCAL_DRIVERS_INFO \ - LOCALPREFIX "/" SYSCONFDIR VULKAN_ICDCONF_DIR ":" LOCALPREFIX \ - "/" DATADIR VULKAN_ICDCONF_DIR ":" -#define LOCAL_ELAYERS_INFO \ - LOCALPREFIX "/" SYSCONFDIR VULKAN_ELAYERCONF_DIR ":" LOCALPREFIX \ - "/" DATADIR VULKAN_ELAYERCONF_DIR ":" -#define LOCAL_ILAYERS_INFO \ - LOCALPREFIX "/" SYSCONFDIR VULKAN_ILAYERCONF_DIR ":" LOCALPREFIX \ - "/" DATADIR VULKAN_ILAYERCONF_DIR ":" +#if defined(EXTRASYSCONFDIR) +#define EXTRA_DRIVERS_SYSCONFDIR_INFO ":" \ + EXTRASYSCONFDIR VULKAN_DIR VULKAN_ICDCONF_DIR +#define EXTRA_ELAYERS_SYSCONFDIR_INFO ":" \ + EXTRASYSCONFDIR VULKAN_DIR VULKAN_ELAYERCONF_DIR +#define EXTRA_ILAYERS_SYSCONFDIR_INFO ":" \ + EXTRASYSCONFDIR VULKAN_DIR VULKAN_ILAYERCONF_DIR #else -#define LOCAL_DRIVERS_INFO -#define LOCAL_ELAYERS_INFO -#define LOCAL_ILAYERS_INFO +#define EXTRA_DRIVERS_SYSCONFDIR_INFO +#define EXTRA_ELAYERS_SYSCONFDIR_INFO +#define EXTRA_ILAYERS_SYSCONFDIR_INFO +#endif + +#if defined(EXTRADATADIR) +#define EXTRA_DRIVERS_DATADIR_INFO ":" \ + EXTRADATADIR VULKAN_DIR VULKAN_ICDCONF_DIR +#define EXTRA_ELAYERS_DATADIR_INFO ":" \ + EXTRADATADIR VULKAN_DIR VULKAN_ELAYERCONF_DIR +#define EXTRA_ILAYERS_DATADIR_INFO ":" \ + EXTRADATADIR VULKAN_DIR VULKAN_ILAYERCONF_DIR +#else +#define EXTRA_DRIVERS_DATADIR_INFO +#define EXTRA_ELAYERS_DATADIR_INFO +#define EXTRA_ILAYERS_DATADIR_INFO #endif #define DEFAULT_VK_DRIVERS_INFO \ - LOCAL_DRIVERS_INFO \ - "/" SYSCONFDIR VULKAN_ICDCONF_DIR ":" \ - "/usr/" DATADIR VULKAN_ICDCONF_DIR -#define DEFAULT_VK_DRIVERS_PATH "" + SYSCONFDIR VULKAN_DIR VULKAN_ICDCONF_DIR ":" \ + DATADIR VULKAN_DIR VULKAN_ICDCONF_DIR \ + EXTRA_DRIVERS_SYSCONFDIR_INFO \ + EXTRA_DRIVERS_DATADIR_INFO #define DEFAULT_VK_ELAYERS_INFO \ - LOCAL_ELAYERS_INFO \ - "/" SYSCONFDIR VULKAN_ELAYERCONF_DIR ":" \ - "/usr/" DATADIR VULKAN_ELAYERCONF_DIR + SYSCONFDIR VULKAN_DIR VULKAN_ELAYERCONF_DIR ":" \ + DATADIR VULKAN_DIR VULKAN_ELAYERCONF_DIR \ + EXTRA_ELAYERS_SYSCONFDIR_INFO \ + EXTRA_ELAYERS_DATADIR_INFO #define DEFAULT_VK_ILAYERS_INFO \ - LOCAL_ILAYERS_INFO \ - "/" SYSCONFDIR VULKAN_ILAYERCONF_DIR ":" \ - "/usr/" DATADIR VULKAN_ILAYERCONF_DIR + SYSCONFDIR VULKAN_DIR VULKAN_ILAYERCONF_DIR ":" \ + DATADIR VULKAN_DIR VULKAN_ILAYERCONF_DIR \ + EXTRA_ILAYERS_SYSCONFDIR_INFO \ + EXTRA_ILAYERS_DATADIR_INFO + +#define DEFAULT_VK_DRIVERS_PATH "" #define DEFAULT_VK_LAYERS_PATH "" + #if !defined(LAYERS_SOURCE_PATH) #define LAYERS_SOURCE_PATH NULL #endif #define LAYERS_PATH_ENV "VK_LAYER_PATH" -#define HOME_VK_DRIVERS_INFO "/.local/share" VULKAN_ICDCONF_DIR -#define HOME_VK_ELAYERS_INFO "/.local/share" VULKAN_ELAYERCONF_DIR -#define HOME_VK_ILAYERS_INFO "/.local/share" VULKAN_ILAYERCONF_DIR + +#define HOME_VK_DRIVERS_INFO VULKAN_DIR VULKAN_ICDCONF_DIR +#define HOME_VK_ELAYERS_INFO VULKAN_DIR VULKAN_ELAYERCONF_DIR +#define HOME_VK_ILAYERS_INFO VULKAN_DIR VULKAN_ILAYERCONF_DIR // C99: #define PRINTF_SIZE_T_SPECIFIER "%zu" @@ -136,12 +133,6 @@ static inline char *loader_platform_dirname(char *path) { return dirname(path); } -// Environment variables - -static inline char *loader_getenv(const char *name) { return getenv(name); } - -static inline void loader_free_getenv(const char *val) {} - // Dynamic Loading of libraries: typedef void *loader_platform_dl_handle; static inline loader_platform_dl_handle @@ -248,11 +239,10 @@ using namespace std; #define PATH_SEPERATOR ';' #define DIRECTORY_SYMBOL '\\' #define DEFAULT_VK_REGISTRY_HIVE HKEY_LOCAL_MACHINE -#define DEFAULT_VK_DRIVERS_INFO "SOFTWARE\\Khronos\\Vulkan\\Drivers" -// TODO: Are these the correct paths +#define DEFAULT_VK_DRIVERS_INFO "SOFTWARE\\Khronos\\" API_NAME "\\Drivers" #define DEFAULT_VK_DRIVERS_PATH "" -#define DEFAULT_VK_ELAYERS_INFO "SOFTWARE\\Khronos\\Vulkan\\ExplicitLayers" -#define DEFAULT_VK_ILAYERS_INFO "SOFTWARE\\Khronos\\Vulkan\\ImplicitLayers" +#define DEFAULT_VK_ELAYERS_INFO "SOFTWARE\\Khronos\\" API_NAME "\\ExplicitLayers" +#define DEFAULT_VK_ILAYERS_INFO "SOFTWARE\\Khronos\\" API_NAME "\\ImplicitLayers" #if !defined(DEFAULT_VK_LAYERS_PATH) #define DEFAULT_VK_LAYERS_PATH "" #endif @@ -322,29 +312,6 @@ static char *loader_platform_basename(char *pathname) { return current; } -// Environment variables - -static inline char *loader_getenv(const char *name) { - char *retVal; - DWORD valSize; - - valSize = GetEnvironmentVariableA(name, NULL, 0); - - // valSize DOES include the null terminator, so for any set variable - // will always be at least 1. If it's 0, the variable wasn't set. - if (valSize == 0) - return NULL; - - // TODO; FIXME This should be using any app defined memory allocation - retVal = (char *)malloc(valSize); - - GetEnvironmentVariableA(name, retVal, valSize); - - return retVal; -} - -static inline void loader_free_getenv(const char *val) { free((void *)val); } - // Dynamic Loading: typedef HMODULE loader_platform_dl_handle; static loader_platform_dl_handle @@ -352,8 +319,8 @@ loader_platform_open_library(const char *libPath) { return LoadLibrary(libPath); } static char *loader_platform_open_library_error(const char *libPath) { - static char errorMsg[120]; - snprintf(errorMsg, 119, "Failed to open dynamic library \"%s\"", libPath); + static char errorMsg[164]; + snprintf(errorMsg, 163, "Failed to open dynamic library \"%s\"", libPath); return errorMsg; } static void loader_platform_close_library(loader_platform_dl_handle library) { diff --git a/third_party/vulkan/loader/wsi.c b/third_party/vulkan/loader/wsi.c index c5f527fb5..25f26300f 100644 --- a/third_party/vulkan/loader/wsi.c +++ b/third_party/vulkan/loader/wsi.c @@ -21,7 +21,6 @@ * Author: Mark Lobodzinski */ -//#define _ISOC11_SOURCE /* for aligned_alloc() */ #define _GNU_SOURCE #include #include @@ -31,52 +30,9 @@ #include "wsi.h" #include -static const VkExtensionProperties wsi_surface_extension_info = { - .extensionName = VK_KHR_SURFACE_EXTENSION_NAME, - .specVersion = VK_KHR_SURFACE_SPEC_VERSION, -}; - -#ifdef VK_USE_PLATFORM_WIN32_KHR -static const VkExtensionProperties wsi_win32_surface_extension_info = { - .extensionName = VK_KHR_WIN32_SURFACE_EXTENSION_NAME, - .specVersion = VK_KHR_WIN32_SURFACE_SPEC_VERSION, -}; -#endif // VK_USE_PLATFORM_WIN32_KHR - -#ifdef VK_USE_PLATFORM_MIR_KHR -static const VkExtensionProperties wsi_mir_surface_extension_info = { - .extensionName = VK_KHR_MIR_SURFACE_EXTENSION_NAME, - .specVersion = VK_KHR_MIR_SURFACE_SPEC_VERSION, -}; -#endif // VK_USE_PLATFORM_MIR_KHR - -#ifdef VK_USE_PLATFORM_WAYLAND_KHR -static const VkExtensionProperties wsi_wayland_surface_extension_info = { - .extensionName = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, - .specVersion = VK_KHR_WAYLAND_SURFACE_SPEC_VERSION, -}; -#endif // VK_USE_PLATFORM_WAYLAND_KHR - -#ifdef VK_USE_PLATFORM_XCB_KHR -static const VkExtensionProperties wsi_xcb_surface_extension_info = { - .extensionName = VK_KHR_XCB_SURFACE_EXTENSION_NAME, - .specVersion = VK_KHR_XCB_SURFACE_SPEC_VERSION, -}; -#endif // VK_USE_PLATFORM_XCB_KHR - -#ifdef VK_USE_PLATFORM_XLIB_KHR -static const VkExtensionProperties wsi_xlib_surface_extension_info = { - .extensionName = VK_KHR_XLIB_SURFACE_EXTENSION_NAME, - .specVersion = VK_KHR_XLIB_SURFACE_SPEC_VERSION, -}; -#endif // VK_USE_PLATFORM_XLIB_KHR - -#ifdef VK_USE_PLATFORM_ANDROID_KHR -static const VkExtensionProperties wsi_android_surface_extension_info = { - .extensionName = VK_KHR_ANDROID_SURFACE_EXTENSION_NAME, - .specVersion = VK_KHR_ANDROID_SURFACE_REVISION, -}; -#endif // VK_USE_PLATFORM_ANDROID_KHR +// The first ICD/Loader interface that support querying the SurfaceKHR from +// the ICDs. +#define ICD_VER_SUPPORTS_ICD_SURFACE_KHR 3 void wsi_create_instance(struct loader_instance *ptr_instance, const VkInstanceCreateInfo *pCreateInfo) { @@ -158,16 +114,16 @@ void wsi_create_instance(struct loader_instance *ptr_instance, } } } -/* - * Linux WSI surface extensions are not always compiled into the loader. (Assume - * for Windows the KHR_win32_surface is always compiled into loader). A given - * Linux build environment might not have the headers required for building one - * of the four extensions (Xlib, Xcb, Mir, Wayland). Thus, need to check if - * the built loader actually supports the particular Linux surface extension. - * If not supported by the built loader it will not be included in the list of - * enumerated instance extensions. This solves the issue where an ICD or layer - * advertises support for a given Linux surface extension but the loader was not - * built to support the extension. */ + +// Linux WSI surface extensions are not always compiled into the loader. (Assume +// for Windows the KHR_win32_surface is always compiled into loader). A given +// Linux build environment might not have the headers required for building one +// of the four extensions (Xlib, Xcb, Mir, Wayland). Thus, need to check if +// the built loader actually supports the particular Linux surface extension. +// If not supported by the built loader it will not be included in the list of +// enumerated instance extensions. This solves the issue where an ICD or layer +// advertises support for a given Linux surface extension but the loader was not +// built to support the extension. bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop) { #ifndef VK_USE_PLATFORM_MIR_KHR if (!strcmp(ext_prop->extensionName, "VK_KHR_mir_surface")) @@ -188,14 +144,10 @@ bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop) { return false; } -/* - * Functions for the VK_KHR_surface extension: - */ -/* - * This is the trampoline entrypoint - * for DestroySurfaceKHR - */ +// Functions for the VK_KHR_surface extension: + +// This is the trampoline entrypoint for DestroySurfaceKHR LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks *pAllocator) { @@ -205,22 +157,49 @@ vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, } // TODO probably need to lock around all the loader_get_instance() calls. -/* - * This is the instance chain terminator function - * for DestroySurfaceKHR - */ + +// This is the instance chain terminator function for DestroySurfaceKHR VKAPI_ATTR void VKAPI_CALL terminator_DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks *pAllocator) { struct loader_instance *ptr_instance = loader_get_instance(instance); - loader_heap_free(ptr_instance, (void *)surface); + VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; + if (NULL != icd_surface) { + if (NULL != icd_surface->real_icd_surfaces) { + uint32_t i = 0; + for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; + icd_term != NULL; icd_term = icd_term->next, i++) { + if (icd_term->scanned_icd->interface_version >= + ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { + if (NULL != icd_term->DestroySurfaceKHR && + NULL != + (void *)(uintptr_t) + icd_surface->real_icd_surfaces[i]) { + icd_term->DestroySurfaceKHR( + icd_term->instance, + icd_surface->real_icd_surfaces[i], pAllocator); + icd_surface->real_icd_surfaces[i] = + (VkSurfaceKHR)(uintptr_t)NULL; + } + } else { + // The real_icd_surface for any ICD not supporting the + // proper interface version should be NULL. If not, then + // we have a problem. + assert( + NULL == + (void *)(uintptr_t)icd_surface->real_icd_surfaces[i]); + } + } + loader_instance_heap_free(ptr_instance, + icd_surface->real_icd_surfaces); + } + + loader_instance_heap_free(ptr_instance, (void *)(uintptr_t)surface); + } } -/* - * This is the trampoline entrypoint - * for GetPhysicalDeviceSurfaceSupportKHR - */ +// This is the trampoline entrypoint for GetPhysicalDeviceSurfaceSupportKHR LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, @@ -235,20 +214,18 @@ vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, return res; } -/* - * This is the instance chain terminator function - * for GetPhysicalDeviceSurfaceSupportKHR - */ -VKAPI_ATTR VkResult VKAPI_CALL -terminator_GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - VkSurfaceKHR surface, - VkBool32 *pSupported) { +// This is the instance chain terminator function for +// GetPhysicalDeviceSurfaceSupportKHR +VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceSupportKHR( + VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, + VkSurfaceKHR surface, VkBool32 *pSupported) { + // First, check to ensure the appropriate extension was enabled: - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = - (struct loader_instance *)phys_dev->this_icd->this_instance; + (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_VK_KHR_surface extension not enabled. " @@ -257,23 +234,29 @@ terminator_GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, } // Next, if so, proceed with the implementation of this function: - struct loader_icd *icd = phys_dev->this_icd; - assert(pSupported && "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported"); *pSupported = false; - assert(icd->GetPhysicalDeviceSurfaceSupportKHR && + assert(icd_term->GetPhysicalDeviceSurfaceSupportKHR && "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer"); - return icd->GetPhysicalDeviceSurfaceSupportKHR( - phys_dev->phys_dev, queueFamilyIndex, surface, pSupported); + VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; + if (NULL != icd_surface->real_icd_surfaces && + NULL != + (void *)(uintptr_t) + icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { + return icd_term->GetPhysicalDeviceSurfaceSupportKHR( + phys_dev_term->phys_dev, queueFamilyIndex, + icd_surface->real_icd_surfaces[phys_dev_term->icd_index], + pSupported); + } + + return icd_term->GetPhysicalDeviceSurfaceSupportKHR( + phys_dev_term->phys_dev, queueFamilyIndex, surface, pSupported); } -/* - * This is the trampoline entrypoint - * for GetPhysicalDeviceSurfaceCapabilitiesKHR - */ +// This is the trampoline entrypoint for GetPhysicalDeviceSurfaceCapabilitiesKHR LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR( VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, @@ -288,19 +271,19 @@ vkGetPhysicalDeviceSurfaceCapabilitiesKHR( return res; } -/* - * This is the instance chain terminator function - * for GetPhysicalDeviceSurfaceCapabilitiesKHR - */ +// This is the instance chain terminator function for +// GetPhysicalDeviceSurfaceCapabilitiesKHR VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceCapabilitiesKHR( VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) { + // First, check to ensure the appropriate extension was enabled: - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = - (struct loader_instance *)phys_dev->this_icd->this_instance; + (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_surface extension not enabled. " @@ -309,22 +292,28 @@ terminator_GetPhysicalDeviceSurfaceCapabilitiesKHR( } // Next, if so, proceed with the implementation of this function: - struct loader_icd *icd = phys_dev->this_icd; - assert(pSurfaceCapabilities && "GetPhysicalDeviceSurfaceCapabilitiesKHR: " "Error, null pSurfaceCapabilities"); - assert(icd->GetPhysicalDeviceSurfaceCapabilitiesKHR && + assert(icd_term->GetPhysicalDeviceSurfaceCapabilitiesKHR && "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer"); - return icd->GetPhysicalDeviceSurfaceCapabilitiesKHR( - phys_dev->phys_dev, surface, pSurfaceCapabilities); + VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; + if (NULL != icd_surface->real_icd_surfaces && + NULL != + (void *)(uintptr_t) + icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { + return icd_term->GetPhysicalDeviceSurfaceCapabilitiesKHR( + phys_dev_term->phys_dev, + icd_surface->real_icd_surfaces[phys_dev_term->icd_index], + pSurfaceCapabilities); + } + + return icd_term->GetPhysicalDeviceSurfaceCapabilitiesKHR( + phys_dev_term->phys_dev, surface, pSurfaceCapabilities); } -/* - * This is the trampoline entrypoint - * for GetPhysicalDeviceSurfaceFormatsKHR - */ +// This is the trampoline entrypoint for GetPhysicalDeviceSurfaceFormatsKHR LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, @@ -339,18 +328,18 @@ vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, return res; } -/* - * This is the instance chain terminator function - * for GetPhysicalDeviceSurfaceFormatsKHR - */ +// This is the instance chain terminator function for +// GetPhysicalDeviceSurfaceFormatsKHR VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormatsKHR( VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats) { + // First, check to ensure the appropriate extension was enabled: - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = - (struct loader_instance *)phys_dev->this_icd->this_instance; + (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_surface extension not enabled. " @@ -359,23 +348,29 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfaceFormatsKHR( } // Next, if so, proceed with the implementation of this function: - struct loader_icd *icd = phys_dev->this_icd; - assert( pSurfaceFormatCount && "GetPhysicalDeviceSurfaceFormatsKHR: Error, null pSurfaceFormatCount"); - assert(icd->GetPhysicalDeviceSurfaceFormatsKHR && + assert(icd_term->GetPhysicalDeviceSurfaceFormatsKHR && "loader: null GetPhysicalDeviceSurfaceFormatsKHR ICD pointer"); - return icd->GetPhysicalDeviceSurfaceFormatsKHR( - phys_dev->phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats); + VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; + if (NULL != icd_surface->real_icd_surfaces && + NULL != + (void *)(uintptr_t) + icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { + return icd_term->GetPhysicalDeviceSurfaceFormatsKHR( + phys_dev_term->phys_dev, + icd_surface->real_icd_surfaces[phys_dev_term->icd_index], + pSurfaceFormatCount, pSurfaceFormats); + } + + return icd_term->GetPhysicalDeviceSurfaceFormatsKHR( + phys_dev_term->phys_dev, surface, pSurfaceFormatCount, pSurfaceFormats); } -/* - * This is the trampoline entrypoint - * for GetPhysicalDeviceSurfacePresentModesKHR - */ +// This is the trampoline entrypoint for GetPhysicalDeviceSurfacePresentModesKHR LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, @@ -390,19 +385,19 @@ vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, return res; } -/* - * This is the instance chain terminator function - * for GetPhysicalDeviceSurfacePresentModesKHR - */ +// This is the instance chain terminator function for +// GetPhysicalDeviceSurfacePresentModesKHR VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceSurfacePresentModesKHR( VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes) { + // First, check to ensure the appropriate extension was enabled: - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = - (struct loader_instance *)phys_dev->this_icd->this_instance; + (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_surface extension not enabled. " @@ -411,42 +406,75 @@ terminator_GetPhysicalDeviceSurfacePresentModesKHR( } // Next, if so, proceed with the implementation of this function: - struct loader_icd *icd = phys_dev->this_icd; - assert(pPresentModeCount && "GetPhysicalDeviceSurfacePresentModesKHR: " "Error, null pPresentModeCount"); - assert(icd->GetPhysicalDeviceSurfacePresentModesKHR && + assert(icd_term->GetPhysicalDeviceSurfacePresentModesKHR && "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer"); - return icd->GetPhysicalDeviceSurfacePresentModesKHR( - phys_dev->phys_dev, surface, pPresentModeCount, pPresentModes); + VkIcdSurface *icd_surface = (VkIcdSurface *)(uintptr_t)surface; + if (NULL != icd_surface->real_icd_surfaces && + NULL != + (void *)(uintptr_t) + icd_surface->real_icd_surfaces[phys_dev_term->icd_index]) { + return icd_term->GetPhysicalDeviceSurfacePresentModesKHR( + phys_dev_term->phys_dev, + icd_surface->real_icd_surfaces[phys_dev_term->icd_index], + pPresentModeCount, pPresentModes); + } + + return icd_term->GetPhysicalDeviceSurfacePresentModesKHR( + phys_dev_term->phys_dev, surface, pPresentModeCount, pPresentModes); } -/* - * Functions for the VK_KHR_swapchain extension: - */ +// Functions for the VK_KHR_swapchain extension: -/* - * This is the trampoline entrypoint - * for CreateSwapchainKHR - */ -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL -vkCreateSwapchainKHR(VkDevice device, - const VkSwapchainCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSwapchainKHR *pSwapchain) { +// This is the trampoline entrypoint for CreateSwapchainKHR +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR( + VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) { const VkLayerDispatchTable *disp; disp = loader_get_dispatch(device); - VkResult res = - disp->CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain); - return res; + return disp->CreateSwapchainKHR(device, pCreateInfo, pAllocator, + pSwapchain); } -/* - * This is the trampoline entrypoint - * for DestroySwapchainKHR - */ +VKAPI_ATTR VkResult VKAPI_CALL terminator_vkCreateSwapchainKHR( + VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) { + uint32_t icd_index = 0; + struct loader_device *dev; + struct loader_icd_term *icd_term = + loader_get_icd_and_device(device, &dev, &icd_index); + if (NULL != icd_term && NULL != icd_term->CreateSwapchainKHR) { + VkIcdSurface *icd_surface = + (VkIcdSurface *)(uintptr_t)pCreateInfo->surface; + if (NULL != icd_surface->real_icd_surfaces) { + if (NULL != + (void *)(uintptr_t)icd_surface->real_icd_surfaces[icd_index]) { + // We found the ICD, and there is an ICD KHR surface + // associated with it, so copy the CreateInfo struct + // and point it at the ICD's surface. + VkSwapchainCreateInfoKHR *pCreateCopy = + loader_stack_alloc(sizeof(VkSwapchainCreateInfoKHR)); + if (NULL == pCreateCopy) { + return VK_ERROR_OUT_OF_HOST_MEMORY; + } + memcpy(pCreateCopy, pCreateInfo, + sizeof(VkSwapchainCreateInfoKHR)); + pCreateCopy->surface = + icd_surface->real_icd_surfaces[icd_index]; + return icd_term->CreateSwapchainKHR(device, pCreateCopy, + pAllocator, pSwapchain); + } + } + return icd_term->CreateSwapchainKHR(device, pCreateInfo, pAllocator, + pSwapchain); + } + return VK_SUCCESS; +} + +// This is the trampoline entrypoint for DestroySwapchainKHR LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator) { @@ -459,59 +487,78 @@ vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, * This is the trampoline entrypoint * for GetSwapchainImagesKHR */ -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL -vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, - uint32_t *pSwapchainImageCount, - VkImage *pSwapchainImages) { +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR( + VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, + VkImage *pSwapchainImages) { const VkLayerDispatchTable *disp; disp = loader_get_dispatch(device); - VkResult res = disp->GetSwapchainImagesKHR( - device, swapchain, pSwapchainImageCount, pSwapchainImages); - return res; + return disp->GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, + pSwapchainImages); } /* * This is the trampoline entrypoint * for AcquireNextImageKHR */ -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL -vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, - uint64_t timeout, VkSemaphore semaphore, VkFence fence, - uint32_t *pImageIndex) { +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR( + VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, + VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex) { const VkLayerDispatchTable *disp; disp = loader_get_dispatch(device); - VkResult res = disp->AcquireNextImageKHR(device, swapchain, timeout, - semaphore, fence, pImageIndex); - return res; + return disp->AcquireNextImageKHR(device, swapchain, timeout, semaphore, + fence, pImageIndex); } -/* - * This is the trampoline entrypoint - * for QueuePresentKHR - */ +// This is the trampoline entrypoint for QueuePresentKHR LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) { const VkLayerDispatchTable *disp; disp = loader_get_dispatch(queue); - VkResult res = disp->QueuePresentKHR(queue, pPresentInfo); - return res; + return disp->QueuePresentKHR(queue, pPresentInfo); +} + +static VkIcdSurface *AllocateIcdSurfaceStruct(struct loader_instance *instance, + size_t base_size, + size_t platform_size, + bool create_icd_surfs) { + // Next, if so, proceed with the implementation of this function: + VkIcdSurface *pIcdSurface = loader_instance_heap_alloc( + instance, sizeof(VkIcdSurface), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + if (pIcdSurface != NULL) { + // Setup the new sizes and offsets so we can grow the structures in the + // future without having problems + pIcdSurface->base_size = (uint32_t)base_size; + pIcdSurface->platform_size = (uint32_t)platform_size; + pIcdSurface->non_platform_offset = (uint32_t)( + (uint8_t *)(&pIcdSurface->base_size) - (uint8_t *)pIcdSurface); + pIcdSurface->entire_size = sizeof(VkIcdSurface); + + if (create_icd_surfs) { + pIcdSurface->real_icd_surfaces = loader_instance_heap_alloc( + instance, sizeof(VkSurfaceKHR) * instance->total_icd_count, + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + if (pIcdSurface->real_icd_surfaces == NULL) { + loader_instance_heap_free(instance, pIcdSurface); + pIcdSurface = NULL; + } else { + memset(pIcdSurface->real_icd_surfaces, 0, + sizeof(VkSurfaceKHR) * instance->total_icd_count); + } + } else { + pIcdSurface->real_icd_surfaces = NULL; + } + } + return pIcdSurface; } #ifdef VK_USE_PLATFORM_WIN32_KHR -/* - * Functions for the VK_KHR_win32_surface extension: - */ +// Functions for the VK_KHR_win32_surface extension: -/* - * This is the trampoline entrypoint - * for CreateWin32SurfaceKHR - */ -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL -vkCreateWin32SurfaceKHR(VkInstance instance, - const VkWin32SurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { +// This is the trampoline entrypoint for CreateWin32SurfaceKHR +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR( + VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { const VkLayerInstanceDispatchTable *disp; disp = loader_get_instance_dispatch(instance); VkResult res; @@ -521,46 +568,82 @@ vkCreateWin32SurfaceKHR(VkInstance instance, return res; } -/* - * This is the instance chain terminator function - * for CreateWin32SurfaceKHR - */ -VKAPI_ATTR VkResult VKAPI_CALL -terminator_CreateWin32SurfaceKHR(VkInstance instance, - const VkWin32SurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { +// This is the instance chain terminator function for CreateWin32SurfaceKHR +VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWin32SurfaceKHR( + VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { + VkResult vkRes = VK_SUCCESS; + VkIcdSurface *pIcdSurface = NULL; + uint32_t i = 0; + + // Initialize pSurface to NULL just to be safe. + *pSurface = VK_NULL_HANDLE; // First, check to ensure the appropriate extension was enabled: struct loader_instance *ptr_instance = loader_get_instance(instance); if (!ptr_instance->wsi_win32_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_win32_surface extension not enabled. " "vkCreateWin32SurfaceKHR not executed!\n"); - return VK_ERROR_EXTENSION_NOT_PRESENT; + vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; + goto out; } // Next, if so, proceed with the implementation of this function: - VkIcdSurfaceWin32 *pIcdSurface = NULL; - - pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceWin32), - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + pIcdSurface = AllocateIcdSurfaceStruct(ptr_instance, + sizeof(pIcdSurface->win_surf.base), + sizeof(pIcdSurface->win_surf), true); if (pIcdSurface == NULL) { - return VK_ERROR_OUT_OF_HOST_MEMORY; + vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } - pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WIN32; - pIcdSurface->hinstance = pCreateInfo->hinstance; - pIcdSurface->hwnd = pCreateInfo->hwnd; + pIcdSurface->win_surf.base.platform = VK_ICD_WSI_PLATFORM_WIN32; + pIcdSurface->win_surf.hinstance = pCreateInfo->hinstance; + pIcdSurface->win_surf.hwnd = pCreateInfo->hwnd; - *pSurface = (VkSurfaceKHR)pIcdSurface; + // Loop through each ICD and determine if they need to create a surface + for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; + icd_term != NULL; icd_term = icd_term->next, i++) { + if (icd_term->scanned_icd->interface_version >= + ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { + if (NULL != icd_term->CreateWin32SurfaceKHR) { + vkRes = icd_term->CreateWin32SurfaceKHR( + icd_term->instance, pCreateInfo, pAllocator, + &pIcdSurface->real_icd_surfaces[i]); + if (VK_SUCCESS != vkRes) { + goto out; + } + } + } + } - return VK_SUCCESS; + *pSurface = (VkSurfaceKHR)(pIcdSurface); + +out: + + if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { + if (NULL != pIcdSurface->real_icd_surfaces) { + i = 0; + for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; + icd_term != NULL; icd_term = icd_term->next, i++) { + if (NULL != (void *)pIcdSurface->real_icd_surfaces[i] && + NULL != icd_term->DestroySurfaceKHR) { + icd_term->DestroySurfaceKHR( + icd_term->instance, pIcdSurface->real_icd_surfaces[i], + pAllocator); + } + } + loader_instance_heap_free(ptr_instance, + pIcdSurface->real_icd_surfaces); + } + loader_instance_heap_free(ptr_instance, pIcdSurface); + } + + return vkRes; } -/* - * This is the trampoline entrypoint - * for GetPhysicalDeviceWin32PresentationSupportKHR - */ +// This is the trampoline entrypoint for +// GetPhysicalDeviceWin32PresentationSupportKHR LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex) { @@ -573,18 +656,17 @@ vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice, return res; } -/* - * This is the instance chain terminator function - * for GetPhysicalDeviceWin32PresentationSupportKHR - */ +// This is the instance chain terminator function for +// GetPhysicalDeviceWin32PresentationSupportKHR VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceWin32PresentationSupportKHR( VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex) { // First, check to ensure the appropriate extension was enabled: - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = - (struct loader_instance *)phys_dev->this_icd->this_instance; + (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_win32_surface_enabled) { loader_log( ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, @@ -594,32 +676,23 @@ terminator_GetPhysicalDeviceWin32PresentationSupportKHR( } // Next, if so, proceed with the implementation of this function: - struct loader_icd *icd = phys_dev->this_icd; - - assert(icd->GetPhysicalDeviceWin32PresentationSupportKHR && + assert(icd_term->GetPhysicalDeviceWin32PresentationSupportKHR && "loader: null GetPhysicalDeviceWin32PresentationSupportKHR ICD " "pointer"); - return icd->GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev->phys_dev, - queueFamilyIndex); + return icd_term->GetPhysicalDeviceWin32PresentationSupportKHR( + phys_dev_term->phys_dev, queueFamilyIndex); } #endif // VK_USE_PLATFORM_WIN32_KHR #ifdef VK_USE_PLATFORM_MIR_KHR -/* - * Functions for the VK_KHR_mir_surface extension: - */ +// Functions for the VK_KHR_mir_surface extension: -/* - * This is the trampoline entrypoint - * for CreateMirSurfaceKHR - */ -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL -vkCreateMirSurfaceKHR(VkInstance instance, - const VkMirSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { +// This is the trampoline entrypoint for CreateMirSurfaceKHR +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR( + VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { const VkLayerInstanceDispatchTable *disp; disp = loader_get_instance_dispatch(instance); VkResult res; @@ -629,46 +702,80 @@ vkCreateMirSurfaceKHR(VkInstance instance, return res; } -/* - * This is the instance chain terminator function - * for CreateMirSurfaceKHR - */ -VKAPI_ATTR VkResult VKAPI_CALL -terminator_CreateMirSurfaceKHR(VkInstance instance, - const VkMirSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { +// This is the instance chain terminator function for CreateMirSurfaceKHR +VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateMirSurfaceKHR( + VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { + VkResult vkRes = VK_SUCCESS; + VkIcdSurface *pIcdSurface = NULL; + uint32_t i = 0; + // First, check to ensure the appropriate extension was enabled: struct loader_instance *ptr_instance = loader_get_instance(instance); if (!ptr_instance->wsi_mir_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_mir_surface extension not enabled. " "vkCreateMirSurfaceKHR not executed!\n"); - return VK_ERROR_EXTENSION_NOT_PRESENT; + vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; + goto out; } // Next, if so, proceed with the implementation of this function: - VkIcdSurfaceMir *pIcdSurface = NULL; - - pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceMir), - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + pIcdSurface = AllocateIcdSurfaceStruct(ptr_instance, + sizeof(pIcdSurface->mir_surf.base), + sizeof(pIcdSurface->mir_surf), true); if (pIcdSurface == NULL) { - return VK_ERROR_OUT_OF_HOST_MEMORY; + vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } - pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_MIR; - pIcdSurface->connection = pCreateInfo->connection; - pIcdSurface->mirSurface = pCreateInfo->mirSurface; + pIcdSurface->mir_surf.base.platform = VK_ICD_WSI_PLATFORM_MIR; + pIcdSurface->mir_surf.connection = pCreateInfo->connection; + pIcdSurface->mir_surf.mirSurface = pCreateInfo->mirSurface; + + // Loop through each ICD and determine if they need to create a surface + for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; + icd_term != NULL; icd_term = icd_term->next, i++) { + if (icd_term->scanned_icd->interface_version >= + ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { + if (NULL != icd_term->CreateMirSurfaceKHR) { + vkRes = icd_term->CreateMirSurfaceKHR( + icd_term->instance, pCreateInfo, pAllocator, + &pIcdSurface->real_icd_surfaces[i]); + if (VK_SUCCESS != vkRes) { + goto out; + } + } + } + } *pSurface = (VkSurfaceKHR)pIcdSurface; - return VK_SUCCESS; +out: + + if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { + if (NULL != pIcdSurface->real_icd_surfaces) { + i = 0; + for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; + icd_term != NULL; icd_term = icd_term->next, i++) { + if (NULL != pIcdSurface->real_icd_surfaces[i] && + NULL != icd_term->DestroySurfaceKHR) { + icd_term->DestroySurfaceKHR( + icd_term->instance, pIcdSurface->real_icd_surfaces[i], + pAllocator); + } + } + loader_instance_heap_free(ptr_instance, + pIcdSurface->real_icd_surfaces); + } + loader_instance_heap_free(ptr_instance, pIcdSurface); + } + + return vkRes; } -/* - * This is the trampoline entrypoint - * for GetPhysicalDeviceMirPresentationSupportKHR - */ +// This is the trampoline entrypoint for +// GetPhysicalDeviceMirPresentationSupportKHR LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceMirPresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, @@ -682,19 +789,19 @@ vkGetPhysicalDeviceMirPresentationSupportKHR(VkPhysicalDevice physicalDevice, return res; } -/* - * This is the instance chain terminator function - * for GetPhysicalDeviceMirPresentationSupportKHR - */ +// This is the instance chain terminator function for +// GetPhysicalDeviceMirPresentationSupportKHR VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceMirPresentationSupportKHR( VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, MirConnection *connection) { + // First, check to ensure the appropriate extension was enabled: - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = - (struct loader_instance *)phys_dev->this_icd->this_instance; + (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_mir_surface_enabled) { loader_log( ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, @@ -704,32 +811,24 @@ terminator_GetPhysicalDeviceMirPresentationSupportKHR( } // Next, if so, proceed with the implementation of this function: - struct loader_icd *icd = phys_dev->this_icd; - assert( - icd->GetPhysicalDeviceMirPresentationSupportKHR && + icd_term->GetPhysicalDeviceMirPresentationSupportKHR && "loader: null GetPhysicalDeviceMirPresentationSupportKHR ICD pointer"); - return icd->GetPhysicalDeviceMirPresentationSupportKHR( - phys_dev->phys_dev, queueFamilyIndex, connection); + return icd_term->GetPhysicalDeviceMirPresentationSupportKHR( + phys_dev_term->phys_dev, queueFamilyIndex, connection); } #endif // VK_USE_PLATFORM_MIR_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR -/* - * Functions for the VK_KHR_wayland_surface extension: - */ - /* * This is the trampoline entrypoint * for CreateWaylandSurfaceKHR */ -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL -vkCreateWaylandSurfaceKHR(VkInstance instance, - const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR( + VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { const VkLayerInstanceDispatchTable *disp; disp = loader_get_instance_dispatch(instance); VkResult res; @@ -739,45 +838,80 @@ vkCreateWaylandSurfaceKHR(VkInstance instance, return res; } -/* - * This is the instance chain terminator function - * for CreateWaylandSurfaceKHR - */ -VKAPI_ATTR VkResult VKAPI_CALL -terminator_CreateWaylandSurfaceKHR( +// This is the instance chain terminator function for CreateWaylandSurfaceKHR +VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateWaylandSurfaceKHR( VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { + VkResult vkRes = VK_SUCCESS; + VkIcdSurface *pIcdSurface = NULL; + uint32_t i = 0; + // First, check to ensure the appropriate extension was enabled: struct loader_instance *ptr_instance = loader_get_instance(instance); if (!ptr_instance->wsi_wayland_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_wayland_surface extension not enabled. " "vkCreateWaylandSurfaceKHR not executed!\n"); - return VK_ERROR_EXTENSION_NOT_PRESENT; + vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; + goto out; } // Next, if so, proceed with the implementation of this function: - VkIcdSurfaceWayland *pIcdSurface = NULL; - - pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceWayland), - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + pIcdSurface = AllocateIcdSurfaceStruct( + ptr_instance, sizeof(pIcdSurface->wayland_surf.base), + sizeof(pIcdSurface->wayland_surf), true); if (pIcdSurface == NULL) { - return VK_ERROR_OUT_OF_HOST_MEMORY; + vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } - pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WAYLAND; - pIcdSurface->display = pCreateInfo->display; - pIcdSurface->surface = pCreateInfo->surface; + pIcdSurface->wayland_surf.base.platform = VK_ICD_WSI_PLATFORM_WAYLAND; + pIcdSurface->wayland_surf.display = pCreateInfo->display; + pIcdSurface->wayland_surf.surface = pCreateInfo->surface; + + // Loop through each ICD and determine if they need to create a surface + for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; + icd_term != NULL; icd_term = icd_term->next, i++) { + if (icd_term->scanned_icd->interface_version >= + ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { + if (NULL != icd_term->CreateWaylandSurfaceKHR) { + vkRes = icd_term->CreateWaylandSurfaceKHR( + icd_term->instance, pCreateInfo, pAllocator, + &pIcdSurface->real_icd_surfaces[i]); + if (VK_SUCCESS != vkRes) { + goto out; + } + } + } + } *pSurface = (VkSurfaceKHR)pIcdSurface; - return VK_SUCCESS; +out: + + if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { + if (NULL != pIcdSurface->real_icd_surfaces) { + i = 0; + for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; + icd_term != NULL; icd_term = icd_term->next, i++) { + if (NULL != pIcdSurface->real_icd_surfaces[i] && + NULL != icd_term->DestroySurfaceKHR) { + icd_term->DestroySurfaceKHR( + icd_term->instance, pIcdSurface->real_icd_surfaces[i], + pAllocator); + } + } + loader_instance_heap_free(ptr_instance, + pIcdSurface->real_icd_surfaces); + } + loader_instance_heap_free(ptr_instance, pIcdSurface); + } + + return vkRes; } -/* - * This is the trampoline entrypoint - * for GetPhysicalDeviceWaylandPresentationSupportKHR - */ +// This is the trampoline entrypoint for +// GetPhysicalDeviceWaylandPresentationSupportKHR LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR( VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, @@ -791,19 +925,19 @@ vkGetPhysicalDeviceWaylandPresentationSupportKHR( return res; } -/* - * This is the instance chain terminator function - * for GetPhysicalDeviceWaylandPresentationSupportKHR - */ +// This is the instance chain terminator function for +// GetPhysicalDeviceWaylandPresentationSupportKHR VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceWaylandPresentationSupportKHR( VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct wl_display *display) { + // First, check to ensure the appropriate extension was enabled: - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = - (struct loader_instance *)phys_dev->this_icd->this_instance; + (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_wayland_surface_enabled) { loader_log( ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, @@ -813,32 +947,23 @@ terminator_GetPhysicalDeviceWaylandPresentationSupportKHR( } // Next, if so, proceed with the implementation of this function: - struct loader_icd *icd = phys_dev->this_icd; - - assert(icd->GetPhysicalDeviceWaylandPresentationSupportKHR && + assert(icd_term->GetPhysicalDeviceWaylandPresentationSupportKHR && "loader: null GetPhysicalDeviceWaylandPresentationSupportKHR ICD " "pointer"); - return icd->GetPhysicalDeviceWaylandPresentationSupportKHR( - phys_dev->phys_dev, queueFamilyIndex, display); + return icd_term->GetPhysicalDeviceWaylandPresentationSupportKHR( + phys_dev_term->phys_dev, queueFamilyIndex, display); } #endif // VK_USE_PLATFORM_WAYLAND_KHR #ifdef VK_USE_PLATFORM_XCB_KHR -/* - * Functions for the VK_KHR_xcb_surface extension: - */ +// Functions for the VK_KHR_xcb_surface extension: -/* - * This is the trampoline entrypoint - * for CreateXcbSurfaceKHR - */ -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL -vkCreateXcbSurfaceKHR(VkInstance instance, - const VkXcbSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { +// This is the trampoline entrypoint for CreateXcbSurfaceKHR +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR( + VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { const VkLayerInstanceDispatchTable *disp; disp = loader_get_instance_dispatch(instance); VkResult res; @@ -848,46 +973,81 @@ vkCreateXcbSurfaceKHR(VkInstance instance, return res; } -/* - * This is the instance chain terminator function - * for CreateXcbSurfaceKHR - */ -VKAPI_ATTR VkResult VKAPI_CALL -terminator_CreateXcbSurfaceKHR(VkInstance instance, - const VkXcbSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { +// This is the instance chain terminator function for CreateXcbSurfaceKHR +VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXcbSurfaceKHR( + VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { + VkResult vkRes = VK_SUCCESS; + VkIcdSurface *pIcdSurface = NULL; + uint32_t i = 0; + // First, check to ensure the appropriate extension was enabled: struct loader_instance *ptr_instance = loader_get_instance(instance); if (!ptr_instance->wsi_xcb_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_xcb_surface extension not enabled. " "vkCreateXcbSurfaceKHR not executed!\n"); - return VK_ERROR_EXTENSION_NOT_PRESENT; + vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; + goto out; } // Next, if so, proceed with the implementation of this function: - VkIcdSurfaceXcb *pIcdSurface = NULL; - - pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceXcb), - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + pIcdSurface = AllocateIcdSurfaceStruct(ptr_instance, + sizeof(pIcdSurface->xcb_surf.base), + sizeof(pIcdSurface->xcb_surf), true); if (pIcdSurface == NULL) { - return VK_ERROR_OUT_OF_HOST_MEMORY; + vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } - pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XCB; - pIcdSurface->connection = pCreateInfo->connection; - pIcdSurface->window = pCreateInfo->window; + pIcdSurface->xcb_surf.base.platform = VK_ICD_WSI_PLATFORM_XCB; + pIcdSurface->xcb_surf.connection = pCreateInfo->connection; + pIcdSurface->xcb_surf.window = pCreateInfo->window; - *pSurface = (VkSurfaceKHR)pIcdSurface; + // Loop through each ICD and determine if they need to create a surface + for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; + icd_term != NULL; icd_term = icd_term->next, i++) { + if (icd_term->scanned_icd->interface_version >= + ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { + if (NULL != icd_term->CreateXcbSurfaceKHR) { + vkRes = icd_term->CreateXcbSurfaceKHR( + icd_term->instance, pCreateInfo, pAllocator, + &pIcdSurface->real_icd_surfaces[i]); + if (VK_SUCCESS != vkRes) { + goto out; + } + } + } + } - return VK_SUCCESS; + *pSurface = (VkSurfaceKHR)(uintptr_t)pIcdSurface; + +out: + + if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { + if (NULL != pIcdSurface->real_icd_surfaces) { + i = 0; + for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; + icd_term != NULL; icd_term = icd_term->next, i++) { + if (NULL != + (void *)(uintptr_t)pIcdSurface->real_icd_surfaces[i] && + NULL != icd_term->DestroySurfaceKHR) { + icd_term->DestroySurfaceKHR( + icd_term->instance, pIcdSurface->real_icd_surfaces[i], + pAllocator); + } + } + loader_instance_heap_free(ptr_instance, + pIcdSurface->real_icd_surfaces); + } + loader_instance_heap_free(ptr_instance, pIcdSurface); + } + + return vkRes; } -/* - * This is the trampoline entrypoint - * for GetPhysicalDeviceXcbPresentationSupportKHR - */ +// This is the trampoline entrypoint for +// GetPhysicalDeviceXcbPresentationSupportKHR LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, @@ -902,19 +1062,19 @@ vkGetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice, return res; } -/* - * This is the instance chain terminator function - * for GetPhysicalDeviceXcbPresentationSupportKHR - */ +// This is the instance chain terminator function for +// GetPhysicalDeviceXcbPresentationSupportKHR VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceXcbPresentationSupportKHR( VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, xcb_connection_t *connection, xcb_visualid_t visual_id) { + // First, check to ensure the appropriate extension was enabled: - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = - (struct loader_instance *)phys_dev->this_icd->this_instance; + (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_xcb_surface_enabled) { loader_log( ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, @@ -924,32 +1084,23 @@ terminator_GetPhysicalDeviceXcbPresentationSupportKHR( } // Next, if so, proceed with the implementation of this function: - struct loader_icd *icd = phys_dev->this_icd; - assert( - icd->GetPhysicalDeviceXcbPresentationSupportKHR && + icd_term->GetPhysicalDeviceXcbPresentationSupportKHR && "loader: null GetPhysicalDeviceXcbPresentationSupportKHR ICD pointer"); - return icd->GetPhysicalDeviceXcbPresentationSupportKHR( - phys_dev->phys_dev, queueFamilyIndex, connection, visual_id); + return icd_term->GetPhysicalDeviceXcbPresentationSupportKHR( + phys_dev_term->phys_dev, queueFamilyIndex, connection, visual_id); } #endif // VK_USE_PLATFORM_XCB_KHR #ifdef VK_USE_PLATFORM_XLIB_KHR -/* - * Functions for the VK_KHR_xlib_surface extension: - */ +// Functions for the VK_KHR_xlib_surface extension: -/* - * This is the trampoline entrypoint - * for CreateXlibSurfaceKHR - */ -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL -vkCreateXlibSurfaceKHR(VkInstance instance, - const VkXlibSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { +// This is the trampoline entrypoint for CreateXlibSurfaceKHR +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR( + VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { const VkLayerInstanceDispatchTable *disp; disp = loader_get_instance_dispatch(instance); VkResult res; @@ -959,46 +1110,81 @@ vkCreateXlibSurfaceKHR(VkInstance instance, return res; } -/* - * This is the instance chain terminator function - * for CreateXlibSurfaceKHR - */ -VKAPI_ATTR VkResult VKAPI_CALL -terminator_CreateXlibSurfaceKHR(VkInstance instance, - const VkXlibSurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { +// This is the instance chain terminator function for CreateXlibSurfaceKHR +VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateXlibSurfaceKHR( + VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { + VkResult vkRes = VK_SUCCESS; + VkIcdSurface *pIcdSurface = NULL; + uint32_t i = 0; + // First, check to ensure the appropriate extension was enabled: struct loader_instance *ptr_instance = loader_get_instance(instance); if (!ptr_instance->wsi_xlib_surface_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_xlib_surface extension not enabled. " "vkCreateXlibSurfaceKHR not executed!\n"); - return VK_ERROR_EXTENSION_NOT_PRESENT; + vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; + goto out; } // Next, if so, proceed with the implementation of this function: - VkIcdSurfaceXlib *pIcdSurface = NULL; - - pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceXlib), - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + pIcdSurface = AllocateIcdSurfaceStruct( + ptr_instance, sizeof(pIcdSurface->xlib_surf.base), + sizeof(pIcdSurface->xlib_surf), true); if (pIcdSurface == NULL) { - return VK_ERROR_OUT_OF_HOST_MEMORY; + vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } - pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XLIB; - pIcdSurface->dpy = pCreateInfo->dpy; - pIcdSurface->window = pCreateInfo->window; + pIcdSurface->xlib_surf.base.platform = VK_ICD_WSI_PLATFORM_XLIB; + pIcdSurface->xlib_surf.dpy = pCreateInfo->dpy; + pIcdSurface->xlib_surf.window = pCreateInfo->window; - *pSurface = (VkSurfaceKHR)pIcdSurface; + // Loop through each ICD and determine if they need to create a surface + for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; + icd_term != NULL; icd_term = icd_term->next, i++) { + if (icd_term->scanned_icd->interface_version >= + ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { + if (NULL != icd_term->CreateXlibSurfaceKHR) { + vkRes = icd_term->CreateXlibSurfaceKHR( + icd_term->instance, pCreateInfo, pAllocator, + &pIcdSurface->real_icd_surfaces[i]); + if (VK_SUCCESS != vkRes) { + goto out; + } + } + } + } - return VK_SUCCESS; + *pSurface = (VkSurfaceKHR)(uintptr_t)pIcdSurface; + +out: + + if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { + if (NULL != pIcdSurface->real_icd_surfaces) { + i = 0; + for (struct loader_icd_term *icd_term = ptr_instance->icd_terms; + icd_term != NULL; icd_term = icd_term->next, i++) { + if (NULL != + (void *)(uintptr_t)pIcdSurface->real_icd_surfaces[i] && + NULL != icd_term->DestroySurfaceKHR) { + icd_term->DestroySurfaceKHR( + icd_term->instance, pIcdSurface->real_icd_surfaces[i], + pAllocator); + } + } + loader_instance_heap_free(ptr_instance, + pIcdSurface->real_icd_surfaces); + } + loader_instance_heap_free(ptr_instance, pIcdSurface); + } + + return vkRes; } -/* - * This is the trampoline entrypoint - * for GetPhysicalDeviceXlibPresentationSupportKHR - */ +// This is the trampoline entrypoint for +// GetPhysicalDeviceXlibPresentationSupportKHR LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, @@ -1012,19 +1198,19 @@ vkGetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice, return res; } -/* - * This is the instance chain terminator function - * for GetPhysicalDeviceXlibPresentationSupportKHR - */ +// This is the instance chain terminator function for +// GetPhysicalDeviceXlibPresentationSupportKHR VKAPI_ATTR VkBool32 VKAPI_CALL terminator_GetPhysicalDeviceXlibPresentationSupportKHR( VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display *dpy, VisualID visualID) { + // First, check to ensure the appropriate extension was enabled: - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = - (struct loader_instance *)phys_dev->this_icd->this_instance; + (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_xlib_surface_enabled) { loader_log( ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, @@ -1034,31 +1220,23 @@ terminator_GetPhysicalDeviceXlibPresentationSupportKHR( } // Next, if so, proceed with the implementation of this function: - struct loader_icd *icd = phys_dev->this_icd; - assert( - icd->GetPhysicalDeviceXlibPresentationSupportKHR && + icd_term->GetPhysicalDeviceXlibPresentationSupportKHR && "loader: null GetPhysicalDeviceXlibPresentationSupportKHR ICD pointer"); - return icd->GetPhysicalDeviceXlibPresentationSupportKHR( - phys_dev->phys_dev, queueFamilyIndex, dpy, visualID); + return icd_term->GetPhysicalDeviceXlibPresentationSupportKHR( + phys_dev_term->phys_dev, queueFamilyIndex, dpy, visualID); } #endif // VK_USE_PLATFORM_XLIB_KHR #ifdef VK_USE_PLATFORM_ANDROID_KHR -/* - * Functions for the VK_KHR_android_surface extension: - */ +// Functions for the VK_KHR_android_surface extension: -/* - * This is the trampoline entrypoint - * for CreateAndroidSurfaceKHR - */ -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL -vkCreateAndroidSurfaceKHR(VkInstance instance, ANativeWindow *window, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { +// This is the trampoline entrypoint for CreateAndroidSurfaceKHR +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR( + VkInstance instance, ANativeWindow *window, + const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { const VkLayerInstanceDispatchTable *disp; disp = loader_get_instance_dispatch(instance); VkResult res; @@ -1067,14 +1245,10 @@ vkCreateAndroidSurfaceKHR(VkInstance instance, ANativeWindow *window, return res; } -/* - * This is the instance chain terminator function - * for CreateAndroidSurfaceKHR - */ -VKAPI_ATTR VkResult VKAPI_CALL -terminator_CreateAndroidSurfaceKHR(VkInstance instance, Window window, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { +// This is the instance chain terminator function for CreateAndroidSurfaceKHR +VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateAndroidSurfaceKHR( + VkInstance instance, Window window, const VkAllocationCallbacks *pAllocator, + VkSurfaceKHR *pSurface) { // First, check to ensure the appropriate extension was enabled: struct loader_instance *ptr_instance = loader_get_instance(instance); if (!ptr_instance->wsi_display_enabled) { @@ -1085,10 +1259,9 @@ terminator_CreateAndroidSurfaceKHR(VkInstance instance, Window window, } // Next, if so, proceed with the implementation of this function: - VkIcdSurfaceAndroid *pIcdSurface = NULL; - - pIcdSurface = loader_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceAndroid), - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + VkIcdSurfaceAndroid *pIcdSurface = + loader_instance_heap_alloc(ptr_instance, sizeof(VkIcdSurfaceAndroid), + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if (pIcdSurface == NULL) { return VK_ERROR_OUT_OF_HOST_MEMORY; } @@ -1104,9 +1277,7 @@ terminator_CreateAndroidSurfaceKHR(VkInstance instance, Window window, #endif // VK_USE_PLATFORM_ANDROID_KHR -/* - * Functions for the VK_KHR_display instance extension: - */ +// Functions for the VK_KHR_display instance extension: LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, @@ -1123,11 +1294,13 @@ vkGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPropertiesKHR( VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkDisplayPropertiesKHR *pProperties) { + // First, check to ensure the appropriate extension was enabled: - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = - (struct loader_instance *)phys_dev->this_icd->this_instance; + (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_display_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_display extension not enabled. " @@ -1136,13 +1309,11 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPropertiesKHR( } // Next, if so, proceed with the implementation of this function: - struct loader_icd *icd = phys_dev->this_icd; - - assert(icd->GetPhysicalDeviceDisplayPropertiesKHR && + assert(icd_term->GetPhysicalDeviceDisplayPropertiesKHR && "loader: null GetPhysicalDeviceDisplayPropertiesKHR ICD pointer"); - return icd->GetPhysicalDeviceDisplayPropertiesKHR( - phys_dev->phys_dev, pPropertyCount, pProperties); + return icd_term->GetPhysicalDeviceDisplayPropertiesKHR( + phys_dev_term->phys_dev, pPropertyCount, pProperties); } LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL @@ -1162,11 +1333,13 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetPhysicalDeviceDisplayPlanePropertiesKHR( VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkDisplayPlanePropertiesKHR *pProperties) { + // First, check to ensure the appropriate extension was enabled: - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = - (struct loader_instance *)phys_dev->this_icd->this_instance; + (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_display_enabled) { loader_log( ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, @@ -1176,14 +1349,12 @@ terminator_GetPhysicalDeviceDisplayPlanePropertiesKHR( } // Next, if so, proceed with the implementation of this function: - struct loader_icd *icd = phys_dev->this_icd; - assert( - icd->GetPhysicalDeviceDisplayPlanePropertiesKHR && + icd_term->GetPhysicalDeviceDisplayPlanePropertiesKHR && "loader: null GetPhysicalDeviceDisplayPlanePropertiesKHR ICD pointer"); - return icd->GetPhysicalDeviceDisplayPlanePropertiesKHR( - phys_dev->phys_dev, pPropertyCount, pProperties); + return icd_term->GetPhysicalDeviceDisplayPlanePropertiesKHR( + phys_dev_term->phys_dev, pPropertyCount, pProperties); } LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL @@ -1200,16 +1371,16 @@ vkGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, return res; } -VKAPI_ATTR VkResult VKAPI_CALL -terminator_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, - uint32_t planeIndex, - uint32_t *pDisplayCount, - VkDisplayKHR *pDisplays) { +VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneSupportedDisplaysKHR( + VkPhysicalDevice physicalDevice, uint32_t planeIndex, + uint32_t *pDisplayCount, VkDisplayKHR *pDisplays) { + // First, check to ensure the appropriate extension was enabled: - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = - (struct loader_instance *)phys_dev->this_icd->this_instance; + (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_display_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_display extension not enabled. " @@ -1218,19 +1389,16 @@ terminator_GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, } // Next, if so, proceed with the implementation of this function: - struct loader_icd *icd = phys_dev->this_icd; - - assert(icd->GetDisplayPlaneSupportedDisplaysKHR && + assert(icd_term->GetDisplayPlaneSupportedDisplaysKHR && "loader: null GetDisplayPlaneSupportedDisplaysKHR ICD pointer"); - return icd->GetDisplayPlaneSupportedDisplaysKHR( - phys_dev->phys_dev, planeIndex, pDisplayCount, pDisplays); + return icd_term->GetDisplayPlaneSupportedDisplaysKHR( + phys_dev_term->phys_dev, planeIndex, pDisplayCount, pDisplays); } -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL -vkGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, - VkDisplayKHR display, uint32_t *pPropertyCount, - VkDisplayModePropertiesKHR *pProperties) { +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayModePropertiesKHR( + VkPhysicalDevice physicalDevice, VkDisplayKHR display, + uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) { VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); const VkLayerInstanceDispatchTable *disp; @@ -1243,11 +1411,13 @@ vkGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayModePropertiesKHR( VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) { + // First, check to ensure the appropriate extension was enabled: - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = - (struct loader_instance *)phys_dev->this_icd->this_instance; + (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_display_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_display extension not enabled. " @@ -1256,20 +1426,17 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayModePropertiesKHR( } // Next, if so, proceed with the implementation of this function: - struct loader_icd *icd = phys_dev->this_icd; - - assert(icd->GetDisplayModePropertiesKHR && + assert(icd_term->GetDisplayModePropertiesKHR && "loader: null GetDisplayModePropertiesKHR ICD pointer"); - return icd->GetDisplayModePropertiesKHR(phys_dev->phys_dev, display, - pPropertyCount, pProperties); + return icd_term->GetDisplayModePropertiesKHR( + phys_dev_term->phys_dev, display, pPropertyCount, pProperties); } -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL -vkCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, - const VkDisplayModeCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkDisplayModeKHR *pMode) { +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayModeKHR( + VkPhysicalDevice physicalDevice, VkDisplayKHR display, + const VkDisplayModeCreateInfoKHR *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) { VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); const VkLayerInstanceDispatchTable *disp; @@ -1279,17 +1446,17 @@ vkCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, return res; } -VKAPI_ATTR VkResult VKAPI_CALL -terminator_CreateDisplayModeKHR(VkPhysicalDevice physicalDevice, - VkDisplayKHR display, - const VkDisplayModeCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkDisplayModeKHR *pMode) { +VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayModeKHR( + VkPhysicalDevice physicalDevice, VkDisplayKHR display, + const VkDisplayModeCreateInfoKHR *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) { + // First, check to ensure the appropriate extension was enabled: - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = - (struct loader_instance *)phys_dev->this_icd->this_instance; + (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_display_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_display extension not enabled. " @@ -1298,19 +1465,16 @@ terminator_CreateDisplayModeKHR(VkPhysicalDevice physicalDevice, } // Next, if so, proceed with the implementation of this function: - struct loader_icd *icd = phys_dev->this_icd; - - assert(icd->CreateDisplayModeKHR && + assert(icd_term->CreateDisplayModeKHR && "loader: null CreateDisplayModeKHR ICD pointer"); - return icd->CreateDisplayModeKHR(phys_dev->phys_dev, display, pCreateInfo, - pAllocator, pMode); + return icd_term->CreateDisplayModeKHR(phys_dev_term->phys_dev, display, + pCreateInfo, pAllocator, pMode); } -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL -vkGetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, - VkDisplayModeKHR mode, uint32_t planeIndex, - VkDisplayPlaneCapabilitiesKHR *pCapabilities) { +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneCapabilitiesKHR( + VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex, + VkDisplayPlaneCapabilitiesKHR *pCapabilities) { VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice); const VkLayerInstanceDispatchTable *disp; @@ -1323,11 +1487,13 @@ vkGetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneCapabilitiesKHR( VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex, VkDisplayPlaneCapabilitiesKHR *pCapabilities) { + // First, check to ensure the appropriate extension was enabled: - struct loader_physical_device *phys_dev = - (struct loader_physical_device *)physicalDevice; + struct loader_physical_device_term *phys_dev_term = + (struct loader_physical_device_term *)physicalDevice; + struct loader_icd_term *icd_term = phys_dev_term->this_icd_term; struct loader_instance *ptr_instance = - (struct loader_instance *)phys_dev->this_icd->this_instance; + (struct loader_instance *)icd_term->this_instance; if (!ptr_instance->wsi_display_enabled) { loader_log(ptr_instance, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_display extension not enabled. " @@ -1336,20 +1502,16 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneCapabilitiesKHR( } // Next, if so, proceed with the implementation of this function: - struct loader_icd *icd = phys_dev->this_icd; - - assert(icd->GetDisplayPlaneCapabilitiesKHR && + assert(icd_term->GetDisplayPlaneCapabilitiesKHR && "loader: null GetDisplayPlaneCapabilitiesKHR ICD pointer"); - return icd->GetDisplayPlaneCapabilitiesKHR(phys_dev->phys_dev, mode, - planeIndex, pCapabilities); + return icd_term->GetDisplayPlaneCapabilitiesKHR( + phys_dev_term->phys_dev, mode, planeIndex, pCapabilities); } -LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL -vkCreateDisplayPlaneSurfaceKHR(VkInstance instance, - const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkSurfaceKHR *pSurface) { +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayPlaneSurfaceKHR( + VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { const VkLayerInstanceDispatchTable *disp; disp = loader_get_instance_dispatch(instance); VkResult res; @@ -1363,42 +1525,95 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR( VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { struct loader_instance *inst = loader_get_instance(instance); - VkIcdSurfaceDisplay *pIcdSurface = NULL; + VkIcdSurface *pIcdSurface = NULL; + VkResult vkRes = VK_SUCCESS; + uint32_t i = 0; - if (!inst->wsi_surface_enabled) { + if (!inst->wsi_display_enabled) { loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0, "VK_KHR_surface extension not enabled. " "vkCreateDisplayPlaneSurfaceKHR not executed!\n"); - return VK_ERROR_EXTENSION_NOT_PRESENT; + vkRes = VK_ERROR_EXTENSION_NOT_PRESENT; + goto out; } - pIcdSurface = loader_heap_alloc(inst, sizeof(VkIcdSurfaceDisplay), - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + // The VK_KHR_display path will continue to use the old path (hence the + // false as the last parameter). + pIcdSurface = + AllocateIcdSurfaceStruct(inst, sizeof(pIcdSurface->display_surf.base), + sizeof(pIcdSurface->display_surf), false); if (pIcdSurface == NULL) { - return VK_ERROR_OUT_OF_HOST_MEMORY; + vkRes = VK_ERROR_OUT_OF_HOST_MEMORY; + goto out; } - pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_DISPLAY; - pIcdSurface->displayMode = pCreateInfo->displayMode; - pIcdSurface->planeIndex = pCreateInfo->planeIndex; - pIcdSurface->planeStackIndex = pCreateInfo->planeStackIndex; - pIcdSurface->transform = pCreateInfo->transform; - pIcdSurface->globalAlpha = pCreateInfo->globalAlpha; - pIcdSurface->alphaMode = pCreateInfo->alphaMode; - pIcdSurface->imageExtent = pCreateInfo->imageExtent; + pIcdSurface->display_surf.base.platform = VK_ICD_WSI_PLATFORM_DISPLAY; + pIcdSurface->display_surf.displayMode = pCreateInfo->displayMode; + pIcdSurface->display_surf.planeIndex = pCreateInfo->planeIndex; + pIcdSurface->display_surf.planeStackIndex = pCreateInfo->planeStackIndex; + pIcdSurface->display_surf.transform = pCreateInfo->transform; + pIcdSurface->display_surf.globalAlpha = pCreateInfo->globalAlpha; + pIcdSurface->display_surf.alphaMode = pCreateInfo->alphaMode; + pIcdSurface->display_surf.imageExtent = pCreateInfo->imageExtent; - *pSurface = (VkSurfaceKHR)pIcdSurface; + // Loop through each ICD and determine if they need to create a surface + for (struct loader_icd_term *icd_term = inst->icd_terms; icd_term != NULL; + icd_term = icd_term->next, i++) { + if (icd_term->scanned_icd->interface_version >= + ICD_VER_SUPPORTS_ICD_SURFACE_KHR) { + if (NULL != icd_term->CreateDisplayPlaneSurfaceKHR) { + vkRes = icd_term->CreateDisplayPlaneSurfaceKHR( + icd_term->instance, pCreateInfo, pAllocator, + &pIcdSurface->real_icd_surfaces[i]); + if (VK_SUCCESS != vkRes) { + goto out; + } + } + } + } - return VK_SUCCESS; + *pSurface = (VkSurfaceKHR)(uintptr_t)pIcdSurface; + +out: + + if (VK_SUCCESS != vkRes && NULL != pIcdSurface) { + if (NULL != pIcdSurface->real_icd_surfaces) { + i = 0; + for (struct loader_icd_term *icd_term = inst->icd_terms; + icd_term != NULL; icd_term = icd_term->next, i++) { + if (NULL != + (void *)(uintptr_t)pIcdSurface->real_icd_surfaces[i] && + NULL != icd_term->DestroySurfaceKHR) { + icd_term->DestroySurfaceKHR( + icd_term->instance, pIcdSurface->real_icd_surfaces[i], + pAllocator); + } + } + loader_instance_heap_free(inst, pIcdSurface->real_icd_surfaces); + } + loader_instance_heap_free(inst, pIcdSurface); + } + + return vkRes; +} + +// This is the trampoline entrypoint +// for CreateSharedSwapchainsKHR +LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR( + VkDevice device, uint32_t swapchainCount, + const VkSwapchainCreateInfoKHR *pCreateInfos, + const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchains) { + const VkLayerDispatchTable *disp; + disp = loader_get_dispatch(device); + return disp->CreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, + pAllocator, pSwapchains); } bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char *name, void **addr) { *addr = NULL; - /* - * Functions for the VK_KHR_surface extension: - */ + // Functions for the VK_KHR_surface extension: if (!strcmp("vkDestroySurfaceKHR", name)) { *addr = ptr_instance->wsi_surface_enabled ? (void *)vkDestroySurfaceKHR : NULL; @@ -1429,14 +1644,12 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, return true; } - /* - * Functions for the VK_KHR_swapchain extension: - * - * Note: This is a device extension, and its functions are statically - * exported from the loader. Per Khronos decisions, the the loader's GIPA - * function will return the trampoline function for such device-extension - * functions, regardless of whether the extension has been enabled. - */ + // Functions for the VK_KHR_swapchain extension: + + // Note: This is a device extension, and its functions are statically + // exported from the loader. Per Khronos decisions, the loader's GIPA + // function will return the trampoline function for such device-extension + // functions, regardless of whether the extension has been enabled. if (!strcmp("vkCreateSwapchainKHR", name)) { *addr = (void *)vkCreateSwapchainKHR; return true; @@ -1459,9 +1672,8 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, } #ifdef VK_USE_PLATFORM_WIN32_KHR - /* - * Functions for the VK_KHR_win32_surface extension: - */ + + // Functions for the VK_KHR_win32_surface extension: if (!strcmp("vkCreateWin32SurfaceKHR", name)) { *addr = ptr_instance->wsi_win32_surface_enabled ? (void *)vkCreateWin32SurfaceKHR @@ -1476,9 +1688,8 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, } #endif // VK_USE_PLATFORM_WIN32_KHR #ifdef VK_USE_PLATFORM_MIR_KHR - /* - * Functions for the VK_KHR_mir_surface extension: - */ + + // Functions for the VK_KHR_mir_surface extension: if (!strcmp("vkCreateMirSurfaceKHR", name)) { *addr = ptr_instance->wsi_mir_surface_enabled ? (void *)vkCreateMirSurfaceKHR @@ -1493,9 +1704,8 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, } #endif // VK_USE_PLATFORM_MIR_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR - /* - * Functions for the VK_KHR_wayland_surface extension: - */ + + // Functions for the VK_KHR_wayland_surface extension: if (!strcmp("vkCreateWaylandSurfaceKHR", name)) { *addr = ptr_instance->wsi_wayland_surface_enabled ? (void *)vkCreateWaylandSurfaceKHR @@ -1510,9 +1720,8 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, } #endif // VK_USE_PLATFORM_WAYLAND_KHR #ifdef VK_USE_PLATFORM_XCB_KHR - /* - * Functions for the VK_KHR_xcb_surface extension: - */ + + // Functions for the VK_KHR_xcb_surface extension: if (!strcmp("vkCreateXcbSurfaceKHR", name)) { *addr = ptr_instance->wsi_xcb_surface_enabled ? (void *)vkCreateXcbSurfaceKHR @@ -1527,9 +1736,8 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, } #endif // VK_USE_PLATFORM_XCB_KHR #ifdef VK_USE_PLATFORM_XLIB_KHR - /* - * Functions for the VK_KHR_xlib_surface extension: - */ + + // Functions for the VK_KHR_xlib_surface extension: if (!strcmp("vkCreateXlibSurfaceKHR", name)) { *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *)vkCreateXlibSurfaceKHR @@ -1544,9 +1752,8 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, } #endif // VK_USE_PLATFORM_XLIB_KHR #ifdef VK_USE_PLATFORM_ANDROID_KHR - /* - * Functions for the VK_KHR_android_surface extension: - */ + + // Functions for the VK_KHR_android_surface extension: if (!strcmp("vkCreateAndroidSurfaceKHR", name)) { *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *)vkCreateAndroidSurfaceKHR @@ -1555,9 +1762,7 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, } #endif // VK_USE_PLATFORM_ANDROID_KHR - /* - * Functions for VK_KHR_display extension: - */ + // Functions for VK_KHR_display extension: if (!strcmp("vkGetPhysicalDeviceDisplayPropertiesKHR", name)) { *addr = ptr_instance->wsi_display_enabled ? (void *)vkGetPhysicalDeviceDisplayPropertiesKHR @@ -1600,5 +1805,12 @@ bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, : NULL; return true; } + + // Functions for KHR_display_swapchain extension: + if (!strcmp("vkCreateSharedSwapchainsKHR", name)) { + *addr = (void *)vkCreateSharedSwapchainsKHR; + return true; + } + return false; } diff --git a/third_party/vulkan/loader/wsi.h b/third_party/vulkan/loader/wsi.h index fa6008884..77cc183d0 100644 --- a/third_party/vulkan/loader/wsi.h +++ b/third_party/vulkan/loader/wsi.h @@ -19,9 +19,38 @@ * */ +#ifndef WSI_H +#define WSI_H + #include "vk_loader_platform.h" #include "loader.h" +typedef struct { + union { +#ifdef VK_USE_PLATFORM_MIR_KHR + VkIcdSurfaceMir mir_surf; +#endif // VK_USE_PLATFORM_MIR_KHR +#ifdef VK_USE_PLATFORM_WAYLAND_KHR + VkIcdSurfaceWayland wayland_surf; +#endif // VK_USE_PLATFORM_WAYLAND_KHR +#ifdef VK_USE_PLATFORM_WIN32_KHR + VkIcdSurfaceWin32 win_surf; +#endif // VK_USE_PLATFORM_WIN32_KHR +#ifdef VK_USE_PLATFORM_XCB_KHR + VkIcdSurfaceXcb xcb_surf; +#endif // VK_USE_PLATFORM_XCB_KHR +#ifdef VK_USE_PLATFORM_XLIB_KHR + VkIcdSurfaceXlib xlib_surf; +#endif // VK_USE_PLATFORM_XLIB_KHR + VkIcdSurfaceDisplay display_surf; + }; + uint32_t base_size; // Size of VkIcdSurfaceBase + uint32_t platform_size; // Size of corresponding VkIcdSurfaceXXX + uint32_t non_platform_offset; // Start offset to base_size + uint32_t entire_size; // Size of entire VkIcdSurface + VkSurfaceKHR *real_icd_surfaces; +} VkIcdSurface; + bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance, const char *name, void **addr); @@ -29,6 +58,10 @@ void wsi_create_instance(struct loader_instance *ptr_instance, const VkInstanceCreateInfo *pCreateInfo); bool wsi_unsupported_instance_extension(const VkExtensionProperties *ext_prop); +VKAPI_ATTR VkResult VKAPI_CALL terminator_vkCreateSwapchainKHR( + VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain); + VKAPI_ATTR void VKAPI_CALL terminator_DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks *pAllocator); @@ -135,3 +168,5 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetDisplayPlaneCapabilitiesKHR( VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDisplayPlaneSurfaceKHR( VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface); + +#endif /* WSI_H */ diff --git a/third_party/vulkan/vk_icd.h b/third_party/vulkan/vk_icd.h index a64936413..7b54fb577 100644 --- a/third_party/vulkan/vk_icd.h +++ b/third_party/vulkan/vk_icd.h @@ -28,7 +28,7 @@ /* * Loader-ICD version negotiation API */ -#define CURRENT_LOADER_ICD_INTERFACE_VERSION 2 +#define CURRENT_LOADER_ICD_INTERFACE_VERSION 3 #define MIN_SUPPORTED_LOADER_ICD_INTERFACE_VERSION 0 typedef VkResult (VKAPI_PTR *PFN_vkNegotiateLoaderICDInterfaceVersion)(uint32_t *pVersion); /* @@ -111,6 +111,12 @@ typedef struct { } VkIcdSurfaceXlib; #endif // VK_USE_PLATFORM_XLIB_KHR +#ifdef VK_USE_PLATFORM_ANDROID_KHR +typedef struct { + ANativeWindow* window; +} VkIcdSurfaceAndroid; +#endif //VK_USE_PLATFORM_ANDROID_KHR + typedef struct { VkIcdSurfaceBase base; VkDisplayModeKHR displayMode; @@ -121,4 +127,5 @@ typedef struct { VkDisplayPlaneAlphaFlagBitsKHR alphaMode; VkExtent2D imageExtent; } VkIcdSurfaceDisplay; + #endif // VKICD_H diff --git a/third_party/vulkan/vk_layer.h b/third_party/vulkan/vk_layer.h index 8b7d82fb5..78f637213 100644 --- a/third_party/vulkan/vk_layer.h +++ b/third_party/vulkan/vk_layer.h @@ -162,6 +162,17 @@ typedef struct VkLayerDispatchTable_ { PFN_vkGetSwapchainImagesKHR GetSwapchainImagesKHR; PFN_vkAcquireNextImageKHR AcquireNextImageKHR; PFN_vkQueuePresentKHR QueuePresentKHR; + PFN_vkCmdDrawIndirectCountAMD CmdDrawIndirectCountAMD; + PFN_vkCmdDrawIndexedIndirectCountAMD CmdDrawIndexedIndirectCountAMD; +#ifdef VK_USE_PLATFORM_WIN32_KHR + PFN_vkGetMemoryWin32HandleNV GetMemoryWin32HandleNV; +#endif + PFN_vkCreateSharedSwapchainsKHR CreateSharedSwapchainsKHR; + PFN_vkDebugMarkerSetObjectTagEXT DebugMarkerSetObjectTagEXT; + PFN_vkDebugMarkerSetObjectNameEXT DebugMarkerSetObjectNameEXT; + PFN_vkCmdDebugMarkerBeginEXT CmdDebugMarkerBeginEXT; + PFN_vkCmdDebugMarkerEndEXT CmdDebugMarkerEndEXT; + PFN_vkCmdDebugMarkerInsertEXT CmdDebugMarkerInsertEXT; } VkLayerDispatchTable; typedef struct VkLayerInstanceDispatchTable_ { @@ -232,6 +243,8 @@ typedef struct VkLayerInstanceDispatchTable_ { GetDisplayPlaneCapabilitiesKHR; PFN_vkCreateDisplayPlaneSurfaceKHR CreateDisplayPlaneSurfaceKHR; + PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV + GetPhysicalDeviceExternalImageFormatPropertiesNV; } VkLayerInstanceDispatchTable; // ------------------------------------------------------------------------------------------------ diff --git a/third_party/vulkan/vk_platform.h b/third_party/vulkan/vk_platform.h index 5d0fc766e..0fa62ee23 100644 --- a/third_party/vulkan/vk_platform.h +++ b/third_party/vulkan/vk_platform.h @@ -51,13 +51,13 @@ extern "C" #define VKAPI_ATTR #define VKAPI_CALL __stdcall #define VKAPI_PTR VKAPI_CALL -#elif defined(__ANDROID__) && defined(__ARM_EABI__) && !defined(__ARM_ARCH_7A__) - // Android does not support Vulkan in native code using the "armeabi" ABI. - #error "Vulkan requires the 'armeabi-v7a' or 'armeabi-v7a-hard' ABI on 32-bit ARM CPUs" -#elif defined(__ANDROID__) && defined(__ARM_ARCH_7A__) - // On Android/ARMv7a, Vulkan functions use the armeabi-v7a-hard calling - // convention, even if the application's native code is compiled with the - // armeabi-v7a calling convention. +#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7 + #error "Vulkan isn't supported for the 'armeabi' NDK ABI" +#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE) + // On Android 32-bit ARM targets, Vulkan functions use the "hardfloat" + // calling convention, i.e. float parameters are passed in registers. This + // is true even if the rest of the application passes floats on the stack, + // as it does by default when compiling for the armeabi-v7a NDK ABI. #define VKAPI_ATTR __attribute__((pcs("aapcs-vfp"))) #define VKAPI_CALL #define VKAPI_PTR VKAPI_ATTR diff --git a/third_party/vulkan/vulkan.h b/third_party/vulkan/vulkan.h index 75afd4a78..b33871ebd 100644 --- a/third_party/vulkan/vulkan.h +++ b/third_party/vulkan/vulkan.h @@ -43,7 +43,7 @@ extern "C" { #define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3ff) #define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xfff) // Version of this file -#define VK_HEADER_VERSION 16 +#define VK_HEADER_VERSION 34 #define VK_NULL_HANDLE 0 @@ -53,11 +53,13 @@ extern "C" { #define VK_DEFINE_HANDLE(object) typedef struct object##_T* object; -#if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) +#if !defined(VK_DEFINE_NON_DISPATCHABLE_HANDLE) +#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object; #else #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object; #endif +#endif @@ -135,6 +137,7 @@ typedef enum VkResult { VK_ERROR_INCOMPATIBLE_DRIVER = -9, VK_ERROR_TOO_MANY_OBJECTS = -10, VK_ERROR_FORMAT_NOT_SUPPORTED = -11, + VK_ERROR_FRAGMENTED_POOL = -12, VK_ERROR_SURFACE_LOST_KHR = -1000000000, VK_ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001, VK_SUBOPTIMAL_KHR = 1000001003, @@ -142,9 +145,9 @@ typedef enum VkResult { VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001, VK_ERROR_VALIDATION_FAILED_EXT = -1000011001, VK_ERROR_INVALID_SHADER_NV = -1000012000, - VK_RESULT_BEGIN_RANGE = VK_ERROR_FORMAT_NOT_SUPPORTED, + VK_RESULT_BEGIN_RANGE = VK_ERROR_FRAGMENTED_POOL, VK_RESULT_END_RANGE = VK_INCOMPLETE, - VK_RESULT_RANGE_SIZE = (VK_INCOMPLETE - VK_ERROR_FORMAT_NOT_SUPPORTED + 1), + VK_RESULT_RANGE_SIZE = (VK_INCOMPLETE - VK_ERROR_FRAGMENTED_POOL + 1), VK_RESULT_MAX_ENUM = 0x7FFFFFFF } VkResult; @@ -214,6 +217,15 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT = 1000022000, VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_TAG_INFO_EXT = 1000022001, VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT = 1000022002, + VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_IMAGE_CREATE_INFO_NV = 1000026000, + VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_BUFFER_CREATE_INFO_NV = 1000026001, + VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV = 1000026002, + VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_NV = 1000056000, + VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_NV = 1000056001, + VK_STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_NV = 1000057000, + VK_STRUCTURE_TYPE_EXPORT_MEMORY_WIN32_HANDLE_INFO_NV = 1000057001, + VK_STRUCTURE_TYPE_WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_NV = 1000058000, + VK_STRUCTURE_TYPE_VALIDATION_FLAGS_EXT = 1000061000, VK_STRUCTURE_TYPE_BEGIN_RANGE = VK_STRUCTURE_TYPE_APPLICATION_INFO, VK_STRUCTURE_TYPE_END_RANGE = VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO, VK_STRUCTURE_TYPE_RANGE_SIZE = (VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO - VK_STRUCTURE_TYPE_APPLICATION_INFO + 1), @@ -426,6 +438,14 @@ typedef enum VkFormat { VK_FORMAT_ASTC_12x10_SRGB_BLOCK = 182, VK_FORMAT_ASTC_12x12_UNORM_BLOCK = 183, VK_FORMAT_ASTC_12x12_SRGB_BLOCK = 184, + VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG = 1000054000, + VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG = 1000054001, + VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG = 1000054002, + VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG = 1000054003, + VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG = 1000054004, + VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG = 1000054005, + VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG = 1000054006, + VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG = 1000054007, VK_FORMAT_BEGIN_RANGE = VK_FORMAT_UNDEFINED, VK_FORMAT_END_RANGE = VK_FORMAT_ASTC_12x12_SRGB_BLOCK, VK_FORMAT_RANGE_SIZE = (VK_FORMAT_ASTC_12x12_SRGB_BLOCK - VK_FORMAT_UNDEFINED + 1), @@ -2347,7 +2367,7 @@ typedef void (VKAPI_PTR *PFN_vkCmdCopyImage)(VkCommandBuffer commandBuffer, VkIm typedef void (VKAPI_PTR *PFN_vkCmdBlitImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit* pRegions, VkFilter filter); typedef void (VKAPI_PTR *PFN_vkCmdCopyBufferToImage)(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions); typedef void (VKAPI_PTR *PFN_vkCmdCopyImageToBuffer)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions); -typedef void (VKAPI_PTR *PFN_vkCmdUpdateBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const uint32_t* pData); +typedef void (VKAPI_PTR *PFN_vkCmdUpdateBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const void* pData); typedef void (VKAPI_PTR *PFN_vkCmdFillBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data); typedef void (VKAPI_PTR *PFN_vkCmdClearColorImage)(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges); typedef void (VKAPI_PTR *PFN_vkCmdClearDepthStencilImage)(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges); @@ -3032,7 +3052,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdUpdateBuffer( VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, - const uint32_t* pData); + const void* pData); VKAPI_ATTR void VKAPI_CALL vkCmdFillBuffer( VkCommandBuffer commandBuffer, @@ -3715,7 +3735,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR( #define VK_EXT_debug_report 1 VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDebugReportCallbackEXT) -#define VK_EXT_DEBUG_REPORT_SPEC_VERSION 2 +#define VK_EXT_DEBUG_REPORT_SPEC_VERSION 3 #define VK_EXT_DEBUG_REPORT_EXTENSION_NAME "VK_EXT_debug_report" #define VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT @@ -3927,6 +3947,213 @@ VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerInsertEXT( #define VK_AMD_GCN_SHADER_EXTENSION_NAME "VK_AMD_gcn_shader" +#define VK_NV_dedicated_allocation 1 +#define VK_NV_DEDICATED_ALLOCATION_SPEC_VERSION 1 +#define VK_NV_DEDICATED_ALLOCATION_EXTENSION_NAME "VK_NV_dedicated_allocation" + +typedef struct VkDedicatedAllocationImageCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkBool32 dedicatedAllocation; +} VkDedicatedAllocationImageCreateInfoNV; + +typedef struct VkDedicatedAllocationBufferCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkBool32 dedicatedAllocation; +} VkDedicatedAllocationBufferCreateInfoNV; + +typedef struct VkDedicatedAllocationMemoryAllocateInfoNV { + VkStructureType sType; + const void* pNext; + VkImage image; + VkBuffer buffer; +} VkDedicatedAllocationMemoryAllocateInfoNV; + + + +#define VK_AMD_draw_indirect_count 1 +#define VK_AMD_DRAW_INDIRECT_COUNT_SPEC_VERSION 1 +#define VK_AMD_DRAW_INDIRECT_COUNT_EXTENSION_NAME "VK_AMD_draw_indirect_count" + +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndirectCountAMD)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndexedIndirectCountAMD)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectCountAMD( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkBuffer countBuffer, + VkDeviceSize countBufferOffset, + uint32_t maxDrawCount, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCountAMD( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkBuffer countBuffer, + VkDeviceSize countBufferOffset, + uint32_t maxDrawCount, + uint32_t stride); +#endif + +#define VK_AMD_negative_viewport_height 1 +#define VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_SPEC_VERSION 1 +#define VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME "VK_AMD_negative_viewport_height" + + +#define VK_AMD_gpu_shader_half_float 1 +#define VK_AMD_GPU_SHADER_HALF_FLOAT_SPEC_VERSION 1 +#define VK_AMD_GPU_SHADER_HALF_FLOAT_EXTENSION_NAME "VK_AMD_gpu_shader_half_float" + + +#define VK_AMD_shader_ballot 1 +#define VK_AMD_SHADER_BALLOT_SPEC_VERSION 1 +#define VK_AMD_SHADER_BALLOT_EXTENSION_NAME "VK_AMD_shader_ballot" + + +#define VK_IMG_format_pvrtc 1 +#define VK_IMG_FORMAT_PVRTC_SPEC_VERSION 1 +#define VK_IMG_FORMAT_PVRTC_EXTENSION_NAME "VK_IMG_format_pvrtc" + + +#define VK_NV_external_memory_capabilities 1 +#define VK_NV_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION 1 +#define VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME "VK_NV_external_memory_capabilities" + + +typedef enum VkExternalMemoryHandleTypeFlagBitsNV { + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_NV = 0x00000001, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_NV = 0x00000002, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_IMAGE_BIT_NV = 0x00000004, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_IMAGE_KMT_BIT_NV = 0x00000008, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkExternalMemoryHandleTypeFlagBitsNV; +typedef VkFlags VkExternalMemoryHandleTypeFlagsNV; + +typedef enum VkExternalMemoryFeatureFlagBitsNV { + VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT_NV = 0x00000001, + VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT_NV = 0x00000002, + VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT_NV = 0x00000004, + VK_EXTERNAL_MEMORY_FEATURE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkExternalMemoryFeatureFlagBitsNV; +typedef VkFlags VkExternalMemoryFeatureFlagsNV; + +typedef struct VkExternalImageFormatPropertiesNV { + VkImageFormatProperties imageFormatProperties; + VkExternalMemoryFeatureFlagsNV externalMemoryFeatures; + VkExternalMemoryHandleTypeFlagsNV exportFromImportedHandleTypes; + VkExternalMemoryHandleTypeFlagsNV compatibleHandleTypes; +} VkExternalImageFormatPropertiesNV; + + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkExternalMemoryHandleTypeFlagsNV externalHandleType, VkExternalImageFormatPropertiesNV* pExternalImageFormatProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceExternalImageFormatPropertiesNV( + VkPhysicalDevice physicalDevice, + VkFormat format, + VkImageType type, + VkImageTiling tiling, + VkImageUsageFlags usage, + VkImageCreateFlags flags, + VkExternalMemoryHandleTypeFlagsNV externalHandleType, + VkExternalImageFormatPropertiesNV* pExternalImageFormatProperties); +#endif + +#define VK_NV_external_memory 1 +#define VK_NV_EXTERNAL_MEMORY_SPEC_VERSION 1 +#define VK_NV_EXTERNAL_MEMORY_EXTENSION_NAME "VK_NV_external_memory" + +typedef struct VkExternalMemoryImageCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlagsNV handleTypes; +} VkExternalMemoryImageCreateInfoNV; + +typedef struct VkExportMemoryAllocateInfoNV { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlagsNV handleTypes; +} VkExportMemoryAllocateInfoNV; + + + +#ifdef VK_USE_PLATFORM_WIN32_KHR +#define VK_NV_external_memory_win32 1 +#define VK_NV_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1 +#define VK_NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_NV_external_memory_win32" + +typedef struct VkImportMemoryWin32HandleInfoNV { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlagsNV handleType; + HANDLE handle; +} VkImportMemoryWin32HandleInfoNV; + +typedef struct VkExportMemoryWin32HandleInfoNV { + VkStructureType sType; + const void* pNext; + const SECURITY_ATTRIBUTES* pAttributes; + DWORD dwAccess; +} VkExportMemoryWin32HandleInfoNV; + + +typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleNV)(VkDevice device, VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagsNV handleType, HANDLE* pHandle); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleNV( + VkDevice device, + VkDeviceMemory memory, + VkExternalMemoryHandleTypeFlagsNV handleType, + HANDLE* pHandle); +#endif +#endif /* VK_USE_PLATFORM_WIN32_KHR */ + +#ifdef VK_USE_PLATFORM_WIN32_KHR +#define VK_NV_win32_keyed_mutex 1 +#define VK_NV_WIN32_KEYED_MUTEX_SPEC_VERSION 1 +#define VK_NV_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_NV_win32_keyed_mutex" + +typedef struct VkWin32KeyedMutexAcquireReleaseInfoNV { + VkStructureType sType; + const void* pNext; + uint32_t acquireCount; + const VkDeviceMemory* pAcquireSyncs; + const uint64_t* pAcquireKeys; + const uint32_t* pAcquireTimeoutMilliseconds; + uint32_t releaseCount; + const VkDeviceMemory* pReleaseSyncs; + const uint64_t* pReleaseKeys; +} VkWin32KeyedMutexAcquireReleaseInfoNV; + + +#endif /* VK_USE_PLATFORM_WIN32_KHR */ + +#define VK_EXT_validation_flags 1 +#define VK_EXT_VALIDATION_FLAGS_SPEC_VERSION 1 +#define VK_EXT_VALIDATION_FLAGS_EXTENSION_NAME "VK_EXT_validation_flags" + + +typedef enum VkValidationCheckEXT { + VK_VALIDATION_CHECK_ALL_EXT = 0, + VK_VALIDATION_CHECK_BEGIN_RANGE_EXT = VK_VALIDATION_CHECK_ALL_EXT, + VK_VALIDATION_CHECK_END_RANGE_EXT = VK_VALIDATION_CHECK_ALL_EXT, + VK_VALIDATION_CHECK_RANGE_SIZE_EXT = (VK_VALIDATION_CHECK_ALL_EXT - VK_VALIDATION_CHECK_ALL_EXT + 1), + VK_VALIDATION_CHECK_MAX_ENUM_EXT = 0x7FFFFFFF +} VkValidationCheckEXT; + +typedef struct VkValidationFlagsEXT { + VkStructureType sType; + const void* pNext; + uint32_t disabledValidationCheckCount; + VkValidationCheckEXT* pDisabledValidationChecks; +} VkValidationFlagsEXT; + + + #ifdef __cplusplus } #endif