You are not logged in.

#726 2023-01-15 03:11:19

vladpen
Member
Registered: 2023-01-14
Posts: 3

Re: chromium: hardware video acceleration with VA-API

@iamUndefined, уou can temporarily use Brave instead, it works for now.

Last edited by vladpen (2023-01-15 03:12:37)

Offline

#727 2023-01-15 05:43:03

shtirlic
Member
Registered: 2022-08-24
Posts: 12
Website

Re: chromium: hardware video acceleration with VA-API

Was using intel iHD vaapi on ice lake with Brave and enabled Vulkan until fresh update from 13-14 January, and it stopped worked  again, 
After hour of experiments this params now working:

brave --enable-features=VaapiVideoDecoder,VaapiVideoEncoder --disable-features=UseChromeOSDirectVideoDecoder --use-gl=egl 

And I see recent commit here https://bugs.chromium.org/p/chromium/is … 36697#c121

Guard VaapiVideoDecoder behind more correct flags

Vulkan on linux also needs the features kVulkanFromANGLE and
kDefaultANGLEVulkan to function properly.

Additinoally, Vaapi on GL needs to be guarded behind a flag.

Also in theDiff  see the new param like VaapiVideoDecodeLinuxGL

PS
Without using --use-gl=egl flag I get

Error: eglChooseConfig returned zero configs
    at Create (../../third_party/dawn/src/dawn/native/opengl/ContextEGL.cpp:53)

[69755:69755:0115/124619.716246:ERROR:gl_display.cc(508)] EGL Driver message (Error) eglCreateContext: Unknown attribute: 0x31b2X
Error: eglCreateContext failed with EGL_BAD_ATTRIBUTE
    at CheckEGL (../../third_party/dawn/src/dawn/native/opengl/UtilsEGL.cpp:71)
    at Create (../../third_party/dawn/src/dawn/native/opengl/ContextEGL.cpp:81)

[69755:69755:0115/124622.548687:ERROR:vaapi_wrapper.cc(2684)] vaPutSurface failed, VA error: invalid parameter
[69755:69755:0115/124622.548998:ERROR:vaapi_video_decode_accelerator.cc(286)] Failed putting surface into pixmap

Last edited by shtirlic (2023-01-15 05:49:51)


H: Thinkpad P14s Gen4 AMD 7840U, S: Wayland, KDE, UEFI SB

Offline

#728 2023-01-15 07:40:37

bsdice
Member
Registered: 2016-08-06
Posts: 14

Re: chromium: hardware video acceleration with VA-API

@shtirlic Your method works (nice digging!), but I get dropped frames in packs of four every couple of seconds on YT stats for nerds (right click into video).

Offline

#729 2023-01-16 03:00:47

shtirlic
Member
Registered: 2022-08-24
Posts: 12
Website

Re: chromium: hardware video acceleration with VA-API

bsdice wrote:

@shtirlic Your method works (nice digging!), but I get dropped frames in packs of four every couple of seconds on YT stats for nerds (right click into video).

I checked on my setup, it's ok, no dropped frames, using X11 BTW.


H: Thinkpad P14s Gen4 AMD 7840U, S: Wayland, KDE, UEFI SB

Offline

#730 2023-01-16 11:14:54

shtirlic
Member
Registered: 2022-08-24
Posts: 12
Website

Re: chromium: hardware video acceleration with VA-API

Update, since new chrome version and new params with it, HW video also possible with vulkan  with  options like that.

brave --enable-features=Vulkan,VulkanFromANGLE,DefaultANGLEVulkan 
Video Acceleration Information
Decoding
Decode h264 baseline
16x16 to 4096x4096 pixels
Decode h264 main
16x16 to 4096x4096 pixels
Decode h264 high
16x16 to 4096x4096 pixels
Decode vp8
16x16 to 4096x4096 pixels
Decode vp9 profile0
16x16 to 8192x8192 pixels
Decode vp9 profile2
16x16 to 8192x8192 pixels
Decode hevc main
16x16 to 8192x8192 pixels
Decode hevc main 10
16x16 to 8192x8192 pixels
Decode hevc main still-picture
16x16 to 8192x8192 pixels

Last edited by shtirlic (2023-01-16 11:16:18)


H: Thinkpad P14s Gen4 AMD 7840U, S: Wayland, KDE, UEFI SB

Offline

#731 2023-01-16 16:53:34

topcat01
Member
Registered: 2019-09-17
Posts: 133

Re: chromium: hardware video acceleration with VA-API

Nice! Is it actually working as indicated by say

intel_gpu_top

or equivalent?

Offline

#732 2023-01-16 21:17:31

adi222
Member
Registered: 2023-01-03
Posts: 11

Re: chromium: hardware video acceleration with VA-API

well that vulkan stuff works only in brave? i tried those flags in chrome or chromium and in both with vulkan enabled videos are software decoded on youtube, without enabled vulkan videos are hw decoded, verified in intel_gpu_top
Still running with old libva 2.16 but i know that's workaround and downgrading package isn't longterm solution, but i don't think there is another way atleast for now, libva 2.17 breaks hw decode even without vulkan

Last edited by adi222 (2023-01-16 21:18:11)

Offline

#733 2023-01-18 12:52:26

Zralle
Member
Registered: 2023-01-18
Posts: 3

Re: chromium: hardware video acceleration with VA-API

Is there a way to get hardware acceleration with VA-API on Brave on wayland (native)? What flags did you use to get it working?

Offline

#734 2023-01-18 13:05:09

shtirlic
Member
Registered: 2022-08-24
Posts: 12
Website

Re: chromium: hardware video acceleration with VA-API

topcat01 wrote:

Nice! Is it actually working as indicated by say

intel_gpu_top

or equivalent?

Yes, I am always checking with gpu_top video cores activity.


H: Thinkpad P14s Gen4 AMD 7840U, S: Wayland, KDE, UEFI SB

Offline

#735 2023-01-18 13:07:18

shtirlic
Member
Registered: 2022-08-24
Posts: 12
Website

Re: chromium: hardware video acceleration with VA-API

adi222 wrote:

well that vulkan stuff works only in brave? i tried those flags in chrome or chromium and in both with vulkan enabled videos are software decoded on youtube, without enabled vulkan videos are hw decoded, verified in intel_gpu_top
Still running with old libva 2.16 but i know that's workaround and downgrading package isn't longterm solution, but i don't think there is another way atleast for now, libva 2.17 breaks hw decode even without vulkan

Do you have any github issue link in github libva project? I don't see anything there right now, maybe it's only in chrome bugs?


H: Thinkpad P14s Gen4 AMD 7840U, S: Wayland, KDE, UEFI SB

Offline

#736 2023-01-18 13:20:22

akmt
Member
Registered: 2023-01-18
Posts: 2

Re: chromium: hardware video acceleration with VA-API

This commit will be the cause.

As a workaround, I disabled this commit and rebuilded libva package as follows.

curl -LO https://raw.githubusercontent.com/archl … k/PKGBUILD
sed -i -e '/arch-meson libva build/i  \ \ sed -i "s\/va_DRI3_Get\/va_DRI2_Get\/g" ./libva/va/x11/va_x11.c' PKGBUILD
makepkg -sc

After installing the rebuilded libva package, videos are hardware decoded.

Offline

#737 2023-01-18 13:25:11

shtirlic
Member
Registered: 2022-08-24
Posts: 12
Website

Re: chromium: hardware video acceleration with VA-API

akmt wrote:

This commit will be the cause.

As a workaround, I disabled this commit and rebuilded libva package as follows.

curl -LO https://raw.githubusercontent.com/archl … k/PKGBUILD
sed -i -e '/arch-meson libva build/i  \ \ sed -i "s\/va_DRI3_Get\/va_DRI2_Get\/g" ./libva/va/x11/va_x11.c' PKGBUILD
makepkg -sc

After installing the rebuilded libva package, videos are hardware decoded.

Wow, did you bisect to find out where it was broken? This commit looks innocent to me at first glance.

Last edited by shtirlic (2023-01-18 13:25:56)


H: Thinkpad P14s Gen4 AMD 7840U, S: Wayland, KDE, UEFI SB

Offline

#738 2023-01-18 13:41:36

akmt
Member
Registered: 2023-01-18
Posts: 2

Re: chromium: hardware video acceleration with VA-API

shtirlic wrote:

Wow, did you bisect to find out where it was broken? This commit looks innocent to me at first glance.

Yes.  I have tried to build the commits since 2.16.0 release.

Offline

#739 2023-01-18 22:33:38

gladykov
Member
Registered: 2022-12-10
Posts: 14

Re: chromium: hardware video acceleration with VA-API

Submitted bug here: https://github.com/intel/libva/issues/677
Please add any relevant info there, which would help solve it

Offline

#740 2023-01-20 23:09:06

bluestang
Member
Registered: 2023-01-20
Posts: 7

Re: chromium: hardware video acceleration with VA-API

Anyone with an AMD RDNA2 gpu getting the vaapi decoder to work successfully without disabling Vulkan and UseChromeOSDirectVideoDecoder features under XWayland?

I have an 6800XT and the only way I can get hw accel to work through Chrome is through the legacy VDAVideoDecoder w/ these flags:

google-chrome-unstable --use-gl=egl --enable-features=VaapiVideoDecoder,VaapiVideoEncoder --disable-features=Vulkan,UseChromeOSDirectVideoDecoder

If I try enabling Vulkan without EGL:

google-chrome-unstable --enable-features=Vulkan,VulkanFromANGLE,DefaultANGLEVulkan,VaapiVideoDecodeLinuxGL,VaapiVideoDecoder,VaapiVideoEncoder

I get the following errors:

[12225:12225:0120/155618.095536:ERROR:gbm_wrapper.cc(255)] Failed to export buffer to dma_buf: No such file or directory (2)
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
Warning: terminator_CreateInstance: Failed to CreateInstance in ICD 0.  Skipping ICD.
Error: eglChooseConfig returned zero configs
    at Create (../../third_party/dawn/src/dawn/native/opengl/ContextEGL.cpp:53)

With Vulkan & EGL enabled:

google-chrome-unstable --use-gl=egl --enable-features=Vulkan,VulkanFromANGLE,DefaultANGLEVulkan,VaapiVideoDecodeLinuxGL,VaapiVideoDecoder,VaapiVideoEncoder

These other errors pop up:

