Triton: DirectX 11 Driver for QEMU
The UTM team unveils Triton, a groundbreaking DirectX 11 driver for QEMU, finally bringing modern graphics acceleration to Windows guests. This deep technical dive explains how they navigated the complexities of DirectX Device Driver Interfaces (DDI) and shader bytecode to achieve near-native performance. It's a significant open-source leap forward for virtualization enthusiasts, especially for running Windows games and applications on macOS hosts.
The Lowdown
The UTM team has announced Triton, a new DirectX 11 driver for QEMU, marking a significant advancement in bringing modern graphics acceleration to Windows guests. Building upon their previous work with Neptune, which initially focused on Direct3D protocol forwarding for Wine on Linux, this project directly addresses the challenge of providing high-performance graphics within Windows virtual machines by implementing the DirectX Device Driver Interface (DDI).
- Triton bypasses previous approaches of replacing
d3d11.dllordxgi.dll, which suffered from poor performance due to CPU blitting and compatibility issues with anti-cheat systems. Instead, it implements the User-Mode Driver (UMD) and Kernel-Mode Driver (KMD) for DirectX 11. - A key innovation is the "inverse transform" approach, converting DDI calls back into DirectX API calls, which allows Triton to leverage the existing and robust Neptune protocol for serialization, simplifying host-side processing.
- Handling DirectX Byte Code (DXBC) presented a major hurdle, as DDI calls only transmit the bytecode without its accompanying metadata. Triton must reconstruct this metadata by interpreting the bytecode to ensure compatibility with the host DirectX renderer.
- The entire rendering pipeline is intricate: guest applications make DirectX calls, Triton converts them to API calls for Neptune, which serializes them through VirtIO to the QEMU host. On the host, virglrenderer's Neptune module deserializes these calls, which are then rendered by the host's DirectX implementation.
- For macOS hosts, Triton explores various backends like DXVK + MoltenVK, a native DXMT variant, and a wrapper for Apple's D3DMetal from the Game Porting Toolkit, each presenting unique challenges and performance characteristics.
- Achieving shared textures and fences—critical for efficient modern graphics—on macOS required clever solutions, including using shared memory (via
shm_open) and emulated GPU fences to manage synchronization across virglrenderer's isolated processes. - While Apple's D3DMetal offers the best performance, its restrictive licensing terms pose a challenge for distribution, leading the team to investigate commercial agreements seen with applications like CrossOver.
This intricate engineering effort provides a powerful open-source foundation for enhanced Windows graphics in QEMU, with the UTM team actively working to upstream their changes and integrate these features into the UTM application for wider adoption.