Intel(R) Media Driver for VAAPI

repository·master·Indexed 22 days ago

https://github.com/intel/media-driver

A 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.

Tokens
12.5K
Snippets
13
Records
39
Agent score
78%

What's inside intel-media-driver

  1. Overview of Intel(R) Media Driver for VAAPI

    master
    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.
  2. Overview of Intel(R) C for Metal Runtime (cmrtlib)

    master
    The cmrtlib library is a runtime used to execute custom GPU kernels on the render engine. It acts as an intermediary that calls the iHD media 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.
  3. Accelerate CPU<->GPU surface sharing with Media Copy

    master

    To 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_userptr for details on user pointer requirements.
    • Supported Formats: Includes Nv12, p010, p016, ARGB, yuy2, y210, y216, AYUV, y410, and ARGB10.
    • Supported Resolutions: Supports common resolutions including 8K, 4K, 2K, 1080p, 720p, 480p, and 320P.

    For implementation details, use the vaCopy API.

  4. Choose between Full Feature Build and Free Kernel Build

    master

    The media driver is available in two distinct build types:

    • Full Feature Build (Default): Supports all features using hardware accelerators and closed-source shaders (media kernel binaries). 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.
  5. Understand Media Driver API stability and compatibility

    master

    API 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.
  6. Understand the components of the Intel(R) Media Driver

    master

    The 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.
    • Video processing: Combines hardware-based video processor (VEBox/SFC) and shader (media kernel) based solutions to support various video processing features.
  7. Configure Media Driver build types

    master

    The 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=ON
      • ENABLE_NONFREE_KERNELS=ON
    • Free Kernel Build: Uses only open-source kernels.
      • ENABLE_KERNELS=ON
      • ENABLE_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 is OFF by default).
  8. Generate kernel source files igvpkrn_g11_icllp.c and igvpkrn_g11_icllp.h

    master

    Once the dependencies are built, you can generate the kernel assembly code into C and header files using the build.py script.

    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 binaries GenKrnBin, KernelBinToSource, and KrnToHex_IGA.
    • compile/IGA/ folder: Must contain the iga64 binary.

    Execution

    Navigate to ./agnostic/gen11_icllp/vp/kernel and run the build.py script.

  9. Collect and parse GPU performance data with UMD Perf Profiler

    master

    To profile media task performance (timing, FPS, and engine concurrency), follow these steps:

    1. Build and install the latest internal-release version of the driver.
    2. Configure the driver by copying the feature file to /etc/ (see Configure the UMD Perf Profiler via igfx_user_feature).
    3. Run your test case. Upon completion, a binary file (e.g., linux_perf_out.bin) will be created in your working directory.
    4. Parse the results using the MediaPerfParser tool to generate performance reports.
  10. Install dependencies for building the Intel(R) Media Driver

    master

    To 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-glx
  11. Build the DS and HME Kernel toolchain

    master

    To 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) and igc (Intel Graphics Compiler).

    1. Build CM Compiler (cmc):
      • Clone/download: https://github.com/intel/cm-compiler
      • Follow the build instructions in the cm-compiler repository.
    2. Build Intel Graphics Compiler (igc):
      • Clone/download: https://github.com/intel/intel-graphics-compiler
      • Follow the build instructions in the intel-graphics-compiler repository.