Try to compile AMD mesa driver for VAAPI

It seems that ClearLinux doesn’t bring back H264/HEVC VAAPI hardware coding in AMD GPU mesa driver, after mesa removed them for patent issues. So I decided to recompile it to add these functionalities, and I found this PKGBULD on GitHub GitHub - archlinux/svntogit-packages at packages/mesa. Following its instructions, ignoring all warnings, and I finally get my VAAPI works. Frankly speaking, ClearLinux is a bad idea for AMD GPU (but a nice choice for AMD CPU).

ClearLinux’s original libva-mesa-driver:

❯ vainfo
Trying display: wayland
Trying display: x11
error: can't connect to X server!
Trying display: drm
libva info: VA-API version 1.17.0
libva info: Trying to open /usr/lib64/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_17
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.17 (libva 2.17.0)
vainfo: Driver version: Mesa Gallium driver 23.1.0-devel for AMD Radeon RX 6600 XT (navi23, LLVM 15.0.7, DRM 3.49, 6.2.1-1280.native)
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileVP9Profile0            :	VAEntrypointVLD
      VAProfileVP9Profile2            :	VAEntrypointVLD
      VAProfileAV1Profile0            :	VAEntrypointVLD
      VAProfileNone                   :	VAEntrypointVideoProc

My compiled one:

❯ vainfo
Trying display: wayland
Trying display: x11
error: can't connect to X server!
Trying display: drm
libva info: VA-API version 1.17.0
libva info: Trying to open /usr/lib64/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_17
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.17 (libva 2.17.0)
vainfo: Driver version: Mesa Gallium driver 23.0.0 for AMD Radeon RX 6600 XT (navi23, LLVM 15.0.7, DRM 3.49, 6.2.1-1280.native)
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointEncSlice
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileHEVCMain10             :	VAEntrypointEncSlice
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileVP9Profile0            :	VAEntrypointVLD
      VAProfileVP9Profile2            :	VAEntrypointVLD
      VAProfileAV1Profile0            :	VAEntrypointVLD
      VAProfileNone                   :	VAEntrypointVideoProc

Here I also share my compiled AMD drivers, in case someone may need them.

https://oss.ziyao.wang/usr/lib64/dri/radeonsi_drv_video.so

2 Likes

I have the exact same GPU as you. Did you install any extra dependencies beside what’s in Clear Linux software bundles? What do I have to replace to use compiled version?

I can get it to compile, but as soon as I copy radeonsi_drv_video.so from /usr/local/lib64/drv to /usr/lib64/drv Gnome crashes.

I hope someone can get it to work through 3rd party repos in the future.

I ssh into ClearLinux server without GUI, so I can’t tell you whether gnome has some video driver integrity checking.

Basically, I only replaced radeonsi_drv_video.so with the compiled version for VAAPI decoding/encoding in Jellyfin. No extra dependencies required as long as you can compile the driver.

BTW, it’s /usr/lib64/dri/

1 Like

In the event helpful, I did a mini-RPM build-like automation for building the NVDEC VA-API backend driver. The same can be done for radeonsi_drv_video.so if you like.

See the “requires” and “rpmbuild” folders. It obtains/installs small rpm packages instead of large bundles. I simply run “build-all” and “clean-all”. Or if you prefer, the scripts can be run individually. Note: Ensure inside the requires directory before running install-dependencies or uninstall-packages.

  1. cd requires; ./install-dependencies

  2. cd rpmbuild
    a. ./01-nv-codec-headers.build
    b. ./02-nvidia-vaapi-driver.build
    c. ./03-vdpau-va-driver-vp9.build

  3. cd requires; ./uninstall-packages

BTW, the HWAccel folder is beneficial for AMD graphics with regards to various browser applications. Though, I do not have AMD graphics to help test radeonsi_drv_video.so.

See HWAccel.

For NVIDIA graphics, there are two VA-API backend drivers. Though, the VDPAU no longer works in Chromium since 110 due to developers removing the --use-gl=desktop option. The VA-API drivers depend on nv-codec-headers. I install minimally just the things needed and not more. Then, clean up.

The other option is requesting the Clear Fraction 3rd-party developer for adding radeonsi_drv_video.so to the codecs bundle. You may need to do the initial work getting the RPM spec file created and tested.

Whatever you decide, you’ll be delighted once automated in some fashion so that others can easily build/install or choose the 3rd-party codecs bundle; providing FFmpeg, Mpv, yt-dlp, and one day the AMD VA-API backend driver.