The Linux Rain Linux General/Gaming News, Reviews and Tutorials

Got tearing with proprietary NVIDIA? Try this.

By Andrew Powell, published 14/02/2016 in Tutorial

If you're using a reasonably modern NVIDIA graphics card on your Linux box with the proprietary driver, there's a fair chance you may encounter that nasty thing called 'screen tearing'. There is a little setting worth trying in NVIDIA's blob driver called 'ForceCompositionPipeline' that can severely reduce tearing to a minimum, perhaps even completely. Here's how to do it.

With the proprietary NVIDIA driver, if you're using a composited Desktop Environment such as GNOME or KDE Plasma, they can hide the screen tearing for the most part, generally to even a quite satisfactory level. But not always. And if you use a non-composited, non-hardware accelerated desktop such as LXDE or MATE, then... chances are you'll be in screen tearing hell, even with NVIDIA's V-sync enabled. And that's the way things will be until we all have support for Wayland.

Thankfully, as long as you're running NVIDIA drivers no older than a year or so, there's a feature worth trying called 'ForceCompositionPipeline'. There's also a variant called 'ForceFullCompositionPipeline', although I am sketchy as to the exact difference between them other than presumably the latter is a stronger version.

Fair warning: this feature has been reported in the past to reduce performance in some OpenGL applications. Up to date NVIDIA drivers seem to have largely optimized the feature enough that the difference generally is barely noticeable (it may cost 1-5 frames here and there in benchmarks as a rough average) whereas in the first iterations, the performance cost used to be nearly as much as 30-40%! Thankfully that seems to be no longer the case, but just bear in mind the potential for loss of performance.

Alright, let's get to it!

Open up a terminal and execute this command:
nvidia-settings --assign CurrentMetaMode="nvidia-auto-select +0+0 { ForceCompositionPipeline = On }"

Note that you can try either 'ForceCompositionPipeline' or 'ForceFullCompositingPipeline'. I tried (and use) the former and it works just fine. But you may need to experiment.

All going well, you should still be at your desktop and if you do some actions like scrolling pages in Firefox, play videos (both windowed and fullscreen) and move some windows around, hopefully your tearing problem is pretty much fixed! If not, perhaps it's not supported on your specific graphics card. Also, on the off-chance that you simply get a black screen or some sort of problem after running the above command, fret not. Just reboot, as the change is only for your current running session.

But it works and I wanna make it permanent!

No worries, fellow Linux user, if you can bear with a bit more terminal text work, you can make this a permanent change that will survive reboots.

Open up a terminal again and, with super user privileges, use your favourite text editor to edit the file /etc/X11/xorg.conf, assuming the file exists but it should for most users using the NVIDIA blob driver. Also it's a good idea to backup the file first, eg. sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup. Now, onto opening the file.

Example (using Pluma text editor, replace with gedit or vim or whatever you please):
sudo pluma /etc/X11/xorg.conf

You then need to add the following line to the "Screen" section of the opened Xorg configuration file:
Option "metamodes" "nvidia-auto-select +0+0 { ForceCompositionPipeline = On }"

UPDATE 16/02/2016: Thanks to commenter David Gettis for pointing this out:

I should also add that the key string to add to /etc/X11/xorg.conf is { ForceCompositionPipeline = On } to the end of the Option "metamodes" line in /etc/X11/xorg.conf.

Some people (like me) have that line already, with custom settings that will get messed up if you replace the entire line with the sample you provide. So, for example, my line now looks like this:

Option "metamodes" "DVI-I-1: 1920x1200 +1920+0, HDMI-0: nvidia-auto-select +0+120 { ForceCompositionPipeline = On }"

So if your xorg.conf file already contains an Option "metamodes" be sure to add just the { ForceCompositionPipeline = On } line of code between the quotation marks at the very end.

See image below for an example of what you should want to have.

Save the file and that's it.

I'm using this setting with an NVIDIA GeForce GTX460 with the 361.18 driver, on a non-composited MATE 1.12 desktop on Arch Linux. Without ForceCompositionPipeline set to 'On', tearing is nearly unbearable. Firefox has terrible tearing when scrolling, fast motion and changing of camera angles in videos cause tears and simply moving or changing focus on windows would cause flickers.

With this setting on, I have no such troubles! While I have not been bothered to run any benchmarks, I have tried some games like Euro Truck Simulator 2 that I have played plenty of hours on with this machine and could not notice any real performance difference at all. It's well worth a shot if you're plagued by screen tearing and don't desire using a fully fledged OpenGL compositing window manager such as Mutter or Kwin, though this setting may even help with those as well. Experimentation is key!

About the author

Andrew Powell is the editor and owner of The Linux Rain who loves all things Linux, gaming and everything in between.

Tags: tutorials nvidia screen-tearing blob nvidia-settings forcecompositionpipeline xorg
blog comments powered by Disqus