{"id":8371,"date":"2023-02-13T09:55:34","date_gmt":"2023-02-13T17:55:34","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/commandline\/?p=8371"},"modified":"2023-02-14T06:20:01","modified_gmt":"2023-02-14T14:20:01","slug":"d3d12-gpu-video-acceleration-in-the-windows-subsystem-for-linux-now-available","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/commandline\/d3d12-gpu-video-acceleration-in-the-windows-subsystem-for-linux-now-available\/","title":{"rendered":"D3D12 GPU Video acceleration in the Windows Subsystem for Linux now available!"},"content":{"rendered":"<h2><span style=\"font-size: 36pt;\">Introduction<\/span><\/h2>\n<p>In <a href=\"https:\/\/devblogs.microsoft.com\/directx\/directx-heart-linux\/\">DirectX \u2764 Linux &#8211; DirectX Developer Blog<\/a> we wrote about DXCore &amp; D3D12 support on WSLg and described OpenGL &amp; OpenCL support by adding a D3D12 backend to <a href=\"https:\/\/mesa3d.org\/\">Mesa 3D<\/a>, allowing such 3D and compute workloads to be offloaded to the GPU. <figure id=\"attachment_8402\" aria-labelledby=\"figcaption_attachment_8402\" class=\"wp-caption alignright\" ><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2023\/02\/wsl_gst_animation.gif\" alt=\"Gstreamer playing an mp4 video in an X11 Windows in WSL using GPU acceleration.\" width=\"426\" height=\"240\" class=\"size-full wp-image-8402\" \/><figcaption id=\"figcaption_attachment_8402\" class=\"wp-caption-text\"><a href=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2023\/02\/wsl_gst_animation.gif\">3<\/a> Gstreamer playing an mp4 video in an X11 Windows in WSL using GPU acceleration.<\/figcaption><\/figure><\/p>\n<p>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 <a href=\"https:\/\/mesa3d.org\/\">Mesa 3D<\/a> D3D12 backend and integrating the <a href=\"https:\/\/github.com\/intel\/libva\">VAAPI<\/a> 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.<\/p>\n<p>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.<\/p>\n<p>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: <a href=\"https:\/\/devblogs.microsoft.com\/directx\/gpus-in-the-task-manager\/\">GPUs in the task manager &#8211; DirectX Developer Blog.<\/a><\/p>\n<h2><span style=\"font-size: 36pt;\">Scenarios<\/span><\/h2>\n<p>Customers can now run video workloads <span class=\"NormalTextRun SCXW35875754 BCX8\">such as <\/span><span class=\"NormalTextRun SCXW35875754 BCX8\">decode<\/span><span class=\"NormalTextRun SCXW35875754 BCX8\">, <\/span><span class=\"NormalTextRun SCXW35875754 BCX8\">encode<\/span><span class=\"NormalTextRun SCXW35875754 BCX8\"> and video processing i<\/span>n WSLg accelerated on the GPU with apps supporting VAAPI, for example: <a href=\"https:\/\/ffmpeg.org\/\">FFmpeg<\/a> or <a href=\"https:\/\/gstreamer.freedesktop.org\/\">GStreamer<\/a>. The following are the VA entrypoints and profiles implemented on top of D3D12.<\/p>\n<table style=\"width: 97.8609%; height: 477px;\" width=\"617\">\n<tbody>\n<tr style=\"height: 61px;\">\n<td style=\"height: 61px;\" width=\"269\">\n<h3>\n          Profile name\n        <\/h3>\n<\/td>\n<td style=\"height: 61px;\" width=\"282\">\n<h3>\n          Entrypoint name\n        <\/h3>\n<\/td>\n<td style=\"height: 61px;\" width=\"65\">\n<h3>\n          Mesa version required\n        <\/h3>\n<\/td>\n<\/tr>\n<tr style=\"height: 30px;\">\n<td style=\"height: 30px;\" width=\"269\">\n        <span style=\"font-size: 12pt;\">VAProfileH264ConstrainedBaseline<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"282\">\n        <span style=\"font-size: 12pt;\">VAEntrypointVLD<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"65\">\n        <span style=\"font-size: 12pt;\">22.2<\/span>\n      <\/td>\n<\/tr>\n<tr style=\"height: 30px;\">\n<td style=\"height: 30px;\" width=\"269\">\n        <span style=\"font-size: 12pt;\">VAProfileH264ConstrainedBaseline<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"282\">\n        <span style=\"font-size: 12pt;\">VAEntrypointEncSlice<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"65\">\n        <span style=\"font-size: 12pt;\">22.2<\/span>\n      <\/td>\n<\/tr>\n<tr style=\"height: 30px;\">\n<td style=\"height: 30px;\" width=\"269\">\n        <span style=\"font-size: 12pt;\">VAProfileH264Main<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"282\">\n        <span style=\"font-size: 12pt;\">VAEntrypointVLD<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"65\">\n        <span style=\"font-size: 12pt;\">22.2<\/span>\n      <\/td>\n<\/tr>\n<tr style=\"height: 30px;\">\n<td style=\"height: 30px;\" width=\"269\">\n        <span style=\"font-size: 12pt;\">VAProfileH264Main<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"282\">\n        <span style=\"font-size: 12pt;\">VAEntrypointEncSlice<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"65\">\n        <span style=\"font-size: 12pt;\">22.2<\/span>\n      <\/td>\n<\/tr>\n<tr style=\"height: 30px;\">\n<td style=\"height: 30px;\" width=\"269\">\n        <span style=\"font-size: 12pt;\">VAProfileH264High<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"282\">\n        <span style=\"font-size: 12pt;\">VAEntrypointVLD<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"65\">\n        <span style=\"font-size: 12pt;\">22.2<\/span>\n      <\/td>\n<\/tr>\n<tr style=\"height: 30px;\">\n<td style=\"height: 30px;\" width=\"269\">\n        <span style=\"font-size: 12pt;\">VAProfileH264High<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"282\">\n        <span style=\"font-size: 12pt;\">VAEntrypointEncSlice<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"65\">\n        <span style=\"font-size: 12pt;\">22.2<\/span>\n      <\/td>\n<\/tr>\n<tr style=\"height: 30px;\">\n<td style=\"height: 30px;\" width=\"269\">\n        <span style=\"font-size: 12pt;\">VAProfileHEVCMain<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"282\">\n        <span style=\"font-size: 12pt;\">VAEntrypointVLD<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"65\">\n        <span style=\"font-size: 12pt;\">22.3<\/span>\n      <\/td>\n<\/tr>\n<tr style=\"height: 30px;\">\n<td style=\"height: 30px;\" width=\"269\">\n        <span style=\"font-size: 12pt;\">VAProfileHEVCMain<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"282\">\n        <span style=\"font-size: 12pt;\">VAEntrypointEncSlice<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"65\">\n        <span style=\"font-size: 12pt;\">22.3<\/span>\n      <\/td>\n<\/tr>\n<tr style=\"height: 30px;\">\n<td style=\"height: 30px;\" width=\"269\">\n        <span style=\"font-size: 12pt;\">VAProfileHEVCMain10<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"282\">\n        <span style=\"font-size: 12pt;\">VAEntrypointVLD<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"65\">\n        <span style=\"font-size: 12pt;\">22.3<\/span>\n      <\/td>\n<\/tr>\n<tr style=\"height: 30px;\">\n<td style=\"height: 30px;\" width=\"269\">\n        <span style=\"font-size: 12pt;\">VAProfileHEVCMain10<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"282\">\n        <span style=\"font-size: 12pt;\">VAEntrypointEncSlice<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"65\">\n        <span style=\"font-size: 12pt;\">22.3<\/span>\n      <\/td>\n<\/tr>\n<tr style=\"height: 30px;\">\n<td style=\"height: 30px;\" width=\"269\">\n        <span style=\"font-size: 12pt;\">VAProfileVP9Profile0<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"282\">\n        <span style=\"font-size: 12pt;\">VAEntrypointVLD<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"65\">\n        <span style=\"font-size: 12pt;\">22.3<\/span>\n      <\/td>\n<\/tr>\n<tr style=\"height: 30px;\">\n<td style=\"height: 30px;\" width=\"269\">\n        <span style=\"font-size: 12pt;\">VAProfileVP9Profile2<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"282\">\n        <span style=\"font-size: 12pt;\">VAEntrypointVLD<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"65\">\n        <span style=\"font-size: 12pt;\">22.3<\/span>\n      <\/td>\n<\/tr>\n<tr style=\"height: 30px;\">\n<td style=\"height: 30px;\" width=\"269\">\n        <span style=\"font-size: 12pt;\">VAProfileAV1Profile0<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"282\">\n        <span style=\"font-size: 12pt;\">VAEntrypointVLD<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"65\">\n        <span style=\"font-size: 12pt;\">22.3<\/span>\n      <\/td>\n<\/tr>\n<tr style=\"height: 30px;\">\n<td style=\"height: 30px;\" width=\"269\">\n        <span style=\"font-size: 12pt;\">VAProfileNone<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"282\">\n        <span style=\"font-size: 12pt;\">VAEntrypointVideoProc<\/span>\n      <\/td>\n<td style=\"height: 30px;\" width=\"65\">\n        <span style=\"font-size: 12pt;\">22.2<\/span>\n      <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-size: 8pt;\"><em>This list is illustrative of a GPU and vendor driver supporting all possible entrypoints\/profiles using mesa 22.3. The actual capabilities reported in <\/em><a href=\"https:\/\/github.com\/intel\/libva\/blob\/6e86b4fb4dafa123b1e31821f61da88f10cfbe91\/va\/va.h#L1447\"><em>vaQueryConfigProfiles<\/em><\/a><em>, <\/em><a href=\"https:\/\/github.com\/intel\/libva\/blob\/6e86b4fb4dafa123b1e31821f61da88f10cfbe91\/va\/va.h#L1459\"><em>vaQueryConfigEntrypoints<\/em><\/a><em> , <\/em><a href=\"https:\/\/github.com\/intel\/libva\/blob\/6e86b4fb4dafa123b1e31821f61da88f10cfbe91\/va\/va.h#L1474\"><em>vaQueryConfigAttributes<\/em><\/a><em>, <\/em><a href=\"https:\/\/github.com\/intel\/libva\/blob\/6e86b4fb4dafa123b1e31821f61da88f10cfbe91\/va\/va_vpp.h#L1576\"><em>VaQueryVideoProcPipelineCaps<\/em><\/a><em> 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.<\/em><\/span><\/p>\n<h2><span style=\"font-size: 36pt;\">Installation<\/span><\/h2>\n<h2><span style=\"font-size: 24pt;\">Required components<\/span><\/h2>\n<ol>\n<li>Install <a href=\"https:\/\/apps.microsoft.com\/store\/detail\/windows-subsystem-for-linux\/9P9TQF7MRM4R?hl=en-us&amp;gl=us\">Windows Subsystem for Linux &#8211; Microsoft Store Apps<\/a> (version <a href=\"https:\/\/github.com\/microsoft\/WSL\/releases\/tag\/1.1.0\">1&#46;1.0<\/a> or newer)<\/li>\n<li>Install a distro like <a href=\"https:\/\/apps.microsoft.com\/store\/detail\/ubuntu-22041-lts\/9PN20MSR04DW\">Ubuntu 22.04.1 LTS &#8211; Microsoft Store Apps<\/a><\/li>\n<li>Enable <a href=\"https:\/\/devblogs.microsoft.com\/commandline\/systemd-support-is-now-available-in-wsl\/#set-the-systemd-flag-set-in-your-wsl-distro-settings\">systemd in WSL<\/a>.<\/li>\n<li>Follow the table in the hardware platforms support section and install a GPU driver from your vendor\u2019s website with a version higher or equal than specified.<\/li>\n<\/ol>\n<h2><span style=\"font-size: 24pt;\">About package manager repositories<\/span><\/h2>\n<p>The scenarios mentioned in this article are upstreamed to <a href=\"https:\/\/gitlab.freedesktop.org\/mesa\/mesa\">mesa\/main<\/a> and available in <a href=\"https:\/\/docs.mesa3d.org\/relnotes\/22.2.0.html\">mesa 22.2.0<\/a> and <a href=\"https:\/\/docs.mesa3d.org\/relnotes\/22.3.0.html\">mesa 22.3.0<\/a> stable releases. However, it takes time for the distros to refresh their package repositories to pick up new versions and when you install <strong>mesa-va-drivers<\/strong> you may get an older version until they\u2019re updated automatically after some time.<\/p>\n<p>For example, in distros with apt you can check the latest available version in the repositories with the commands:<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">sudo apt-get update\napt list mesa-va-drivers -a<\/code><\/pre>\n<p>If the available mesa version in your distro is older than the mesa version required for the profile\/entrypoint from the &#8220;Scenarios&#8221; section table you\u2019d like to try, there are a couple of different options you choose to follow, described below.<\/p>\n<h3>Option 1. Build mesa from source code<\/h3>\n<p>In this option, you will build and install mesa from the <a href=\"https:\/\/archive.mesa3d.org\/mesa-22.3.0.tar.xz\">mesa-22.3.0.tar.xz release<\/a> or newer. If you follow this route, you can skip installing the <strong>mesa-va-drivers<\/strong> package in the section &#8220;Setting up Video acceleration in WSLg&#8221;.<\/p>\n<ol>\n<li>Make sure to include the following meson configuration flags <\/li>\n<\/ol>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">-Dgallium-drivers=swrast,d3d12 -Dgallium-va=true -Dvideo-codecs=h264dec,h264enc,h265dec,h265enc,vc1dec<\/code><\/pre>\n<ol>\n<li>Build and install mesa<\/li>\n<li>Set the <strong>LIBVA_DRIVERS_PATH<\/strong> environment variable to the directory containing the custom built and installed <strong>d3d12_drv_video.so<\/strong>. You may want to add this in your <strong>~\/.bashrc<\/strong> file as it\u2019s necessary on every new WSL console session.<\/li>\n<li>Follow the instructions in the section &#8220;Setting up Video acceleration in WSLg&#8221;.<\/li>\n<\/ol>\n<h3>Option 2. Use a 3<sup>rd<\/sup> party repository for the mesa library packages<\/h3>\n<h4>Adding the 3<sup>rd<\/sup> party repository<\/h4>\n<p>In Ubuntu 22.04 and newer, you can add this 3<sup>rd<\/sup> party repository to make available <strong>the bleeding edge\/unstable daily mesa packages built from<\/strong> <a href=\"https:\/\/gitlab.freedesktop.org\/mesa\/mesa\">mesa\/main<\/a> with the following commands.<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">sudo add-apt-repository ppa:oibaf\/graphics-drivers\nsudo apt-get update && sudo apt-get upgrade<\/code><\/pre>\n<p><span style=\"font-size: 1rem;\">After adding the repository, follow the instructions in the section &#8220;Setting up Video acceleration in WSLg&#8221;.<\/span><\/p>\n<h4>Removing the 3<sup>rd<\/sup> party repository<\/h4>\n<p>In the case you added the <strong><em>ppa:oibaf<\/em><\/strong> repository and followed the setup steps in the section &#8220;Setting up Video acceleration in WSLg&#8221;, and now want <strong>to revert back to the previous state<\/strong>, please follow these steps.<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">sudo apt-get install ppa-purge\nsudo ppa-purge ppa:oibaf\/graphics-drivers\nsudo apt-get update && sudo apt-get upgrade<\/code><\/pre>\n<h2><span style=\"font-size: 24pt;\">Setting up Video acceleration in WSLg<\/span><\/h2>\n<p>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.<\/p>\n<p>1&#46;Make sure you have the latest updates installed<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">sudo apt-get update && sudo apt-get upgrade<\/code><\/pre>\n<p>2&#46; Install vainfo (and libva dependencies)<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">sudo apt-get install vainfo<\/code><\/pre>\n<p><em>3&#46; *Install mesa libraries *(skip this if built from mesa source code)<\/em><\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">sudo apt-get mesa-va-drivers<\/code><\/pre>\n<p>4&#46; Configure libva environment. You may want to add this in your <strong>~\/.bashrc<\/strong> file as it\u2019s necessary on every new WSL console session.<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">export LIBVA_DRIVER_NAME=d3d12<\/code><code class=\"language-default\" style=\"font-size: 14.4px;\"><\/code><\/pre>\n<p>5&#46; Enumerate libva capabilities for your current hardware<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">vainfo --display drm --device \/dev\/dri\/card0<\/code><\/pre>\n<p>The vainfo utility <strong>will indicate the libva and mesa<\/strong> <strong>versions<\/strong> <strong>installed<\/strong> and list the subset of entrypoints and profiles supported by your hardware, for example:<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">vainfo: VA-API version: 1.15 (libva 2.12.0)\nvainfo: Driver version: Mesa Gallium driver 22.2.1 for D3D12\nvainfo: Supported profile and entrypoints\nVAProfileH264ConstrainedBaseline: VAEntrypointVLD\nVAProfileH264ConstrainedBaseline: VAEntrypointEncSlice\nVAProfileH264Main\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : VAEntrypointVLD\nVAProfileH264Main\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : VAEntrypointEncSlice\nVAProfileH264High\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : VAEntrypointVLD\nVAProfileH264High\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : VAEntrypointEncSlice\nVAProfileNone\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : VAEntrypointVideoProc<\/code><\/pre>\n<p><span style=\"font-size: 8pt;\"><em>This list is illustrative of a GPU supporting only a subset of the implemented features on the indicated libva\/mesa versions.<\/em><\/span><\/p>\n<p>Adding the \u201c<strong>-a<\/strong>\u201d 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.<\/p>\n<h2><span style=\"font-size: 36pt;\">Examples using GPU Video acceleration<\/span><\/h2>\n<p><figure id=\"attachment_8406\" aria-labelledby=\"figcaption_attachment_8406\" class=\"wp-caption alignright\" ><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2023\/02\/Screenshot-2023-02-09-163918-300x250.png\" alt=\"Gstreamer in WSL performing GPU accelerated alpha blend composition and rendering into an X11 window\" width=\"300\" height=\"250\" class=\"size-medium wp-image-8406\" srcset=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2023\/02\/Screenshot-2023-02-09-163918-300x250.png 300w, https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2023\/02\/Screenshot-2023-02-09-163918.png 749w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><figcaption id=\"figcaption_attachment_8406\" class=\"wp-caption-text\">]<a href=\"https:\/\/devblogs.microsoft.com\/commandline\/wp-content\/uploads\/sites\/33\/2023\/02\/Screenshot-2023-02-09-163918.png\">16<\/a> Gstreamer in WSL performing GPU accelerated alpha blend composition and rendering into an X11 window<\/figcaption><\/figure><\/p>\n<p>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.<\/p>\n<p>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.<\/p>\n<p>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.<\/p>\n<h3><span style=\"font-size: 24pt;\">Install ffmpeg and gstreamer<\/span><\/h3>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">sudo apt-get install ffmpeg\nsudo apt-get install gstreamer1.0-plugins-bad gstreamer1.0-tools gstreamer1.0-vaapi<\/code><\/pre>\n<h3><span style=\"font-size: 24pt;\">Command line examples<\/span><\/h3>\n<p>1&#46;Requires mesa 22.2 + H264 VAEntrypointEncSlice. Generate 250 test frames and encode to an H.264 file using the GPU with VAAPI.<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">gst-launch-1.0 -v videotestsrc num-buffers=250 ! video\/x-raw,width=1920,height=1200 ! vaapipostproc ! vaapih264enc ! filesink location=~\/wsl_test.h264<\/code><\/pre>\n<p>2&#46; Requires mesa 22.2 + H264 VAEntrypointVLD. Decode wsl_test.h264 using the GPU with VAAPI and encode using H264 software encoder.<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">gst-launch-1.0 -v -m filesrc location=~\/wsl_test.h264 ! h264parse ! vaapih264dec ! x264enc qp-max=5 tune=zerolatency ! filesink location=~\/x264enc_output.h264<\/code><\/pre>\n<p>3&#46; Requires mesa 22.2 + H264 VAEntrypointVLD + VAEntrypointEncSlice. Decode wsl_test.h264 using the GPU with VAAPI and encode using the GPU VAAPI encoder.<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">gst-launch-1.0 -v -m filesrc location=~\/wsl_test.h264 ! h264parse ! vaapih264dec ! vaapih264enc ! filesink location=~\/va264enc_output.h264<\/code><\/pre>\n<p>4&#46; Requires mesa 22.2 + H264 VAEntrypointVLD + VAEntrypointEncSlice + <a href=\"https:\/\/github.com\/intel\/libva\/blob\/6e86b4fb4dafa123b1e31821f61da88f10cfbe91\/va\/va_vpp.h#L1576\">VaQueryVideoProcPipelineCaps<\/a> supporting scale + rotation. Decode wsl_test.h264 using the GPU with VAAPI, scale, rotate and encode using the GPU VAAPI encoder.<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">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<\/code><\/pre>\n<p>5&#46; Requires mesa 22.3 + H264 VAEntrypointVLD + HEVC VAEntrypointEncSlice + <a href=\"https:\/\/github.com\/intel\/libva\/blob\/6e86b4fb4dafa123b1e31821f61da88f10cfbe91\/va\/va_vpp.h#L1576\">VaQueryVideoProcPipelineCaps<\/a> 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.<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">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<\/code><\/pre>\n<p>6&#46; Requires mesa 22.3 + HEVC VAEntrypointVLD. Given an H265 file, play it in window using the GPU decoder.<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">gst-launch-1.0 -vf filesrc location=~\/scaled_output.h265 ! h265parse ! vaapih265dec ! autovideosink<\/code><\/pre>\n<p>7&#46; Transcode wsl_test.h264 using only the CPU. This sample is intended for comparison with the next one which uses GPU acceleration.<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">ffmpeg -i ~\/wsl_test.h264 -c:v h264 ~\/output_sw.h264<\/code><\/pre>\n<p>8&#46; Requires mesa 22.2 + H264 VAEntrypointVLD + H264 VAEntrypointEncSlice. Transcode wsl_test.h264 using only the GPU.<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_device \/dev\/dri\/card0 -i ~\/wsl_test.h264 -c:v h264_vaapi ~\/output_hw.h264<\/code><\/pre>\n<p>Here you can find the related command line documentation for <a href=\"https:\/\/ffmpeg.org\/ffmpeg.html\">ffmpeg<\/a> and <a href=\"https:\/\/gstreamer.freedesktop.org\/documentation\/plugins_doc.html?gi-language=c\">gstreamer plugins<\/a> used in the command lines for further reference.<\/p>\n<h2><span style=\"font-size: 36pt;\">Hardware platforms support<\/span><\/h2>\n<p>Please see below the list of hardware platforms that currently have support for Video acceleration in WSLg.<\/p>\n<table style=\"width: 98.0548%; height: 492px;\" width=\"660\">\n<tbody>\n<tr>\n<td width=\"62\">\n        Vendor\n      <\/td>\n<td width=\"429\">\n        Supported platforms\n      <\/td>\n<td width=\"168\">\n        Minimum video driver version\n      <\/td>\n<\/tr>\n<tr>\n<td width=\"62\">\n        AMD\n      <\/td>\n<td width=\"429\">\n<p>\n          Radeon RX 5000 series or greater\n        <\/p>\n<p>\n          Ryzen 4000 series or greater\n        <\/p>\n<\/td>\n<td width=\"168\">\n<p>\n          Adrenalin 23.3.1\n        <\/p>\n<p>\n          ETA March 2023\n        <\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"62\">\n        Intel\n      <\/td>\n<td width=\"429\">\n<p>\n          11th Gen Intel\u00ae Core\u2122 processor family (Codename Tiger Lake, Rocket Lake)\n        <\/p>\n<p>\n          12th Gen Intel\u00ae Core\u2122 processor family (Codename Alder Lake)\n        <\/p>\n<p>\n          13th Gen Intel\u00ae Core\u2122 processor family (Codename Raptor Lake)\n        <\/p>\n<p>\n          Intel\u00ae Iris\u00ae Xe Dedicated Graphics family (Codename DG1)\n        <\/p>\n<p>\n          Intel\u00ae Arc\u00ae Graphics family (Codename Alchemist)\n        <\/p>\n<\/td>\n<td width=\"168\">\n        31.0.101.4032\n      <\/td>\n<\/tr>\n<tr>\n<td width=\"62\">\n        NVIDIA\n      <\/td>\n<td width=\"429\">\n<p>\n          GeForce GTX 10 Series and newer\n        <\/p>\n<p>\n          GeForce RTX 20 Series and newer\n        <\/p>\n<p>\n          Quadro RTX\n        <\/p>\n<p>\n          NVIDIA RTX\n        <\/p>\n<\/td>\n<td width=\"168\">\n        526.47\n      <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u00a0<\/h2>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In DirectX \u2764 Linux &#8211; DirectX Developer Blog we wrote about DXCore &amp; D3D12 support on WSLg and described OpenGL &amp; 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 [&hellip;]<\/p>\n","protected":false},"author":70024,"featured_media":8406,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,9],"tags":[],"class_list":["post-8371","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-commandline","category-bash-on-ubuntu-on-windows"],"acf":[],"blog_post_summary":"<p>Introduction In DirectX \u2764 Linux &#8211; DirectX Developer Blog we wrote about DXCore &amp; D3D12 support on WSLg and described OpenGL &amp; 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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/posts\/8371","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/users\/70024"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/comments?post=8371"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/posts\/8371\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/media\/8406"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/media?parent=8371"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/categories?post=8371"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/commandline\/wp-json\/wp\/v2\/tags?post=8371"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}