Intel (and AMD) Graphics - tear free video under X11
Annoyed with video playback tearing on your Linux machine? Fortunately there is an easy fix. Usual disclaimer applies.
This is a brief tutorial for those who aren't yet willing to put up with the instabilities of Wayland and are running Ubuntu 18.04 or 20.04 desktop. In case you are unsure what screen tearing is, this useful YouTube video provides a good example and explanation.
The default configuration for Xorg will not enable tear free video because of Linux's low end ethos, trying to limit GPU memory consumption, latency and performance overheads at all cost. Fortunately there is a properly implemented solution for it in the driver code just waiting to solve your tearing issues. All that's required is an extra configuration file.
If you are with Team Blue:
To set up:
sudo vi /usr/share/X11/xorg.conf.d/10-intelgpu.confSection "Device" Identifier "Intel" Driver "intel" Option "TearFree" "true"EndSectionsudo reboot
For some Intel GPUs, usually older ones pre Sandybridge, you will also need to specify the "AccelMethod" parameter. But only set this if your system actually needs it as otherwise you'd be overriding the default which is SNA (Sandybridge's New Acceleration - creative naming for sure).
sudo vi /usr/share/X11/xorg.conf.d/10-intelgpu.confSection "Device" Identifier "Intel" Driver "intel" Option "TearFree" "true" Option "AccelMethod" "uxa"EndSection
to test (replacing "username" with your account username):
sudo cat /home/username/.local/share/xorg/Xorg.0.log | grep "Tear"### output below:[ 47.755] (**) intel(0): Option "TearFree" "true"[ 47.770] (**) intel(0): TearFree enabled
If you are with Team Red:
sudo vi /usr/share/X11/xorg.conf.d/10-amdgpu.confSection "Device" Identifier "AMD Graphics" Driver "amdgpu" Option "TearFree" "true"EndSection
For older AMD graphics cards you can use this:
sudo vi /usr/share/X11/xorg.conf.d/10-radeon.confSection "Device" Identifier "AMD Graphics" Driver "radeon" Option "TearFree" "true"EndSection
Reboot after creating the file and you should now be able to enjoy tear free video on your system without the need for wrangling Wayland.
With Christmas Cheers and best wishes for the festive season.
Till next time!