Dolphin, the GameCube and Wii emulator - Forums

Full Version: Question about how shader caching works
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Head scratcher for the experts:

I've been doing some tests on my never-ending quest to squash the last few remaining occasional stutters I encounter with Dolphin.  Don't get me wrong, the emulator is at an incredible level, and I can enjoy the games just fine, but tweaking and fine-tuning emulator settings is somewhat of a hobby for me.  Direct3D 11 works best for me, when it comes to stutters.  Direct3D 12 seems to work just as well or better, but it crashes too much for me, so I don't use it -- a topic for another time.

Here is something I've found with D3D11 that has me puzzled:

Today I was stutter-testing the various backends on several different games because I recently bought another, newer AMD GPU and settled on D3D11, as usual, as the best backend to manage stuttering.  Before each test I was deleting the contents of dolphin's shaders folder, but not deleting my UID caches, of course. I would then launch the game and goof around looking for stuttering.  After testing a game with a mature UID cache once, then deleting the shader cache and launching it again, the game would stutter much less than when I revisited the same areas the first time.

I was expecting that by deleting the shader cache and going back into the game, the same stutters would occur again, but it's like a cache has been built somewhere and is preventing the stutter from happening again.  The first thing that comes to mind is that the UID cache got updated, but these are the same games I've tested over and over again through the years, so it is unlikely that I'm finding new shaders by revisiting the same well-throdded areas, starting from the same save files each time.  All of this happens all over again when I update dolphin or the GPU drivers (I need to verify which one, or if both), so I'm never fully rid of these mini-stuttters.

Could it be that aside from dolphin's own shader cache, the Windows D3D cache is also getting in on the action?  As test, I cleared the windows Direct3D cache using disk cleanup, and it did not bring back the stutter, so this is unlikely.  I also think that dolphin creates cache and does not rely on the one in Windows.

If no external caching is involved, what could explain this situation?

NOTE: I always use hybrid ubershaders and compile before starting the games.
Graphics drivers have their own caches. Even if Dolphin thinks it's the first time it's used a particular shader, it's possibly still cached elsewhere if you didn't purge the GPU driver's cache.
That would explain a lot. Thank you for explaining.
It is entirely possible then, that many of those little stutters I've experienced over the years are simply from "translated" shaders that dolphin is requesting the GPU to execute and that, although I might have previosly run them, they might have been lost through a driver update or some other way.
That's my layman's interpretation of what you said, but if it's wrong, please let me know.