skip to content

On bandwidth-limited hardware, how do you estimate a deferred renderer's G-buffer memory traffic per frame at a given resolution, and how do you cut it?

level: seniorimportance: should knowfreq 30%

answer

  1. bytes per pixel times pixels
  2. count every pass that touches it
  3. per-light re-reads multiply
  4. two channels for a normal
  5. on-chip tile memory

basics

~20 s

Multiply bytes per pixel by pixel count, then count each write and read: geometry-pass writes, lighting reads, lit-target writes and per-light re-reads in classic deferred. Cut it with packed channels, position from depth, tiled lighting and on-chip G-buffers on tile-based GPUs.

solid answer

~50 s

Start from the layout: a 32-bit depth target and four 32-bit colour targets is 20 bytes per pixel. At 2560x1440 that is 3,686,400 pixels, about 74 MB written by the geometry pass and 74 MB read back by a single lighting pass, plus about 29.5 MB for an 8-byte HDR result: roughly 177 MB per frame, near 10.6 GB/s at 60 Hz, before overdraw. Classic per-light deferred multiplies the reads: twenty overlapping lights each re-reading 20 bytes and read-modify-writing 8 bytes is about 2.65 GB per frame. To cut it, light each pixel once with tiled or clustered lists, pack normals octahedrally into two channels, rebuild position from depth, size formats to the precision needed, stop overdraw writes with a depth pre-pass, and on tile-based GPUs keep the G-buffer in on-chip tile memory so it never reaches main memory.

code

pseudocode · 19 lines
pseudocode
// octahedral normal encoding: unit vector -> two values in [-1, 1]
function signNotZero(v):                     // per component: +1 if >= 0, else -1
    return (sign0(v.x), sign0(v.y))

function sign0(a):
    if a >= 0: return 1
    return -1

function octEncode(n):                       // n has length 1
    p = n.xy / (abs(n.x) + abs(n.y) + abs(n.z))
    if n.z < 0:                               // fold the lower half outward
        p = (1 - abs(p.yx)) * signNotZero(p)
    return p                                  // store as two 16-bit channels

function octDecode(e):
    n = (e.x, e.y, 1 - abs(e.x) - abs(e.y))
    if n.z < 0:
        n.xy = (1 - abs(n.yx)) * signNotZero(n.xy)
    return normalize(n)

go deeper

for a junior

Recall that every G-buffer channel is written and read for every pixel, so bytes per pixel times resolution sets the cost.

for a middle

Compute bytes per pixel and per frame for a stated layout and resolution, and explain octahedral normals and rebuilding position from depth.

for a senior

Count every pass that touches the G-buffer, show how per-light re-reads multiply traffic, and justify each packing or on-chip choice against the device's bandwidth.

for a principal

Set a bytes-per-pixel budget for the G-buffer per hardware tier and make every proposed channel argue its way in against it.

