Problem
The RHI struct in src/engine/graphics/rhi.zig violates the Single Responsibility Principle (SRP). It acts as a monolithic facade ("God Object") that handles widely divergent responsibilities:
- Resource Management (Buffers, Textures, Shaders)
- Command Recording & Submission
- UI Rendering
- Device Queries & Synchronization
- Presentation & VSync
This centralization makes the graphics subsystem rigid and difficult to unit test or refactor.
Impacted Files
src/engine/graphics/rhi.zig
src/engine/graphics/rhi_vulkan.zig
Action Plan
- Define Subsystems:
- ResourceManager: Dedicated to
createBuffer, createTexture, destroy*.
- RenderCommandQueue: Handles
beginFrame, endFrame, and submission logic.
- SwapchainPresenter: Handles surface, vsync, and presentation.
- Refactor RHI: Change
RHI to be a container that holds references to these subsystems, rather than implementing the methods directly via a giant VTable.
- Update Implementation: Split
VulkanContext to align with these new boundaries.
Acceptance Criteria
RHI struct is significantly smaller or acts only as a composition root.
- Resource creation and command submission are distinct logical paths.
Problem
The
RHIstruct insrc/engine/graphics/rhi.zigviolates the Single Responsibility Principle (SRP). It acts as a monolithic facade ("God Object") that handles widely divergent responsibilities:This centralization makes the graphics subsystem rigid and difficult to unit test or refactor.
Impacted Files
src/engine/graphics/rhi.zigsrc/engine/graphics/rhi_vulkan.zigAction Plan
createBuffer,createTexture,destroy*.beginFrame,endFrame, and submission logic.RHIto be a container that holds references to these subsystems, rather than implementing the methods directly via a giant VTable.VulkanContextto align with these new boundaries.Acceptance Criteria
RHIstruct is significantly smaller or acts only as a composition root.