Skip to content

Commit

Permalink
Vulkan: Fix ImGui font leak
Browse files Browse the repository at this point in the history
  • Loading branch information
goeiecool9999 committed Nov 4, 2024
1 parent e524e08 commit b784c32
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,7 @@ void VulkanRenderer::Initialize()

void VulkanRenderer::Shutdown()
{
DeleteFontTextures();
Renderer::Shutdown();
SubmitCommandBuffer();
WaitDeviceIdle();
Expand Down Expand Up @@ -2675,6 +2676,7 @@ void VulkanRenderer::RecreateSwapchain(bool mainWindow, bool skipCreate)
Vector2i size;
if (mainWindow)
{
ImGui_ImplVulkan_DestroyFontsTexture();
ImGui_ImplVulkan_Shutdown();
gui_getWindowPhysSize(size.x, size.y);
}
Expand Down
9 changes: 9 additions & 0 deletions src/imgui/imgui_impl_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b784c32

Please sign in to comment.