Skip to content

[SOLID] [M12] Allow backends to implement individual RHI sub-interfaces (drop composite bundling) #797

Description

@MichaelFisher1997

Part of #776 — SOLID architecture debt umbrella.
Phase: P2 · Finding: M12

Problem

modules/engine-rhi/src/rhi.zig:1028-1046 composite RHI.VTable re-bundles all 14 sub-vtables (comment: (temp)). A backend must implement all 14 even to do resource creation only — no way to ship a headless asset-baking backend. rhi_vulkan.zig:959-1067 is one 100+-function literal.

Evidence

rhi.zig:1028-1046:

pub const VTable = struct {
  init, deinit,
  // Composition of all vtables (temp)
  resources: IResourceFactory.VTable,
  render: IRenderContext.VTable,
  passes: IPassOrchestrationContext.VTable,
  ... all 14 ...
};

Fix

Allow backends to implement individual sub-interfaces and compose them at the seam. A backend that only creates resources implements only IResourceFactory.

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 M11 (split of IRenderOptionsContext). Both touch the vtable structure. Large, invasive — sequence after the P1 splits.

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