Tweak: Improve pause menu dungeon map performance #3773
Merged
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.
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 theWORK_DISP
in a non-standard way.Depends on Kenix3/libultraship#408Fixes #3761
Build Artifacts