-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
Dynamic Font Atlas and how to fix glitch? [solved] #4723
Comments
I didn't have a chance to read through all your code, but at a glance it doesn't look like you're ensuring the GPU is done with the old font texture before you destroy it in If you don't have the Vulkan validation layers enabled you probably should. |
Thank you so much, I will think about it and work on it. Maybe, I will come back after several hours because I must think, it makes things perfect. Also, I already enabled the Validation Layers, it's about Vulkan Errors Debugging. |
Note that the change for #3761 (we have transitioned this to a private WIP branch) will make it possible for backends to have multiple in-flight textures, as this it will required to allows full rebuilding or GC-ing of atlas. In 99% cases adding new glyphs should fill empty spaces and not require multiple in-flight textures but mid-frame resizing or full rebuilding or atlas will. |
As @PathogenDavid explained, I tried to remove the code deleting by letting my program leak, then the glitch is still there. When I comment the code deleting, then there is so many memory leak. As @ocornut explained, from that link #3761, I download the latest "dear imgui, v1.86 WIP" and I searched for the term ImGui_ImplVulkan_UpdateFontsTexture in the entire solution and the text was not found. That thread was posted on Jan 26. The problem is still not solved, and I have no idea how to fix it. I just sleep on bed and an idea comes to my head that it's about multi-threading problem, like another thread erases a part of another thread due to bad synchronization. I'm just telling hint if anyone can help because I'm a very beginner in Vulkan. |
Conclusion, the glitch has nothing to do with ImGui_ImplVulkan_UpdateFontsTexture or ImGui_ImplVulkan_CreateFontsTexture because I completely modify the function using my engine font texture's variables and the problem is still not solved. The good thing is the code of my project becomes much simpler, and I like it.
|
That bug fix is important, and I hope someone will fix it soon because it's not in my engine, it's inside Dear ImGui, that glitch is very popular, people call it "Draw call explosion for dynamically font change". Another conclusion, the glitch is not in the function FrameRender in examples/example_sdl_vulkan/main.cpp because when I replace ImGui_ImplVulkan_RenderDrawData with my own code and I change the font size dynamically then there's still the exact same glitch. What am I doing now is to explore the link that administrator gave me: #3471 --> #797 (which is awesome, I don't know how did you do that? I can do that with my own engine without problem, but there's a glitch on ImGui windows when change font size, and it's annoying because it's like ImGui is forever with me as a debugging tool unless I will replace it in the future with my own tools, that's the only solution, so sad). I downloaded the example and I compiled it and it runs, and I notice that when I zoom the node editor then the font texture doesn't change, just the vertices are scaled up, and I like that idea because it's smooth (only for node editor), as font size is only integer (only for gui). I keep silence for now because I post too much, I cannot ask question that's impossible for others to answer. Solution of the main problem
|
Version/Branch of Dear ImGui:
Version: v1.84
Branch:
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_sdl.cpp + imgui_impl_vulkan.cpp
Compiler: Visual Studio 2015
Operating System: Windows 10
Introduction of the glitch:
Edit: How the animation looks like after I solved the problem?
But it's a luck that I found the problem, it's about philosophy because if you work hard then you will get reward with lucks like magic, and I believe in that.
My Issue/Question:
![screenshot](https://user-images.githubusercontent.com/26832285/141764911-62245974-611e-4686-9e99-f55f64bfc427.jpg)
![imgui_glitch_gui](https://user-images.githubusercontent.com/26832285/141762210-177f3852-1f98-4a9b-8d3a-4edeb4ca6b69.gif)
My engine has separated FontAtlas Texture and ImGui windows have separated FontAtlas Texture which is explained in the C++ code at bottom (paragraphs 2. and 3.). fontGroups[0] is for ImGui windows text, and when I change the font size of fontGroups[1] which is for my engine gui then there is a risk that the ImGui windows texts show glitch just like in the .jpg image below and in the animations. The reason I use many fontGroups is there can be many groups using the same font with same size, so they are all share the same ImFont's Texture.
The question is: "How to fix that glitch in the animation?".
There's a glitch in the ImGui window texts when resizing fonts.
The reason I can build things so fast is I have high experience in my own sources, but when I don't have experience in other sources then I'm stuck. For example, I'm a beginner in Vulkan which is the hardest backend, and I have no idea how to fix the glitch by analyzing 'imgui_impl_vulkan.cpp', because Vulkan is too difficult, I'm only a beginner on it.
1. How I use the function buildFontAtlasIfNeeded_ImGui in my engine
2. Old code. Upload Fonts code referenced from "examples/example_sdl_vulkan/main.cpp > in function main" in official ImGui v1.84
3. I modified the function ImGui_ImplVulkan_CreateFontsTexture for multiple FontAtlas Texture updates reason
4. Advanced reading just to explain how I update FontAtlas in my engine
The text was updated successfully, but these errors were encountered: