Skip to content

LOD GPU roadmap Phase 1: remove CPU and submission hot spots #920

Description

@MichaelFisher1997

Goal

Capture low-risk gains before adding GPU compute. Keep policy, persistence, and procedural generation on CPU while eliminating unnecessary scans, locks, I/O, and draw submission.

Depends on

Phase 0 profiling baselines.

Parallel workstreams

Visibility and coverage

  • Frustum/radius reject before isCoveredByChunks.
  • Replace per-region full-chunk enumeration with cached/coarse coverage data.
  • Build visibility once per frame and share it between terrain and water.
  • Measure candidates/reject reasons by LOD level.

Lifecycle and threading

  • Replace repeated HashMap scans/sorts with state queues, counters, and bounded priority structures.
  • Snapshot/pin immutable source data, mesh outside the manager lock, and publish with token/version validation.
  • Move cache reads, deserialization, dirty serialization, and writes off the update thread.
  • Reconcile pause/unpause states for jobs cleared from the queue.

Draw submission

  • Production-harden and default-enable existing terrain MDI where supported.
  • Add pooled/indirect batching for LOD water.
  • Keep a tested direct-draw fallback.

Far-detail density

  • Benchmark reduced LOD3/4 sample grids and cheaper representative sampling.
  • Reuse coarse parent samples while refining children.
  • Disable or aggregate vegetation detail where it is sub-pixel.

Relevant code

  • modules/world-lod/src/lod_renderer.zig
  • modules/world-lod/src/lod_manager_generation_ops.zig
  • modules/world-lod/src/lod_manager_cache_ops.zig
  • modules/world-lod/src/lod_mesh.zig
  • modules/world-lod/src/lod_scheduler.zig
  • modules/worldgen-overworld-v2/src/lod_sampling.zig

CPU/GPU decision

Scheduling, persistence, procedural sampling, and coarse visibility remain CPU work. The GPU receives batched drawing, not generation, in this phase.

Acceptance criteria

  • No synchronous disk I/O on the frame/update path.
  • Meshing does not hold the global manager lock for its full duration.
  • Terrain and water do not independently repeat identical visibility/coverage work.
  • MDI reduces LOD submission/draw overhead without visual regressions; fallback remains functional.
  • Benchmarks demonstrate lower p95/p99 CPU frame time, not only higher average FPS.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions