How to get gpu acceleration working in chromium browsers for AMD APUs

Hi,

lately I had been trying if I can get the GPU acceleration working on my machine when watching videos in the browser, but unfortunately I couldn’t figure this one out.

I tried several recommendations for chromium based browsers, starting with special flags, … , but none of them changed the current situation.
Is there any dependency, which is required to get GPU acceleration working for chromium browsers in combination with amdgpu driver?

Some details about my installation:

  • Laptop with AMD Ryzen 9 5900HX with Radeon Graphics
  • Fedora 35 GNOME
  • Wayland
  • amdgpu as displaydriver
  • browser: BRAVE or Chrome

If you had been able to get it working, please let me know what steps had been required.

→ my chrome://gpu page looks like this:

Graphics Feature Status

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

Problems Detected

  • Accelerated video encode has been disabled, either via blocklist, about:flags or the command line.
    Disabled Features: video_encode
  • Accelerated video decode has been disabled, either via blocklist, about:flags or the command line.
    Disabled Features: video_decode

For vivaldi did you launch it with --use-gl=desktop --enable-features=VaapiVideoDecoder

Did you also change enable this setting: chrome://flags/#ignore-gpu-blocklist

2 Likes

Hi dalto,

yes had been trying this before but lets check it again.

performed steps

  1. adjust #ignore-gpu-blocklist
  2. relaunch browser with your given parameters

result

when opening from command line i found this messages being displayed:

$ brave-browser --use-gl=desktop --enable-features=VaapiVideoDecoder
libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[156435:156435:0210/182455.725781:ERROR:gpu_init.cc(454)] Passthrough is not supported, GL is desktop, ANGLE is 
[156435:156435:0210/182455.743609:ERROR:sandbox_linux.cc(377)] InitializeSandbox() called with multiple threads in process gpu-process.
Failed to parse JSON adblock resources: EOF while parsing a value at line 1 column 0

OK, but browser did open and it showed some different setting in the gpu screen

Graphics Feature Status

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

So at least the decoding should work, right?
I jumped over to youtube and opened a random video.

checked nerd stats → VP09 Codec being used
checked dev tools → media

seems to me that the video is still not being decoded via hw.
what do you think?

you may want to run vainfo in a terminal to see what is supported.

If it is not installed, sudo dnf install libva-utils

If VP9 is not supported you could look into the h264ify extension.

Hi grumpey,

libva-utils is installed on this machine.
I did run vainfo again and this is the result:

$ vainfo 
libva info: VA-API version 1.13.0
libva info: Trying to open /usr/lib64/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_13
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.13 (libva 2.13.0)
vainfo: Driver version: Mesa Gallium driver 21.3.5 for AMD RENOIR (DRM 3.44.0, 5.16.5-200.fc35.x86_64, LLVM 13.0.0)
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

As far as I interpret the output information, it indicates that hw decoding for VP9 should work, right?

:thinking: If I can remember correctly last time I read about this, we need to run it on xorg session. If we run it in wayland session, actually it run on xwayland instead of wayland.

For xwayland: --use-gl=egl --enable-features=VaapiVideoDecoder
For xorg: we can use above and also we can also use --use-gl=desktop --enable-features=VaapiVideoDecoder

Then check again with chrome://gpu.

Hi guys,

I had been playing around the last days with this problem, but still couldn’t get it working.

  1. --use-gl=egl --enable-features=VaapiVideoDecoder
    chrome://gpu shows Video Decode: Hardware accelerated
    When playing a video in VP9 Video in Youtube, media tab still shows the VpxVideoDecoder and experienced extreme stutter.

  2. --use-gl=desktop --enable-features=VaapiVideoDecoder
    chrome://gpu shows Video Decode: Hardware accelerated
    When playing a video in VP9 Video in Youtube, media tab still shows the VpxVideoDecoder. No stutter in video playback

  3. --enable-features=VaapiVideoDecoder
    same result as #2

Further information:

  • added ENV variables

    $ printenv | grep -i libva
    LIBVA_DRIVER_NAME=radeonsi
    LIBVA_DRIVERS_PATH=/usr/lib64/dri
    

    This helped to get rid of some initialization error messages. driver = (null)

  • checked gstreamer output

    $ gst-inspect-1.0 vaapi
    Plugin Details:
      Name                     vaapi
      Description              VA-API based elements
      Filename                 /usr/lib64/gstreamer-1.0/libgstvaapi.so
      Version                  1.20.0
      License                  LGPL
      Source module            gstreamer-vaapi
      Source release date      2022-02-03
      Binary package           gstreamer-vaapi
      Origin URL               https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/issues
    
      vaapidecodebin: VA-API Decode Bin
      vaapih264dec: VA-API H264 decoder
      vaapih264enc: VA-API H264 encoder
      vaapih265dec: VA-API H265 decoder
      vaapih265enc: VA-API H265 encoder
      vaapijpegdec: VA-API JPEG decoder
      vaapimpeg2dec: VA-API MPEG2 decoder
      vaapipostproc: VA-API video postprocessing
      vaapisink: VA-API sink
      vaapivc1dec: VA-API VC1 decoder
      vaapivp9dec: VA-API VP9 decoder
    
      11 features:
      +-- 11 elements
    

To me the VA-API looks well configured and should be able to handle the decoding.

What other possibilities do I have?
Check with another problem? Like Mediaplayer?

I would check here for additional suggestions: chromium: hardware video acceleration with VA-API (Page 26) / Applications & Desktop Environments / Arch Linux Forums

I was unable to get this working on chromium freeworld this morning unless I ran Gnome X11 for the session.
I was able to get it working with h264ify enhanced extension with the ungoogled-chromium flatpak with the following flags running a wayland session (sway):

--disable-features=UseChromeOSDirectVideoDecoder
--enable-features=VaapiVideoDecoder
--ignore-gpu-blocklist
--enable-gpu-rasterization
--enable-accelerated-2d-canvas
--enable-accelerated-video-decode
--enable-zero-copy
--ozone-platform-hint=x11
--use-gl=egl
1 Like

Hi grumpey,

tried your list of additional attributes and it seems this fixed it for now!

  1. Media Tab is first time showing hardware decoding true!
    Bildschirmfoto vom 2022-02-17 21-19-50

  2. in chrome://gpu I can see the first time Video Acceleration Information.

I will monitor this topic for some time and also play around with the parameters, which one in the end helped to get it working.

played around with the attributes and this had been the minimal version that enabled hw decoding

brave-browser \
--disable-features=UseChromeOSDirectVideoDecoder \
--enable-features=VaapiVideoDecoder \
--ignore-gpu-blocklist \
--use-gl=egl

To me it looks like the attribute --disable-features=UseChromeOSDirectVideoDecoder did the trick.

2 Likes

U can get both Encode and Decode get worked by using the following

/usr/bin/brave-browser-stable %U --use-gl=desktop --enable-features=VaapiVideoDecoder,VaapiVideo
Encoder 

or simply

brave-browser --use-gl=desktop --enable-features=VaapiVideoDecoder,VaapiVideo
Encoder 

image

1 Like

Does it actually use the hardware though? You can check by going to a video on youtube.com and looking at the developer tools → media tab.