envycontrol icon indicating copy to clipboard operation
envycontrol copied to clipboard

Screen tearing in Nvidia mode (AMD + Nvidia system)

Open ASOwnerYT opened this issue 3 years ago • 19 comments

When I boot into Nvidia mode, there is a lot of screen tearing. I have AMD intergrated graphics (on Ryzen 5), and an Nvidia GTX 1050.

Laptop: ASUS TUF Gaming FX505DD Distro: Manjaro KDE DE: KDE Plasma WM: SDDM (default) Nvidia driver version: 510.47.03 EnvyControl 1.3

ASOwnerYT avatar Feb 07 '22 04:02 ASOwnerYT

What's the output of cat /proc/cmdline and are you using dual monitors? Also, what's the output of nvidia-settings --assign CurrentMetaMode="nvidia-auto-select +0+0 { ForceFullCompositionPipeline = On }"

DaVikingMan avatar Feb 07 '22 04:02 DaVikingMan

Output of cat /proc/cmdline:

BOOT_IMAGE=/boot/vmlinuz-5.16-x86_64 root=UUID=96529aef-29ca-48e1-9810-0be4ba6af252 rw quiet apparmor=1 security=apparmor udev.log_priority=3

Output of nvidia-settings --assign CurrentMetaMode="nvidia-auto-select +0+0 { ForceFullCompositionPipeline = On }":

ERROR: Error assigning value nvidia-auto-select+0+0{ForceFullCompositionPipeline=On} to attribute 'CurrentMetaMode' (asowneryt-manjaro:0.0) as specified in assignment 'CurrentMetaMode=nvidia-auto-select +0+0 {
       ForceFullCompositionPipeline = On }' (Attribute not available).

I am not using dual monitors, just my laptop screen. Thanks.

ASOwnerYT avatar Feb 08 '22 06:02 ASOwnerYT

You can try to enable KMS for nvidia to see if that fixes the problem. To enable it:

  1. Open /etc/default/grub with a text editor of choice(with sudo)
  2. Add the line nvidia-drm.modeset=1 to GRUB_CMDLINE_LINUX=""(there should be two of these lines in the file, add it to the one which has an empty quotation marks. You can also append this line instead of adding it to an existing one, it should look something like GRUB_CMDLINE_LINUX="nvidia-drm.modeset=1")
  3. Run sudo grub-mkconfig -o /boot/grub/grub.cfg
  4. Reboot
  5. Check the output of cat /proc/cmdline to see if it has nvidia-drm.modeset=1 included in its output

DaVikingMan avatar Feb 08 '22 16:02 DaVikingMan

I followed your instructions but I'm still having the screen tearing issue. nvidia-drm.modeset=1 is included in the output, though. Here's the full output of cat /proc/cmdline now:

BOOT_IMAGE=/boot/vmlinuz-5.16-x86_64 root=UUID=96529aef-29ca-48e1-9810-0be4ba6af252 rw nvidia-drm.modeset=1 quiet apparmor=1 security=apparmor udev.log_priority=3

Thanks for trying to help btw, I really appreciate it. I've had this problem for ages now, and it would be fantastic to get it fixed.

ASOwnerYT avatar Feb 09 '22 03:02 ASOwnerYT

Can you try to run nvidia-xconfig as root as that sometimes does fix the problem although be prepared if any problems occur as the file generated by this command sometimes has incorrect screen ids? After running the command, if what you're seeing after a reboot is a black screen, you should open a new tty(ctrl+alt+f{any function num which doesn't point to the current boot session}) and remove the file /etc/X11/xorg.conf

DaVikingMan avatar Feb 09 '22 14:02 DaVikingMan

Also can you tell what version of kde you are using?

DaVikingMan avatar Feb 09 '22 15:02 DaVikingMan

I ran nvidia-xconfig as root and restarted my system and it seems that nothing has changed and I'm still having the screen tearing issue. My KDE Plasma version is 5.23.5

In case it helps, here's some more details from the 'About this System' section in KDE settings:

Operating System: Manjaro Linux
KDE Plasma Version: 5.23.5
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2
Kernel Version: 5.16.5-1-MANJARO (64-bit)
Graphics Platform: X11
Processors: 8 × AMD Ryzen 5 3550H with Radeon Vega Mobile Gfx
Memory: 13.7 GiB of RAM
Graphics Processor: NVIDIA GeForce GTX 1050/PCIe/SSE2

ASOwnerYT avatar Feb 10 '22 06:02 ASOwnerYT

Can you try to follow the instructions at this page(https://wiki.archlinux.org/title/NVIDIA/Troubleshooting#Avoid_screen_tearing_in_KDE_(KWin) to see if that fixes the problem?

DaVikingMan avatar Feb 10 '22 14:02 DaVikingMan

@ASOwnerYT, can you confirm if your issue has been fixed or not with the fix that I had sent you?

DaVikingMan avatar Feb 12 '22 10:02 DaVikingMan

Nope the issue still isn't fixed. I followed the instructions you sent and it didn't seem to do anything. Thanks.

ASOwnerYT avatar Feb 12 '22 21:02 ASOwnerYT

You can try the following solutions to see if one of these fixes the problem:(each numbered line represents one solution):

  1. Try running sudo envycontrol --switch nvidia --dm sddm
  2. Add export KWIN_TRIPLE_BUFFER=1 to /etc/profile
  3. Update your system(as kde plasma did have a recent update recently, although I don't know if it available in the manjaro repos but it is in the arch ones)
  4. Remove xorg.conf. Set vsync to automatic in kwin settings

DaVikingMan avatar Feb 13 '22 10:02 DaVikingMan

I am not using dual monitors, just my laptop screen. Thanks.

Hello there @ASOwnerYT, could you check if modesetting is actually enabled?

Please run:

sudo cat /sys/module/nvidia_drm/parameters/modeset

Also attach the output of this command:

xrandr --prop

Greetings.

bayasdev avatar Feb 18 '22 15:02 bayasdev

@geminis3 The output of the first command was Y, and here's the output of the second command on Pastebin: https://pastebin.com/00Xict0J

ASOwnerYT avatar Feb 19 '22 09:02 ASOwnerYT

@geminis3 The output of the first command was Y, and here's the output of the second command on Pastebin: https://pastebin.com/00Xict0J

I see the problem, PRIME synchronization isn't getting enabled automatically despite using modeset.

Can you try this command?

xrandr --output eDP-1-1 --set "PRIME Synchronization" 1

bayasdev avatar Feb 19 '22 13:02 bayasdev

I tried the command you sent, the screen went black for a few seconds and came back, and it didn't seem to fix the issue. I still have screen tearing. Sorry for the late reply.

ASOwnerYT avatar Feb 24 '22 06:02 ASOwnerYT

Can you try booting a live USB with Pop OS (Nvidia) and check if tearing also appears there?

El jue, 24 de feb. de 2022 01:58, ASOwnerYT @.***> escribió:

I tried the command you sent, the screen went black for a few seconds and came back, and it didn't seem to fix the issue. I still have screen tearing. Sorry for the late reply.

— Reply to this email directly, view it on GitHub https://github.com/geminis3/envycontrol/issues/14#issuecomment-1049550402, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALY7IYNRHZ2SJ6M5RPOAA63U4XJHRANCNFSM5NWLHLNQ . You are receiving this because you were mentioned.Message ID: @.***>

bayasdev avatar Feb 24 '22 12:02 bayasdev

Hey, i have the same issue, it's an issue with Xorg, on Wayland i have no tearing. It was first introduced (for me at least) on xorg 1.20.13. I have a Ryzen 5 4600H+GTX 1650. Here is the issue on their Gitlab, i'd love to have more people chime in with this issue. https://gitlab.freedesktop.org/xorg/xserver/-/issues/1231

CygnusTerminal avatar Feb 24 '22 22:02 CygnusTerminal

Can you try booting a live USB with Pop OS (Nvidia) and check if tearing also appears there? El jue, 24 de feb. de 2022 01:58, ASOwnerYT @.> escribió: I tried the command you sent, the screen went black for a few seconds and came back, and it didn't seem to fix the issue. I still have screen tearing. Sorry for the late reply. — Reply to this email directly, view it on GitHub <#14 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALY7IYNRHZ2SJ6M5RPOAA63U4XJHRANCNFSM5NWLHLNQ . You are receiving this because you were mentioned.Message ID: @.>

The pop os iso will also have screen tearing, the only way I found for it to fix screen tearing is to enable both Prime Synchronization and for tearfree be enabled for the amdgpu driver when using the nvidia mode and hybrid mode.

I had to create a script that that would run automatically on login in pop-os Script

Note Prime Sync will always show a zero in xrandr be it enable or not, some problems with amd driver apparently

cronyakatsuki avatar Feb 27 '22 11:02 cronyakatsuki

I have found a fix but don't know how to do pull requests or how to actually make it work in python. So in short here is what needs to be done for the nvidia mode to work without screen tearing with amd igou's.

  1. In your script you need to make the driver in the XORG_CONTENT_AMD for the amdgpu device to be amdgpu not modesetting.
  2. You will prob need to add additional variable for the XRANDR_SCRIPT since when setting the xrandr provider source it needs to be the name of the amd igpu, but since they all don't have the same name like intel first you need to get it with xrandr --listproviders

example

$ xrandr --listrprovides
Providers: number : 2
Provider 0: id: 0x1dc cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 4 outputs: 2 associated providers: 1 name:AMD Radeon Vega 8 Graphics @ pci:0000:05:00.0
Provider 1: id: 0x1b7 cap: 0x1, Source Output crtcs: 0 outputs: 0 associated providers: 1 name:NVIDIA-0

The command then needs to look like xrandr --setprovideroutputsource "AMD Radeon Vega 8 Graphics @ pci:0000:05:00.0" NVIDIA-0

  1. At this point there will be screen tearing when moving the mouse, then the user himself needs to run xrandr --output eDP-1-0 --set "PRIME Synchronization" 1 (eDP-1-0 being the name of the screen that he get's from running xrandr -q.

NOTE

I recommend any amd igpu user to also enable TearFree since it also greatly helps in removing screen tearing and allows you to play games even without a compositor with no tearing no matter the mode used. Here is a script that I recommend for anybody who has a amd + nvidia system to run when logged into the desktop environment

#!/bin/sh

mode=$(envycontrol --status | awk '{ print $5 }')
nv_screen="eDP-1-0" // screen when in nvidia mode
screen="eDP" // screen when in integrated,hybrid mode

if [ "$mode" = "nvidia" ]; then
    xrandr --output $nv_screen --set TearFree on
    xrandr --output $nv_screen --set "PRIME Synchronization" 1
elif [ "$mode" = "integrated" ]; then
    xrandr --output $screen --set TearFree on
elif [ "$mode" = "hybrid" ]; then
    xrandr --output $screen --set TearFree on
fi

cronyakatsuki avatar Feb 28 '22 18:02 cronyakatsuki