Two-phase occlusion culling: switch on/off automatically by how much it culls #806

Open
opened 2026-10-17 15:03:18 +00:00 by sky_line · 0 comments
Owner

Two-phase Hi-Z occlusion culling (RenderVKOcclusion2Phase) is now off by default (a911265b9b). In an open outdoor scene it costs more than it saves. On a GTX 1080 at 4K with Firestorm-equivalent settings, turning it off took the frame from 25.4 to 22.1 ms and from 23.6 to 20.9 ms in two A/B pairs, about 3 ms either way. The second pre-pass phase, the Hi-Z build and the occlusion test cost more than the little geometry they hide. In dense interiors and cities it should still pay off.

Goal: turn it on and off by itself, based on how much it actually culls in the current scene, without causing hitches or popping.

Things to get right

  • Signal. Measure the benefit from what the GPU already reports, a few frames late: instances or triangles rejected by the phase-2 test against those tested, and the GPU time of the pre-pass p2 + c_hiz + c_occl_p2 + c_occl_split markers. Compare against an estimate of the work it saves. Smooth the signal over seconds, not frames.
  • Hysteresis.
    • Separate on and off thresholds, plus a minimum time in each state so camera turns can't make it flip-flop.
    • While it is off, re-probe at a low rate: one measured frame now and then, or a cheap estimate, so it can find out when a scene would benefit.
    • Re-evaluate right away on teleport or region change.
  • No hitches when switching. Enabling it must not create resources or rebuild descriptors in the frame it switches. Keep its buffers and Hi-Z allocated, or allocate them ahead of time while it is off, so a switch only changes which passes get recorded. Watch for the first-frame problem: the phase-1 "visible last frame" list is empty or stale right after it turns on.
  • Consistency. No popping. Phase 2 must still draw everything phase 1 missed, both on the switch frame and on the frame after.
  • Cluster LOD dependency. With two-phase and RenderVKOcclusionCull both off, no Hi-Z is built, so RenderVKClusterOcclusion is idle too. Decide whether a Hi-Z should still be built cheaply for cluster culling while two-phase is off, and measure that on its own.
  • Measure per GPU class. Pascal pays more for the extra passes than newer cards do, so the on/off thresholds may need to depend on the GPU. Test on the GTX 1080 box and on a current card, in an outdoor scene, a dense city and an interior.

Settings stay available for A/B: RenderVKOcclusion2Phase forces it on, and an auto mode would sit alongside it.

Two-phase Hi-Z occlusion culling (`RenderVKOcclusion2Phase`) is now **off by default** (a911265b9b). In an open outdoor scene it costs more than it saves. On a GTX 1080 at 4K with Firestorm-equivalent settings, turning it off took the frame from 25.4 to 22.1 ms and from 23.6 to 20.9 ms in two A/B pairs, about 3 ms either way. The second pre-pass phase, the Hi-Z build and the occlusion test cost more than the little geometry they hide. In dense interiors and cities it should still pay off. **Goal:** turn it on and off by itself, based on how much it actually culls in the current scene, without causing hitches or popping. **Things to get right** - **Signal.** Measure the benefit from what the GPU already reports, a few frames late: instances or triangles rejected by the phase-2 test against those tested, and the GPU time of the pre-pass `p2` + `c_hiz` + `c_occl_p2` + `c_occl_split` markers. Compare against an estimate of the work it saves. Smooth the signal over seconds, not frames. - **Hysteresis.** - Separate on and off thresholds, plus a minimum time in each state so camera turns can't make it flip-flop. - While it is off, re-probe at a low rate: one measured frame now and then, or a cheap estimate, so it can find out when a scene would benefit. - Re-evaluate right away on teleport or region change. - **No hitches when switching.** Enabling it must not create resources or rebuild descriptors in the frame it switches. Keep its buffers and Hi-Z allocated, or allocate them ahead of time while it is off, so a switch only changes which passes get recorded. Watch for the first-frame problem: the phase-1 "visible last frame" list is empty or stale right after it turns on. - **Consistency.** No popping. Phase 2 must still draw everything phase 1 missed, both on the switch frame and on the frame after. - **Cluster LOD dependency.** With two-phase and `RenderVKOcclusionCull` both off, no Hi-Z is built, so `RenderVKClusterOcclusion` is idle too. Decide whether a Hi-Z should still be built cheaply for cluster culling while two-phase is off, and measure that on its own. - **Measure per GPU class.** Pascal pays more for the extra passes than newer cards do, so the on/off thresholds may need to depend on the GPU. Test on the GTX 1080 box and on a current card, in an outdoor scene, a dense city and an interior. Settings stay available for A/B: `RenderVKOcclusion2Phase` forces it on, and an auto mode would sit alongside it.
sky_line added this to the Slipstream project 2026-10-17 15:03:18 +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#806
No description provided.