IT lexicon › Programming › State sorting

State sorting

Programming På svenska → Updated: 2026-10-25

Reordering draw calls so objects sharing the same shader, texture and render state are drawn together, minimising expensive GPU state changes per frame.

Every time the renderer switches shader, blend mode, bound texture or vertex format, the driver has to revalidate and reconfigure the pipeline — one of the costliest things a frame does. State sorting groups the frame's draw calls by a composite sort key (often packed into a 64-bit integer: layer, then material, then depth) so the GPU flips state as rarely as possible.

The idea predates modern APIs; Christer Ericson's 2008 "order your graphics draw calls" write-up is the standard reference. Opaque geometry is typically sorted front-to-back within a material to exploit early-Z; transparent geometry must be sorted back-to-front for correct blending, which fights the grouping.

← Back to the lexicon