What Actually Happens in a Depth Prepass
A depth prepass runs your geometry twice - but the second pass costs almost nothing. Here's why that trade-off is worth it.
A depth prepass (or Z-prepass) is a two-pass technique. In the first pass, you render your opaque meshes using a vertex shader only - no pixel shader, no render target bound - purely to write depth values into the depth buffer.
In the second pass, when you render the scene for real, the GPU uses that pre-populated depth buffer to discard any fragment that isn't the closest visible surface before the pixel shader ever runs. That guarantee of zero overdraw is the whole point.
The diagram below shows both passes and how they connect.
For comparison, here is the standard pipeline without a Z-prepass:
Without a pre-populated depth buffer, every fragment that survives rasterization goes straight to the pixel shader - regardless of whether it's actually visible. In a dense scene this leads to overdraw: the same pixel being shaded multiple times, with only the final result kept.
Pass 1 is intentionally fast and cheap. Using a position-only vertex buffer reduces memory bandwidth. With no pixel shader and no render target, more draw calls can share the same vertex shader and render state - which improves batching and reduces per-draw call CPU overhead.
The optional tessellation and geometry stages (Hull, Tessellator, Domain, Geometry Shader) are part of the full rendering pipeline but are seldom used in typical video-game rendering. There are exceptions, like Ocean or Snow rendering where you would use Tessellation.
Early-Z is the payoff. Because the depth buffer is already populated from Pass 1, the GPU can reject occluded fragments before they reach the pixel shader. In a dense scene - foliage, interiors, overlapping geometry - this can save a significant amount of pixel shader work that would otherwise run on pixels you'd never see.
This also unlocks several downstream techniques: SSAO can be kicked off early using the depth buffer, hierarchical-Z occlusion culling becomes possible, and screen-space shadows and screen-space reflections can raymarch against depth before the main pass completes.
This is my interpretation based on what I've read in books and online - things do change as technology evolves.
© 2026 Stefan Groenewoud - All views are my own, not those of my employer.

