Microsoft is adding DirectX support to Linux distros running in a WSL 2 environment. The change goes live with first 21H1 builds from the Iron (Fe) branch in the Fast Ring, which are expected to come this June.
Microsoft is introducing Windows Display Driver Model version 2.9, WDDMv2.9, which will bring GPU acceleration to WSL 2. To make it possible, there is a special Linux kernel module on WSL's side,
Dxgkrnl is a brand-new kernel driver for Linux that exposes the /dev/dxg device to user mode Linux. /dev/dxg exposes a set of IOCTL that closely mimic the native WDDM D3DKMT kernel service layer on Windows. Dxgkrnl inside of the Linux kernel connects over the VM Bus to its big brother on the Windows host and uses this VM bus connection to communicate with the physical GPU.
If the host has multiple GPUs, all GPUs are projected and available to the Linux environment (assuming all of these GPUs are running WDDMv2.9 drivers).
Microsoft claims that the architecture won't limit or interfere performance of WSL apps, and GPU resources will be properly shared between Windows apps running alongside the Linux GUI and console apps that utilize DirectX.
Dxgkrnl Linux edition is being made open source.
DxCore & D3D12 on Linux
This projects brings full D3D12 API to Linux with no imitations.ibd3d12.so is compiled from the same source code as d3d12.dll on Windows but for a Linux target. It offers the same level of functionality and performance (minus virtualization overhead). The only exception is Present(). There is currently no presentation integration with WSL as WSL is a console only experience today. The D3D12 API can be used for offscreen rendering and compute, but there is no swapchain support to copy pixels directly to the screen.
DxCore (libdxcore.so) is a simplified version of dxgi where legacy aspects of the API have been replaced by modern versions. DxCore is available on both Windows and Linux. DxCore is also used to host a flat version of the D3DKMT API used by a WDDM based driver on Windows to talk with the GPU. This API abstracts the differences in how the various WDDM services make their way to the kernel (service table on Windows versus IOCTL on Linux).
libd3d12.so and libdxcore.so are closed source, pre-compiled user mode binaries that ship as part of Windows. These binaries are compatible with glibc based distros and are automatically mounted under /usr/lib/wsl/lib and made visible to the loader. In other words, these APIs work right out of the box without the need to install additional packages or tweak the distro’s configuration. Support is currently limited to glibc based distros inlcuding Ubuntu, Debian, Fedora, Centos, SUSE, and so on.
D3D12 wouldn’t be able to operate without a GPU specific user mode driver (UMD) provided by GPU manufacturer partners. The UMD is responsible for things like compiling shaders to hardware specific byte code and translating API rendering requests into actual GPU instructions in command buffers to be executed by the GPU. The host driver package is mounted inside of WSL at /usr/lib/wsl/drivers and directly accessible to the d3d12 API. Again WDDM 2.9 driver is required.
Microsoft is also working on bringing GPU acceleration for OpenGL, OpenCL & Vulkan in WSL through the Mesa library.
Support for DxCore, D3D12, DirectML and NVIDIA CUDA is coming to a Windows Insider Fast build soon. The Fast ring is currently on the Manganese (Mn) OS branch. The Fast ring is expected to switch over to the new
Iron (Fe) branch toward the later part of June which will expose this new functionality to Insiders.
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options: