-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vulkan: Adding leak prevention if the fonts need to be recreated #6943
Conversation
I will create a minimal example if required. Thanks! |
Seems like there are a ton of different approaches to this problem. ~~The benefit of my approach is that the resources are guaranteed to free if ImGui_ImplVulkan_CreateFontsTexture() ~~ #4618 seems like the better approach |
I appreciate your edits and looking into this. My problem at this point is that every PR has variations and confusion or unanswered questions. I realize it isn't a complicated problem but I think one clean PR, _and a repro of well-intending user code (ex: patch in one of main.cpp) exhibiting the bug, I don't think I've had one. (That could be a separate commit in the same PR that I would avoid merging) |
I'm looking into this now and trying to understand the differences between all 5 versions.
|
I have merged 6e7b43b Adding 79a9e2f Following the above and the realization that UploadFonts() didn't need to rely on data created by the example code, I moved it to the backends. Which results in: (1) Removing parameter from I'm honestly a bit embarrassed at the ongoing complexity of the Vulkan backend: this simplification has been at reach for years and nobody seemingly investigated the thing deeply enough (me included, as I barely understand many of the concepts here). If this was possible to be overlooked, god knows what other healthy simplifications could be done to the backend. Anyway, it's done now AFAIK, it both fixes the leak/validation error, makes examples/user code simpler, and makes reloading font simpler. My quick testbed was adding this at the very beginning of main loop (before the NewFrame() calls): if (ImGui::IsKeyPressed(ImGuiKey_F1))
{
static float size = 13.0f;
size += 1.0f;
io.Fonts->Clear();
ImFontConfig cfg;
cfg.SizePixels = size;
io.Fonts->AddFontDefault(&cfg);
io.Fonts->Build();
ImGui_ImplVulkan_CreateFontsTexture();
} Closing 5 pr/issues, yay! Thanks all! |
Congrats! |
Issue:
I implemented support for DPI awareness in our ImGui based application by following #3925 .
It was adapted for Win32 and Vulkan.
ImGui_ImplVulkan_CreateFontsTexture() needs to be called each time the DPI changes
but I noticed that the font resources are never cleaned up creating a resource leak.
This diff prevents the leak from occurring.
Thanks!