Dolphin, the GameCube and Wii emulator - Forums

Full Version: Option to force shader recompiling (Ubershaders)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

So while this option may seem a bit weird to have initially, let me explain.

I've been playing Metroid Prime 2: Echoes (NGC) the last week and it runs perfectly on my computer (except for the small laggspikes when moving out of water or opening a portal (refraction?)) but yesterday I encountered something weird when I started the game.. The main menu had a green overlay and when I loaded my save it looked like this:
[Image: Qt5V816.png]
[Image: STairp9.png]
[Image: GT9qNfE.png]

So that was weird.. As I'm a programmer myself I knew it had something to do with shaders or textures missing, then I remembered saying that driver updates, swapping GPU or anything like that might invalidate the shader cache used by the Ubershaders and they'd have to be compiled again.. Now let luck have it that the night before Windows decided to update. I believe it also updated my graphics drivers among other things.. So ok.. I'll need dolphin to recompile shaders for me..

No problem, let's see.. Dolphin directory.. Hmm where does Dolphin keep its compiled shaders.. Not here anywhere..
Ok perhaps it keeps it elsewhere, lets check %appdata% .. Not in the roaming folder, not in the local folder..., come on this is the spot where application data should be kept.. even temporary..
C:\ProgramData\ perhaps? Nope not here, Ok let's google quickly, saves are kept in My Documents, ok lets have a look there.

Ok My Documents it was, though a bit weird to keep all the other data in here too but sure.. Now to find the shaders..
"Documents\Dolphin Emulator\Cache\Shaders" That seems like it, now delete it all and Dolphin would have to force a shader recompile.

So I run the game.. No recompile? huh that's weird, booted up and same issue.. So I check the settings.. it IS set to Exclusive mode on Ubershaders. Well how do I get Dolphin to recompile my shaders ugh, Ok I know, I'll just switch rendering API (Vulkan -> D3D) and bam there it goes, compiling shaders, and we're all set now it works again..

So that was ehm a bit of a hassle to go through..

So my request, especially as Windows updates can happen frequently (and/or graphics drivers too)
Can we have a flag or a button that recompiles the shaders the next time a game is run? Because it seems it doesn't automatically detect it (or not in all cases atleast). Its little effort and helps a lot.
Some GPU vendors (like Nvidia and AMD, though I believe the AMD one is opt-in on a per game basis so probably doesn't get enabled with Dolphin - not sure about Nvidia) have their own shader cache implemented in the driver. It's possible that you've successfully removed the dolphin-managed cached shaders, so dolphin is submitting them for a recompile, but the driver cache still has an old shader, and the driver cache is incorrectly returning that instead of actually recompiling the shader. You may need to clear this cache too.

That is all assuming it is actually a shader cache issue. Generally, there have been a number of issues with the drivers on windows update being older than the ones on the vendor website (nvidia.com) - it may be that the windows update actually *downgraded* your GPU driver - this happened to me when I got the latest fall creator update. Getting the latest version off the vendor website and installing that may help.
If you're running on an NVIDIA GPU and is using Dolphin's OpenGL backend, try clearing the contents of "C:\Users\<your username>\AppData\Local\NVIDIA\GLCache"...
(11-20-2017, 05:07 PM)mbc07 Wrote: [ -> ]If you're running on an NVIDIA GPU and is using Dolphin's OpenGL backend, try clearing the contents of "C:\Users\<your username>\AppData\Local\NVIDIA\GLCache"...


I was running Vulkan at that moment as the window title shows, I somehow managed to get it to recompile shaders by switching over to DirectX11 again and doing some stuff which I can't remember..

Anyhow a "Clear Shaders" button or something like that would make this a lot easier Tongue
I'm not a fan of something like that for a couple of reasons.

1. If this is a bug, all we would be doing is making the bug go away and not fixing it proper

2. Since NVIDIA and AMD do global shader caches, this includes programs other than Dolphin. nvidia hashes the names so we can't be precise with what we purge, and would have to purge the entire cache. Dolphin has no business messing with the cache of other programs.
Hmm fair enough, any way I could help you find out if this is a bug or not? Need any specific system info for that?

The problem itself is already gone, so I doubt I could reproduce it without a windows update coming along every attempt.
Though perhaps it happens when a driver downgrade occurs? I'm not sure if that is what actually happened, but it's a scenario that could be tested. Like it potentially doesn't detect invalid shaders if the version its compiled with is higher than the current version (and only the other way around, I'm sure that's a bug I'd ever write ( I mean.. versions only go up right? Tongue)).
Interesting that this happened in the Vulkan backend. We actually compare the UUID when loading the shader cache (see https://github.com/dolphin-emu/dolphin/b...e.cpp#L563), I'm guessing the driver upgrade didn't change the UUID? Perhaps we should include the driver version as well, which would result in the cache being ignored on driver changes. Could do the same with OpenGL by comparing GL_VERSION.

Feel free to open a feature request issue about it.