Skip to content

[SOLID] [M3] Split rhi.zig into interfaces/wrappers; decompose VulkanContext god-struct #787

Description

@MichaelFisher1997

Part of #776 — SOLID architecture debt umbrella.
Phase: P1 · Finding: M3

Problem

modules/engine-rhi/src/rhi.zig (1,384 LOC) mixes interface vtables + 4 wrapper structs + a legacy composite + ~50 deprecated passthroughs (self-admitted at line 1012). VulkanContext (rhi_context_types.zig:192-231) is a 24+-field god-struct spanning every rendering subsystem.

Evidence

rhi.zig:1012:

/// DEPRECATED: retained as a composition root during the RHI
/// modularization refactoring (issue #291 / #272).

rhi_context_types.zig:192-231 — 24+ fields: vulkan_device, resources, frames, swapchain, descriptors, pipeline_manager, render_pass_manager, shadow_system, ssao_system, bloom_system, water_system, taa_state, depth_pyramid, dynamic_resolution, timing, …

Fix

  1. Split rhi.zig into interfaces.zig (vtables) + wrappers.zig (ResourceManager/RenderContext/UIRenderer/ShadowSystemWrapper).
  2. Delete the ~50 deprecated passthrough methods (lines 1120-1383) once migration is confirmed complete.
  3. Group VulkanContext fields into PostProcessBackend, ShadowBackend, HdrBackend, etc., then compose.

Verification

  • nix develop --command zig build test (includes shader validation)
  • If rendering-touching: capture headless screenshot baseline before/after (-Dskip-present)
  • If behavior-preserving refactor: golden-output test must stay green

Constraints

  • Small reviewable PR targeting dev; conventional commit (refactor: / feat:)
  • Preserve current behavior unless this issue explicitly changes it
  • Keep worker-thread RHI isolation intact (no RHI calls off main thread)

Notes

Coordinate with C2/C3 — those issues add new vtable entries; land this split first or agree on a merge order.

Tracking: #776

Metadata

Metadata

Assignees

No one assigned

    Labels

    automated-auditIssues found by automated opencode audit scansbugSomething isn't workingengineenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions