RuntimeConfig
TheRuntimeConfig structure provides dependency injection for Runtime subsystem backends. This keeps the runtime library decoupled from concrete backend implementations (graphics, audio, input).
Structure Definition
Fields
Graphics backend implementation. Moved directly into Runtime during
Setup().Available implementations:rex::graphics::vulkan::VulkanGraphicsSystem(cross-platform)rex::graphics::d3d12::D3D12GraphicsSystem(Windows only)
REX_GRAPHICS_BACKEND() macro for easy instantiation.Factory function that creates an audio backend. Takes a
Processor* because IAudioSystem requires processor access at construction time (only available during Setup()).Available implementations:rex::audio::sdl::SDLAudioSystem(cross-platform, SDL2-based)
REX_AUDIO_BACKEND() macro for easy factory creation.Factory function that creates an input backend. Takes
tool_mode parameter to allow skipping input initialization in headless tools.Available implementations:rex::input::CreateDefaultInputSystem(platform-dependent default)
REX_INPUT_BACKEND() macro for easy factory creation.If
true, skips GPU initialization for analysis tools (like codegen). Audio and input may also be skipped based on factory implementation.Helper Macros
The SDK provides three helper macros for populatingRuntimeConfig with concrete backends:
REX_GRAPHICS_BACKEND
Graphics system class name (e.g.,
rex::graphics::vulkan::VulkanGraphicsSystem).REX_AUDIO_BACKEND
Processor* during runtime initialization.
Audio system class name with a static
Create(Processor*) method (e.g., rex::audio::sdl::SDLAudioSystem).REX_INPUT_BACKEND
tool_mode flag during runtime initialization.
Input system setup function with signature
std::unique_ptr<IInputSystem>(bool tool_mode).Design Notes
Why Factories for Audio and Input?
Audio uses a factory becauseIAudioSystem requires a Processor* at construction time. The processor is only available during Runtime::Setup(), so we can’t construct audio backends before calling Setup().
Input uses a factory to allow the backend to check tool_mode and skip initialization in headless scenarios (e.g., codegen tools).
Graphics is passed directly as a unique_ptr because it doesn’t require runtime-specific parameters at construction.
Usage Example
Full Configuration
Tool Mode (No GPU)
Platform-Specific Graphics
Real-World Example
Fromsrc/ui/rex_app.cpp:122-133:
Macro Expansion Example
To understand what the macros do, here’s what they expand to:See Also
- rex::Runtime - Main runtime class that consumes this config
- Graphics System - GPU emulation backends
- Audio System - Audio processing backends
- Input System - Controller and keyboard input backends