Video acceleration API (VA-API) now available on Windows!
Originally developed by Intel, VAAPI (Video Acceleration API) is an open-source library and API specification, which provides access to graphics hardware acceleration capabilities for video processing. It consists of a main library and driver-specific acceleration backends for each supported hardware vendor. Apps can use it to access video hardware acceleration capabilities via its interface specification for workloads such as decode, encode, processing, etc. The libva library -an Intel implementation for VA-API- is used along with a VA-API driver, to which the video operations are delegated into from the libva library, and then implemented in the driver targeting the specific hardware platform the app is running on. This API is primarily used in Linux-based environments today and several well-known media applications utilize it to access GPU acceleration for diverse video operations.
What’s the benefit of VA-API on Windows?
Having VA-API on Windows enables developers to build video apps that work across platforms. This work continues our pattern of supporting a wide range of other APIs by layering them on top of the Direct3D 12 driver model (ie. OpenCL™ and OpenGL® Compatibility Pack) and having this layering makes it easier to port existing media applications such as FFmpeg or GStreamer, which can have their existing VA-API backends target libva-win32 and work across platforms and hardware vendors.
How does it work on Windows?
VA-API library and driver implementations
As described more in detail in D3D12 GPU Video acceleration in the Windows Subsystem for Linux now available! – Windows Command Line, we have recently added support for video hardware acceleration via VA-API in the Windows Subsystem for Linux with a VA-API driver implemented using the D3D12 Video APIs.
With the objective of layering a wide range of software on top of the Direct3D 12 driver model, to give developers and end users the full benefit of hardware acceleration, we worked on supporting this stack on Windows as well.
- Since libva 2.17 a new libva-win32 node was added to enable support on Windows platforms and provide VA-API acceleration from any chosen GPU adapter.
- Since Mesa 22.3 the same VA-API driver used in WSL can be compiled for Windows, and we named it VAOn12. Implemented on top of the D3D12 Video APIs, provides cross-hardware-vendor VA-API acceleration.
These two new components combined expose the same VA entry points and profiles as in WSL to applications that can now target both Windows and other existing VA-API platforms (ie. DRM, X11, etc).
The new vaGetDisplayWin32 function creates a VADisplay from an Adapter LUID pointer which can be NULL for adapter auto selection or can be used together with DXGI or DXCore APIs to enumerate and select the adapter which will perform the video acceleration.
- vaCreateSurfaces can import existing D3D12 resources into VASurface objects.
- vaExportSurfaceHandle can export an existing VASurface into a D3D12 resource.
- vaAcquireBufferHandle and vaReleaseBufferHandle have similar support.
Using the functions above on their D3D12 app, developers can now inter-operate between D3D12 and libva workloads in both directions. For example, a libva video decode/processing workload can feed exported surfaces to a D3D12 pipeline for further rendering to screen using a swapchain. Conversely, a D3D12 rendering pipeline can feed textures to be imported as VASurface’s and used for libva workloads such as processing/encode for video streaming.
How do I get it?
Both libva-win32 and the VaOn12 driver can be downloaded from NuGet Gallery | Microsoft.Direct3D.VideoAccelerationCompatibilityPack and can be used by configuring the environment variables:
LIBVA_DRIVERS_PATH=<path to folder containing vaon12_drv_video.dll>
A couple of new DirectX-Graphics-Samples: D3D12HelloVAEncode, D3D12HelloVADecode and D3D12HelloVAResourceInterop were written with the new nuget package, showing how D3D12-based applications can now be developed with interoperability between libva for video decode, encode and processing workloads and D3D12.
These samples will first check for support on your underlying hardware and then implement some scenarios for video operations between D3D12 and libva on platforms that support the underlying GPU Video capabilities, as well as how to present the contents of the rendered surfaces to screen. Also present in the samples you can find examples of how to enumerate and select adapters to use with vaGetDisplayWin32, importing of existing D3D12 resources into VASurfaces to be video decoded or processed and finally encoded into a compressed video bitstream.
Let us know what you think! Feel free to get in touch with us on our Discord server at discord.gg/directx.
OS/D3D12 requirements for using VAOn12 driver
For video decoding and processing, at least Windows 10 November 2019 Update or Windows 11 is required.
For video encoding, at least Windows 10 November 2019 Update with the usage of DirectX 12 Agility SDK 1.608.2+, or Windows 11 is required.
GPU hardware and driver requirements for using VAOn12 driver
The availability of the VA entrypoints, profiles, formats and other specific features exposed by the VAOn12 driver (vaon12_drv_video.dll) are directly tied to the capabilities reported by the underlying hardware and drivers via the D3D12 Video APIs. No additional requirements are introduced by the usage of VAOn12 respect to using the D3D12 Video APIs directly.
There are no additional OS, hardware nor driver requirements to using the libva runtime in your applications (va.dll and va_win32.dll)