[12636:12636:0120/155708.559701:ERROR:gpu_init.cc(523)] Passthrough is not supported, GL is egl, ANGLE is
[12636:12636:0120/155708.560897:ERROR:gl_display.cc(503)] EGL Driver message (Error) eglQueryDeviceAttribEXT: eglQueryDeviceAttribEXT
[12636:12636:0120/155708.560943:ERROR:gl_angle_util_vulkan.cc(189)] Failed to retrieve vkGetInstanceProcAddr
[12636:12636:0120/155708.560982:ERROR:vulkan_instance.cc(91)] Failed to get vkGetInstanceProcAddr pointer from ANGLE.
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
Warning: terminator_CreateInstance: Failed to CreateInstance in ICD 0.  Skipping ICD.
ERR: Display.cpp:1014 (initialize): ANGLE Display::initialize error 12289: Could not make the initialization pbuffer current.
ERR: Display.cpp:1014 (initialize): ANGLE Display::initialize error 12289: Could not make the initialization pbuffer current.
Error: eglInitialize failed with EGL_NOT_INITIALIZED
    at CheckEGL (../../third_party/dawn/src/dawn/native/opengl/UtilsEGL.cpp:71)
    at Create (../../third_party/dawn/src/dawn/native/opengl/ContextEGL.cpp:38)

ERR: Display.cpp:1014 (initialize): ANGLE Display::initialize error 12289: Could not make the initialization pbuffer current.
ERR: Display.cpp:1014 (initialize): ANGLE Display::initialize error 12289: Could not make the initialization pbuffer current.
Error: eglInitialize failed with EGL_NOT_INITIALIZED
    at CheckEGL (../../third_party/dawn/src/dawn/native/opengl/UtilsEGL.cpp:71)
    at Create (../../third_party/dawn/src/dawn/native/opengl/ContextEGL.cpp:38)

And while the Vulkan & EGL flags do report Video Acceleration Information under chrome://gpu the VaapiVideoDecoder runs into the following error:

"VaapiVideoDecoder: failed Initialize()ing the frame pool"

And playback falls back to the software decoders - VpxVideoDecoder or Dav1dVideoDecoder.

The reason I am not satisified w/ the VDAVideoDecoder is because it can't do HEVC or AV1, so we I am stuck with VP9.

Offline

#741 2023-01-21 21:55:10

thubble
Member
Registered: 2023-01-21
Posts: 4

Re: chromium: hardware video acceleration with VA-API

The problem with AMD GPUs is that AMD drivers export video textures in a different format than Intel, and Chromium's VaapiVideoDecoder is designed around the assumptions of the Intel format. Specifically, VAAPI video textures are exported as 2 planes; Intel exports these planes in the same buffer object, while AMD exports 2 different buffer objects with one plane each. Most of Chromium's code is designed around assuming every texture has a single buffer object. This is where the "failed Initialize()ing the frame pool" error comes from.

I created a patch a while ago to get VaapiVideoDecoder working with AMD drivers. I posted it in the original Chromium bug for VaapiVideoDecoder on Linux, but didn't get any feedback. It's not ready to submit for merge anyway (a lot of "hack" comments), and I'm not really sure about signing the CLA, so I don't know if I'm even going to try to submit it.

It's worked for me consistently on several Chromium versions though, at least on my RX6800 (including AV1 acceleration), so if you want to try it, just apply this patch: https://gist.github.com/thubble/235806c … 173d24d9f/

Offline

#742 2023-01-22 00:57:35

gladykov
Member
Registered: 2022-12-10
Posts: 14

Re: chromium: hardware video acceleration with VA-API

New intel driver was released intel-media-driver 23.1.0 , which seems compatible with libva 2.17 , but it does not mean HW acc video works in Chromium. Can you please test it?

So far tested:

libva 2.16 and intel-media-driver-22.6.6

works together, no error in vainfo, HW acc video works with --use-gl=desktop

==========

libva 2.16 does not work with latest intel-media-driver 23.1.0-1

vainfo
libva error: /usr/lib/dri/iHD_drv_video.so has no function __vaDriverInit_1_0

==========

Libva 2.17 and intel-media-driver 23.1.0

vainfo

no error

with --use-gl=desktop - no hw acc video (Chromium 108)
with --use-gl=egl - video freezes, but hw acc video when using video poput (Opera feature)

Offline

#743 2023-01-22 10:21:06

adi222
Member
Registered: 2023-01-03
Posts: 11

Re: chromium: hardware video acceleration with VA-API

gladykov wrote:

New intel driver was released intel-media-driver 23.1.0 , which seems compatible with libva 2.17 , but it does not mean HW acc video works in Chromium. Can you please test it?

So far tested:

libva 2.16 and intel-media-driver-22.6.6

works together, no error in vainfo, HW acc video works with --use-gl=desktop

==========

libva 2.16 does not work with latest intel-media-driver 23.1.0-1

vainfo
libva error: /usr/lib/dri/iHD_drv_video.so has no function __vaDriverInit_1_0

==========

Libva 2.17 and intel-media-driver 23.1.0

vainfo

no error

with --use-gl=desktop - no hw acc video (Chromium 108)
with --use-gl=egl - video freezes, but hw acc video when using video poput (Opera feature)

with hacked libva 2.17(built against commit https://github.com/intel/libva/commit/e … d7c14dcc57) and intel-media-driver 23.1.0 vainfo doesn't have errors and hw acc in chrome works fine, check few comments before how to do this if ya don't know

Trying display: wayland
Trying display: x11
vainfo: VA-API version: 1.17 (libva 2.17.1)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 23.1.0 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileNone                   : VAEntrypointStats
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointFEI
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointFEI
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointFEI
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointFEI
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD

Last edited by adi222 (2023-01-22 10:28:31)

Offline

#744 2023-01-23 04:25:52

bluestang
Member
Registered: 2023-01-20
Posts: 7

Re: chromium: hardware video acceleration with VA-API

thubble wrote:

The problem with AMD GPUs is that AMD drivers export video textures in a different format than Intel, and Chromium's VaapiVideoDecoder is designed around the assumptions of the Intel format. Specifically, VAAPI video textures are exported as 2 planes; Intel exports these planes in the same buffer object, while AMD exports 2 different buffer objects with one plane each. Most of Chromium's code is designed around assuming every texture has a single buffer object. This is where the "failed Initialize()ing the frame pool" error comes from.

Thanks for the explanation. I wonder how FireFox handles this, since it's the only browser that works with AMD cards and the AV1 format?

I created a patch a while ago to get VaapiVideoDecoder working with AMD drivers. I posted it in the original Chromium bug for VaapiVideoDecoder on Linux, but didn't get any feedback. It's not ready to submit for merge anyway (a lot of "hack" comments), and I'm not really sure about signing the CLA, so I don't know if I'm even going to try to submit it.

You should try to submit it even though it has hacks in it right now. Reviewers should address the hacks and should provide inputs where needed. I doubt Chromium folks will address this problem because of their assumptions.

It's worked for me consistently on several Chromium versions though, at least on my RX6800 (including AV1 acceleration), so if you want to try it, just apply this patch: https://gist.github.com/thubble/235806c … 173d24d9f/

Thanks, I will give a try.

Offline

#745 2023-01-23 17:49:40

Inixi
Member
Registered: 2016-10-15
Posts: 54

Re: chromium: hardware video acceleration with VA-API

My current setup is:

amdgpu - Ryzen 4900HS
chromium-wayland-vaapi 109.0.5414.74-1
Type=wayland

Flags:

--enable-features=WebUIDarkMode,VaapiVideoEncoder,VaapiVideoDecoder,CanvasOopRasterization,RawDraw,WebRTCPipeWireCapturer,Vulkan,VulkanFromANGLE,DefaultANGLEVulkan
--enable-zero-copy
--use-gl=egl
--force-dark-mode
--enable-raw-draw
--enable-gpu-rasterization
--use-vulkan
--disable-sync-preferences
--disable-features=UseChromeOSDirectVideoDecoder
--ozone-platform-hint=auto
--ozone-platform=wayland
--enable-drdc

Hardware decoding mostly works (except AV1 which is expected on this GPU). But I have different problem - 360 videos on youtube give me black screen. When I change to `--use-gl=desktop` and comment out `--ozone-platform-hint=auto` and `--ozone-platform=wayland` 360 videos are working correctly, but I don't have HW accelerated videos. Also I think I need `--ozone-platform-hint=auto` and `--ozone-platform=wayland`  because without that on multidisplay setup without those flags Chromium becomes unstable...


2020 ASUS Zephyrus G14

Offline

#746 2023-01-24 20:43:59

Begemoth
Member
Registered: 2022-06-01
Posts: 4

Re: chromium: hardware video acceleration with VA-API

ungoogled-chromium-bin works well on my AMDGPU, all I need is --disable-features=UseChromeOSDirectVideoDecoder.
No matter wayland or xwayland.

But no big luck for intel iHD620. Brave and yandex works with --use-gl=egl --disable-features=UseChromeOSDirectVideoDecoder --enable-features=VaapiVideoDecoder, but video pauses after changing workspace in Gnome. ungoogled-chromium-bin with that flags eats a lot of power. What a shame: chromiums uses VideoEnhance feature, that drops intel GPU frequency a lot → drops power consumption. Why Firefox does not use it? sad

Offline

#747 2023-01-25 10:34:05

joshtau
Member
Registered: 2014-01-28
Posts: 10

Re: chromium: hardware video acceleration with VA-API

So, this has been a bit of a mess to get Hardware Acceleration working for videos through Chrome/Chromium, as it's confusing as the flags change between versions of Chrome, and some supported on Chromium, some supported on certain versions Chrome Stable, some supported on dev.. Plus, a lot are internal so they can change randomly.

So, here's what I did to get hardware acceleration working for videos with an AMD 5600XT (Navi10) AMDGPU..

The following versions were used, which are latest as of 25th January 2023:

Linux Kernel 6.1.8

Chromium 109.0.5414.74
Google Chrome 108.0.5359.124 
Google Chrome 111.0.5545.6 dev

Wayland:
wayland 1.21.0-2
wayland-protocols-git 1.31.r1.g37a7b9d-1
wayland-utils 1.1.0-1.1
xorg-xwayland 22.1.7-1.1

Desktop:
sway-git r7058.36f627d0-1

I use Sway, which is Wayland. However, this should also work with KDE/Gnome etc, and X11.

I am using mesa-git from https://github.com/Frogging-Family/mesa-git , but it shouldn't make a difference. I use this because I usually test and apply custom patches for mesa, and this makes it easier smile. If you use the mesa drivers from the main repository (i.e. NOT

mesa-git

), ensure you have followed the wiki. You do NOT need the prosperity drivers.

I've tested with both Chromium from the official repository AND compiling chromium-wayland-vaapi with and without the chromium patch for AMDGPU (thanks for that, it's awesome, <3!).

Hardware Accelerated Videos works out of the box right now with XWayland (or if you use X11, it'll "just work" for you"), however not with Wayland enabled.

Sidenote: I haven't updated yet to Chrome 109 because 109 has broken mouse scrolling with smooth scrolling off, and I haven't dug into why yet.

Anyway, here are the instructions:

1. Edit

/etc/libva.conf

, and edit it to be the following:

LIBVA_MESSAGING_LEVEL=2
LIBVA_TRACE=/tmp/libva
LIBVA_MESSAGING_LEVEL

by default is 1, which only shows info, 2 makes it also show errors. 0 shows nothing.

LIBVA_TRACE

means that it'll debug log to /tmp/libva.xxx, so you can see if it's actually working and if it's not, hopefully a hint to why.

2. Ensure you have the following environment setting in your /etc/environment:

LIBVA_DRIVER_NAME="radeonsi"

Probably want to add

VDPAU_DRIVER="radeonsi"

there as well.

3. Ensure you've run this patch to revert the breaking change to dri3, thanks akmt for the bisect!.

Option 1) Patch this yourself:

curl -LO https://raw.githubusercontent.com/archlinux/svntogit-packages/packages/libva/trunk/PKGBUILD
sed -i -e '/arch-meson libva build/i  \ \ sed -i "s\/va_DRI3_Get\/va_DRI2_Get\/g" ./libva/va/x11/va_x11.c' PKGBUILD
makepkg -si

Option 2) Download the patched version I have built (which is the above):
libva-2.17.0-1-x86_64.pkg.tar.zst
sha256sum: 97b4e615bee751e800b5dd140fa39a57fc84af94cef2fdf180d7b52a4e31776a

4. Reboot. You can probably relog, but I've had dramas with libva not setting the correct variables until reboot.

5. Ensure

vainfo

works. Here's my output (notice the LIBVA_TRACE message is now shown):

Trying display: wayland
libva info: Open new log file /tmp/libva.045614.thd-0x00001cde for the thread 0x00001cde
libva info: LIBVA_TRACE is on, save log into /tmp/libva.045614.thd-0x00001cde
libva info: VA-API version 1.17.0
libva info: User environment variable requested driver 'radeonsi'
libva info: Trying to open /usr/lib/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.1)
vainfo: Driver version: Mesa Gallium driver 23.1.0-devel for AMD Radeon RX 5600 XT (navi10, LLVM 15.0.7, DRM 3.49, 6.1.8-1-cachyos-cfs)
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
      VAProfileNone                   : VAEntrypointVideoProc

6. Let's make sure we're using a fresh Chromium profile. Close all chromium instances, then backup your config. Ensure you have all Chromium instances completely closed!

mv ~/.config/chromium ~/.config/chromium-backup

7. Now let's setup Chromium for testing, and ensure things work. First, open chromium by just running

chromium

in your terminal, and see if there are any errors/issues with just this. If there are not, you should be good to go.

Next, we're going to setup the "Media" tab in Developer Tools so we can see if Hardware Acceleration is actually working. Opening developer tools can be done a few ways:
7a.

F12

7b.

CTRL+SHIFT+I

7c. At the top right, where the ... button is, click that -> More Tools -> Developer Tools.

By default the media tab isn't shown, you need to click the three little dots in the bottom right corner, then click "More Tools" then click "Media". Then click the "Media" tab. Make sure this is still selected, as we want this this tab  to open everytime you launch chromium, saving you from having to do it manually.. something you might end doing a LOT.
How to enable media on Developer Tools]

You probably want to also dock the developer tools to the bottom of the screen (click the third little icon on the Dock Side, as per the image above), as it makes it a bit easier to use.

Now a great extension for privacy is "UBlock Origin". It also has the benefit of improving the experience of YouTube, as opening and closing many videos you might see something that isn't your video. Just sayin'.

Now try opening a YouTube video. A good test would be a video with many resolutions, and hopefully 60FPS. A good test video is https://www.youtube.com/watch?v=LXb3EKWsInQ , which is generic, has up to 4k 60FPS and has moving scenery to figure out if you're seeing tearing. Plus it's not Rick Roll! If the video plays normally, you should be able to keep testing for Hardware Acceleration.

Completely close Chromium, and ensure it's closed by checking the terminal window you opened. We're going to be using flags, and having existing instances open can interfere with testing.

8. Now we're going to launch Chromium with the bare flags to make VAAPI work, at least for what I could get with AMDGPU and XWayland (Sway).

chromium --use-gl=egl --disable-features=UseChromeOSDirectVideoDecoder "https://www.youtube.com/watch?v=LXb3EKWsInQ" --auto-open-devtools-for-tabs

The two flags I needed to make vaapi work with XWayland were:

--use-gl=egl

forces egl.

--use-gl=desktop

is for xorg.

--disable-features=UseChromeOSDirectVideoDecoder

I think there is a bug where it thinks it's running on ChromeOS? This fixes HWA for me 100% of the time.

Extra flags, but useful for testing:

--auto-open-devtools-for-tabs

Will show dev tools by default. As you've enabled the media tab, and hopefully had it as the last tab open, it will show this by default.

https://www.youtube.com/watch?v=LXb3EKWsInQ

