You can sign up to get a daily email of our articles, see the Mailing List page!

How To: An update on fixing screen-tearing on Linux with an NVIDIA GPU

Posted by , | Views: 89,739
My original guide on how to help fix screen-tearing on Linux with an NVIDIA GPU is a bit dated, so here’s an even easier way.

Notes
You will likely need the 375.26 driver or newer for this to show up in "nvidia-settings".

These options may cause a loss in performance. For me personally, the loss is next to nothing.

It probably won't work with Optimus right now, but this may be fixed in future.

What to do
Previously you needed to edit config files, and it was a little messy. Thankfully, NVIDIA added options in nvidia-settings to essentially do it all for you. The options were added in a more recent NVIDIA driver version, so be sure you're up to date.

Load "nvidia-settings" and you will need to go to this screen and then hit “Advanced” at the bottom (my screenshot doesn't have the button, as this is what you see after you hit it):
image
Tick the boxes for “Force Composition Pipeline” and “Force Full Composition Pipeline” and then hit "Apply".

You can then enjoy a tear-free experience on Linux with an NVIDIA GPU. It really is that damn easy now.

Note: You will likely need to run nvidia-settings with “sudo” for the below to work.
If you want this applied all the time on startup (without needing to do anything), you can hit “Save to X Configuration File”. I have mine located at “/etc/X11/xorg.conf.d/xorg.conf” on Antergos, but your location may be different. I also recommend backing any existing xorg.conf file up if one exists.

This step isn't needed, but it's a fun and useful extra!
I also have mine set to a script and then to a keyboard shortcut, for those times when a game reverts the desktop to a low resolution after exiting, or when a game turns off a second monitor, this will turn it back on.

For that I manually set the resolution like so:
nvidia-settings --assign CurrentMetaMode="DVI-I-1:1920x1080_60 +0+0 { ForceFullCompositionPipeline = On }, HDMI-0:1920x1080_60 +1920+0 { ForceFullCompositionPipeline = On }"
Edit that for your details, like your resolution and monitor connections (you can see them by running "xrandr --query" in terminal), and then save it as an easy to remember filename. You can then set it as a custom shortcut, I use “CTRL+ALT+F4” as it’s not used for anything else.

This has been tested and works for me perfectly across Ubuntu Unity, Ubuntu MATE and Antergos KDE. Article taken from GamingOnLinux.com.
Tags: HOWTO, NVIDIA
10 Likes, Who?
We do often include affiliate links to earn us some pennies. We are currently affiliated with GOG, Humble Store and Paradox Interactive. See more information here.
About the author -
I am the owner of GamingOnLinux. After discovering Linux back in the days of Mandrake in 2003, I constantly came back to check 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.
See more from me
The comments on this article are closed.
63 comments
Page: «6/7»
  Go to:

tuubi 12 January 2017 at 7:48 am UTC
monnefThe tearing is very visible when watching full hd video. Sadly it is working fine in Windows 10 (dual boot), so it shouldn't be a hw issue.
Which player? Use something that supports VPDAU, like mpv or Kodi. Or are you talking about Flash video on the web?

EDIT: Sorry, just noticed your earlier message. I remember having trouble with video tearing as well back before I started using Compton.


Last edited by tuubi on 12 January 2017 at 8:06 am UTC
kokoko3k 12 January 2017 at 12:04 pm UTC
cxpher@gmail.comAn important point to note is that if you enable FCP, you might want to disable in game vsync. You'll encounter performance hits that can be pretty massive. In game vsync is no longer necessary.

Not quite right, on contrary, you may waste GPU/CPU cycles trying to render more frames than the monitor would allow; if the game has no vsync logic enabled, it is probably completely unaware of the monitor refresh rate, so it will render as fast as it can, and that could lead to jerkyness because the couple [compositor+monitor refresh] is not synced to game frames.

Indeed, one thing i noticed with compositors that do vsync (*AND* vsync is disabled in games) is that motion is jerky/jumpy in games (it is still smooth in movies because the fps is limited by the movie itself).

The workaround for that is:
Given "C" a compositor that provides a working vsync (nvidia forcefullcompositionpipeline, kwin with tearing prevention on, compton with vsync enabled and so on):

* If the game provides a working vsync, enable it and disable "C"

*If the game provides a non working vsync, enable it and leave "C" enabled; this is needed because even if you got tearing with the Game's non-working vsync option turned on, it will still be useful, because it limits the framerate to the monitor refresh rate; this helps "C" to stay in sync with the frames -> provide a smooth gameplay.

I've tested that on trine 2 and grid autsport.

My current setup is as follows:
Desktop Use:
- KDE/Plasma, compositor enabled but with "tearing prevention" disabled
- ForceFullCompositionPipeline enabled.
- vsync disabled in mpv (framerate is limited anyway by the movie)

Gaming:
- KDE/Plasma compositor completely disabled (to gain some fps)
but with frame limiter set to 75 (because my monitor uses 75hz).
Do that in ~/.config/kwinrc, add MaxFPS=75 in the "[Compositing]" section.
- Vsync option in game enabled
- If the games has a working vsync -> ForceFullCompositionPipeline disabled.
- If the games has a non-working vsync -> ForceFullCompositionPipeline enabled.

All the switches are bound to shortcuts alt-shift-f12 and alt-shift-f11
alt-shift-f12 comes with kdekwin and completely disables the compositor
alt-shift-f11 is bound to the following:

> cat ~/scripts/nvidia.compositionpipeline.switch.sh 
#!/bin/bash
killall aosd_cat
if nvidia-settings -t -q CurrentMetaMode|grep 'ForceCompositionPipeline=On' &>/dev/null ; then
    ~/scripts/nvidia.compositionpipeline.disable.sh &
    echo "FFCP=OFF" | aosd_cat -n "Sans Bold 15"  -x 0 -y 0 -p 0 -t 0 -b 255 -s 255 -d 10 -R yellow  -u 5000 &
    echo "FFCP=OFF" | aosd_cat -n "Sans Bold 15"  -x 0 -y 0 -p 2 -t 0 -b 255 -s 255 -d 10 -R yellow  -u 5000 &
        else
    ~/scripts/nvidia.compositionpipeline.enable.sh &
    echo "FFCP=ON" | aosd_cat -n "Sans Bold 15"   -x 0 -y 0 -p 0 -t 0 -b 255 -s 255 -d 10 -R "#99ccff"  -u 5000 &
    echo "FFCP=ON" | aosd_cat -n "Sans Bold 15"   -x 0 -y 0 -p 2 -t 0 -b 255 -s 255 -d 10 -R "#99ccff"  -u 5000 &
fi
###########
> cat ~/scripts/nvidia.compositionpipeline.disable.sh 
#!/bin/bash
sh -c "nvidia-settings --assign CurrentMetaMode=\"$(nvidia-settings -t -q CurrentMetaMode |tr -d "\n"|sed 's/.*:://'|sed 's/^ *//;s/ *$//'|sed "s/CompositionPipeline=On/CompositionPipeline=Off/g")\""
###########
> cat ~/scripts/nvidia.compositionpipeline.enable.sh 
#/bin/bash
sh -c "nvidia-settings --assign CurrentMetaMode=\"$(nvidia-settings -t -q CurrentMetaMode |tr -d "\n"|sed 's/ViewPortIn=/ForceFullCompositionPipeline=On, ViewPortIn=/g'|sed 's/.*:://'|sed 's/^ *//;s/ *$//')\""


Hitting a shortcut is faster than opening the nvidia's control panel, and the aosd_cat command is useful because it show the current FFCP (ForceFullCompositionPipeline) state.


Last edited by kokoko3k on 12 January 2017 at 4:27 pm UTC
stan 12 January 2017 at 1:07 pm UTC
  • Supporter
  • Top Supporter
staticx27Being able to set brightness or contrast using this option (and using it in the past with my old GTX 660ti) does not work, In game or on the desktop (Redshift). Not sure why this is, but I thought people should be aware. Unfortunately this makes it not an option for me.
Redshift works for me even when FCP is active (GTX 1060, nvidia 375.26, but I think it already worked on my 660 with an older driver version).
stan 12 January 2017 at 1:22 pm UTC
  • Supporter
  • Top Supporter
kokoko3kOne thing i noticed with compositors that do vsync, is that motion is jerky/jumpy in games (it is smooth in movies).
I’ve noticed that as well: when the game’s framerate goes above the monitor’s refresh rate, it starts stuttering.

Quote* If the game provides a working vsync, enable it and disable "C"
I wouldn’t suggest that, as most games use a simple double buffering technique that will slow the framerate down to 30 FPS as soon as it can’t maintain 60. IMO it’s only a good idea when the game is constantly above 60 (or if you can tolerate 30…).

An alternative to enabling in-game vsync to limit the framerate is to use libstrangle. I’ve used it for Mad Max, Deus Ex and other games. It’s awesome.

Some rare games like Aragami have an in-game frame limiter too.

Quote> cat ~/scripts/nvidia.compositionpipeline.switch.sh
Ohh, you managed to make a script to switch FCP, very nice! I tried to do it months ago but it seemed impossible. I’ve copy-pasted it in case I need it in the future . For now I’m happy with Compton as the performance loss is minimal and I use it to get nice shadows too.
kokoko3k 12 January 2017 at 4:21 pm UTC
libstrangle seems really great, thank you!
RafiLinux 12 January 2017 at 5:11 pm UTC
I am on 367.45 driver on my main gaming rig. I've had no visual tearing but this is due to using Compton on Ubuntu Mate 16.10 64 bit with some startup settings enabled.
warrengbrn 12 January 2017 at 10:53 pm UTC
fabry92i need to set every reboot 144 Hz... Btw "force full composition" disable gsync. I use it only for vulkan games beacuse gsync on vulkan it's not supported at moment

I used to have to set my refresh rate to 144hz on every reboot, until I found out that you have to hit APPLY in the "Display" program on ubuntu after applying it in the nvidia settings. Mint may have a similar method?
monnef 14 January 2017 at 10:36 am UTC
tuubi
monnefThe tearing is very visible when watching full hd video. Sadly it is working fine in Windows 10 (dual boot), so it shouldn't be a hw issue.
Which player? Use something that supports VPDAU, like mpv or Kodi. Or are you talking about Flash video on the web?

EDIT: Sorry, just noticed your earlier message. I remember having trouble with video tearing as well back before I started using Compton.
I am using SMPlayer (mpv backend).

With those 6 env. variables mentioned in previous post I got very bad fps drops when using vdpau, nothing changed in opengl mode.

I tried several different combinations of env. variables, smplayer settings and nvidia settings. I found a working combo - NO special env. variable (that was probably breaking it for me earlier, namely __GL_YIELD and __GL_THREADED_OPTIMIZATIONS), in nvidia settings only check "force full composition pipeline" on a "tv" monitor (and save the config, in my case [kubuntu] to /usr/share/X11/xorg.conf.d) and in SMPlayer use opengl or vdpau output driver. Yey, finally got smooth video playback .
fabry92 14 January 2017 at 11:55 am UTC
warrengbrn
fabry92i need to set every reboot 144 Hz... Btw "force full composition" disable gsync. I use it only for vulkan games beacuse gsync on vulkan it's not supported at moment

I used to have to set my refresh rate to 144hz on every reboot, until I found out that you have to hit APPLY in the "Display" program on ubuntu after applying it in the nvidia settings. Mint may have a similar method?

THANK YOU!! FINALLY I FIXED IT T_T
yerbestpal 31 January 2017 at 3:24 pm UTC
This worked perfectly, although I didn't have nearly the amount of advanced options you did. I just generated the .conf file, edited it as per your instructions, and that was it. It's the first time I've experienced no screen-tearing on Linux. Though when I started up my PC the next day, I couldn't get past grub. I had to use a different virtual terminal to delete the .conf file and it booted again.
  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
None currently, submit yours here!
Popular this week
View by Category
Contact
Latest Comments
Latest Forum Posts