Skip to content

Defer GX pipeline UID cache writes in libretro - #503

Merged
cscd98 merged 2 commits into
libretro:masterfrom
rtomasa:libretro-defer-shader-uid-writes
Sep 24, 2026
Merged

cscd98 merged 2 commits into
libretro:masterfrom
rtomasa:libretro-defer-shader-uid-writes

Conversation

@rtomasa

@rtomasa rtomasa commented Sep 23, 2026

Copy link
Copy Markdown

Summary

Several games experience frequent brief stalls, sometimes severe enough to make them unplayable. Each newly discovered GX pipeline UID is currently written to disk from the draw path, making rendering sensitive to storage delays.

In the libretro core, this change queues new UIDs in memory and writes them together when the cache closes on reload or shutdown.

Following the PR rules, I want to disclose that this issue was identified during an AI review of the draw path that I requested. I reviewed the code myself, and other users and I tested the change.

Testing

  • In Resident Evil Zero on RePlay with Vulkan, the first launch logged Read 0 pipeline UIDs. After a clean unload, the next launch logged Read 6 pipeline UIDs from GBZP08.uidcache, confirming the entries were saved and reloaded.
  • Several testers reported substantially smoother gameplay in Resident Evil Zero and other games.

Queue newly discovered GX pipeline UIDs during rendering and append them when the cache closes on reload or shutdown. Keep the existing immediate writes for standalone Dolphin.
@cscd98

cscd98 commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR! Is this something that can be upstream to dolphin-emu?

@rtomasa

rtomasa commented Sep 24, 2026

Copy link
Copy Markdown
Author

I guarded the code with #ifdef LIBRETRO because of your previous recommendation of avoiding any change on non-libretro code, but definitely this is something that could be added upstream.
Standalone emulator uses buffered writes, so probably it is not so heavily affected because in libretro this operation is passed to the VFS implementation that normally perform immediate operations in the same thread.
That said, this will help removing any stall also in the standalone if any. The only tradeoff of this change is that you are not writing buffered UID that are in RAM in case that the emulator/core crashes, but this should be totally fine.

@cscd98

cscd98 commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Quite possibly this is due to me implementing VFS for everything and not specific to ISO loading 👍

Could you restore the comments? I try to keep this repo as close to upstream as possible.

@rtomasa

rtomasa commented Sep 24, 2026

Copy link
Copy Markdown
Author

Using VFS is definitely the right thing to do, but the original code was already writing to disk from the draw path. Cached or not, I think deferring those writes is a much better approach. The improvement is pretty noticeable.

BTW, I’ve already restored the original comments.

@cscd98
cscd98 merged commit f85959c into libretro:master Sep 24, 2026
6 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.

2 participants