Major occlusion search optimizations #34

Merged
embeddedt merged 11 commits from occlusion-opts into stonecutter 2026-08-18 19:59:03 -04:00
Owner

Significantly improves the performance of occlusion search, with particularly noticeable gains at large render distances, or when async occlusion is disabled.

Summary of changes:

  • Frustum tests are now memoized across the whole region where possible. Specifically, the region's bounding box is evaluated for being fully inside/fully outside/partially inside the frustum, and the first two cases are used to skip the per-section test entirely.
  • The occlusion graph data structures have been completely reworked, and now use flat arrays rather than a Java object per node. This drastically reduces the amount of pointer chasing and cache misses during the graph traversal.
  • Some metadata on render sections has been packed into a bitfield rather than stored as individual fields, which allows it to be efficiently cached in the occlusion graph, for similar reasons to above.
  • In general much of the occlusion culling code is a lot more C-like, e.g. some queues were replaced by plain arrays with pointer bumping.

AI disclosure: These improvements were made with assistance from Claude Fable 5 & Opus 5 (design details), Opus 4.8 (final production implementation), and GPT-5.6-Luna (most docs). The added lines of code look quite concerning, but most are from the newly added comments. With comments & blank lines excluded, the PR works out to roughly 620 lines added and 310 removed.

Performance figures: A draft implementation (separate codebase from the one on this branch) written by the Fable/Opus team and tested in isolation on an i5-1135G7 system yielded ~60-74% reduction in CPU time spent on occlusion culling. When testing the final implementation on my main PC (Ryzen 7 7700X, RX 6600) the game now remains GPU-bound at a render distance of 64 when shaking the camera (while otherwise remaining still, to avoid overhead from chunk loading/unloading).

Significantly improves the performance of occlusion search, with particularly noticeable gains at large render distances, or when async occlusion is disabled. Summary of changes: - Frustum tests are now memoized across the whole region where possible. Specifically, the region's bounding box is evaluated for being fully inside/fully outside/partially inside the frustum, and the first two cases are used to skip the per-section test entirely. - The occlusion graph data structures have been completely reworked, and now use flat arrays rather than a Java object per node. This drastically reduces the amount of pointer chasing and cache misses during the graph traversal. - Some metadata on render sections has been packed into a bitfield rather than stored as individual fields, which allows it to be efficiently cached in the occlusion graph, for similar reasons to above. - In general much of the occlusion culling code is a lot more C-like, e.g. some queues were replaced by plain arrays with pointer bumping. AI disclosure: These improvements were made with assistance from Claude Fable 5 & Opus 5 (design details), Opus 4.8 (final production implementation), and GPT-5.6-Luna (most docs). The added lines of code look quite concerning, but most are from the newly added comments. With comments & blank lines excluded, the PR works out to roughly 620 lines added and 310 removed. Performance figures: A draft implementation (separate codebase from the one on this branch) written by the Fable/Opus team and tested in isolation on an i5-1135G7 system yielded ~60-74% reduction in CPU time spent on occlusion culling. When testing the final implementation on my main PC (Ryzen 7 7700X, RX 6600) the game now remains GPU-bound at a render distance of 64 when shaking the camera (while otherwise remaining still, to avoid overhead from chunk loading/unloading).
embeddedt added 5 commits 2026-08-17 20:21:05 -04:00
rdh requested review from rdh 2026-08-17 21:48:57 -04:00
embeddedt added 1 commit 2026-08-17 22:58:03 -04:00
Optimize rebasing the lattice
ci / build (push) Successful in 2m49s
a0d478d012
embeddedt added 5 commits 2026-08-18 19:52:51 -04:00
embeddedt merged commit 7704538a23 into stonecutter 2026-08-18 19:59:03 -04:00
embeddedt deleted branch occlusion-opts 2026-08-18 19:59:03 -04:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: embeddedt/celeritas#34