Tearing / set ForceCompositionPipeline=On for optimus system (Asus Notebook with Ryzen CPU)

Hello!

I’ve got a problem with tearing and I don’t know how to disable it. Usually it’s done by setting ForceCompositionPipeline=On but that’s not working here, as CurrentMetaMode is NULL (the nvidia GPU is set as primary device):

~> nvidia-settings -q CurrentMetaMode -t
id=50, switchable=yes, source=xconfig :: NULL

Some information about the used hardware:

# lspci | grep VGA
01:00.0 VGA compatible controller: NVIDIA Corporation TU117M [GeForce GTX 1650 Mobile / Max-Q] (rev a1)
05:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Picasso/Raven 2 [Radeon Vega Series / Radeon Vega Mobile Series] (rev c1)

~> xrandr -q
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
HDMI-0 disconnected (normal left inverted right x axis y axis)
eDP-1-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
   1920x1080     59.93*+  39.99  
   1680x1050     59.95    59.93    59.88  
   1400x1050     59.98  
   1600x900      59.95    59.82  
   1280x1024     59.93    60.02  
   1440x900      59.93  
   1400x900      59.96    59.88  
   1280x960      60.00  
   1368x768      59.88    59.85  
   1280x800      59.93    59.97    59.81    59.91  
   1280x720      59.93    59.99    59.86    59.74  
   1024x768      59.93    60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   1024x576      59.95    59.96    59.90    59.82  
   960x600       59.93    60.00  
   960x540       59.96    59.99    59.63    59.82  
   800x600       59.93    60.00    60.32    56.25  
   840x525       60.01    59.88  
   864x486       59.92    59.57  
   700x525       59.98  
   800x450       59.95    59.82  
   640x512       60.02  
   700x450       59.96    59.88  
   640x480       59.93    60.00    59.94  
   720x405       59.51    58.99  
   684x384       59.88    59.85  
   640x400       59.88    59.98  
   640x360       59.86    59.83    59.84    59.32  
   512x384       60.00  
   512x288       60.00    59.92  
   480x270       59.63    59.82  
   400x300       60.32    56.34  
   432x243       59.92    59.57  
   320x240       60.05  
   360x202       59.51    59.13  
   320x180       59.84    59.32

~> glxinfo  
name of display: :0
display: :0  screen: 0
direct rendering: Yes
server glx vendor string: NVIDIA Corporation
server glx version string: 1.4
...

~> rpm -qa | grep nvidia
x11-video-nvidiaG05-470.103.01-lp153.48.1.x86_64
nvidia-gfxG05-kmp-preempt-470.103.01_k5.3.18_57-lp153.48.1.x86_64
nvidia-glG05-470.103.01-lp153.48.1.x86_64
kernel-firmware-nvidia-20210208-2.4.noarch
nvidia-computeG05-470.103.01-lp153.48.1.x86_64
(openSUSE LEAP 15.3 with kernel 5.15.16-1.1-default)

CPU: AMD Ryzen 7 3750H with Radeon Vega Mobile Gfx

Does anybody does have any idea how to enable ForceCompositionPipeline in this special case?

TIA
nvUser66

Please try setting kernel parameter
nvidia-drm.modeset=1

I already did it - unfortunately it didn’t change anything.

I now tried to switch to offload mode and started glxgears with

__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxgears

This gave the expected framerate:

303 frames in 5.0 seconds = 60.542 FPS
300 frames in 5.0 seconds = 59.937 FPS
300 frames in 5.0 seconds = 59.931 FPS

nvidia-smi says:

# nvidia-smi 
Mon Feb  7 17:45:50 2022       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.103.01   Driver Version: 470.103.01   CUDA Version: 11.4     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   38C    P8     4W /  N/A |     10MiB /  3911MiB |     10%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A     18156      G   /usr/bin/X                          6MiB |
|    0   N/A  N/A     20006      G   glxgears                            2MiB |
+-----------------------------------------------------------------------------+

Ok, glxgears uses nvidia gpu. I tested the same with firefox and run tearing test in Youtube - worked fine. But there is an error when starting e.g. Thunderbird, because it want’s to have nouveau_dri.so:

MESA-LOADER: failed to open nouveau: /usr/lib64/dri/nouveau_dri.so

Crash Annotation GraphicsCriticalError: |[0][GFX1-]: Failed to create EGLSurface!: 0x3009 (t=2.49448) [GFX1-]: Failed to create EGLSurface!: 0x3009
Crash Annotation GraphicsCriticalError: |[0][GFX1-]: Failed to create EGLSurface!: 0x3009 (t=2.49448) |[1][GFX1-]: Failed to create EGLSurface (t=2.49454) [GFX1-]: Failed to create EGLSurface
Crash Annotation GraphicsCriticalError: |[0][GFX1-]: Failed to create EGLSurface!: 0x3009 (t=2.49448) |[1][GFX1-]: Failed to create EGLSurface (t=2.49454) |[2][GFX1-]: Fallback WR to SW-WR (t=2.51412) [GFX1-]: Fallback WR to SW-WR
IPDL protocol error: Handler returned error code!

How can I ensure, that the correct driver get’s loaded?

Some more info for offload mode:

~> xrandr -q
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
eDP connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
   1920x1080     59.93*+  39.99  
   1680x1050     59.93  
   1280x1024     59.93  
   1440x900      59.93  
   1280x800      59.93  
   1280x720      59.93  
   1024x768      59.93  
   800x600       59.93  
   640x480       59.93  
HDMI-1-0 disconnected (normal left inverted right x axis y axis)

Seems that on prime-select nvidia mode the driver doesn’t get the correct framerate because it doesn’t know enough about the screen? Is there a possibility to provide the necessary information to the driver?

TIA
nvUser66

Please run nvidia-bug-report.sh as root and attach the resulting nvidia-bug-report.log.gz file to your post.

Attached you will find the desired bug-report output.
nvidia-bug-report.log.gz (1.5 MB)

You’re using the modesetting driver, for vsyc/prime sync, you need to use the amdgpu driver. Rather delete /etc/X11/xorg.conf.d/90-nvidia.conf

If I delete 90-nvidia.conf I’m getting the pure amd interface / driver. But that’s not what I want.

Do you want to say, the only way to correctly use the nvidia GPU is the offload mode by using the above mentioned environment variables to force applications to use nvidia?

Section "ServerLayout"
    Identifier "layout"
    Screen "amd"
    Option "AllowNVIDIAGPUScreens"
EndSection

Section "Device"
    Identifier "amd"
    Driver "modesetting"
    BusID "PCI:5:0:0"
EndSection

Section "Screen"
    Identifier "amd"
    Device "amd"
EndSection

# needed for NVIDIA PRIME Render Offload
Section "Device"
  Identifier "nvidia"
  Driver "nvidia"
  BusID "PCI:1:0:0"
EndSection

xrandr -q
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
eDP connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
   1920x1080     59.93*+  39.99  
   1680x1050     59.93  
   1280x1024     59.93  
   1440x900      59.93  
   1280x800      59.93  
   1280x720      59.93  
   1024x768      59.93  
   800x600       59.93  
   640x480       59.93  
HDMI-1-0 disconnected (normal left inverted right x axis y axis)

I tested the offload mode and realized, that mpv e.g. automatically uses nvidia - even w/o setting the above mentioned environment variables.
Update: That’s not completely true. mpv uses the nvidia-libraries - but not the nvidia device. If you really want to get the output via /dev/nvidia*, you have to use the environment variables.

I attached the Xorg.0.log for offload configuration.
Xorg.0.log.gz (7.3 KB)

You don’t need to use offload mode for vsync, just the amdgpu driver instead of modesetting. You should just clean up your config files as this seems a bit messy.
Besides /etc/X11/xorg.conf.d/90-nvidia.conf you also have /etc/X11/xorg.conf.d/20-amdgpu.conf defining explicit “Section Device”. You can delete both and instead use /etc/X11/xorg.conf.d/10-nvidia-primary.conf

Section "OutputClass"
	Identifier "nvidia-primary"
	MatchDriver "nvidia-drm"
	Driver "nvidia"
        Option "PrimaryGpu" "yes"
EndSection

you can then use the primarygpu option to toggle between offload and primary mode.

1 Like

That’s a very friendly description … .

I followed your suggestion and it works perfectly! It’s much easier as expected - but that’s pretty often if you know what you’re doing … .

I “fixed” suse-prime 0.8.5 as attached in prime.tar.gz (it’s the directory in /usr/share/) and removed some historical config files in /etc/X11/xorg.conf.d/.
The xorg.conf.d.tar.gz contains the device specific configuration for amd only, nvidia only and offload mode after using prime-select amd | nvidia | offload.

A bit strange: starting firefox (96.0.1) in offload mode using the offload environment variables

export __NV_PRIME_RENDER_OFFLOAD=1
export __GLX_VENDOR_LIBRARY_NAME=nvidia

leads to

[GFX1-]: Fallback WR to SW-WR

Using nvidia only, it’s working fine (no fallback messages appear).

Many thanks for your very friendly help!

Btw 1: the original problem, setting ForceCompositionPipeline isn’t need any more, as the refresh rate detection problem is solved. But

~> nvidia-settings -q CurrentMetaMode -t
id=50, switchable=yes, source=xconfig :: NULL

