-
Notifications
You must be signed in to change notification settings - Fork 2
Implement font memory guards to prevent using too much texture memory #135
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
base: main
Are you sure you want to change the base?
Conversation
…o limit texture memory allocation for fonts, enhancing performance on low-end GPUs. Updated font initialization to incorporate memory constraints and fallback strategies, ensuring efficient resource usage. Updated package versions for dependencies.
…methods to public, enhancing accessibility. Updated integrated GPU detection patterns for AMD and Intel, and improved memory limit calculations for both GPU types. Added comprehensive unit tests for FontMemoryGuard functionality, ensuring robust memory estimation and GPU detection.
|
…mGuiApp.Test, and ImGuiAppDemo projects to support .NET 8.0 and 9.0. Reintroduced coverlet.collector dependency in test dependencies section of Directory.Packages.props. Updated ktsu SDK versions to 1.56.0 across all projects for improved functionality.
|
@copilot please make this branch ready to merge into main |
|
@matt-edmondson I've opened a new pull request, #144, to work on those changes. Once the pull request is ready, I'll request review from you. |
Implement font memory guards to prevent texture memory exhaustion on integrated GPUs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| builder.BuildRanges(ref reducedRanges); | ||
|
|
||
| return reducedRanges.Data; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Dangling Pointer From Out-of-Scope Data
The GetReducedUnicodeRanges method returns a dangling pointer. It creates a local ImVector<uint> reducedRanges, builds glyph ranges into it, and returns reducedRanges.Data. However, the local ImVector goes out of scope immediately after the method returns, making the returned pointer invalid. This causes undefined behavior when the pointer is later used in LoadFontFromMemory. The method should follow the pattern used in FontHelper.GetExtendedUnicodeRanges by storing the ImVector in a static field to keep it alive, similar to how extendedUnicodeRanges and emojiRanges are managed.


Note
Adds a GPU-aware FontMemoryGuard with fallbacks and integrates it into font initialization, plus tests, config hooks, and build/dependency updates.
FontMemoryGuardintoInitFonts()with GPU detection, memory estimation, and fallback strategies (reduced sizes, disable emojis, reduced Unicode).ApplyFallbackConstraints,ShouldLoadEmojis,ShouldUseReducedUnicode,GetConstrainedGlyphRanges,LogFontAtlasInfo.ImGuiApp/FontMemoryGuard.cs: GPU memory detection (NVIDIA/AMD extensions, Intel/AMD APU heuristics), config (FontMemoryConfig), estimation (FontMemoryEstimate), strategies (FallbackStrategy), range reducers and utilities.ImGuiAppConfig: addsFontMemoryConfigto control font memory limits/behavior.ImGuiApp.Test/FontMemoryGuardTests.cs: unit tests for estimation, fallbacks, heuristics, config, and logging.ImGuiApp.Test/ImGuiAppTests.cs: updates to support new APIs/usings.net9.0(libs, tests, demo).Hexa.NET.ImGui,SixLabors.ImageSharp,System.Text.Json, MSTest packages; updatesglobal.jsonSDKs.Written by Cursor Bugbot for commit dad3369. This will update automatically on new commits. Configure here.