YouTube video to test with (It's safe, it's a test that has up to 4k with 60fps, it's not Rick Roll I promise).

Now, you should be able to see that "Hardware decoder" is true under the currently playing video. Ignore the "Player title" tabs. The decoder should be

VDAVideoDecoder

.
Hardware Decoder

Going to

chrome://gpu

should show

Video Decode: Hardware accelerated

.
Hardware Decoder


You should also see

libva info: xxx

in your terminal where you launched chromium, with logs like this:

libva info: Open new log file /tmp/libva.052537.thd-0x0000652d for the thread 0x0000652d
libva info: LIBVA_TRACE is on, save log into /tmp/libva.052537.thd-0x0000652d
libva info: VA-API version 1.17.0
libva info: User environment variable requested driver 'radeonsi'
libva info: Trying to open /usr/lib/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_17
libva info: va_openDriver() returns 0
libva info: Save context 0x00000003 into log file /tmp/libva.052537.thd-0x0000652d
libva info: Save context 0x00000015 into log file /tmp/libva.052537.thd-0x0000652d
libva info: Open new log file /tmp/libva.052537.thd-0x000065f4 for the thread 0x000065f4
libva info: Save context 0x00000015 into log file /tmp/libva.052537.thd-0x0000652d

Those log files have debug info and also show if things are working. If working, these files should be multi megabyte sized, as the logs are quite big. I've only tested a few mins worth of video, and the size goes between 5-10mb. Once you're happy with libva, you can remove the LIBVA_TRACE and change LIBVA_MESSAGING_LEVEL back to

LIBVA_MESSAGING_LEVEL=1

in

/etc/libva.conf

and it won't log anymore. These files should have lines like

VAPictureParameterBufferVP9

.

However, this isn't running Chromium in Wayland! :-(

We can use https://archlinux.org/packages/extra/x86_64/xorg-xlsclients/ to verify which programs are running in Wayland.

$ xlsclients
chromium

So how do we make it work with Wayland?

We can use

--ozone-platform-hint=auto

!

However, with the default Chromium from the official ArchLinux repository this means that hardware decoding doesn't work with Wayland. I tried a bunch of flags, and just couldn't get this to work on Wayland.

There is however a fix for this as recommended by the ArchWiki, called chromium-wayland-vaapi, where you can compile Chromium with this fix, a package submitted by hedgepigdaniel and maintained by mars. Thanks so much <3.

However, there is still an issue with Wayland and AMDGPUs, with a fantastic analysis here on why it doesn't work is insightful.

Basically, to get this to work, I had to do the following:

1. Download and extract the snapshot from https://aur.archlinux.org/packages/chro … land-vaapi
2. Download the patch from thubble
3. Add the patch to the PKGBUILD

curl -LO https://aur.archlinux.org/cgit/aur.git/snapshot/chromium-wayland-vaapi.tar.gz
tar xvf chromium-wayland-vaapi.tar.gz
cd chromium-wayland-vaapi
curl -LO https://gist.githubusercontent.com/thubble/235806c4c64b159653de879173d24d9f/raw/b754e405d6d84d690741a06120802792693fc091/chromium-support-disjoint-vaapi-export-import.patch
sed -i -e "s/use-oauth2-client-switches-as-default.patch/use-oauth2-client-switches-as-default.patch\n        chromium-support-disjoint-vaapi-export-import.patch/g"s PKGBUILD
sed -i -e "s/'e393174d7695d0bafed69e868c5fbfecf07aa6969f3b64596d0bae8b067e1711'/'e393174d7695d0bafed69e868c5fbfecf07aa6969f3b64596d0bae8b067e1711'\n            'd2ca9f7619085855deda4a04a3ec6c4a5a5ded1db80cb5fb255683698deee421'/g" PKGBUILD

Now we can run

makepkg -si

to build chromium. This will take a while.

If you want to test without waiting, I have compiled it here:

chromium-wayland-vaapi-debug-109.0.5414.74-1-x86_64.pkg.tar.zst
https://mirror.joshtaylor.id.au/chromium-wayland-vaapi-109.0.5414.74-1-x86_64.pkg.tar.zst

sha256sum:

49fac7836c13430c9c226e0ce80d6a685f7360355d22435e1a8a7a0969444155  chromium-wayland-vaapi-109.0.5414.74-1-x86_64.pkg.tar.zst
6eb1d9fd416ec2aa3275968439df92c69418f7a6c7eea66eb7b460c057ff349f  chromium-wayland-vaapi-debug-109.0.5414.74-1-x86_64.pkg.tar.zst

(run

pacman -U chromium-wayland-vaapi-109.0.5414.74-1-x86_64.pkg.tar.zst

to install it).

Now you should be able to launch with the following settings, and see that Hardware Acceleration works:

chromium --use-gl=egl --disable-features=UseChromeOSDirectVideoDecoder --auto-open-devtools-for-tabs --ozone-platform-hint=auto "https://www.youtube.com/watch?v=LXb3EKWsInQ"

And you should be able to see that

xlsclients

doesn't show Chromium now!

Running this works great, and works with Wayland and Vulkan.



## Cleanup
1. Edit

/etc/libva.conf

, changing to the following:

LIBVA_MESSAGING_LEVEL=1

2. Close Chromium, and copy back your profile:

mv ~/.config/chromium ~/.config/chromium-testing
mv ~/.config/chromium-backup ~/.config/chromium

3. You can edit the

~/.config/chromium-flags.conf

file to have the flags you want, so you don't need to always open with these config settings. This file is one line per setting, so like this for Wayland:

--use-gl=egl
--disable-features=UseChromeOSDirectVideoDecoder
--ozone-platform-hint=auto

## Flags
Chrome/Chromium has a lot of flags. Most of them you probably don't need, so play with them as enable/disable them as you need. A lot can also be configured via

chrome://flags

, which also give you a summary of what it should do.

## Troubleshooting
[h3]Basic troubleshooting steps[/h3]
1. Check the wiki for Hardware Acceleration, and ensure you have the correct drivers. mesa-git should have everything you need.
2. Check

vainfo

is correct.
3. Double check you have the environment variables exported.
4. Check the libva log via

tail -f /tmp/libva.*

. Note new files won't be automatically tailed if running this.

[h3]Advanced troubleshooting steps[/h3]
[h4]Old references[/h4]
I had to remove old references to libva in my root /usr to get this to work. Note to backup first!

To check if you have libva references that are outside of what pacman installs, you can use the following shell script to find if there are any libva files not installed via pacman in your

/usr

:

find /usr | grep libva | LC_ALL=C pacman -Qqo - 2>&1 >&- >/dev/null | cut -d ' ' -f 5-

with thanks to the ArchWiki)

