https://devblogs.microsoft.com/commandline/d3d12-gpu-video-acceleration-in-the-windows-subsystem-for-linux-now-available/ Skip to main content [RE1Mu3b] Microsoft Windows Command Line Windows Command Line Windows Command Line * Home * DevBlogs * Developer + Visual Studio + Visual Studio Code + Visual Studio for Mac + DevOps + Developer support + CSE Developer + Engineering@Microsoft + Azure SDK + IoT + Command Line + Perf and Diagnostics + Dr. International + Notification Hubs + Math in Office + React Native * Technology + DirectX + PIX + SurfaceDuo + Startups + Sustainable Engineering + Windows AI Platform * Languages + C++ + C# + F# + Visual Basic + TypeScript + PowerShell Community + PowerShell Team + Python + Q# + JavaScript + Java + Java Blog in Chinese * .NET + .NET + .NET MAUI + Blazor + ASP.NET + NuGet + Xamarin + .NET Blog in Chinese * Platform Development + #ifdef Windows + Apps for Windows + Azure Depth Platform + Azure Government + Bing Dev Center + Microsoft Edge Dev + Microsoft Azure + Microsoft 365 Developer + Old New Thing + Windows MIDI and Music dev + Windows Search Platform * Data Development + Azure Cosmos DB + Azure Data Studio + Azure SQL Database + OData + Revolutions R + SQL Server Data Tools * More [ ] Search Search * No results Cancel D3D12 GPU Video acceleration in the Windows Subsystem for Linux now available! [png] Sil Vilerino February 13th, 20230 2 Introduction 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. Gstreamer playing an mp4 video in an X11 Windows in WSL using GPU acceleration.3 Gstreamer playing an mp4 video in an X11 Windows in WSL using GPU acceleration. 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. Scenarios 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. Mesa Profile name Entrypoint name 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. Installation Required components 1. Install Windows Subsystem for Linux - Microsoft Store Apps (version 1.1.0 or newer) 2. Install a distro like Ubuntu 22.04.1 LTS - Microsoft Store Apps 3. Enable systemd in WSL. 4. 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. About package manager repositories 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". 1. Make sure to include the following meson configuration flags -Dgallium-drivers=swrast,d3d12 -Dgallium-va=true -Dvideo-codecs=h264dec,h264enc,h265dec,h265enc,vc1dec 1. Build and install mesa 2. 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 your ~/.bashrc file as it's necessary on every new WSL console session. 3. Follow the instructions in the section "Setting up Video acceleration in WSLg". Option 2. Use a 3^rd party repository for the mesa library packages Adding the 3^rd party repository In Ubuntu 22.04 and newer, you can add this 3^rd party repository to make available the bleeding edge/unstable daily mesa packages built from mesa/main with the following commands. sudo add-apt-repository ppa:oibaf/graphics-drivers sudo apt-get update && sudo apt-get upgrade After adding the repository, follow the instructions in the section "Setting up Video acceleration in WSLg". Removing the 3^rd party repository In the case you added the ppa:oibaf repository and followed the setup steps in the section "Setting up Video acceleration in WSLg", and now want to revert back to the previous state, please follow these steps. sudo apt-get install ppa-purge sudo ppa-purge ppa:oibaf/graphics-drivers sudo apt-get update && sudo apt-get upgrade Setting up Video acceleration in WSLg Open the WSL console and run the following commands to install the required components. The following steps use the apt package manager, but you may replace it with the appropriate equivalent on your distro. 1.Make sure you have the latest updates installed sudo apt-get update && sudo apt-get upgrade 2. Install vainfo (and libva dependencies) sudo apt-get install vainfo 3. *Install mesa libraries *(skip this if built from mesa source code) sudo apt-get mesa-va-drivers 4. Configure libva environment. You may want to add this in your ~ /.bashrc file as it's necessary on every new WSL console session. export LIBVA_DRIVER_NAME=d3d12 5. Enumerate libva capabilities for your current hardware vainfo --display drm --device /dev/dri/card0 The vainfo utility will indicate the libva and mesa versions installed and list the subset of entrypoints and profiles supported by your hardware, for example: vainfo: VA-API version: 1.15 (libva 2.12.0) vainfo: Driver version: Mesa Gallium driver 22.2.1 for D3D12 vainfo: Supported profile and entrypoints VAProfileH264ConstrainedBaseline: VAEntrypointVLD VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice VAProfileH264Main : VAEntrypointVLD VAProfileH264Main : VAEntrypointEncSlice VAProfileH264High : VAEntrypointVLD VAProfileH264High : VAEntrypointEncSlice VAProfileNone : VAEntrypointVideoProc This list is illustrative of a GPU supporting only a subset of the implemented features on the indicated libva/mesa versions. Adding the "-a" argument to the vainfo command will give you more detailed support information such as rate control modes, max reference frames, slice modes, etc for each entrypoint/profile available on your hardware. Examples using GPU Video acceleration Gstreamer in WSL performing GPU accelerated alpha blend composition and rendering into an X11 window]16 Gstreamer in WSL performing GPU accelerated alpha blend composition and rendering into an X11 window You can now install some media apps with VA acceleration and use GPU video acceleration, below are some examples you can try. Please check that the mesa version and the entrypoints required for each example are supported on your platform by checking the vainfo utility. The Windows Task Manager will show the CPU/GPU usage for each of these samples, and you can compare the results for different samples using CPU only or GPU acceleration. To begin please follow the steps below to install ffmpeg and/or gstreamer and then you can try some of the command line samples below. Install ffmpeg and gstreamer sudo apt-get install ffmpeg sudo apt-get install gstreamer1.0-plugins-bad gstreamer1.0-tools gstreamer1.0-vaapi Command line examples 1.Requires mesa 22.2 + H264 VAEntrypointEncSlice. Generate 250 test frames and encode to an H.264 file using the GPU with VAAPI. gst-launch-1.0 -v videotestsrc num-buffers=250 ! video/x-raw,width=1920,height=1200 ! vaapipostproc ! vaapih264enc ! filesink location=~/wsl_test.h264 2. Requires mesa 22.2 + H264 VAEntrypointVLD. Decode wsl_test.h264 using the GPU with VAAPI and encode using H264 software encoder. gst-launch-1.0 -v -m filesrc location=~/wsl_test.h264 ! h264parse ! vaapih264dec ! x264enc qp-max=5 tune=zerolatency ! filesink location=~/x264enc_output.h264 3. Requires mesa 22.2 + H264 VAEntrypointVLD + VAEntrypointEncSlice. Decode wsl_test.h264 using the GPU with VAAPI and encode using the GPU VAAPI encoder. gst-launch-1.0 -v -m filesrc location=~/wsl_test.h264 ! h264parse ! vaapih264dec ! vaapih264enc ! filesink location=~/va264enc_output.h264 4. Requires mesa 22.2 + H264 VAEntrypointVLD + VAEntrypointEncSlice + VaQueryVideoProcPipelineCaps supporting scale + rotation. Decode wsl_test.h264 using the GPU with VAAPI, scale, rotate and encode using the GPU VAAPI encoder. gst-launch-1.0 -v -m filesrc location=~/wsl_test.h264 ! h264parse ! vaapih264dec ! vaapipostproc width=800 height=600 video-direction=180 ! vaapih264enc ! filesink location=~/va264enc_proc_output.h264 5. Requires mesa 22.3 + H264 VAEntrypointVLD + HEVC VAEntrypointEncSlice + VaQueryVideoProcPipelineCaps supporting scale. Decode wsl_test.h264 using the H264 GPU decoder, scale it using the GPU video processor, and re-encode it using the H265 GPU encoder. ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_device /dev/dri/card0 -i ~/wsl_test.h264 -vf 'scale_vaapi=w=640:h=480' -c:v hevc_vaapi ~/scaled_output.h265 6. Requires mesa 22.3 + HEVC VAEntrypointVLD. Given an H265 file, play it in window using the GPU decoder. gst-launch-1.0 -vf filesrc location=~/scaled_output.h265 ! h265parse ! vaapih265dec ! autovideosink 7. Transcode wsl_test.h264 using only the CPU. This sample is intended for comparison with the next one which uses GPU acceleration. ffmpeg -i ~/wsl_test.h264 -c:v h264 ~/output_sw.h264 8. Requires mesa 22.2 + H264 VAEntrypointVLD + H264 VAEntrypointEncSlice. Transcode wsl_test.h264 using only the GPU. ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_device /dev/dri/renderD128 -i ~/wsl_test.h264 -c:v h264_vaapi ~/output_hw.h264 Here you can find the related command line documentation for ffmpeg and gstreamer plugins used in the command lines for further reference. Hardware platforms support Please see below the list of hardware platforms that currently have support for Video acceleration in WSLg. Vendor Supported platforms Minimum video driver version Radeon RX 5000 series or greater Adrenalin 23.3.1 AMD Ryzen 4000 series or greater ETA March 2023 11th Gen Intel(r) Core(tm) processor family (Codename Tiger Lake, Rocket Lake) 12th Gen Intel(r) Core(tm) processor family (Codename Alder Lake) Intel 13th Gen Intel(r) Core(tm) processor family (Codename Raptor Lake) 31.0.101.4032 Intel(r) Iris(r) Xe Dedicated Graphics family (Codename DG1) Intel(r) Arc(r) Graphics family (Codename Alchemist) GeForce GTX 10 Series and newer GeForce RTX 20 Series and newer NVIDIA 526.47 Quadro RTX NVIDIA RTX [png] Sil Vilerino Senior Software Engineer, DirectX Follow Posted in Command Line Windows Subsystem for Linux (WSL) Read next Windows Terminal Preview 1.17 Release The Windows Terminal team is back with our first release of the year! This release introduces version 1.17 to Windows Terminal Preview and updates Windows Terminal ... [png]Christopher Nguyen January 24, 2023 6 comments Windows Package Manager 1.4 The Windows Package Manager team has been busy working on WinGet 1.4. This release introduces support for .zip-based packages. WinGet can now extract and run an installer... [png]Demitrius Nelon January 23, 2023 4 comments 0 comments Leave a commentCancel reply Log in to join the discussion. Topics AccessibilityAF_UNIXANSI/VT Sequencesautomountbackground tasksBash BASICBuffersBuildBuild2017Build2019Build2020Build2021chmodChocolatey cmdColorCommand-LineConPTYConsolecontainersCreators Updatedaemons DrvFsDvfFsEncodingfilesystemfontifconfiginotifyinteropLinuxLinuxTools metadataMS-DOSMSBuildnetworkingOpen-SourceOpenSSHPowerShell PseduoConsolePseudo ConsolePTYreleaseRenderingsettingssocketsStore SyscallsTabs & SetsTeletypeTerminalThemesTmuxTTYUbuntuUnicodeUTF-8 VIntageVisual StudioWhat's NewWin10SWindowsWindows 10Windows 10 S Windows Package Managerwingetwinget.exewingetcreatewinuiWSLwslconf Zoom Top Bloggers [png] Kayla Cinnamon Program Manager II [png] Demitrius Nelon Senior Product Manager [png] Craig Loewen Program Manager II [png] lhecker [png] Sil Vilerino Senior Software Engineer Archive February 2023 January 2023 November 2022 October 2022 September 2022 August 2022 July 2022 June 2022 May 2022 March 2022 February 2022 December 2021 November 2021 October 2021 August 2021 July 2021 May 2021 April 2021 March 2021 January 2021 December 2020 November 2020 October 2020 September 2020 August 2020 July 2020 June 2020 May 2020 April 2020 March 2020 February 2020 January 2020 December 2019 November 2019 October 2019 September 2019 August 2019 July 2019 June 2019 May 2019 February 2019 December 2018 November 2018 October 2018 September 2018 August 2018 July 2018 June 2018 May 2018 April 2018 March 2018 February 2018 January 2018 December 2017 November 2017 October 2017 August 2017 July 2017 June 2017 May 2017 April 2017 February 2017 January 2017 November 2016 October 2016 September 2016 July 2016 June 2016 April 2016 March 2016 Stay informed Login Theme * light-theme-iconLight * dark-theme-iconDark Insert/edit link Close Enter the destination URL URL [ ] Link Text [ ] [ ] Open link in a new tab Or link to existing content Search [ ] No search term specified. Showing recent items. Search or use up and down arrow keys to select an item. Cancel [Add Link] Code Block x Paste your code snippet [ ] Cancel Ok Feedback usabilla icon What's new * Surface Pro 9 * Surface Laptop 5 * Surface Studio 2+ * Surface Laptop Go 2 * Surface Laptop Studio * Surface Go 3 * Microsoft 365 * Windows 11 apps Microsoft Store * Account profile * Download Center * Microsoft Store support * Returns * Order tracking * Virtual workshops and training * Microsoft Store Promise * Flexible Payments Education * Microsoft in education * Devices for education * Microsoft Teams for Education * Microsoft 365 Education * Education consultation appointment * Educator training and development * Deals for students and parents * Azure for students Business * Microsoft Cloud * Microsoft Security * Dynamics 365 * Microsoft 365 * Microsoft Power Platform * Microsoft Teams * Microsoft Industry * Small Business Developer & IT * Azure * Developer Center * Documentation * Microsoft Learn * Microsoft Tech Community * Azure Marketplace * AppSource * Visual Studio Company * Careers * About Microsoft * Company news * Privacy at Microsoft * Investors * Diversity and inclusion * Accessibility * Sustainability Your California Privacy Choices Your California Privacy Choices * Sitemap * Contact Microsoft * Privacy * Manage cookies * Terms of use * Trademarks * Safety & eco * Recycling * About our ads * (c) Microsoft 2023