In DirectX ❤ Linux – DirectX Developer Blog we wrote about DXCore & D3D12 support on WSLg and described OpenGL & OpenCL support by adding a D3D12 backend to Mesa 3D, allowing such 3D and compute workloads to be offloaded to the GPU.

To extend the types of workloads that we can accelerate with the GPU in WSLg, we also recently added support for GPU Video Acceleration by building on top of the existing Mesa 3D D3D12 backend and integrating the VAAPI mesa frontend. Several linux media apps use the VAAPI interface to access hardware video acceleration when available, and this can now be leveraged in WSLg.
When decoding, encoding or processing a video, you have the option to do so using the CPU or -when available- offload it to accelerator hardware, usually delegating it to the GPU. Leveraging video hardware acceleration instead of using the CPU usually has several benefits: increased performance, lower power consumption and it frees up those CPU cycles to be available for other tasks in WSL or even in the Windows host, increasing overall performance. The benefits of using the GPU increase as the resolution of the video gets higher.
When running the samples at the end of this post, you can check out in the Windows Task Manager the CPU/GPU usage difference when enabling WSLg hardware video acceleration or when using the CPU. More information about this at: GPUs in the task manager – DirectX Developer Blog.
Customers can now run video workloads such as decode, encode and video processing in WSLg accelerated on the GPU with apps supporting VAAPI, for example: FFmpeg or GStreamer. The following are the VA entrypoints and profiles implemented on top of D3D12.
Profile name
|
Entrypoint name
|
Mesa version required
|
VAProfileH264ConstrainedBaseline | VAEntrypointVLD | 22.2 |
VAProfileH264ConstrainedBaseline | VAEntrypointEncSlice | 22.2 |
VAProfileH264Main | VAEntrypointVLD | 22.2 |
VAProfileH264Main | VAEntrypointEncSlice | 22.2 |
VAProfileH264High | VAEntrypointVLD | 22.2 |
VAProfileH264High | VAEntrypointEncSlice | 22.2 |
VAProfileHEVCMain | VAEntrypointVLD | 22.3 |
VAProfileHEVCMain | VAEntrypointEncSlice | 22.3 |
VAProfileHEVCMain10 | VAEntrypointVLD | 22.3 |
VAProfileHEVCMain10 | VAEntrypointEncSlice | 22.3 |
VAProfileVP9Profile0 | VAEntrypointVLD | 22.3 |
VAProfileVP9Profile2 | VAEntrypointVLD | 22.3 |
VAProfileAV1Profile0 | VAEntrypointVLD | 22.3 |
VAProfileNone | VAEntrypointVideoProc | 22.2 |
This list is illustrative of a GPU and vendor driver supporting all possible entrypoints/profiles using mesa 22.3. The actual capabilities reported in vaQueryConfigProfiles, vaQueryConfigEntrypoints , vaQueryConfigAttributes, VaQueryVideoProcPipelineCaps and others are dynamically queried from the underlying GPU and might vary between platforms and driver versions. The vainfo utility will list the actual subset of entrypoints/profiles supported by your hardware and applications will adjust to the available features reported.
- Install Windows Subsystem for Linux – Microsoft Store Apps (version 1.1.0 or newer)
- Install a distro like Ubuntu 22.04.1 LTS – Microsoft Store Apps
- Enable systemd in WSL.
- Follow the table in the hardware platforms support section and install a GPU driver from your vendor’s website with a version higher or equal than specified.
The scenarios mentioned in this article are upstreamed to mesa/main and available in mesa 22.2.0 and mesa 22.3.0 stable releases. However, it takes time for the distros to refresh their package repositories to pick up new versions and when you install mesa-va-drivers you may get an older version until they’re updated automatically after some time.
For example, in distros with apt you can check the latest available version in the repositories with the commands:
sudo apt-get update
apt list mesa-va-drivers -a
If the available mesa version in your distro is older than the mesa version required for the profile/entrypoint from the “Scenarios” section table you’d like to try, there are a couple of different options you choose to follow, described below.
Option 1. Build mesa from source code
In this option, you will build and install mesa from the mesa-22.3.0.tar.xz release or newer. If you follow this route, you can skip installing the mesa-va-drivers package in the section “Setting up Video acceleration in WSLg”.
- Make sure to include the following meson configuration flags
-Dgallium-drivers=swrast,d3d12 -Dgallium-va=true -Dvideo-codecs=h264dec,h264enc,h265dec,h265enc,vc1dec
- Build and install mesa
- Set the LIBVA_DRIVERS_PATH environment variable to the directory containing the custom built and installed d3d12_drv_video.so. You may want to add this in yo
!-->