-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or requestquestionFurther information is requestedFurther information is requested
Description
Problem
The RHI struct in src/engine/graphics/rhi.zig (754 lines) is a composite God Object that combines 8+ interface vtables into a single struct:
- IResourceFactory (buffer/texture/shader creation)
- IRenderContext (frame/render pass management)
- IShadowContext (shadow mapping)
- IUIContext (2D/UI rendering)
- IGraphicsCommandEncoder (draw commands)
- IRenderStateContext (uniforms/state)
- ISSAOContext (SSAO computation)
- IDeviceQuery/IDeviceTiming (device queries)
This violates SRP and makes the code difficult to maintain and test.
Current State
RHI struct acts as a monolithic facade over many concerns.
Proposed Solution
Keep the segregated interfaces (which are well-designed!) but refactor how they're composed:
- Option A: Keep separate interface instances instead of one composite
- Option B: Create focused subsystem wrappers:
ResourceManager- owns IResourceFactoryRenderContext- owns IRenderContext + IGraphicsCommandEncoderShadowSystem- owns IShadowContextUIRenderer- owns IUIContext
Benefits
- Clients depend only on interfaces they actually use
- Easier to mock for unit testing
- Clearer dependencies between subsystems
- Reduced cognitive load per module
Acceptance Criteria
- Split RHI composite into focused subsystems
- Update all callers to use appropriate subsystem
- No change to underlying Vulkan implementation
- All tests pass
- Document the new architecture
Related Files
src/engine/graphics/rhi.zigsrc/engine/graphics/rhi_vulkan.zig
SOLID Principles
- Single Responsibility Principle (SRP)
- Interface Segregation Principle (ISP)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or requestquestionFurther information is requestedFurther information is requested