## Step 1: bytes per pixel On hardware where memory bandwidth is the limit, a deferred renderer's G-buffer is often the largest single item in the frame's memory traffic. Estimate it from the layout first. The example layout for this scenario: | Target | Format | Bytes per pixel | |---|---|---| | Depth | 32-bit | 4 | | Base colour and occlusion | `RGBA8` | 4 | | Normal, octahedral | `RG16` | 4 | | Roughness, metalness, material ID, spare | `RGBA8` | 4 | | Motion vector | `RG16F` | 4 | | **G-buffer total** | | **20** | | Lit HDR target | `RGBA16F` | 8 | At 2560x1440 there are 3,686,400 pixels, so the G-buffer is 3,686,400 x 20 = 73,728,000 bytes, about **74 MB**, and the lit target 3,686,400 x 8 bytes, about **29.5 MB**. ## Step 2: count every pass that touches it 1. **The geometry pass writes** the G-buffer: about 74 MB, more where opaque overdraw writes a pixel more than once. 2. **The lighting pass reads** it: about 74 MB if each pixel is read once. 3. **The lighting pass writes** the lit target: about 29.5 MB. 4. **Other readers**: ambient occlusion, reflections, decals and temporal effects read depth, normals or motion again. Steps 1 to 3 alone are about 177 MB per frame, roughly 10.6 GB/s at 60 Hz. This is a first-order estimate: caches, hardware framebuffer compression and partial reads lower the real figure, so confirm it against the GPU's own counters. ## Step 3: the per-light multiplier Classic deferred lighting draws one volume per light and blends into the lit target. For each light covering a pixel it reads the 20-byte G-buffer and read-modify-writes the 8-byte lit value: 20 + 8 + 8 = 36 bytes per light. In a night market where twenty lanterns overlap a typical pixel, that is 720 bytes per pixel, 3,686,400 x 720 bytes, about **2.65 GB per frame**, around 159 GB/s at 60 Hz, which is more than many bandwidth-limited devices can move. This is usually the real problem, and it is solved by changing the lighting pass rather than the layout. ## Cutting the traffic - **Light each pixel once.** Tiled or clustered deferred builds a light list per screen region, reads each pixel's attributes once and accumulates every light in registers: 28 bytes per pixel instead of 720 in the example. - **Pack normals.** An octahedral mapping folds the unit sphere onto a square, so a normal fits two 16-bit channels instead of three floats. - **Rebuild position from depth** rather than storing it, which avoids 12 to 16 bytes per pixel. - **Size formats to the precision needed.** A packed 32-bit float format with 11-, 11- and 10-bit channels can replace a 64-bit HDR target where its precision and lack of alpha are acceptable, and material parameters rarely need more than 8 bits. - **Write only what changes.** Camera motion for static pixels can be derived from depth and the camera's movement, so motion vectors need writing only for moving objects. - **Stop overdraw writes.** A depth pre-pass, or rough front-to-back order, keeps hidden fragments from writing attributes. ## Tile-based GPUs: keep it on-chip Many GPUs in phones and other low-power devices render one screen tile at a time into fast **on-chip tile memory** and write the finished tile to main memory at the end. If geometry and lighting run inside one render pass, the lighting stage can read the current pixel's G-buffer values straight from tile memory, and the G-buffer targets can be marked as never stored, so they never touch main memory. Only the final colour has to leave the chip: if tone mapping also runs in the pass and writes 4 bytes per pixel, that is about 14.7 MB per frame instead of about 177 MB. The constraints: - Reads are limited to the current pixel, or at most the current tile. Ambient occlusion, reflections or blurs that read neighbouring pixels force the G-buffer, or part of it, out to memory. - On-chip storage per tile is fixed, so a fatter per-pixel footprint can shrink the tiles or exceed what the hardware keeps on-chip; the 20-byte layout matters here too. - Splitting geometry and lighting into separate passes, or leaving an attachment set to be stored, silently loses the benefit. ## Checking the estimate Compare the computed figure with the device's peak bandwidth and with measured counters, and remember that textures, shadow maps and post-processing share the same bus. A G-buffer that takes a third of the budget on its own leaves too little for everything else.

  • Why are octahedral normals preferred over storing x and y and rebuilding z?
    Rebuilding z from x and y assumes its sign is known. Even in view space, perspective and normal mapping let visible surfaces have normals that point slightly away from the camera, so the sign is lost and lighting flips. Octahedral mapping covers the whole sphere in two channels with fairly even precision, so two 16-bit channels give accurate normals in the same 4 bytes.
  • On a tile-based GPU, what forces the G-buffer out of on-chip memory?
    Any pass that reads a G-buffer value at a different pixel than the one being shaded, such as ambient occlusion, screen-space reflections or a blur, because tile memory exposes only the current pixel or at most the current tile. Splitting geometry and lighting into separate passes, or storing an attachment that is never needed later, also writes it out. Feed such effects from a separately stored depth target or a reduced-resolution buffer.

  • G-buffer bandwidth is just its size, written once per frame.
  • Storing world position is cheaper than rebuilding it from depth.
  • Packing a normal into two channels always loses visible quality.
  • A tile-based GPU keeps the whole G-buffer on-chip whatever passes read it.
  • Tiled light culling reduces the G-buffer writes of the geometry pass.