Because every PC’s GPU is different, shader compilation is necessary for games to run on different brands and models of graphics card. Unfortunately, that compilation process can cause annoying stutter.
Some games have a type of stutter that happens no matter how powerful your computer is, or which settings you choose. This is caused by a process known as “shader compilation,” and it’s a growing issue in PC gaming.
What Are Shaders?
Shaders are computer programs that help determine various aspects of rendered graphics. Pixel shaders, for example, calculate the attributes of a pixel. This includes the color, brightness, reflectivity, or transparency of that pixel. If you want something in your game to look wet, you use a special shader to achieve that look rather than do it painstakingly by hand.
Shaders are what make modern GPUs so flexible since these GPUs are designed to run anything that can be expressed in shader programming language. They replace the old “fixed-function pipeline” GPU technology where the types of graphical math a GPU could do were hard-wired into its silicon.
What Is Shader Compilation?
“Compilation” is a computer term that refers to taking the code as written by a human programmer and translating it to machine code that the specific processor that’s meant to run the software in question can understand. So, for example, you might compile your code to run on an Intel CPU or Apple Silicon.
The same thing is necessary for a GPU. The shader code must be compiled to run on the specific GPU brand and model in question. If you change the GPU, update its drivers, or the game receives an update, the shaders must be compiled again.
Why Do Some PC Games Have Shader Compilation Stutter?
In some games, compiling shaders in the background interferes with the game itself, causing a visible stutter. The computer is working too hard at compiling the shaders to run the game smoothly. Some developers labor to optimize compilation so that it has little or no impact on game performance, while others spread shader compilation out throughout the game, hoping that the hitching will be short-lived. In that case, you’d only encounter the stutters at the start of a new level or when you enter a new environment that uses shaders that haven’t been necessary up to that point.
Compilation stutters have been particularly egregious in Unreal Engine 4 games, which is a widespread and popular game engine. Specifically, these stutters become an issue when running a game under DirectX 12. This is partly because DirectX 12 changes how shader compilation works, putting more control in the hands of developers. However, this also means that developers may not have the best way to optimize shader compilation nailed down using the latest and greatest version of DirectX.
Why Don’t Consoles Have Shader Compilation Stutter?
Shader compilation stutter is a problem that’s completely absent from consoles like the PS5 and Xbox Series X|S. This is simply because developers know exactly what hardware is inside each console so that they can pre-compile all the shaders; there’s no need to compile them on the local system because you already know which GPU you’re targeting.
It is possible to do this on PC, but since there are so many GPUs and system configurations, it wouldn’t be practical. However, in the case of the Valve Steam Deck, Valve includes a pre-compiled shader cache with some games because, of course, all Steam Decks have the same GPU.
What Can You Do About Compilation Stutter?
Unfortunately, most of the time, the developers have to fix shader compilation problems. The good news is that they’ll eventually get a handle on the process. Unreal Engine 5.1 may include an automated feature that will help developers with caching without the impact on performance being so severe.
The list of things you can do to mitigate stutter isn’t long, but some of these options may help:
- If a game lets you pre-compile shaders, let it. This may take a while, but the game experience will be stutter-free.
- Unless a game update includes a shader stutter fix, hold off until you have finished playing, or shaders may compile again.
- Hold off on GPU driver updates until you have finished your current game in case it triggers compilation again.
- When compilation stutter starts in a game, hit the pause button and wait until it is finished before playing further.
- Use the DirectX 11 instead of the DirectX 12 version of a game. Often shader stutter is reduced or absent, although you’ll give up DX12 features in the bargain.
- Play the game on a console instead.
Over time this problem will likely go away or become much less intrusive. For example, developers may offload shader compilation onto CPU cores the game doesn’t need, which is a common situation on modern PCs with many cores. Until then, the #stutterstruggle will remain an irritating issue in PC gaming.