Shader Cache is (Finally) Here!

Shader Cache is (Finally) Here!

Ryujinx has seen incredible progress over the course of 2020, but so far one particular feature has remained glaringly absent: a disk-based shader cache. That changes today with our latest update: project code name Salieri!

While not a core function of emulation, this feature's addition to the emulator is a quantum leap forward in gameplay enjoyability for end users and one that a multitude have been earnestly requesting for many months (shader cache when???).

What's the big deal about shader cache?

Up until now, Ryujinx has been compiling shaders on the fly when the game requests them, causing FPS drops and stutters lasting anywhere from a split second to nearly a minute, depending on the game and the size of the shader. Once compiled, these shaders remained in RAM only until the emulator was closed. On subsequent replays of the same game those shaders had to be compiled yet again, bringing with them the same slowdowns. While there are driver-level shader cache functions available on Nvidia and AMD GPUs, these only offered minor relief and are invalidated completely from time to time.

With today's update, delivered by Ryujinx developer Thog (who also implemented the complete audio renderer rewrite Amadeus earlier this year), the shaders you've compiled are now written to disk where they safely reside until being loaded into RAM on the next boot of the game. This means that even after you close and reopen the emulator, reboot your PC or update your GPU driver, Ryujinx will pre-load the appropriate game's shaders for you in just a few seconds. All this nets a significant reductionor complete eliminationof FPS drops and stutters in your favorite game. And there's one more thing: the shader compilation process itself has been optimized, noticeably reducing stutters & FPS drops during initial gameplay.

Will I ever have to rebuild my shader cache/will it ever be invalidated?

Thanks to this clever implementation, the shader cache will rebuild itself on boot if an invalidating event occurs i.e. updating your GPU drivers or if Ryujinx releases an update that affects shader code. This rebuild process takes a few minutes but surely beats having to play the game with stutters again just to build up your cache. Upgrading your PC? No problem! You can even transfer your shader cache files to the new hard drive when it's time; the shaders will be rebuilt for you on the first boot of the associated game.

What's coming next?

Shader cache plays an important role in another Ryujinx feature: LDN/local-wireless. A second LDN preview build is on the way and, with this new disk-based shader cache being incorporated, should enjoy a much more stable connection in shader-heavy games. Expect more news on this very soon!

As always, we would like to thank all our patrons and contributors; your support means a lot to us! If you can write code and know C#, or simply find emulators as fun and fascinating as we do, feel free to stop by on our Discord. Ask questions and submit a pull request; new contributors are always welcome! We have many ambitious ideas for 2021, so please consider supporting Ryujinx on Patreon to help make these goals a reality.