ifcviewer: same-frame HiZ occlusion cull on GPU (step 3d)

Two-phase compute-cull dispatch when IFC_GPU_CULL=1:

  Phase 1  frustum + contribution + LOD, no HiZ  → survivors
  Depth    render survivors depth-only into half-viewport FBO
  Build    GPU compute max-reduce depth → R32F mip pyramid
  Phase 2  same cull + HiZ test                  → final survivors
  Color    render final survivors

The compact shader's new hizOccluded() projects 8 AABB corners to
screen space, picks the mip level where the covered rect fits in ≤2×2
texels, and rejects when the AABB's near-depth exceeds the pyramid's
max depth.

New GPU resources (per-window):
  hiz_gpu_fbo_ / hiz_gpu_depth_tex_  — depth-only FBO at half viewport
  hiz_gpu_pyramid_tex_                — R32F mipmapped pyramid
  hiz_gpu_copy_prog_                  — compute: depth → pyramid L0
  hiz_gpu_reduce_prog_                — compute: max-reduce L(n-1)→L(n)
  hiz_gpu_depth_prog_                 — vertex + trivial fragment

On a dense 18-model BIM dataset:
  survivors:  140k → 65k  (HiZ rejects ~50%)
  triangles:  22M  → 13M
  gpu_cull:   0.06ms → 22.5ms  (depth pre-pass CP overhead)

The depth pre-pass suffers the same empty-sub-draws CP overhead as the
color pass (690k commands, most with instanceCount=0).  Once MDI
compaction lands, both passes will be fast.  For now, net FPS is flat
(savings on color ≈ cost of depth pre-pass).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dion Moult
2026-04-17 10:12:56 +10:00
parent e5ed7b53d4
commit a34c36d22e
3 changed files with 304 additions and 45 deletions
+6 -1
View File
@@ -803,7 +803,12 @@ single giant model / <18 cores CPU BVH trv Phase 3E GPU cull (plann
pixel radius and routes to LOD1 bucket when below threshold.
Per-mesh `has_lod1` flags SSBO. 4 buckets per mesh (fwd/rev ×
LOD0/LOD1), 4M commands total, 2 MDIs per model.
- [ ] 3d: HiZ with same-frame depth pre-pass
- [x] 3d: same-frame HiZ — two-phase dispatch: phase 1 (no HiZ)
drives a depth-only pre-pass, GPU max-reduce builds HiZ
pyramid, phase 2 (with HiZ) produces final survivors.
Occlusion halves survivors on dense interiors. Depth
pre-pass has same CP overhead as color pass (690k empty
sub-draws); cost dominated by MDI command processing.
- [ ] MDI compaction — compact non-empty commands into contiguous
buffer, use `glMultiDrawElementsIndirectCount` (GL 4.6 /
`ARB_indirect_parameters`). Deferred until all feature buckets