Skip to content

Phase 3: WorldStreamer SRP Extraction #455

@MichaelFisher1997

Description

@MichaelFisher1997

Phase 3: WorldStreamer SRP Extraction

Goal

Split src/world/world_streamer.zig into smaller responsibilities so chunk lifecycle, LOD, and GPU acceleration can evolve independently.

Why this matters

WorldStreamer currently manages queues, predictive loading, uploads, LOD coordination, save integration, and GPU block-buffer orchestration. It is the largest SRP risk in the world pipeline.

Parallel Tasks

Issue 3.1: Extract the chunk queue and upload coordinator

  • Type: refactor / solid
  • Scope: src/world/world_streamer.zig
  • Problem: generation, meshing, upload queues, and job handlers are all owned by one module.
  • Work:
    • Create a focused coordinator for generation/meshing/upload progression
    • Move processGenJob, processMeshJob, and processUploads into that coordinator
    • Keep the same chunk state machine and worker pool behavior
  • Acceptance criteria:
    • Queue management is separated from LOD and GPU concerns
    • Chunk generation still reaches renderable through the same states
  • Parallel-safe: yes

Issue 3.2: Extract the LOD and predictive-loading coordinator

  • Type: refactor / solid
  • Scope: src/world/world_streamer.zig, src/world/lod_manager.zig
  • Problem: predictive loading and render-distance logic are mixed into queue orchestration.
  • Work:
    • Move PlayerMovement and related priority weighting into a dedicated coordinator
    • Isolate all lod_manager interactions behind a small API
    • Keep render-distance clamping behavior unchanged
  • Acceptance criteria:
    • LOD decisions are no longer embedded in the chunk queue code
    • Changing render distance still triggers the expected rescan behavior
  • Parallel-safe: yes

Issue 3.3: Extract the GPU acceleration coordinator

  • Type: refactor / solid
  • Scope: src/world/world_streamer.zig, src/world/gpu_block_buffer.zig, src/world/gpu_mesher.zig
  • Problem: GPU upload and compute-meshing concerns are intermixed with chunk lifecycle logic.
  • Work:
    • Move gpu_block_buffer and gpu_mesher ownership into a dedicated helper/coordinator
    • Keep upload fallback behavior for CPU meshing intact
    • Preserve safe-mode and GPU fallback logic
  • Acceptance criteria:
    • GPU acceleration code is separated from the core queue coordinator
    • CPU fallback still functions when GPU meshing is disabled or unavailable
  • Parallel-safe: yes

Dependencies

  • Phase 2 should be stable before major world-system reshaping, but the tasks do not directly depend on it

Verification

  • nix develop --command zig build test
  • nix develop --command zig build test-integration

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions