Vulkan: Fix ImGui font leak

This commit is contained in:
goeiecool9999 2024-11-04 22:42:26 +01:00
parent e524e080e1
commit 16c5726db5
2 changed files with 12 additions and 0 deletions

View file

@ -1623,6 +1623,7 @@ void VulkanRenderer::Initialize()
void VulkanRenderer::Shutdown()
{
DeleteFontTextures();
Renderer::Shutdown();
SubmitCommandBuffer();
WaitDeviceIdle();
@ -1853,6 +1854,7 @@ void VulkanRenderer::DeleteTexture(ImTextureID id)
void VulkanRenderer::DeleteFontTextures()
{
WaitDeviceIdle();
ImGui_ImplVulkan_DestroyFontsTexture();
}
@ -2675,6 +2677,7 @@ void VulkanRenderer::RecreateSwapchain(bool mainWindow, bool skipCreate)
Vector2i size;
if (mainWindow)
{
ImGui_ImplVulkan_DestroyFontsTexture();
ImGui_ImplVulkan_Shutdown();
gui_getWindowPhysSize(size.x, size.y);
}

View file

@ -465,6 +465,15 @@ void ImGui_ImplVulkan_DestroyFontsTexture()
if (g_FontView) { vkDestroyImageView(v->Device, g_FontView, v->Allocator); g_FontView = VK_NULL_HANDLE; }
if (g_FontImage) { vkDestroyImage(v->Device, g_FontImage, v->Allocator); g_FontImage = VK_NULL_HANDLE; }
if (g_FontMemory) { vkFreeMemory(v->Device, g_FontMemory, v->Allocator); g_FontMemory = VK_NULL_HANDLE; }
ImGuiIO& io = ImGui::GetIO();
auto texture = io.Fonts->TexID;
if(texture != (ImTextureID)nullptr)
{
ImGui_ImplVulkan_DeleteTexture(texture);
delete (ImGuiTexture*)texture;
io.Fonts->TexID = nullptr;
}
}
bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer)