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

Improve texture replacement cache and allow read from zip #16304

Merged
merged 8 commits into from
Oct 31, 2022

Conversation

unknownbrackets
Copy link
Collaborator

@unknownbrackets unknownbrackets commented Oct 30, 2022

This makes a few changes:

  1. Moves decoded image data caching to cache by filename, rather than by cache key. This reduces duplicate cache data in memory.
  2. Imposes pressure on the cache after 1 GB maximizing at 4 GB, linearly increasing decimation aggressiveness.
  3. Allows the use of a textures.zip file inside PSP/TEXTURES/GAME12345/ in place of textures.ini, for better performance.

Note: I'm pretty sure that pointers to values in std::unordered_map are permanent until erased, but correct me if I'm mistaken.

To use textures.zip:

  • textures.ini must be at the root of the zip, not inside a subfolder. Don't zip the folder, add the contents themselves.
  • It's recommended to use "store" compression mode (zim or zip files will already be compressed, so zip compression will just waste performance.)
  • Save new textures works, but won't save into the zip file and the saved files won't be used.
  • Make sure textures.zip is inside the game-specific folder, exactly where textures.ini would've gone.

Currently there's no way to directly install a textures.zip file, and as noted it's a bit more restrictive than the installer allows (i.e. with textures.ini required at the root.) That said, the installer could be changed to just copy the zip into place.

Fixes #16135.

-[Unknown]

Will work on all platforms, but intended for situations like Android where
random access to files on storage is horribly slow.
@hrydgard
Copy link
Owner

hrydgard commented Oct 30, 2022

Iterators in unordered_map get invalidated when the map rehashes, which it can do when it grows. See https://stackoverflow.com/questions/16781886/can-we-store-unordered-maptiterator for example.

Will actually look at the code now - or actually later.

@unknownbrackets
Copy link
Collaborator Author

@hrydgard
Copy link
Owner

Yeah you're right, those should be fine, unlike iterators - if it was allowed to move the nodes in memory, a lot of stuff would break.

@hrydgard hrydgard merged commit 3f33cf1 into hrydgard:master Oct 31, 2022
@unknownbrackets unknownbrackets deleted the replacement branch October 31, 2022 13:55
@rorowong888
Copy link

Thank you so much for this act. Which is a hugh upgrade for reading texture pack via zip packing method.
Some of the hd pack especially racing game is very largely if using old version.But now ,that is no longer after 1.14.4.
Thank again hrydgard and keep it up 👍

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.

Persona 3 memory leak loading texture replacments
3 participants