Skip to main content

ADR-014: Cross-Platform Architecture

Status

Accepted

Context

VR creators use both Windows and Linux systems. SteamVR supports both platforms. Many users dual-boot or have mixed environments. We need consistent behavior across platforms while leveraging platform-specific optimizations.

Decision

Implement a Platform Abstraction Layer (PAL) with trait-based interfaces:

  • All platform-specific code isolated in platform crate
  • Compile-time platform selection via cfg attributes
  • Consistent API across platforms
  • Platform-specific optimizations allowed

Primary platforms:

  • Windows 10/11: Full support from day one
  • Linux: Ubuntu 20.04+, Fedora 35+, SteamOS 3.0+
  • macOS: Future support when Apple adds VR

Consequences

Positive

  • Single codebase for all platforms
  • Platform-specific optimizations possible
  • Easier testing with trait mocking
  • Clear separation of concerns
  • Community can add platform support

Negative

  • Additional abstraction layer complexity
  • Must test on multiple platforms
  • Platform-specific bugs possible
  • Some features may not have equivalents

Alternatives Considered

  1. Windows-only: Would exclude Linux VR users (growing segment)
  2. Lowest common denominator: Would sacrifice performance
  3. Separate codebases: Maintenance nightmare
  4. Web-based only: Can't access VR APIs properly

Implementation

Platform traits cover:

  • Window management
  • GPU access (DirectX 12 / Vulkan)
  • File system paths
  • Process management
  • Network interfaces
  • System tray integration

Example:

pub trait GpuDevice: Send + Sync {
type Texture: GpuTexture;
type CommandList: GpuCommandList;

fn create_texture(&self, desc: &TextureDesc) -> Result<Self::Texture>;
fn submit(&self, commands: Self::CommandList) -> Result<()>;
}

#[cfg(target_os = "windows")]
pub type PlatformGpuDevice = crate::dx12::Dx12Device;

#[cfg(target_os = "linux")]
pub type PlatformGpuDevice = crate::vulkan::VulkanDevice;