Browse Source

destroy_gpu_instance() function wait for all devices to be idle before destroy (#4763)

* destroy_gpu_instance() will internally ensure that all vulkan devices are idle before proceeding with destruction.
tags/20240410
張小凡 GitHub 2 years ago
parent
commit
3b048d1923
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions
  1. +13
    -0
      src/gpu.cpp
  2. +1
    -0
      src/gpu.h

+ 13
- 0
src/gpu.cpp View File

@@ -2091,6 +2091,19 @@ void destroy_gpu_instance()
if (g_instance.created == 0)
return;

for (int i = 0; i < NCNN_MAX_GPU_COUNT; i++)
{
VulkanDevice* vulkan_device = g_default_vkdev[i];
if (vulkan_device)
{
VkDevice vkdev = g_default_vkdev[i]->vkdevice();
if (vkdev)
{
vkDeviceWaitIdle(vkdev);
}
}
}

// NCNN_LOGE("destroy_gpu_instance");

if (g_instance.glslang_initialized)


+ 1
- 0
src/gpu.h View File

@@ -37,6 +37,7 @@ NCNN_EXPORT VkInstance get_gpu_instance();

// Destroy VkInstance object and free the memory of the associated object
// Usually called in the destructor of the main program exit
// The function will internally ensure that all vulkan devices are idle before proceeding with destruction.
NCNN_EXPORT void destroy_gpu_instance();

// vulkan core


Loading…
Cancel
Save