Chasm: Fix achievement popups on low-memory devices.#7
Open
ThalesC wants to merge 1 commit into
Open
Conversation
Achievement icons live in the drmfree atlas. On low-memory devices, texture bank switches can leave that atlas unloaded, causing popups to show missing icons or crash. Reload drmfree after texture bank switches instead of disabling achievement rendering.
Owner
|
Thank you for the contribution! I have some more changes to do in regards to fixing issues due to SDL3 support being added to FNA3D which caused some linking woes. When I find myself going back I'll review, merge and credit you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR restores achievement popups on low-memory devices by fixing the underlying texture atlas unloading issue.
Previously, achievement rendering was disabled entirely to avoid crashes:
Instead of suppressing achievement popups, this patch reloads the
drmfreetexture atlas after texture bank switches, allowing achievements to render normally.Root cause
Achievement icons are stored in the
drmfreetexture atlas.On low-memory devices,
Database.LoadTextureKey()unloads texture atlases that are no longer needed. After switching texture banks, thedrmfreeatlas can be unloaded while achievement popups may still need to reference textures from it.When an achievement is displayed, this results in a crash while drawing the popup.
Reloading
drmfreeafter texture bank switches ensures the achievement atlas remains available whenever achievement popups are rendered.Memory impact
I inspected the atlas used for achievement icons:
atlas_drmfree_0)SurfaceFormat.ColorLevelCount = 1This corresponds to approximately 256 KiB of GPU texture memory, making the tradeoff very small while restoring the intended game behavior.
The previous workaround disabled achievement rendering to avoid the crash. This patch restores the original functionality while keeping the additional memory usage limited to a single 256 KiB texture atlas.
Testing
Tested on:
Verified that achievement popups:
The screenshot below shows the Warrior achievement popup rendered correctly after the patch.
The screenshot below shows two achievement popups rendered correctly after the patch.