[h4]Default files[/h4]
By default, the patched libva 2.17 will add the following files (sha256sum is from my zst above):

7e99b19bb83a4e7908cbc02c7d4354e0e1bf86f5ff2538df607ad01ad616d5f3  ./.BUILDINFO
0dcffaeb151aede10a0120900c1e38528f0f9116b6f47bcc5dcce8041eece230  ./.MTREE
75d8fd3ab5d1a50523fa207d36c4622599a7ab324945b31fd7b3bfef20e393c3  ./.PKGINFO
8725754a727fc0572872b0ff7256ff8679c6349f972cef3f517068e5ab0afdbb  ./etc/libva.conf
10489527809c4457ebf8d973c9201d47945e7c725f0f048f3afd596227b85e89  ./usr/include/va/va.h
bbbb7ac7a32019a6173b58b0c46800f1973005e2a80c6ed1f3762d88dbe323b7  ./usr/include/va/va_backend.h
f783f4f23450d9b8f4e1a3b126a6c98e1bc412dd7dfcce142958f6ab0b3a6706  ./usr/include/va/va_backend_glx.h
8d7ae3ced06c471dda1da0659a1e8cc36dbada4a74e91b4ebc30f543d98191bd  ./usr/include/va/va_backend_prot.h
c2abf2b69e82bc5b267a5937b0c9274acb3f0c46a11ef0a935ecd01e78b18f56  ./usr/include/va/va_backend_vpp.h
6f25642892e12f63b64312c7b340f635be3857d0ef0c26ba779a7f9e2cf8aafb  ./usr/include/va/va_backend_wayland.h
b3ae37a62e910f32b4ce43ace596e0a280e8aa60c9426e24c17e29c1d8c24197  ./usr/include/va/va_compat.h
fba81be5acc10046c25e5b5cef9fe97d98ecf7d441b9bdc214e7451d84a1a1e4  ./usr/include/va/va_dec_av1.h
3d8d3b6d1f4ec9ca055769579164352cded8987dfc7c9c5339af88fced45a6f3  ./usr/include/va/va_dec_hevc.h
0849e5a5dc867dfc6724ae3234d4f553fb6cf87623bc70810d204172c246dcae  ./usr/include/va/va_dec_jpeg.h
8bce249838e87735ff725c14e77953efb8e3e99baf80063454a9cb4230096859  ./usr/include/va/va_dec_vp8.h
7e66bb433e6f4a50753fdcb2da937ed20426f87901b2c78ee8b8baf827786f3d  ./usr/include/va/va_dec_vp9.h
7dcd333f073827883b60a71f2084b4bb77a509de69acf98f3808a1cc90980e19  ./usr/include/va/va_dri2.h
fe460e776996649ee62577c4930041bea6abd388d544100f731ae0f7f4043563  ./usr/include/va/va_dricommon.h
73cf45f9fa2c36454378cbf92607d3205dcfa8747ce4578a85ee1b40954c7698  ./usr/include/va/va_drm.h
08d15e601bb39ca1161b2a0a12d3edb370b1413cf3c395cad1b091c910b53954  ./usr/include/va/va_drmcommon.h
9aca64c0c139355da196b58d50fe6ab6d7850286fdf0381cf0b51ab1a994357b  ./usr/include/va/va_egl.h
c4434a187a60985667454fd493183427014b220b78f8041aea3be30cad29a7e3  ./usr/include/va/va_enc_av1.h
2474cc028a8e77d17cb46c825c1688f749ce09f4bf18efc15aae7e77045814e5  ./usr/include/va/va_enc_h264.h
2264e100efce0246c27eca53fad5298d9f744465e0fb7168b6b62f38a7e345af  ./usr/include/va/va_enc_hevc.h
5e864e285352bffa2a9de26d61064f501af0bdce984ee7fa616a119eeccec7c3  ./usr/include/va/va_enc_jpeg.h
4aebd65137ef7089560bf82a68a15a7a2530fce1f0eae185a0f219539e5b246f  ./usr/include/va/va_enc_mpeg2.h
020fb8f4891875b8226e606537d20ce143e6151bccfc8f827bad8cadba4778cd  ./usr/include/va/va_enc_vp8.h
493bda53db163ca8e48391b4f60cd9c1162e6b4f033748de5a0c8f94920eb7ec  ./usr/include/va/va_enc_vp9.h
0b28d6e5a50035e1e58d76082512f530c6989b1035cdda39a62cfc3fe045601b  ./usr/include/va/va_fei.h
928c2d075056236335368b78b4e6e3eb3f443cf966b651f02b5f7132976bce55  ./usr/include/va/va_fei_h264.h
1796a2884b01c4dcedd3f91388c1af7bd0c5abf126d97076938b3ec4d55efa11  ./usr/include/va/va_fei_hevc.h
8e357a428039379347e13f158a9d186fb99f8494b10fdfdf610719ae7b748805  ./usr/include/va/va_glx.h
032428ed1fc5013ac53f41916b8c9926101c2fb273a69bdd951a97b8f77af177  ./usr/include/va/va_prot.h
9d2f5b9ea4f41da38cbe9575bef1f59deb920d7f6736a0843f7e712d20cbf058  ./usr/include/va/va_str.h
94d6b6393530277baae52e06323f30a582a5cb068bdfa5f1a0ae6c5c215f9b29  ./usr/include/va/va_tpi.h
d1c9124f51c2fc7735edb73c89c932a24122beaaca41b54f43eb293ff57347c0  ./usr/include/va/va_version.h
739c6182aded885dde3774b58b7cba408f615d95bf29650819776a5f1aa139a4  ./usr/include/va/va_vpp.h
a055b197a0803993063d84e4383f5bb8f9593753301c953210212f06ff9383a2  ./usr/include/va/va_wayland.h
b8a6dac505ef5fa8772308ba51c7956b2813cbaa244c68379f4e880b80379de5  ./usr/include/va/va_x11.h
2f7628761cc74678af479c9ae1a6e7303dd75c0adcdc4d0b048f3783097027ea  ./usr/lib/libva-drm.so.2.1700.0
dac42404930b8c35d3caaaf5ad3f0f9e22dc752a70a35346989d3eb874a4778a  ./usr/lib/libva-glx.so.2.1700.0
8213857b0ee759ef33579b284303142b272be7a4cc82301f57354c99cdf4a8ef  ./usr/lib/libva-wayland.so.2.1700.0
419ebf40d2218ca173ec042c155d18a931cb61c24bcdc753e025957dd6d44436  ./usr/lib/libva-x11.so.2.1700.0
24adb819b513436e2e0dd0216b92894078380c2a6bf74c3ae544695d4ca55c62  ./usr/lib/libva.so.2.1700.0
0a1d9cc414b456f2e6118198f25af3ede48706660c241a68e64eb6fc17415f04  ./usr/lib/pkgconfig/libva-drm.pc
1b59d9a5cfacf4b7b8999e4c3bab791e2c17a46b1e374cdeb596efd8725688ef  ./usr/lib/pkgconfig/libva-glx.pc
9104e84de9a583a3eb9f4cbd9957a750364b0f3c7fe76743812a8fead1c49b2b  ./usr/lib/pkgconfig/libva-wayland.pc
cbdf73962d0bc9c556f565adb6882da40b6be5c09024eed534a27b1fde6c02c7  ./usr/lib/pkgconfig/libva-x11.pc
b3c6cea91f96ef3d27ebd964efc9e15b7dc9735a6c394ae4a0d59b4ec78a8a97  ./usr/lib/pkgconfig/libva.pc
c86a782ee845b52472dae9b9d79fb915d333628ac0efe49cdce63644814931de  ./usr/share/licenses/libva/COPYING

