From bfc0ffa353cb2b7bfda65c6b65f15c5c4d0564d0 Mon Sep 17 00:00:00 2001 From: Antonio Caggiano Date: Fri, 6 Dec 2024 13:13:57 +0100 Subject: [PATCH] api_dump: Fix destroy instance dispatch table Make sure to get the dispatch key before destroying the instance as it might not be valid anymore after calling `DestroyInstance`. --- layersvt/generated/api_dump.cpp | 3 ++- scripts/api_dump_generator.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/layersvt/generated/api_dump.cpp b/layersvt/generated/api_dump.cpp index adf37cc337..b67668c480 100644 --- a/layersvt/generated/api_dump.cpp +++ b/layersvt/generated/api_dump.cpp @@ -161,9 +161,10 @@ VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAlloca { std::lock_guard lg(ApiDumpInstance::current().outputMutex()); dump_function_head(ApiDumpInstance::current(), "vkDestroyInstance", "instance, pAllocator", "void"); + auto dispatch_key = get_dispatch_key(instance); instance_dispatch_table(instance)->DestroyInstance(instance, pAllocator); - destroy_instance_dispatch_table(get_dispatch_key(instance)); + destroy_instance_dispatch_table(dispatch_key); if (ApiDumpInstance::current().shouldDumpOutput()) { switch(ApiDumpInstance::current().settings().format()) { diff --git a/scripts/api_dump_generator.py b/scripts/api_dump_generator.py index 278c049fed..3251cdd2f5 100644 --- a/scripts/api_dump_generator.py +++ b/scripts/api_dump_generator.py @@ -237,6 +237,9 @@ }} @end if + @if('{funcName}' == 'vkDestroyInstance') + auto dispatch_key = get_dispatch_key(instance); + @end if @if('{funcReturn}' != 'void') {funcReturn} result = instance_dispatch_table({funcDispatchParam})->{funcShortName}({funcNamedParams}); @end if @@ -256,7 +259,7 @@ }} @end if @if('{funcName}' == 'vkDestroyInstance') - destroy_instance_dispatch_table(get_dispatch_key(instance)); + destroy_instance_dispatch_table(dispatch_key); @end if @if('{funcName}' == 'vkGetPhysicalDeviceToolPropertiesEXT')