Images have millions of pixels. All these pixels can be computed with the same steps, at the same time. A GPU is a processor designed to do a lot of small, similar operations in parallel. Historically, that meant turning 3D triangles into pixels on your screen; today it also means physics, video encoding/decoding, and general number-crunching (LLMs, simulations, etc.). If a CPU is optimized to handle a few very different tasks with its few cores, a GPU is designed to run the same task across thousands or millions of data points. While CPUs have a few powerful cores, GPUs have thousands of small cores, that can only execute simple operations (like arithmetic).
GPUs are used mostly to execute small programs called shaders.
For example, in videogame graphics, vertex shaders are used to render the shapes of the environment, by taking all of the vertices of all of the items appearing on screen and calculating their next position using the GPU. Simple example, if the game is showing a simple triangle with vertices
a, b and c, and you want to rotate it clockwise, you'll write a simple vertex shader like a function that takes the current positions of a, b and c as input and returns a new position (moved clockwise) for each of them. If you want the triangle to spin endlessly, you can write a shader that constantly returns new positions for the three vertexes.Pixel shaders are used to render colors: you can write a pixel shader that takes the position of each pixel on the screen and returns a new color for it (in the RGB format we discussed in the chapter about encoding media).
As you can imagine, in a modern game these shaders are supposed to operate on a lot of vertices and pixels to render scenes, and they need to compute them all at once; simple mathematical operations, but executed in parallel over a lot of data points...that's why the GPU, with his thousands of small cores, comes in handy.
Shader languages, like HLSL or GLSL are special languages used primarily to write shaders. They're usually compiled and then fed to the driver of the graphics card. But what is a "driver"? We'll learn about that in the next section.