in nvidia mode e.g. still doesn’t work - but that’s not a problem any more for me at this time.

Btw 2: Meanwhile I switched to nvidia 510.47.03.

xorg.conf.d.tar.gz (717 Bytes)
prime.tar.gz (1.0 KB)

Options like ForceCompositionPipeline and MetaModes only apply to displays directly connected to the nvidia gpu. The internal display of your laptop is connected to the amd gpu, so those options have no effect on that.

1 Like

Perfectly. After connecting a screen to the HDMI interface, I’m getting a value different of NULL:

~> nvidia-settings -q CurrentMetaMode -t                                           
id=50, switchable=yes, source=RandR :: DPY-0: nvidia-auto-select @2560x1440 +1920+0 {AllowGSYNC=Off, ViewPortIn=2560x1440, ViewPortOut=2560x1440+0+0}

> xrandr -q
Screen 0: minimum 8 x 8, current 4480 x 1440, maximum 32767 x 32767
HDMI-0 connected 2560x1440+1920+0 (normal left inverted right x axis y axis) 597mm x 336mm
   2560x1440     59.95*+
   2048x1280     60.00  
   1920x1200     59.88  
   1920x1080     60.00    59.94    50.00  
   1680x1050     59.95  
   1600x1200     60.00  
   1600x900      60.00  
   1440x900      59.89  
   1280x1024     75.02  
   1280x720      60.00    59.94    50.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    59.94    59.93
...

I tested tearing with this screen and - yes, there is massive tearing. I fixed it with

nvidia-settings -a CurrentMetaMode="DPY-0: nvidia-auto-select @2560x1440 +1920+0 {AllowGSYNC=Off, ViewPortIn=2560x1440, ViewPortOut=2560x1440+0+0, ForceCompositionPipeline=On}"

Is there a chance to get this config statically to a cfg file (even if there isn’t any screen connected)? How would it look like?

Just change the config file from my post to

Section "OutputClass"
    Identifier "nvidia-primary"
    MatchDriver "nvidia-drm"
    Driver "nvidia"
    Option "PrimaryGpu" "yes"
    Option "ForceCompositionPipeline" "true"
EndSection

This will enable it on all monitors you connect to the nvidia gpu.

1 Like

Works perfectly. Thanks!

During tests I realized a problem regarding S2RAM / resume with Thunderbird (91.5.0) running nvidia PRIME. The Thunderbird window stays empty or black - or it contains the content of the overlaying window and can’t be refreshed after resume. Even minimizing it or changing the size of the window doesn’t solve the problem. I have to restart Thunderbird to get it working again. Is this a known problem?
Maybe kwin could trigger the problem - because on every resume (with nvidia graphics) I get a message like that, that the desktop effects would have been restarted.

Please see this:
https://download.nvidia.com/XFree86/Linux-x86_64/495.44/README/powermanagement.html
so you need to enable the three systemd units and set the module parameter. Though there seems to be a bug with this on drivers 495/510, so YMMV.

The complete nvidia specific systemd configuration was laid out - but not activated. I activated those three services and added the NVreg_PreserveVideoMemoryAllocations=1 kernel module.
The “restarted desktop effects” notification disappeared - but the problem regarding Thunderbird didn’t change (surprisingly it worked 2 times). Therefore I started Thunderbird in konsole and got this Error:

Crash Annotation GraphicsCriticalError: |[0][GFX1-]: GFX: RenderThread detected a device reset in PostUpdate (t=35.9602) [GFX1-]: GFX: RenderThread detected a device reset in PostUpdate
IPDL protocol error: Handler returned error code!

Maybe interesting: if you blindly click to a global menu entry (like file e.g.), the related pull down menu can be seen. You’re even getting a new mail window to write a new mail e.g.

KDE detects this problem, too, but obviously can handle the problem better.

Feb 08 17:18:53 notebook4 kglobalaccel5[19571]: Crash Annotation GraphicsCriticalError: |[0][GFX1-]: GFX: RenderThread detected a device reset in PostUpdate (t=95.777) [GFX1-]: GFX: RenderThread detected a device reset in PostUpdate
Feb 08 17:18:53 notebook4 kglobalaccel5[19510]: [GFX1-]: GFX: RenderThread detected a device reset in PostUpdate

Nvidias documentation recommends to use hibernate instead of sleep - but that doesn’t work on a “lockdowned” kernel.

Ok - not a big problem - but maybe there will be a solution some day.

Like said, it’s just a bug in current drivers, is working with 470 so will/should be fixed in a future driver update.

Unfortunately same behavior with 470.103.01. Seems to be another problem (nvidia-glG05-470.103.01-lp153.48.1.x86_64, … from here).

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.