Check out our Monthly Survey Page to see what our users are running.
We do often include affiliate links to earn us some pennies. See more here.

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.

 

Article taken from GamingOnLinux.com.
Tags: Editorial, HOWTO
0 Likes
About the author -
author picture
I am the owner of GamingOnLinux. After discovering Linux back in the days of Mandrake in 2003, I constantly checked on the progress of Linux until Ubuntu appeared on the scene and it helped me to really love it. You can reach me easily by emailing GamingOnLinux directly. You can also follow my personal adventures on Bluesky.
See more from me
The comments on this article are closed.
All posts need to follow our rules. For users logged in: please hit the Report Flag icon on any post that breaks the rules or contains illegal / harmful content. Guest readers can email us for any issues.
64 comments Subscribe
Page: «2/4»
  Go to:

Liam Dawe 12 May 2016
Liam, one question?

why don't you use the following in your <xorg>.conf ?
Option "metamodes" "nvidia-auto-select +0+0 { FroceFullCompositionPipeline = On } "
It requires you to not have to f-about with any xorg files. It means you can store it on a partition that doesn't get wiped between installs and have it right where you need it.

That, plus, as written in the article you need to re-do it when games change your resolution. Putting it in xorg will not solve that.

Hmm the above should automatically aply the ForceFullCompostionPipeline=On to any resolution which your xorg knows about. Strange overall ... maybe someone should describe and report that "need to reenabled" issue to nvidia (sounds to me like a bug).

And i was just curious overall.
I did some testing using "nvidia-auto-select", the problem is again with games that change your desktop resolution. It's the same issue, ForceFullCompostionPipeline reverts to off.
ljrk 12 May 2016
Huh, am I blind or the only one with not having the issue?
GTX 970 + nVidia drivers.

I do have the issue on my Optimus-Laptop since there's yet no sync of the integrated for display output and the rendering GPU (possibly to come...) but on the desktop I notice it not.
Liam Dawe 12 May 2016
Huh, am I blind or the only one with not having the issue?
GTX 970 + nVidia drivers.

Honestly, until Samsai repeatedly pointed it out to me in my videos and livestreams, I didn't notice too much. Now I know about it, I see it all the time. Until I came up with this solution that is.
ljrk 12 May 2016
Huh, am I blind or the only one with not having the issue?
GTX 970 + nVidia drivers.

Honestly, until Samsai repeatedly pointed it out to me in my videos and livestreams, I didn't notice too much. Now I know about it, I see it all the time. Until I came up with this solution that is.

Hm, I'n glad then I don't notice xD

