Microsoft will bring its famed set of DirectX gaming application programming interfaces to the Windows Subsystem for Linux 2 (WSL 2) environment to provide hardware accelerated graphics for Linux applications.
With a slew of Windows graphics features soon being available on WSL 2, Microsoft is already talking about moving the Linux environment out of being text console mode only, with applications getting graphical user interfaces (GUIs) as well.
A new Linux dxgkrnl kernel driver was clean-room developed for the WSL DirectX support, based on Microsoft's Windows Display Driver Model graphics processing unit para-virtualisation (GPU-PV) technology.
The driver will communicate with the Windows kernel and the physical graphics card; Microsoft said multiple GPUs are supported if they run WDDM 2.9 drivers.
Sharing the GPU between Windows and WSL 2 is dynamic and not subject to partitioning or resource limits with applications running at near native speed less some virtualisation overheads.
Microsoft said that its method of projecting a WDDM-compatible abstraction for the graphics card inside the Linux kernel allowed the company to recompile its entire DirectX API to WSL 2.
This means the full Direct 3D version 12 and DxCore APIs, with the caveat being that support is currently limited to GNU C library (glibc) distributions such as Fedora, Ubuntu, CentOS and others.
Graphics card vendors will need to provide user mode drivers (UMDs) for their hardware too.
The Linux dxgkrnl driver will also be used to provide support for non-DirectX hardware acceleration through the Khronos APIs such as OpenGL and OpenCL through the Mesa library, Microsoft said.
Vulkan is not yet supported, but Microsoft said it's looking into how to integrate that particular Khronos API for Linux as well.
Over the years, Microsoft has extended the role of DirectX beyond gaming and graphics, and added support for machine learning and artificial intelligence training.
Its machine learning API, DirectML, has been ported and works on Linux when running WSL 2, Microsoft said.
Microsoft will also add support for the Nvidia CUDA API for WSL 2.
This means hardware acceleration for CUDA-X libraries like cuDNN, cuBLAS and TensorRT.
Support for CUDA will come with Nvidia's WDDM v2.9 driver, and be automatically installed and work on glibc-based Linux distributions running on WSL 2.
Hardware acceleration for Nvidia's Docker tools within WSL 2 will also be supported for containerised workloads, and available as an adddional package.
To try out DirectX on Linux and WSL 2, users need to join the Windows 10 Insider preview program and select the Fast ring.