Walk the geometry, not the pixels
Rasterisation takes the first of the two possible loops. For each triangle, find the pixels it covers, and write to them. The outer loop is over geometry and the inner loop is over the pixels of one triangle.
That choice fixes the cost model immediately. Total work is proportional to the number of triangles plus the total area they cover, and it never depends on how many triangles are in the scene behind the one being drawn, except through the covered area.
It also creates the problem the rest of this lesson solves. Because triangles are processed independently and in arbitrary order, a triangle can be drawn into a pixel that a nearer triangle has already claimed, or will claim later. Something must arbitrate, and doing it by sorting triangles turns out to be both slow and, for interpenetrating geometry, impossible.

