Perf: avoid drawing opaque geometry twice (depth prepass 3.5 ms) #259

Closed
opened 2026-10-03 02:34:27 +00:00 by sky_line · 2 comments
Owner

Measured at a Baltimare party (85 avatars, 4K, 5090, FSR native AA, RT shadows): ~47-54 FPS, GPU ~20 ms ≈ CPU main ~21 ms (balanced).

g_prepass = 3.49 ms, then gbuf_static 2.60 + gbuf_rigged 1.05 redraw the same geometry. Options: HiZ-only occlusion (two-phase cull already exists) and drop the prepass where early-Z in the G-buffer pass suffices; prepass only for alpha-masked/expensive materials; or move toward the visibility buffer (#256).

Measured at a Baltimare party (85 avatars, 4K, 5090, FSR native AA, RT shadows): ~47-54 FPS, GPU ~20 ms ≈ CPU main ~21 ms (balanced). g_prepass = 3.49 ms, then gbuf_static 2.60 + gbuf_rigged 1.05 redraw the same geometry. Options: HiZ-only occlusion (two-phase cull already exists) and drop the prepass where early-Z in the G-buffer pass suffices; prepass only for alpha-masked/expensive materials; or move toward the visibility buffer (#256).
sky_line added this to the Slipstream project 2026-10-06 15:04:14 +00:00
Author
Owner

Status 2026-10-10: not done. The depth pre-pass is still on by default (RenderVKDepthPrepass: opaque + alpha-mask depth pre-pass, then the lit pass tests EQUAL with early fragment tests), so opaque geometry is still drawn twice by design; g_prepass measured ~1.0 ms at 4K in a quiet home region (3.5 ms at the Baltimare party). Two-phase occlusion (cf18746620) exists. The options in the description (drop the pre-pass where early-Z suffices, pre-pass only for alpha-mask / expensive materials, visibility buffer #256) are still open; RenderVKDepthPrepass 0 is the live A/B for measuring.

Status 2026-10-10: not done. The depth pre-pass is still on by default (RenderVKDepthPrepass: opaque + alpha-mask depth pre-pass, then the lit pass tests EQUAL with early fragment tests), so opaque geometry is still drawn twice by design; g_prepass measured ~1.0 ms at 4K in a quiet home region (3.5 ms at the Baltimare party). Two-phase occlusion (cf18746620) exists. The options in the description (drop the pre-pass where early-Z suffices, pre-pass only for alpha-mask / expensive materials, visibility buffer #256) are still open; RenderVKDepthPrepass 0 is the live A/B for measuring.
Author
Owner

Closing: measured, and the premise doesn't hold. The depth prepass is a large net win.

A/B on 2026-10-10 (RTX 5090, 3840x2088 with FSR, busy sim, GPU timers, RenderVKDepthPrepass toggled live):

prepass ON prepass OFF
FPS ~91 ~38
GPU frame 10.7 ms 26 ms
g_prepass 0.81 ms —
g_gbuf_static + rigged 1.22 + 0.25 ms —
g_lit_static + rigged (forward fallback) — 15.0 + 3.2 ms
q_mask_ao / c_rtmask 1.37 / 0.80 ms 0 / 0 (not run)
  • Overdraw: with the prepass, the material pass tests depth EQUAL, so the expensive shading runs once per pixel. Without it, the forward fallback shades every overlapping surface. About 0.8 ms of prepass saves about 17 ms.
  • Inputs: the prepass's depth, normals and motion feed AO, the RT shadow mask, VRS and Hi-Z occlusion. With it off, AO and the RT shadow mask don't run at all (avatars lose AO and the denoised RT shadows).
  • Cost now: about 0.8–1.2 ms (3.5 ms at the Baltimare party when this was filed, before the crowd and pre-skin work).

"Draw geometry once" without losing these inputs is the visibility-buffer work: #256. Removing the forward fallback is tracked separately (#640).

Closing: measured, and the premise doesn't hold. The depth prepass is a large net win. A/B on 2026-10-10 (RTX 5090, 3840x2088 with FSR, busy sim, GPU timers, `RenderVKDepthPrepass` toggled live): | | prepass ON | prepass OFF | |---|---|---| | FPS | ~91 | ~38 | | GPU frame | 10.7 ms | 26 ms | | g_prepass | 0.81 ms | — | | g_gbuf_static + rigged | 1.22 + 0.25 ms | — | | g_lit_static + rigged (forward fallback) | — | 15.0 + 3.2 ms | | q_mask_ao / c_rtmask | 1.37 / 0.80 ms | 0 / 0 (not run) | - **Overdraw:** with the prepass, the material pass tests depth EQUAL, so the expensive shading runs once per pixel. Without it, the forward fallback shades every overlapping surface. About 0.8 ms of prepass saves about 17 ms. - **Inputs:** the prepass's depth, normals and motion feed AO, the RT shadow mask, VRS and Hi-Z occlusion. With it off, AO and the RT shadow mask don't run at all (avatars lose AO and the denoised RT shadows). - **Cost now:** about 0.8–1.2 ms (3.5 ms at the Baltimare party when this was filed, before the crowd and pre-skin work). "Draw geometry once" without losing these inputs is the visibility-buffer work: #256. Removing the forward fallback is tracked separately (#640).
sky_line 2026-10-10 11:10:46 +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#259
No description provided.