Shader Compilation and Hitching in PC games SUCKS
What is the reality of this situation? We as gamers, simply can't have any faith that a dev studio will do the required work to fix/mitigate this issue on their own. Whether by lack of knowledge/ability, tools/support, time/budget, or straight up lack of care.. this is not something we can expect consistently across all developers/studios.
What do we as gamers know? We know many games have terrible hitching on PC due to PSO/shader compilation, and it's getting worse. We also know that if we play through a game enough times, the more shader/pipeline state is compiled and cached, and those stutters tend to go away.
Now what seems to be the problem for developers? (I'm guessing here) Obvious things. PC platform complexities (GPUs, Drivers, OSes, APIs) for one. Also engines like Unreal, which allow less technically proficient (or should I say specialized) developers and artists to create games with stunning looking visuals through their intuitive development tools... which can potentially end up unoptimized for PC. That's fine for console development, where the engine can compile the code knowing the exact environment that it will run in. However, when it comes to the PC, it's anything but predicable, and it seems to catch them off guard.
Why? This isn't an Unreal Engine specific problem... other engines have essentially have to do the same thing. Typically though if a studio has a proprietary engine, they have the low level coders with intimate knowledge of exactly how the engine works and so they're very cognizant of how the shaders should be authored in the first place to reduce permutations/pipelines to as low as possible, and how to capture that pipeline data . With Unreal.. that's not a guarantee. By design it allows developers to go wild.. and thus things get out of control quickly. Sure there are amazing developers that can make that engine hum and purr like a kitten on PC... but the vast majority of Unreal developers are indie/AA studios which definitely don't.
Essentially it comes down to gathering as much shaders and pipeline state information as possible so that it can be used to pre-compile shaders, which they can do at initial load, loading screens, or in the background... but they need to know that information so they can compile the shaders/materials they need. The only way to do this.. is essentially by playing through the game over and over again, doing everything and redoing it again slightly different, and then again, and again. The more its done, the better the outcome, the more they can compile upfront.
This process seems to be an issue for developers. Not everything can be easily captured, and maybe it's just not feasible for smaller studios to spend precious time (which means budget) trying to do it the best they can. Maybe some developers miss, or don't bother with doing a thorough job of it? *sigh* I don't know. I always hate to say stuff like that, because you'd think that once a game goes gold, they'd toss it in a random PC and play through it and say "ok something is wrong here".. but I digress..
So... at the end of the day what can be done? Multiple things. Developers already do multiple things that we know of (diligence during development, pre-comp processes, background shader comp, ect) I definitely don't want to come across like as if they aren't already doing anything in their power to mitigate the issue.. there are some freaking heroes out there. However like I said... we cannot rely on hopes and dreams that all developers will or can do all this stuff... so what's the next best thing?
Valve with Steam once again, have essentially solved this problem in an incredible way. When I say essentially, I mean "for the most part"...excluding some fringe cases. They've created a system which essentially allows them to capture GPU independent shader/pipeline state, and replay it. This allows them to collect, upload, and redistribute this GPU independent code alongside their respective game packages. Steam downloads a "pre-caching update" and it will take those files, and run them through the driver and compile the shaders/pipeline as the game downloads. It's called Fossilize, and it's pretty damn cool.
The only issue, is that it's Vulkan only
This, is honestly the most elegant "solution" to this problem that I can see for many reasons:
1. It can be done completely independent of the developer. (Doesn't require game specific support)
2. It's done at the Steam level... meaning any games that support Vulkan can benefit from this. (more on this in a sec)
3. Outside of developers doing a better job themselves, this can catch a lot of the more egregious examples of compilation stutters. (Games don't need to be perfect, but much better than they are)
4. It's the least intrusive method because it allows shaders to be compiled as the game downloads.. when you can't play it. Reducing friction, without requiring long pre-compiling processes upon initial launch.
5. Gives the user a choice. (Can be opted-in or out)
User choice is important because these downloads can begin to add up in size when you have multiple games receiving them, and as the pre-caching updates grow in size. If you're on a limited data plan, you may want to forego them.
To me, this entire setup is excellent. Of course the best thing is for developers to do as good of a job on their side as possible first and foremost. After that, it helps catches those cases where developers can't do the job on their own. There's also the fact that this issue will only get harder for developers themselves to deal with in the future, as things get ever more complex. I think most people would accept a bit larger of a download to have a smoother game without hitching. It's about as little friction as one could hope for, given the realities of the PC platform. And it's essentially completely transparent to the user. They don't have to think about anything or do anything special.. they're just downloading their games as usual.
Of course, the caveat is that, as I said, it's Vulkan only. Steam through Proton on Linux is essentially brute forcing this stuff.. because as you know every supported game gets translated to Vulkan. However in Windows-land, we're stuck with Vulkan only games supporting it currently.
Which is why we have to push Microsoft, to build a Fossilize equivalent for DirectX APIs. Maybe that's not possible? I don't know... but what I do know is that teams of incredibly talented and intelligent people are putting in massive amounts of work to make this a reality through Vulkan,
and it works. It's being put to the test every single day.
If for some reason MS can't do something equivalent and make it work for Windows (and really this should be their highest damn priority!) then I either want Valve to somehow implement VKD3D/DXVK into Steam directly on Windows so it can be done, or.. I'd rather just move over to SteamOS completely and wish for developers to drop DirectX and just go full Vulkan.
That's where I'm at. Thanks for reading.
This post was brought to you by: Hopes and Dreams™