Skip to content

Chasm: Fix achievement popups on low-memory devices.#7

Open
ThalesC wants to merge 1 commit into
JohnnyonFlame:masterfrom
ThalesC:master
Open

Chasm: Fix achievement popups on low-memory devices.#7
ThalesC wants to merge 1 commit into
JohnnyonFlame:masterfrom
ThalesC:master

Conversation

@ThalesC

@ThalesC ThalesC commented Jul 8, 2026

Copy link
Copy Markdown

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:

// Don't draw achievements...
return false;

Instead of suppressing achievement popups, this patch reloads the drmfree texture atlas after texture bank switches, allowing achievements to render normally.

Root cause

Achievement icons are stored in the drmfree texture atlas.

On low-memory devices, Database.LoadTextureKey() unloads texture atlases that are no longer needed. After switching texture banks, the drmfree atlas 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 drmfree after texture bank switches ensures the achievement atlas remains available whenever achievement popups are rendered.

Memory impact

I inspected the atlas used for achievement icons:

  • 1 atlas (atlas_drmfree_0)
  • 256 × 256 pixels
  • SurfaceFormat.Color
  • LevelCount = 1

This 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:

  • RG35XX H
  • Knulli

Verified that achievement popups:

  • render their icons correctly,
  • no longer crash the game,
  • and continue to work after multiple texture bank switches.

The screenshot below shows the Warrior achievement popup rendered correctly after the patch.

warrior-achievement

The screenshot below shows two achievement popups rendered correctly after the patch.

warrior_and_wendigo_achievements

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.
@JohnnyonFlame

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants