Fixing Screen Tearing on Linux (running Nvidia GPU)
Introduction
It’s the beginning of the new semester of university and I’m taking a course on game development using Unity.
However, when I downloaded it on my Arch Linux system, I ran into screen tearing issues.
This short blog post is about how I fixed it.
Note: The second method is what actually fixed this particular issue.
My current set up
Arch Linux
DWM
(usingX11
of course)GRUB
boot-loader- I have a laptop with a Nvidia GPU (it also includes an integrated Intel GPU but I have disabled it).
Attempt 1: Adjusting kernel parameters to load DRM
This requires you to be using the grub boot-loader, and generating the configuration file for it using grub-mkconfig. If you are running something else, please have a look through this: Kernel parameters (Arch Wiki).
Open your
grub
configuration file:sudoedit /etc/default/grub
(this is where it is on my system).- Note that
sudoedit
will open up your default editor assudo
. It should be the default way you edit text files if you need root access. - You will see a line that will contain the variable:
GRUB_CMDLINE_LINUX_DEFAULT=[some options]
- Note that
You will need to paste in the following line between the double quotes:
nvidia_drm.modeset=1
.- For me, it looks like this (after the modification):
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet nvidia_drm.modeset=1 rcutree.rcu_idle_gp_delay=1"
.
- For me, it looks like this (after the modification):
After that, you should run the command
grub-mkconfig -o /boot/grub/grub.cfg
.- This will regenerate your grub boot configuration.
Small Note
This actually did not fix my screen tearing issues. However, this should be a good thing to do anyways (if you have a Nvidia graphics card). Because it also apparently prevents screen tearing issues.
Attempt 2: Fix screen-tearing using a compositor (Picom)
I never bothered to download and install a compositor because I did not like the idea of having an unnecessary program that serves no purpose besides prettifying my screen. But it turns out I was wrong and a program called Picom can actually fix screen-tearing issues!
- Download and install
Picom
from your Linux distributions package repository. - This step may be optional but I downloaded someones
Picom
configuration file and moved it into~/.config/picom/
.- You can find many configuration files if you just search
picom configuration
on Github.
- You can find many configuration files if you just search
- I edited my
xprofile
file to ensure that it loadspicom
afterdwm
starts. This file is found in your home directory (if you have not moved it). It is essentially a script that loads up stuff you want for your session. - Rebooted my computer (you can also just restart your
x
session), and voila! No more screen tearing whilst I mess around on Unity.