All games today have a portion of their source code that is executed by the GPU in the form of programs that we call shaders and that run in the homonymous units of the GPU. The name of these units changes depending on the brand we are talking about, for example they are called SM by NVIDIA, Compute Unit by AMD and Xe Core by Intel. His function? Run a series of programs that use the enormous capacity for parallel computing, either to manipulate graphics primitives or to apply mathematical algorithms at high speed.
The shader compilation problem
Shader units differ in architecture from what a conventional processor is and have some shortcomings that prevent them from working in the center of a PC, but we won’t get into that here here, but one thing they have is a set of registers and instructions, and since no one programs in binary, there are high level languages that humans can use to write such programs. The most famous on PC? HLSL in DirectX and GLSL in Vulkan and OpenGL.
The problem on PC? Manufacturers themselves do not respect their ISA from one GPU design to another, which makes shader programs unable to come compiled. We are not talking about the set of registers and instructions changing from generation to generation, but that it can even occur within the same family. This means that in PC games shaders have to be compiled on the fly and assumes a loss of performance while we are playing.
Compiling shaders has become an issue when playing many PC games, especially in large open world games where data is continually being output to RAM as we explore the environment. the NVMe SSD. The reason? Load times in many PC video games are used to compile shaders.
This does not happen on consoles
A video game console does not change its specifications at all during its lifetime, which means that its GPU does not change and therefore neither does its ISA. In other words, there is no need to compile the shaders on the fly like on PC and these are already compiled with the rest of the game code.
This is a double-edged sword, for the backward compatibility of future systems. For example, much of the development of the Xbox Series and PS5 APUs has to do with understanding the previous generation shader binary. At the same time, Nintendo and NVIDIA facing the successor to Switch have to develop a variant that includes the shaders compiled for the hybrid console’s GPU.
The most logical solution to the problem
To solve the problem of compiling shaders in PC games, there are two different solutions:
- Create a repository that the game can access during installation that contains the shader code already compiled for each ISA on the different graphics cards. The problem is that this would force developers to maintain such a growing repository for a long time without any financial compensation.
- Compiling shaders during game installation takes a bit longer, but game performance suffers.
What do we think the majority of developers will do? Use the cores from several different Intel and AMD processors to perform the shader build with them. This is one of the background tasks that, for example, the Intel Core 12 E-Cores will do, although in general they will end up using multiple cores in parallel to compile the different shader programs as quickly as possible, especially When the load times for this will be suppressed by the use of high speed SSD drives.