Chapter 04 · The GPU

How GPUs turn
math into pixels.

You've built vectors, curves and matrices. Now meet the machine that runs that math — not once, but a hundred million times a second. The trick isn't a faster worker. It's an absurd number of tiny, identical ones.

"papa, please — an RTX 4080 Ti" · press play ↓
▶ watch rgbguy's original — How GPUs Turn Math Into Pixels
The lesson · a 90-second movie you can touch

Press play. It explains itself.

Plays like the video — one caption at a time, the picture animating under it — and it pauses when it's your turn. Skip around with the dots or arrow keys. The full lab comes after.

1
skip the lesson ↓
90 seconds · it pauses when it's your turn
Step 1 · Size the problem

The problem: 124 million little jobs

Every pixel on your screen needs a color, computed from scratch, every single frame. Do the math on a plain 1080p monitor and the number gets silly fast. A single brilliant worker won't cut it — no matter how fast it is.

0 × 0 pixels across × down
= 0 pixels on your screen
× 0 frames per second
= 0 little math jobs, every second
Step 2 · Watch the race

One genius vs two million interns

Same picture, two strategies. The CPU is a genius: it paints one cell at a time, blisteringly fast, in order. The GPU hires a patient little worker for every cell and tells them all "go" at once. Each cell's color doesn't depend on any other cell — so nobody has to wait. Watch who finishes.

CPU · SERIAL— ms
SERIAL — 1 worker, fast
GPU · PARALLEL— ms
PARALLEL — 2,000,000 workers, patient
1 core
the race starts when it scrolls into view…

and remember — this toy grid is 1,296 cells. your real screen is 1,600× bigger.

Step 3 · From triangle to pixels

Rasterization: the coverage test

Every 3D model — every dragon, every face, every blade of grass — is just triangles. The GPU's job is to figure out which screen pixels each triangle covers, then color them. Step through the stages below. Drag the vertices. The key thing to notice: every cell runs the exact same test, independently — which is exactly why parallel wins.

drag v0, v1, v2 ↓

Stage

3 vertices — that's ALL the geometry the GPU is given.
stage 1 · vertices
v0 = (—, —)
v1 = (—, —)
v2 = (—, —)
covered pixels: —
Step 4 · The real code

An actual vertex shader

This is not pseudocode. This is GLSL — the language shipped to your graphics card by every OpenGL game. One tiny program, and the GPU runs it for every vertex of every model, simultaneously. Look at the line that matters: it's the matrix multiply from chapter 03, verbatim.

vertex.glsl
#version 460 core
layout (location = 0) in vec4 aPosition;
uniform mat4 uModelMatrix;
uniform mat4 uViewMatrix;
uniform mat4 uProjectionMatrix;
void main(void)
{
    gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * aPosition;
}
runs ONCE PER VERTEX —
all the vertices, at the same time
these three = the matrices
you built in chapter 03

CPU RUNS

  • game logic
  • physics
  • AI
"one story, in order"

GPU RUNS

  • vertex shading
  • rasterizing
  • pixel shading
"millions of tiny identical jobs"
Step 5 · Spot it in the wild
why "lots of dumb workers" explains so much —
  • Crypto mining & AI training. Hashing and neural nets are the same shape of work as pixels: millions of small, independent multiply-adds. That's why GPUs got drafted for both — same silicon, different math jobs.
  • Your laptop fan in games. 124M+ jobs/second means billions of transistors switching flat-out. All that math is heat — the fan is literally cooling arithmetic.
  • Resolution vs framerate. 4K has 4× the pixels of 1080p — 4× the jobs per frame. Drop resolution and the same GPU finishes each frame sooner: that's the whole trade-off in your graphics settings.
See it in 3D · orbit it like Blender

Thousands of cubes, one draw call

This is the chapter's whole argument, rendered: every cube below is drawn in a single draw call — the CPU issues one command, and your GPU's army of tiny workers runs the same little vertex program for every corner of every cube, in parallel. Crank the count and watch the framerate not care.

drag to orbit · scroll to zoom

Headcount

y = sin(x·k + t) + cos(z·k + t)
4,096 cubes · 1 draw call
The source · rgbguy's original

Watch the video, jump by section

Click any moment on the right — it takes you straight there (in place when this site is served over http, on YouTube when opened as a local file).