You can sign up to get a daily email of our articles, see the Mailing List page!
Support us on Patreon to keep GamingOnLinux alive. This ensures we have no timed articles and no paywalls. Just good, fresh content! Alternatively, you can donate through Paypal, Flattr and Liberapay!

I have finally found a way to sort out screen tearing on Nvidia with Linux

Posted by , | Views: 76,131

Update: You can do it easier now with the NVIDIA control panel. See this newer article for info.

Thanks to a few different people for their advice (xpander for the initial advice on a script and HeavyHDx on twitter) I have finally found a way to stop screen tearing with Nvidia proprietary drivers.

I have been struggling with this issue for months across all the different desktop environments I tried (KDE, GNOME, Cinnamon, Unity), and it has caused me a fair amount of headaches and stress, so I am pleased to finally find a solution. It's not perfect, slightly annoying, but also quite useful too.

You have probably heard of ForceFullCompositionPipeline before and that is what I am using. I have two scripts setup on keyboard shortcuts depending on the resolution that I am using (4K or 1080p). Why both? I hear you ask. It's simple, performance in a lot of games at 4K resolution is terrible, and some games have tiny unreadable text, so I run certain games at 1080p.

Here's where the confusion came from...
The problem with ForceFullCompositionPipeline is when you play a game that has a fullscreen mode that changes your desktop resolution, instead of stretching a fullscreen window, is that ForceFullCompositionPipeline is reset back to disabled. If you have noticed screen tearing returning at times even with using ForceFullCompositionPipeline, that could well be your issue too. Like me, if you didn't know that, it was probably bugging you a lot. This is also why simply putting it in an xorg config file will not 100% solve it, where as with this method you can just re-run it any time you need to.

So, here are the two very simple scripts I run. They are both put in plain text files and allowed to run as an executable (right click -> properties -> permissions -> tick "Allow executing file as program").

First up is for the 4K resolution (I have this set to run at start-up so I don't have to mess with xorg stuff directly):
nvidia-settings --assign CurrentMetaMode="DP-4:3840x2160_60 +0+0 { ForceFullCompositionPipeline = On }, DVI-I-1:1920x1080_60 +3840+0 { ForceFullCompositionPipeline = On }"
And for 1080p resolution:
nvidia-settings --assign CurrentMetaMode="DP-4:1920x1080_60 +0+0 { ForceFullCompositionPipeline = On }, DVI-I-1:1920x1080_60 +1920+0 { ForceFullCompositionPipeline = On }"
If you only have one monitor, you won't need the addition part after the comma.

You can run the script at any time. Your monitor(s) will blink, and then come back all sorted.

You will of course need to change things like "DP-4" and "DVI-I-1" to the connections your monitor is using (or monitors in my case as I have two). You can find them out by running the "xrandr" command in terminal. It will give you a list of things, like this:

QuoteDP-4 connected primary 3840x2160+0+0 (normal left inverted right x axis y axis) 621mm x 341mm

 


I hope this helps someone else, as it has been driving me nutty. They are pretty safe scripts to use, I have been testing switching between them constantly, but don't blame me if you blow your computer up.

These two little scripts have literally changed my gaming life on Linux for the better.

Where it becomes even more useful
A nice side-effect of the script: Games like RunningWithRifles which has poor multi-monitor support, it actually turns off my main monitor. Hitting the desktop shortcut I set for it will bring that monitor back, and still allow me to play the game. So not only do you get zero tearing, you get your normal multi-monitor experience back.

Feel free to share what methods you're using on your favourite desktops. Let's see if we can help each other in the comments.

 

0 Likes
We do often include affiliate links to earn us some pennies. We are currently affiliated with GOG and Humble Store. See more information here.
The comments on this article are closed.
70 comments
Page: 1/7»
  Go to:

Segata Sanshiro 12 May 2016 at 7:14 pm UTC
If this works for me then I'll uninstall compton since that gives a bit of a performance hit.
Daverball 12 May 2016 at 7:25 pm UTC
For me creating a file "Tearing.sh" in /etc/profile.d did the trick:

# /etc/profile.d/Tearing.sh export KWIN_TRIPLE_BUFFER=1

Of course you may still end up having screen tearing in some games that do not have it enabled by default, but at least the desktop experience should be mostly tearing free with that and it also doesn't randomly break by launching a game.

Naturally also relies on you running KDE with Kwin.


Last edited by Daverball at 12 May 2016 at 7:25 pm UTC
vipor29 12 May 2016 at 7:41 pm UTC
{ ForceFullCompositionPipeline = On } that command right there is key for the tearing to stop,it works for me too,this will stop screen tearing.
liamdawe 12 May 2016 at 7:46 pm UTC
vipor29{ ForceFullCompositionPipeline = On } that command right there is key for the tearing to stop,it works for me too,this will stop screen tearing.
Indeed, but it gets disabled any time a game or anything using fullscreen changes your resolution (surprisingly a lot).
chuzzle44 12 May 2016 at 7:49 pm UTC
Been using compton myself. Took me forever to find the right options to completely eliminate tearing and I've been scared to touch it again since. I may have to try this.
Avehicle7887 12 May 2016 at 8:05 pm UTC
Will this also act as an fps limiter depending on the monitor's refresh rate too? (60FPS in my case). If yes, that would be wonderful.

Thanks for sharing Liam, I'll try this with a few games where tearing is incredibly noticeable.
liamdawe 12 May 2016 at 8:12 pm UTC
Avehicle7887Will this also act as an fps limiter depending on the monitor's refresh rate too? (60FPS in my case). If yes, that would be wonderful.

Thanks for sharing Liam, I'll try this with a few games where tearing is incredibly noticeable.
No, this does not limit the FPS.
Avehicle7887 12 May 2016 at 8:18 pm UTC
liamdawe
Avehicle7887Will this also act as an fps limiter depending on the monitor's refresh rate too? (60FPS in my case). If yes, that would be wonderful.

Thanks for sharing Liam, I'll try this with a few games where tearing is incredibly noticeable.
No, this does not limit the FPS.


I've just tested Shadowrun Returns after adding this script to my startup list and the tearing has gone poof. Another issue out of the way :-)
liamdawe 12 May 2016 at 8:26 pm UTC
Avehicle7887
liamdawe
Avehicle7887Will this also act as an fps limiter depending on the monitor's refresh rate too? (60FPS in my case). If yes, that would be wonderful.

Thanks for sharing Liam, I'll try this with a few games where tearing is incredibly noticeable.
No, this does not limit the FPS.


I've just tested Shadowrun Returns after adding this script to my startup list and the tearing has gone poof. Another issue out of the way :-)
Fantastic, really pleased it helped.

The good thing about having it as a simple script, is you can re-run it any time tearing returns. Poof, gone again!
stan 12 May 2016 at 8:31 pm UTC
I’ve been happy with Compton for several years. ForceCompositionPipeline works too but Xfwm’s compositor is not as pretty or fast as Compton, and the performance gain is minimal (if I don’t enable Xfwm’s compositor; otherwise it’s a loss).


Last edited by stan at 12 May 2016 at 8:32 pm UTC
  Go to:
While you're here, please consider supporting GamingOnLinux on Patreon, Liberapay or Paypal. We have no adverts, no paywalls, no timed exclusive articles. Just good, fresh content. Without your continued support, we simply could not continue!

You can find even more ways to support us on this dedicated page any time. If you already are, thank you!
Livestreams & Videos
Community Livestreams
  • Puzzle Tiles: „The Cave“
  • Date:
See more!
Popular this week
View by Category
Contact
Latest Comments
Latest Forum Posts