HOWTO fix screen tearing
Screen tearing can be a problem on GNU/Linux with some combinations of graphics drivers and window-managers such as Xfce 4.12's xfwm4. Luckily, it's easily fixable by adding a minor snippet to Xorg's configuration file.
Create one of the following configuration files in /etc/X11/xorg.conf.d/
(create that folder if it does not exist, there's no such folder on Ubuntu by default but it does look for it and read files in it) with TearFree
in a Device
section to avoid screen tearing.
Why Xorg Defaults To Screen Tearing[edit]
Question: Why do you need to add this to X's configuration?
Imagine the setting Xorg |
"The "TearFree" option isn't enabled by default because it has drawbacks (higher GPU memory consumption, performance overhead for unredirected fullscreen apps); also, it can be enabled at runtime with xrandr.
Maybe try barking up your DE's tree for not exposing a setting for that.
Don't like tearing? Use Wayland!"
in a secret developers hangout called "#radeon on Freenode"
September 30, 2020
Intel iGPUs[edit]
Section "Device" Identifier "Intel Graphics" Driver "intel" Option "TearFree" "true" EndSection
Some rare Intel CPUs will additionally need "AccelMethod" "uxa"
. That is usually not the case but that's what you need to add if the above configuration does not completely eliminate screen tearing on Intel GPUs:
Section "Device" Identifier "Intel Graphics" Driver "intel" Option "AccelMethod" "uxa" Option "TearFree" "true" EndSection
Do not use "AccelMethod" "uxa"
unless you actually need it. That may be the case if your hardware is very old. It is not the case if it's new.
AMD GPUs[edit]
If you are using a not ancient AMD GPU you're using the "amdgpu" driver and you need this:
Section "Device" Identifier "AMD Graphics" Driver "amdgpu" Option "TearFree" "true" EndSection
If you're using a very rather old AMD graphics card then you're using the "radeon" driver, not "amdgpu", and you will instead you need:
Section "Device" Identifier "AMD Graphics" Driver "radeon" Option "TearFree" "true" EndSection
You can check the X log using grep if you are unsure what driver you are using by:
grep drivers /var/log/Xorg.0.log
That will produce a line such as:
[ 24.285] (II) Loading /usr/lib64/xorg/modules/drivers/amdgpu_drv.so
or
[ 24.285] (II) Loading /usr/lib64/xorg/modules/drivers/radeon_drv.so
or, if you are using an Intel (i)GPU:
[ 21.857] (II) Loading /usr/lib64/xorg/modules/drivers/intel_drv.so
Setting TearFree Using xrandr[edit]
You can change the TearFree in X using xrandr
with:
xrandr --output DisplayPort-0 --set TearFree on
xrandr --verbose
will show the TearFree status on the connected displays and xrandr --verbose|grep TearFree
will just list the TearFree
settings.
A --output
option is required and you can not use all
. You can also not specify multiple displays with xrandr --output DisplayPort-0 --output DisplayPort-1 --output DisplayPort-2 --set TearFree on
as that only applies it to the last --output
.
One possible "solution" is to ask xrandr what displays happen to be connected and use a loop to apply (or disable) TearFree with one command for each display:
xrandr |grep ' connected'|cut -f 1 -d ' '|while read display;do xrandr --output $display --set TearFree on;done
The above one-liner is not at all elegant, but it does work.
Enable comment auto-refresher