AMD GPU Gnome/Wayland Firefox hw decode accel

Hello forum, I’ve been playing with firefox/wayland and finally got hardware acceleration working, just wanna share:

Tested and it’s working, using a AMD RX 6600 XT

- vaapi
# pacman -S libva-utils
# pacman -S libva-mesa-driver

- enable Webrender firefox:
To enable WebRender, go to about:config page and look for gfx.webrender.all and gfx.webrender.enabled preferences and set them to true.

To check if WebRender is enabled, go to about:support and under the "Graphics" section, in the "Decision Log" sub-section, look for "WEBRENDER". If it reports "available by user: Force enabled by pref", it means is enabled. If it only reports "opt-in by default: WebRender is an opt-in feature", it means it is disabled. 
Also check for Composition, it should be WebRender and not WebRender Software.

- Set the following flags in about:config:
media.ffmpeg.vaapi.enabled to true in order to enable the use of VA-API with FFmpeg.
media.ffvpx.enabled to false to disable the internal decoders for VP8/VP9. This is necessary despite this bug being fixed [9][10].
media.navigator.mediadatadecoder_vpx_enabled to true to enable hardware VA-API decoding for WebRTC [11].
media.rdd-vpx.enabled to false to disable the remote data decoder process for VP8/VP9. Firefox attempts to use the RDD process for VP8/VP9 but the RDD sandbox blocks VA-API access [12]. Disabling the remote data decoder for VP8/VP9 process means VA-API will run in the content process instead. The best solution is to move VA-API to the GPU process [13].

- To set environment variables, copy the .desktop file from /usr/share/applications/ to $XDG_DATA_HOME/ (~/.local/share/applications/) and edit the Exec= command line by prepending env.
cp /usr/share/applications/firefox.desktop ~/.local/share/applications/firefox.desktop
nano ~/.local/share/applications/firefox.desktop
change Exec line from default to:
Exec=env MOZ_ENABLE_WAYLAND=1 /usr/lib/firefox/firefox %u

On native Wayland Firefox rendering performance can be significantly improved by setting gfx.webrender.compositor.force-enabled to true in about:config. As of Firefox 89, this feature is experimental and Firefox Nightly is recommended for testing. 


-Useful links:
https://wiki.archlinux.org/title/firefox#Hardware_video_acceleration
https://wiki.archlinux.org/title/Firefox/Tweaks#Enable_WebRender_compositor
https://mastransky.wordpress.com/2021/01/10/firefox-were-finally-getting-hw-acceleration-on-linux/
https://wiki.archlinux.org/title/Environment_variable
4 Likes

Thanks for posting and sharing your findings!
:enos_flag:

2 Likes