The Rendering Pipeline

Right now, sixty times a second, the machine in front of you is performing a small miracle: it takes a 3-D model — nothing but a list of corner points floating in space — and turns it into a flat grid of a few million coloured pixels, fast enough that a spinning character or a swooping camera looks perfectly smooth. A modern 4K display holds roughly 8{,}000{,}000 pixels, and every single one of them has to be worked out again for the next frame, and the next, and the next.

How does a bag of 3-D points become a 2-D picture? Not in one leap. It flows down an ordered assembly line of stages called the rendering pipeline (or graphics pipeline). Each stage does one job and hands its result to the next, exactly like a factory conveyor belt: raw geometry goes in at one end, finished pixels come out the other. Understanding this one idea — the order of the stages and what each one is for — is the map that makes every other computer-graphics topic fall into place.

The stages, in order

The classic pipeline has a fixed shape. Data always flows the same way — you can never rasterize before you've projected, and you can never shade a pixel that doesn't exist yet:

\text{vertices} \to \text{model \& view} \to \text{projection} \to \text{clipping} \to \text{rasterization} \to \text{fragment shading} \to \text{framebuffer}

Click through the assembly line

Here is the whole pipeline as a flow of stages. Step through it and watch the geometry travel from raw vertices on the left round to finished pixels — the same journey every triangle in every frame takes.

Worked example: following one corner through

Let's trace a single vertex — the tip of a triangle sitting at local coordinates (1, 0, 0) — all the way down the belt.

One corner, eight steps, a fraction of a microsecond. Now multiply that by every vertex of every triangle, and every pixel of every triangle, sixty times a second. The pipeline's whole reason for existing is to make that torrent of work regular — the same fixed sequence for everything — so hardware can run millions of these journeys in parallel.

The earliest 3-D hardware had a fixed-function pipeline: the stages were baked into silicon and you could only tweak a few dials. Modern GPUs made two of the stages — the vertex transform and the fragment shading — programmable. You write little programs called shaders that run once per vertex and once per fragment, in massive parallel. The order of the stages, though, is still exactly the flow on this page; what changed is that you now get to write the code for two of the boxes rather than accept the factory settings.

And the parallelism is staggering. Because every vertex is transformed independently, and every fragment is shaded independently, a GPU can chew through thousands of them at once. That is the deep reason graphics chips look nothing like a CPU: the pipeline is an embarrassingly parallel assembly line, and the hardware is built to exploit it.