On my Laptop I have my dedicated GPU disabled anyway sk that doesn't scratch me anymore neither.
Pinguino 12 May 2016
This is amazing. This is the first time I've seen my PC pass Youtube's video tearing tests (e.g. https://youtu.be/cuXsupMuik4). Thanks, Liam!


Last edited by Pinguino on 12 May 2016 at 9:51 pm UTC
Liam Dawe 12 May 2016
This is amazing. This is the first time I've seen my PC pass Youtube's video tearing tests (e.g. https://youtu.be/cuXsupMuik4). Thanks, Liam!
Really pleased to help another, you're welcome.
wolfyrion 12 May 2016
Guys really ???? now you are sorting your tearing issues???
I wonder if I should laugh or cry ??? :O

1. First KWIN compositor is the best compositor available at the time being! no doubt about that and anyone says the opposite have no clue....

2. Second KWIN has a major bug right now that it disables the compositor every time you are launching an opengl application or game so in short you will face tearing issues or texture corruptions because the compositor is disable.

-> Temporary Fix Solution Run "kcmshell5 kwinrules" and create a blind rule (just don't press the detect button),name it whatever you want, then go to the last tab Appearance and Fixes --> "Block Compositing" -> Force -> "No" This will prevent opengl games or apps to turn off the compositor so the compositor will always stay on and you will not experience these kind of problems.

3. Other Nvidia Tweaks (I am using KWIN Tribble buffer so I am fine )

Option "NoLogo" "1"
Option "MigrationHeuristic" "greedy"
Option "RenderAccel" "True"
Option "AddARGBGLXVisuals" "True"
Option "OnDemandVBlankInterrupts" "True"
Option "InitialPixmapPlacement" "2"
Option "BackingStore" "True"
Option "DamageEvents" "True"
Option "UseEvents" "False"
Option "Coolbits" "1"
Option "DisableGLXRootCliping" "True"
Option "TripleBuffer" "False"
Option "Coolbits" "24"
Option "NoLogo" "1"
Option "PixmapCacheSize" "300000"
Option "GlyphCache" "1"

4. etc/profile tweaks

# /etc/profile (export sdl ro prevent sdl games to take over my second monitor)
export __GL_SYNC_TO_VBLANK=1
export __GL_SYNC_DISPLAY_DEVICE=DVI-I-1
export __VDPAU_NVIDIA_SYNC_DISPLAY_DEVICE==DVI-I-1
export __GL_SYNC_DISPLAY_DEVICE=DVI-I-1
export SDL_VIDEO_FULLSCREEN_HEAD=1
export SDL_VIDEO_FULLSCREEN_DISPLAY=1
export SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0
export KWIN_TRIPLE_BUFFER=1
export KWIN_USE_BUFFER_AGE=0

5. Forcefullcomposition has been there for ages , some say that it takes out performance some other not so I am not use it at all the same goes with __GL_YIELD="USLEEP" that it causes a bit of trouble.
I have tested and played many games and thats all the results based on my experience.

(some Nvidia tweaks may not work for everyone so is just my personal tweak options...)

Thats all for now...

Take care and have fun


Last edited by wolfyrion on 12 May 2016 at 11:30 pm UTC
Nel 13 May 2016
Option "TripleBuffer" "True"

This simple line in /etc/X11/xorg.conf, Section "Screen", did the trick for me.
I'm on Debian Jessie + KDE.

I also have a shortcut key to disable composition manually if needed.
TheRiddick 13 May 2016
I remember having a issue with tearing with my 980GTX when I had it, when enabling vsync it would murder the FPS. This will come in handy if I get a 1080 card later next month. Hopefully I can keep most games at 4k resolutions.

Honestly NVIDIA should really integrate all these functions into their control panel and not force people to fiddle around with scripts and config files...


Last edited by TheRiddick on 13 May 2016 at 2:20 am UTC
N30N 13 May 2016
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.
Well the advantage to this is you don't need to switch compositor, which many probably aren't comfortable with :)
You misunderstand, [nvidia's composition pipeline](http://us.download.nvidia.com/XFree86/Linux-x86/364.19/README/configtwinview.html) is for people that are not running a compositor.

On a general note: I think this is one of the more important issues and, to put it slightly hyperbolically, especially newcomers will be very easily put off if you tell them 'to get a tearing-free experience on linux you need to edit xorg.conf' they will go 'huh?' and return to Windows.
All major desktop environments include a compositor. This is why, if you're experiencing tearing you should file a bug report with your given distro (so it gets fixed for all your fellow users).


Last edited by N30N on 13 May 2016 at 3:52 am UTC
Beamboom 13 May 2016
But what's the tradeoff? Surely there must be one?
wojtek88 13 May 2016
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").
This is the funniest way to make a file executable in Linux I've ever heard. I mean, I understand that not everyone is using console very often, but seriously, I've never thought that someone is changing file to be executable without chmod, instead is using GUI.
But of course, GUI is meant to make things easier. Anyway, I've smiled a bit.
ghiuma 13 May 2016
hello guys, I have solved so:

screen tearing kde

sudo kate

export KWIN_TRIPLE_BUFFER=1
export __GL_YIELD=”USLEEP”

name file: Tearing.sh
save in: /etc/profile.d
Xpander 13 May 2016
best way to check your monitors is to use this:

nvidia-settings -q dpys | grep connected

it reports nicely whats connected and what is enabled also.



Option "TripleBuffer" "True"

This simple line in /etc/X11/xorg.conf, Section "Screen", did the trick for me.
I'm on Debian Jessie + KDE.

I also have a shortcut key to disable composition manually if needed.

i wouldnt use that triplebuffer option if you want to record gameplay videos. and it also makes weird fps drops in some games
Nel 13 May 2016
Option "TripleBuffer" "True"

This simple line in /etc/X11/xorg.conf, Section "Screen", did the trick for me.
I'm on Debian Jessie + KDE.

I also have a shortcut key to disable composition manually if needed.
i wouldnt use that triplebuffer option if you want to record gameplay videos. and it also makes weird fps drops in some games
I never record games and never experienced any fps drop in my 450+ games.
BTW, I use a 660GTX.


Last edited by Nel on 13 May 2016 at 8:36 am UTC
titi 13 May 2016
Is this tearing problem maybe a KDE only problem? I never noticed anything unusual using mate so far.
Liam Dawe 13 May 2016
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.
Well the advantage to this is you don't need to switch compositor, which many probably aren't comfortable with :)
You misunderstand, [nvidia's composition pipeline](http://us.download.nvidia.com/XFree86/Linux-x86/364.19/README/configtwinview.html) is for people that are not running a compositor.

On a general note: I think this is one of the more important issues and, to put it slightly hyperbolically, especially newcomers will be very easily put off if you tell them 'to get a tearing-free experience on linux you need to edit xorg.conf' they will go 'huh?' and return to Windows.
All major desktop environments include a compositor. This is why, if you're experiencing tearing you should file a bug report with your given distro (so it gets fixed for all your fellow users).

I did make a bug report to the Cinnamon developers back in January with no reply: https://github.com/linuxmint/Cinnamon/issues/4990

Considering it's also an issue in KDE, GNOME and Unity as well as Cinnamon which I use currently, something is broken on all of them if running my script fixes it nicely.

Also considering all the people across the net I've found using all manner of different fixes, and also shown by some of what people are commenting here on GOL, it's a wide issue on all desktops.
berkwit 13 May 2016
I had this horrible bug at COMPIZ and xfwm4. Now I using mutter (cinnamon) there is no tearing. (Nvidia 364.19)
Mountain Man 13 May 2016
I've had the ForceFullCompositionPipeline command in my xorg.conf file for years, first with KDE (Kubuntu) and now with Xfce (Xubuntu). My solution whenever I lost sync through a resolution change was to reboot X, but running a simple command script is more elegant and less disruptive.

If you're curious why I went from Kubuntu to Xubuntu, I saw a noticeable performance increase when running Xfce. KDE is pretty, but it's quite à resource hog.
Guest 13 May 2016
I did make a bug report to the Cinnamon developers back in January with no reply: https://github.com/linuxmint/Cinnamon/issues/4990

Considering it's also an issue in KDE, GNOME and Unity as well as Cinnamon which I use currently, something is broken on all of them if running my script fixes it nicely.

Also considering all the people across the net I've found using all manner of different fixes, and also shown by some of what people are commenting here on GOL, it's a wide issue on all desktops.

I think the next logical step for this is a application profile utility for gnome,cinnamon,kde maintained and updated on GitHub. All you need is a GUI way ( perhaps a gnome extension ) to +ADD application -> then enter its name from a list of found (( just like choosing a preferred application )) or some magic and get the steam installed games list to appear inside that same list , then all you need is a check box, Direct/Undirect.

call it Syncpro and have done with it, before long it will be featured on cinnamon as default as the mint team are usually good at listening to concerns over vsync, its why muffin is probably one of the most reliable gaming compositors, the lack of application toggle is all that sets it back.

Something like that could make its way into SteamOS eventually :)


Last edited by on 13 May 2016 at 12:06 pm UTC
While you're here, please consider supporting GamingOnLinux on:

Reward Tiers: Patreon. Plain Donations: PayPal.

This ensures all of our main content remains totally free for everyone! Patreon supporters can also remove all adverts and sponsors! Supporting us helps bring 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!
The comments on this article are closed.