ELI5: What is Compiling Shaders and Why does it take so long?

r/

You update your drivers and now your PC games have to Compile Shaders on start up.
What is it and why does it take so long.

Comments

  1. indign Avatar

    When you download the game, you download the same thing as everyone else. But your computer is unique. The parts of the game that have to do with displaying graphics can run a lot faster if the data is rearranged to work better with your specific graphics card. That’s what “compiling shaders” means.

    Sometimes, you can skip precompiling shaders and still play the game. The game will still work, but it’ll be slower, since the shaders are compiled for your system on the fly while the game is running, taking up processing power.

  2. DeHackEd Avatar

    GPUs are small computers of their own, but with drastically differently engineered CPUs. They still run software, just designed for doing math in a whole different way.

    Shaders are essentially pieces of code that describe how to draw things. A fundamental unit of a 3d world might be a triangle, and the world is built by drawing many of them, but you can apply shaders to it and help give it a texture like wood, or scuffed metal, etc. It gives that realistic lighting effect and makes the world look much more real than something from the early 1990s.

    That said, how the game writes shaders and how the graphics card and its drivers process them are entirely different things. Each manufacturer, each product generation, each major update of the drivers, will mean things are different and the shaders are processed from the general description in the game to the specific math and code the GPU needs. But there is a processing delay in preparing these “shaders” for use on your GPU. Doing them ahead of time means the game doesn’t need to do them on the fly, which would result in performance hiccups and random loading delays.

  3. Improbabilities Avatar

    Shaders are little programs that tell your graphics hardware how to draw the game. They are distributed as source code, that needs to be compiled to be usable. The source code describes how to compile the shaders for any graphics hardware, so when you launch the game the first time it makes a compiled version for your graphics hardware.

    The alternative would be to have pre-compiled shaders for every single model of graphics card, but that’s difficult to maintain, and would require you to download a large amount of data that is totally useless for your computer