6. Chromium has a debugging feature you can use, add the following to the end of your chromium flags:

--enable-logging=stderr --v=1 > ~/full_log.txt 2>&1

This will enable debug logging, and log to a file called "full_log.txt" in your home directory. Change the location if needed.

Last edited by joshtau (2023-01-25 10:38:31)

Offline

#748 2023-01-26 16:06:37

salvaju29ro
Member
Registered: 2023-01-26
Posts: 5

Re: chromium: hardware video acceleration with VA-API

Does anyone know why in my lasts Chromium builds, acceleration seems to be active even without adding any flags?

cat /home/salvatore/.config/chromium-flags.conf

--enable-features=WebUIDarkMode
--force-dark-mode
--disable-smooth-scrolling
--force-device-scale-factor=1.2

Graphics Feature Status

Canvas: Hardware accelerated
Canvas out-of-process rasterization: Disabled
Direct Rendering Display Compositor: Disabled
Compositing: Hardware accelerated
Multiple Raster Threads: Enabled
OpenGL: Enabled
Rasterization: Hardware accelerated
Raw Draw: Disabled
Video Decode: Hardware accelerated
Video Encode: Software only. Hardware acceleration disabled
Vulkan: Disabled
WebGL: Hardware accelerated
WebGL2: Hardware accelerated
WebGPU: Disabled

System info:

Operating System: ArchLinux
KDE Plasma Version: 5.26.5
KDE Frameworks Version: 5.102.0
Qt Version: 5.15.8
Kernel Version: 6.1.7-arch1-1 (64-bit)
Graphics Platform: X11
Processors: 12 × AMD Ryzen 5 5600G with Radeon Graphics
Graphics Processor: AMD Radeon Graphics

Last edited by salvaju29ro (2023-01-26 16:07:13)

Offline

#749 2023-01-28 10:08:35

shtirlic
Member
Registered: 2022-08-24
Posts: 12
Website

Re: chromium: hardware video acceleration with VA-API

Some new commits for this topic, Issue 1399897: Vaapi On GL (don't rely on vulkan) https://bugs.chromium.org/p/chromium/is … 1399897#c5


H: Thinkpad P14s Gen4 AMD 7840U, S: Wayland, KDE, UEFI SB

Offline

#750 2023-01-28 16:52:03

bluestang
Member
Registered: 2023-01-20
Posts: 7

Re: chromium: hardware video acceleration with VA-API

shtirlic wrote:

Some new commits for this topic, Issue 1399897: Vaapi On GL (don't rely on vulkan) https://bugs.chromium.org/p/chromium/is … 1399897#c5

Do these patches fix anything with AMD gpus?

Offline

Board footer

Powered by FluxBB