ReSTIR emissive build: whole-grid gather costs ~7 ms/frame when far emitters overflow the pairs cap (camera high above an emissive build) #1108

Open
opened 2026-10-26 10:14:34 +00:00 by sky_line · 0 comments
Owner

Symptom: with the camera high above a large emissive build (about 3 km above an all-emissive race track, draw distance at max), the ReSTIR emissive light-grid build costs about 7 ms every frame. The deferred chain on the async queue grows from about 5 ms to about 12 ms, and the graphics queue waits on all of it.

Measured (GPU timers, 5 s averages, RTX 5090):

Timer This case Normal ground spot
c_rs_emissive (mode 7, cell population) 6.9 - 7.1 ms 0.09 - 0.12 ms
c_rs_em_long (mode 9, long cells) 0.004 ms ~0.27 ms
c_rs_em_select (mode 11) 0.005 ms ~0.01 ms
q_defer_light ~12.0 ms ~5.2 ms

Nsight GPU Trace of the mode 7 dispatch: 2.0 warps per SM on average (4% occupancy), SM throughput 9%, RT core 0%, active threads per warp 13.8 of 32. The stalls are shared-memory loads and SFU work: a few long workgroups each loop serially over emitters, with a long tail.

Why: the light grid is centred on the camera (4 levels, outermost about +-128 m across). From far above, every cell is empty air and every emitter is about equally far from every cell, so distance rules nothing out. Every emitter becomes a candidate for every cell, the pairs cap overflows, mode 5 flags a whole-grid gather (bypassing the cell lists and select; that's why modes 9 and 11 drop to near zero), and mode 7 loops each cell over every emitter record. None of it reaches the picture: the emitters are far outside the grid, and their contribution at the grid is negligible.

Fix:

  1. Cull emitters by reach before the build: skip an emitter whose largest possible contribution anywhere inside the grid's bounds is below the irradiance floor. This alone should bring this case back to the normal cost.
  2. Bound the gather when it still happens: spread it across the GPU (more, smaller units of work instead of one long loop per lane) and/or budget it across frames, keeping last build's cells meanwhile.
  3. Log each full-grid gather with its reason (pairs cap overflow, cache invalidation) and the emitter and pair counts, rate-limited.

Test: hover about 3 km above a large emissive build with max draw distance and GPU timers on (RenderVKGpuTimers 1). c_rs_emissive should stay near its ground-level cost; emissive lighting near emitters at ground level must be unchanged.

**Symptom:** with the camera high above a large emissive build (about 3 km above an all-emissive race track, draw distance at max), the ReSTIR emissive light-grid build costs about **7 ms every frame**. The deferred chain on the async queue grows from about 5 ms to about 12 ms, and the graphics queue waits on all of it. **Measured (GPU timers, 5 s averages, RTX 5090):** | Timer | This case | Normal ground spot | |---|---|---| | `c_rs_emissive` (mode 7, cell population) | 6.9 - 7.1 ms | 0.09 - 0.12 ms | | `c_rs_em_long` (mode 9, long cells) | 0.004 ms | ~0.27 ms | | `c_rs_em_select` (mode 11) | 0.005 ms | ~0.01 ms | | `q_defer_light` | ~12.0 ms | ~5.2 ms | Nsight GPU Trace of the mode 7 dispatch: 2.0 warps per SM on average (4% occupancy), SM throughput 9%, RT core 0%, active threads per warp 13.8 of 32. The stalls are shared-memory loads and SFU work: a few long workgroups each loop serially over emitters, with a long tail. **Why:** the light grid is centred on the camera (4 levels, outermost about +-128 m across). From far above, every cell is empty air and every emitter is about equally far from every cell, so distance rules nothing out. Every emitter becomes a candidate for every cell, the pairs cap overflows, mode 5 flags a whole-grid gather (bypassing the cell lists and select; that's why modes 9 and 11 drop to near zero), and mode 7 loops each cell over every emitter record. None of it reaches the picture: the emitters are far outside the grid, and their contribution at the grid is negligible. **Fix:** 1. **Cull emitters by reach before the build:** skip an emitter whose largest possible contribution anywhere inside the grid's bounds is below the irradiance floor. This alone should bring this case back to the normal cost. 2. **Bound the gather when it still happens:** spread it across the GPU (more, smaller units of work instead of one long loop per lane) and/or budget it across frames, keeping last build's cells meanwhile. 3. **Log each full-grid gather with its reason** (pairs cap overflow, cache invalidation) and the emitter and pair counts, rate-limited. **Test:** hover about 3 km above a large emissive build with max draw distance and GPU timers on (`RenderVKGpuTimers 1`). `c_rs_emissive` should stay near its ground-level cost; emissive lighting near emitters at ground level must be unchanged.
sky_line added this to the Slipstream project 2026-10-26 10:14:34 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sky_line/Slipstream#1108
No description provided.