I often see online people complaining that we have to get rid of X11 and start using Wayland because Wayland fixes the screen tearing on Linux desktop. I scratch my head as there have been solutions for screen tearing on X11 for years. I want to show you a simple solution to tackle screen tearing, but it depends which GPU your machine has.
Intel and newer AMD cards
Intel and AMD has made it really simple! Basically just enable the TearFree option with this line in your X11 configuration:
Option "TearFree" "true"
I recommend to create a new configuration file in
/etc/X11/xorg.conf.d/ for example
20-amd.conf. The file could look like this:
# If Intel: # /etc/X11/xorg.conf.d/20-intel.conf Section "Device" Identifier "Intel Graphics" Driver "intel" Option "TearFree" "true" EndSection # Or if AMD: # /etc/X11/xorg.conf.d/20-amd.conf Section "Device" Identifier "AMD" Driver "amdgpu" Option "TearFree" "true" EndSection
Then reboot (or just restart your X server) to apply these settings. On AMD this works on newer cards which use the new AMDGPU driver.
Older AMD cards
This is for older AMD cards which use the Radeon driver. The line in the X11 configuration looks similar:
Option "TearFree" "on"
Include this to the configuration file in
# etc/X11/xorg.conf.d/20-radeon.conf Section "Device" Identifier "Radeon" Driver "radeon" Option "TearFree" "on" EndSection
Then reboot or restart your X server.
On NVIDIA running with the proprietary drivers I would recommend using the nvidia-settings tool instead of editing the X11 configuration files yourself. The nvidia-settings application gives you nice graphical user interface to manage all the settings you need. Using the application, first click X Server Display Configuration from the menu on the left and then click the Advanced… button:
Then click the checkboxes for Force Composition Pipeline and Force Full Composition Pipeline:
Then click the button Save to X Configuration File and restart your X server to apply the new settings.
If all else fails
Above solutions should work 98% of the time (that number was pulled out of my arse), but I’ve heard that for some people they don’t. Also if you’re running NVIDIA hardware with the free Nouveau drivers, the above won’t work. Then the last solution is to run an external compositor. If you’re desktop environment doesn’t offer you proper one (disable that one before running this one), I would recommend using Compton. Compton should be available from your distributions repository and it has quite many options to choose from. From my experience these options work fine:
compton -b --vsync opengl-swc --backend glx
Compton won’t perform as well as solutions mentioned before should. It is worth trying is nothing else works. Compton doesn’t require you to restart your X server and the changes should apply immediately.