As many of you know, UE4 games are well known for having a stuttering problem. I used to think it was due to the asset streaming efficiency of the engine, but now I know that isn’t the case; at least most of the time.
The past few months have seen two major UE4 titles come to PC, Jedi Fallen Order and Gears 5. The former being DX11 and the latter being DX12. While I had no problems with Gears 5 when it launched (it ran beautifully), the last few patches have left the game with serious performance issues on my rig. Gears 5 would run absolutely horribly on my rig, with lots of lag and hitching and stuttering. This is a far cry from how it ran originally when it launched, and I’ve been tearing my hair out trying to figure out why this has happened.
I tried reinstalling Windows 10, different drivers, disabling control flow guard, different SSD, different antivirus all to no avail.
What fixed it in the end was something so simple, you could not believe. I merely turned shader cache on in the NVidia driver control panel! Doing this fixed every problem I had with the game’s performance.
The setting is typically turned on by default globally, but I’ve always disabled it because I didn’t want any unnecessary writes to my SSD. Plus I’ve never really known it to have a significant impact on performance generally speaking.
But now it seems that games are actually being designed with shader caches in mind. While Gears 5 originally had no problem running without shader cache turned on, but the developer changed something in how the game is programmed and now it runs like crap if shader cache is disabled. Why would they do this?
Probably to reduce CPU cycles and make it so that lower spec machines can run the game properly. Shader compilation is something that the CPU does on the fly in real time, and depending on how many threads are available for that function and how fast the CPU is, can make a huge difference in a player’s overall experience. It’s also probably the number one cause of stuttering in PC games, especially if shader compilation is running on the same thread as the renderer. So what shader cache does is store the pre-compiled shaders so that they only need to be fetched rather than actually compiled in real time, lowering CPU time.
This seems like an excellent concept to reduce CPU time and stuttering, but from my experience, it depends on the 3D engine if it’s useful or not. With Frostbite 3 games for example, turning the shader cache on doesn’t seem to have much of an effect, and this is likely because the Frostbite 3 engine is more parallel than UE4. By that I mean it has more threads available for rendering and shader compilation, so the latter running in real time doesn’t interfere with rendering and cause lag and stuttering.
Battlefield 5 needs at least a straight quad core to run properly, while Gears 5 will run decently on a dual core with SMT enabled. You get the point.
Anyway, I enabled shader cache for Jedi Fallen Order as well and voila, stuttering and hitching diminished by roughly 90%! It’s still there, but compared to how it was before it’s literally night and day. And I have the game installed on a fast NVME SSD. It’s likely that the other 10% is due to the game’s weak streaming and single threaded nature because of DX11.
TLDR; Shader cache must be enabled on all modern UE4 titles to have good performance and to minimize stuttering and hitching.