Skip to content
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

Tweak: Improve pause menu dungeon map performance #3773

Merged

Conversation

Archez
Copy link
Contributor

@Archez Archez commented Dec 30, 2023

This attempts to improve pause menu performance in dungeons with HD texture packs (specifically when HD dungeon map textures are provided). Previously the dungeon map textures needed to be invalidated every frame so that the shader cache is bypassed and the texture is remade with the dynamic palette for the pulsating effect. This was fine but has introduced a performance cost on lower end devices after the introduction of #3496 for HD textures. Rebuilding high resolution textures every frame, at the 30fps from the pause menu is not good.

Turns out the renderer and shader caching can handle caching a texture per palette. The problem however is that the dynamic palette from the interface context is a reused pointer, so although the colors are changed, the pointer address does not, hence the need to invalidate the cache for the map to update.

To help with performance, I have added an array of map palettes, so that a distinct palette is used per pulsating frame. There are 40 frames in total (20 ramping up, 20 ramping down). By having a unique palette per pulse color, we can remove the texture invalidation and leverage the shader cache. Now we only need to invalidate once on pause and once when changing floors on the map menu. This will probably still incur a stutter for those 40 frames until they get cached, but thats probably on par with the rest of HD stutters at the moment.

The ramping up and ramping down unfortunately are not the "exact" colors, so I can't cheat by using only 20 palettes. Some of the palettes are the same on the end (the pulsating color eases at the ends), so if we wanted to squeeze more performance we could probably drop it from 40 frames to 32, but that wont make the stutter go away, so maybe its not worth it as is.


Additionally I leveraged the new Gfx_TextureCacheDelete to clean up the cache clearing for KD lava to no longer use the WORK_DISP in a non-standard way.

Depends on Kenix3/libultraship#408

Fixes #3761

Build Artifacts

@LuigiXHero
Copy link
Contributor

LuigiXHero commented Dec 30, 2023

If you are already changing the vanilla code to using an array you don't really need to match it 1:1 with vanilla and can probably just cut it down significantly to like 10 colors as long as it looks good. 40 colors seems like a huge overkill to me.

@Archez Archez force-pushed the improve-dungeon-map-perf branch from 6dac62c to c3f961b Compare January 5, 2024 05:08
@garrettjoecox
Copy link
Contributor

@Archez does our LUS for macready have this change yet?

@Archez
Copy link
Contributor Author

Archez commented Jan 15, 2024

@Archez does our LUS for macready have this change yet?

Yes

@garrettjoecox garrettjoecox merged commit 1da1b1a into HarbourMasters:develop-macready Jan 15, 2024
8 checks passed
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.

Error with the minimaps in inverted mode
3 participants