Skip to content

Commit

Permalink
api_dump: Fix destroy instance dispatch table
Browse files Browse the repository at this point in the history
Make sure to get the dispatch key before destroying the instance as it
might not be valid anymore after calling `DestroyInstance`.
  • Loading branch information
antonio-lunarg committed Dec 9, 2024
1 parent 4e9bb6f commit bfc0ffa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion layersvt/generated/api_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,10 @@ VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAlloca
{
std::lock_guard<std::mutex> 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())
{
Expand Down
5 changes: 4 additions & 1 deletion scripts/api_dump_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand Down

0 comments on commit bfc0ffa

Please sign in to comment.