What is shader compilation and why is it so prevalent now?

139 views

With the recent hubbub about The Calisto Protocol stuttering due to rampant “shader compilation”, I was recently reminded that other recent games (like Horizon Zero Dawn) were also known for shader compilation issues.

What is the game doing that makes it different from other games that just open and play without stutter or compilation?

I also don’t remember anyone making a fuss about this for titles 5 years ago.

In: 30

5 Answers

Anonymous 0 Comments

A shader is a small program that is executed by a GPU. But before it can be executed it needs to be compiled, which means to turn it from a human readable text file into something the GPU can work with. And that takes some time.

The name shader goes back to when games were less complicated and mostly applied simple color shading to the faces of 3d meshes (the arrangement of polygons that make up a 3d object). Nowadays shader programs can do all kinds of other things but we still call them shaders.

Five years ago stuttering from shader compilation was still a problem but the shader programs were simpler so they took less time to compile, there were less of them to compile, and there were other limitations that sort of kept the problem in line.

One of those limitations was draw calls, which is basically the game telling the GPU driver “I have all this stuff figured out for this 3d mesh and I’m calling on you to tell the GPU to draw it on the screen”. Five years ago game devs had to pay more attention to draw calls than shader compilation. It was draw calls that was the bottleneck and the major cause of stutters.

One of the main goals of the modern graphical APIs (the software interface between the game and the GPU) was to reduce that bottleneck and games now can issue dozens of times more draw calls every frame. And within each of those draw calls more work can be done.

That has led to an explosion in 3d mesh complexity which is why games now have so much more geometric detail, which in turn requires more (and more complicated) shader programs to be executed for every frame. So essentially we’ve moved the bottleneck which is why shader compilation issues are more prevalent now.

But like everything else in computer science there are workarounds and clever ideas to mask the problem. But they don’t work well in all cases, they require careful planning and design of the game levels and 3d meshes, and all of that takes expertise, time, and money.

You are viewing 1 out of 5 answers, click here to view all answers.