Repository navigation
Description
Follow-up to #249 (frame-side frustum culling).
Problem
#249 culls in the G-buffer pass (OffscreenSubpass::Draw), so a mesh outside the view skips its draw and its uniform buffer write. The per-mesh frame work before that still runs for every mesh, visible or not:
Graphics.PublishSnapshot(PublishSnapshotSystem) blends eachTransformup the parent chain (Interpolate::BlendedWorld: lerp, slerp and a matrix per parent) and writes aMeshDrawItemfor every mesh.- The proxy sync in
OffscreenSubpasswalks every snapshot item.
In Level_1, 591 of 756 meshes are culled each frame, yet all 756 are blended and written into the snapshot.
This is not new in #249: before it, every mesh was blended and drawn. #249 just doesn't reduce this part.
Root cause
The renderer's camera (FirstPersonCamera) is only final in VulkanApp::Update, after the frame systems (Order::Frame, Order::Render) have run. PublishSnapshotSystem can't cull against it: the previous frame's camera would not be conservative and could hide a mesh that is on screen.
Proposed fix
- Settle the camera before the frame systems run: move the debug/first-person camera update into a frame system that writes
CameraView(or a new Presentation singleton with the final view-projection), ordered beforeGraphics.PublishSnapshot. - In
PublishSnapshotSystem, test each mesh's world bounds against that frustum before the blend. Skip the blend and the snapshot entry for culled meshes, or mark them culled.- It needs a cheap conservative bound before the blend, for example the union of the bounds at
BlendFromandBlendTo. - Bounds would need to be reachable from the frame side, for example a Presentation component or a lookup from the mesh path.
- It needs a cheap conservative bound before the blend, for example the union of the bounds at
- Keep the culling in the G-buffer pass as the exact test, or remove it if the snapshot test is exact.
Watch out for:
- Proxy churn: a mesh leaving the snapshot frees its proxy and GPU resources. Prefer a "culled" flag on
MeshDrawItemover dropping the entry. - Point-light gizmos and any future shadow pass need the casters outside the view.
Out of scope
The publish copy from the game thread to the main thread (TickPacket) is separate. Change tracking / delta packets are the fix for that, not camera culling.
Done when
- Culled meshes do no blend or matrix work in
PublishSnapshotSystem(shown by a test, e.g. a counter or an instrumented run). - Offscreen screenshots are byte-identical with culling on and off (Level_1,
Levels/PhysicsTest.json). -
GraphicsTests "[culling]"and the full CTest suite pass.
Activity