Intel(R) Media Driver for VAAPI
repository·master·Indexed 22 days ago
https://github.com/intel/media-driverA user-mode driver for the Video Acceleration API (VA-API) enabling hardware-accelerated video decoding, encoding, and post-processing for Intel GEN-based graphics hardware. It supports a wide range of architectures from Broadwell (BDW) to Nova Lake (NVL). The project includes the cmrtlib runtime for executing custom GPU kernels and provides both Full Feature and Free Kernel build options.
What's inside intel-media-driver
- The Intel(R) Media Driver for VAAPI is a user-mode driver for the Video Acceleration API (VA-API). It provides hardware-accelerated decoding, encoding, and video post-processing for GEN-based Intel graphics hardware.
Overview of Intel(R) C for Metal Runtime (cmrtlib)
masterThecmrtliblibrary is a runtime used to execute custom GPU kernels on the render engine. It acts as an intermediary that calls theiHDmedia driver to load kernels and allocate necessary resources. It provides a direct set of APIs for applications to interact with the GPU hardware for custom compute tasks.Accelerate CPU<->GPU surface sharing with Media Copy
masterTo improve performance during interactions between CPU and GPU memory, the driver supports Media Copy. This feature uses GPU hardware engines or GPU kernels to accelerate copying surfaces to and from CPU-accessible locations.
Requirements and Constraints:
- Platform Support: Supported on ATSM/Meteor Lake (MTL) and newer platforms.
- Memory Alignment: The CPU start address must be 4k aligned. Refer to
drm_i915_gem_userptrfor details on user pointer requirements. - Supported Formats: Includes
Nv12,p010,p016,ARGB,yuy2,y210,y216,AYUV,y410, andARGB10. - Supported Resolutions: Supports common resolutions including 8K, 4K, 2K, 1080p, 720p, 480p, and 320P.
For implementation details, use the
vaCopyAPI.Choose between Full Feature Build and Free Kernel Build
masterThe media driver is available in two distinct build types:
- Full Feature Build (Default): Supports all features using hardware accelerators and closed-source shaders (
media kernelbinaries). This is the build used by most OSVs like RHEL, SUSE, and Fedora. - Free Kernel Build: Uses fully open-source shaders (
media kernels) and hardware features, but some features may be limited.
Ubuntu/Debian Users:
- For the Full feature build, install
intel-media-va-driver-non-free. - For the Free kernel build, install
intel-media-va-driver.
- Full Feature Build (Default): Supports all features using hardware accelerators and closed-source shaders (
Understand Media Driver API stability and compatibility
masterAPI Stability
- Stable Interface: API options are considered a stable interface.
- Unstable Interface: Debug parameters, environmental variables, and internal data structures are not considered a stable interface and may be changed or removed without notice.
Hardware Compatibility
- The driver maintains strict backward compatibility; no code changes should regress support for currently supported hardware.
- Any deliberate removal of hardware support will be communicated in the release notes.
Understand the components of the Intel(R) Media Driver
masterThe Intel(R) Media Driver for VAAPI consists of three primary functional components:
- Video decoding: Utilizes the hardware-based decoder (
VDBox) to provide fully-accelerated hardware video decoding, offloading the graphics engine. - Video encoding: Supports two modes selectable via VA-API:
- Low power encoding using the hardware-based encoder (
VDEnc/Huc). - Hardware (
PAK) + shader (media kernel+VME) based encoding.
- Low power encoding using the hardware-based encoder (
- Video processing: Combines hardware-based video processor (
VEBox/SFC) and shader (media kernel) based solutions to support various video processing features.
- Video decoding: Utilizes the hardware-based decoder (
Configure Media Driver build types
masterThe Media Driver can be built with different kernel feature sets. Use the following build configuration options to select your desired build type:
- Full Feature Build: Includes all kernels (default).
ENABLE_KERNELS=ONENABLE_NONFREE_KERNELS=ON
- Free Kernel Build: Uses only open-source kernels.
ENABLE_KERNELS=ONENABLE_NONFREE_KERNELS=OFF
When performing a Free Kernel Build, you can further control how kernels are handled:
- To use pre-built open source kernel binaries: Set
BUILD_KERNELS=OFF(default). - To rebuild open source kernels from source code: Set
BUILD_KERNELS=ON.
To enable support for DG1/SG1 or ATSM platforms (which require a special i915 kernel mode driver), you must set:
ENABLE_PRODUCTION_KMD=ON(Note: this isOFFby default).
- Full Feature Build: Includes all kernels (default).
Generate kernel source files igvpkrn_g11_icllp.c and igvpkrn_g11_icllp.h
masterOnce the dependencies are built, you can generate the kernel assembly code into C and header files using the
build.pyscript.Prerequisites
Ensure you have organized your tools in the following structure within the kernel directory:
- Kernel Directory:
./agnostic/gen11_icllp/vp/kernel compile/folder: Must contain the binariesGenKrnBin,KernelBinToSource, andKrnToHex_IGA.compile/IGA/folder: Must contain theiga64binary.
Execution
Navigate to
./agnostic/gen11_icllp/vp/kerneland run thebuild.pyscript.- Kernel Directory:
Collect and parse GPU performance data with UMD Perf Profiler
masterTo profile media task performance (timing, FPS, and engine concurrency), follow these steps:
- Build and install the latest internal-release version of the driver.
- Configure the driver by copying the feature file to
/etc/(see Configure the UMD Perf Profiler via igfx_user_feature). - Run your test case. Upon completion, a binary file (e.g.,
linux_perf_out.bin) will be created in your working directory. - Parse the results using the
MediaPerfParsertool to generate performance reports.
Install dependencies for building the Intel(R) Media Driver
masterTo build the driver on Ubuntu 16.04 or newer, you must first install the required system dependencies using
apt.apt install autoconf libtool libdrm-dev xorg xorg-dev openbox libx11-dev libgl1-mesa-glxBuild the DS and HME Kernel toolchain
masterTo compile and convert DS (Deep Learning Super Sampling) and HME (Hardware Media Engine) kernels, you must first build the required compiler toolchain components:
cmc(CM Compiler) andigc(Intel Graphics Compiler).- Build CM Compiler (cmc):
- Clone/download:
https://github.com/intel/cm-compiler - Follow the build instructions in the
cm-compilerrepository.
- Clone/download:
- Build Intel Graphics Compiler (igc):
- Clone/download:
https://github.com/intel/intel-graphics-compiler - Follow the build instructions in the
intel-graphics-compilerrepository.
- Clone/download:
- Build CM Compiler (cmc):
Build DS and HME Kernels
masterOnce the compilers are built, you can generate the kernel binaries using the provided build script. You must ensure the compiler paths are included in your
PATHenvironment variable before running the script.export PATH=$PATH:<cm_compiler_path>/include:<cm_compiler_path>/bin run build.py to generate kernel binary