Every now and then you run into a little oddity that reminds you you're running Linux. Something that you really shouldn't even have to think about, but somehow lacks any GUI configuration, and is tucked away behind a config file you have to create yourself.
This feels especially noticeable because it feels like such a stark contrast with most other times. A fresh install of Ubuntu or your favorite flavor comes with out-of-the-box support of AMD GPUs, you don't even have to install a single driver for that. Want to be on the more cutting edge of things? Sure, just install mesa drivers and bob's your uncle.
Open source, powerful goodies make it possible to even run the latest and greatest games, sometimes without a single bit of effort, or even with better support than Windows proper when it comes to older games. Truly an amazing time for gaming on Linux, and Linux as a whole. And given all this and much more, having awful screen tearing even when doing something like browsing or watching a video just pulls you straight out of it.
I have to admit that I hadn't gotten around to doing this since switching fully to Ubuntu nearly a year ago, probably because I had run into issues when trying to apply this under Manjaro. But I don't think that had anything to do with Manjaro as a whole, just that at the time there were some additional issues. I rarely if ever play games on my machine, and when writing code it is indeed not very noticeable, but it was always lingering around, popping up every now and then to remind me I had unfinished work.
But I digress. This will be faster and easier than it took for you to read through my overly long intro, so let's get to it.
How to check the current status
To check the current status of this option on all your currently connected displays, run the following command:
xrandr --verbose | grep "TearFree"
In my case it responded with
TearFree: auto four times (as I have four displays connected). To be honest I am not entirely sure what it might use to decide when to turn itself on or off when it's set to
auto as I had very noticeable screen tearing on all my displays, but perhaps this default works better with certain other hardware combinations, even though mine isn't unusual or anything. Regardless, I want it to be
on, so let's proceed.
Note: The following fix is for
X11specifically, not Wayland. With Wayland you most likely will have no screen tearing issues at all, although using it might come with a disadvantage when it comes to gaming. If you want you can try using Wayland instead of the following fix to see if that works well for you. You can select which one you'd like to use at the Ubuntu login screen (bottom-right).
Let's fix screen tearing
Open up a terminal window and
/etc/X11. You'll either need to
sudo each of the following commands, or start a sudo session using
sudo -s as the files and folders we'll be working with are owned by root.
We'll need to create a new sub-folder here if one doesn't already exist called
xorg.conf.d, so do that now if there indeed is no such folder yet. Then,
cd into it and, using your favorite text editor, create a new file called
20-amdgpu.conf with the following contents:
Section "Device" Identifier "AMD Graphics" Driver "amdgpu" Option "TearFree" "true" EndSection
If you already have a configuration file here for
amdgpu, the important bit here is setting
TearFree, so you can add that to your existing file.
This should be all there is to it. Just reboot (or relaunch X I suppose) and you should now be able to enjoy a tear-free experience. Why this (still) isn't the default, I don't know, but here we are.
Now, using the previously mentioned command to check the status we can see they're fully enabled:
That's it! Enjoy your now (finally) tear-free experience :).