Screen Tearing with Games on linux using wine/steam

I am using docker-nvidia-egl-desktop to launch containers (base on Xvfb virtual display) on a headless server having NVIDIA RTX 4090 card , and streaming using webrtc . When I launch games using wine/lutris with Xvfb resolution set to 1080p or higher, screen tear is visible in the center of the screen. But for resolutions 720p or lower no screen tear is visible. How can the VSync /ForceFullCompositionPIpeline=true be set for the virtual display (Xvfb) to solve the screen tearing problem. Please help to resolve the screen tearing problem.
Thanks
Srinidhi

@aplattner I would like to refer this issue to you, since you were the point of contact in Headless Vulkan with multiple GPUs.
CC @amrits

The issue happens in 560.35.03 and 570.86.16.

Container toolkit version:

NVIDIA Container Toolkit CLI version 1.17.4
commit: 9b69590c7428470a72f2ae05f826412976af1395
GL_RENDERER   = NVIDIA GeForce RTX 4090/PCIe/SSE2
GL_VERSION    = 4.6.0 NVIDIA 560.35.03
GL_VENDOR     = NVIDIA Corporation

The methodology being incorporated here is identical to the virtual Vulkan X11 swapshain described in Headless Vulkan with multiple GPUs - #15 by aplattner and Headless Vulkan with multiple GPUs - #9 by aplattner.

More references: Screen Tearing with Nvidia RTX 4090 , Xvfb and VGL · Issue #273 · VirtualGL/virtualgl · GitHub

Below, Final Fantasy VII Remake is used with the flag -d3d11 by @srinidhikrs, which uses DXVK.

(1) So in short, the issue is a massive level of tearing when using a virtual X11 server, such as Xvfb, combined with the above virtual Vulkan X11 swapchain. Here, NVIDIA_DRIVER_CAPABILITIES=all was used, as omitting graphics or display obviously does not work at all in an unprivileged environment.

Results of running some basic tests:

nonprivileged.zip (7.6 KB)

(1-1) Tearing persists when -e VKD3D_FRAME_RATE=60 -e DXVK_FRAME_RATE=60 were added to the above configuration (see Number 3 for why I added this).

Results:

dxvknonprov.zip (7.6 KB)

(2) The tearing issue happening above does not exist when using an Xorg server with nvidia Xorg drivers. So it is only an issue in combination with the virtual Vulkan X11 swapchain plus a virtual X11 server such as Xvfb. Here, NVIDIA_DRIVER_CAPABILITIES=all was used.

Using the Xorg server with nvidia Xorg drivers (great glxgears -info framerate with no tearing issues):

glx_display_graphics.zip (6.0 KB)

(3) One interesting additional finding was that for some reason, when using --privileged with Docker, and when using a virtual X11 server (Xvfb) with the virtual Vulkan X11 swapchain, where only -e NVIDIA_DRIVER_CAPABILITIES=video was used in Docker with --runtime=nvidia/--gpus 1 (most critical part being where there is no display or graphics in NVIDIA_DRIVER_CAPABILITIES), there was no tearing with the VKD3D/DXVK workload, along with a subtle (about 20%) increase in frames for glxgears -info.

However, GPU usage on RTX 4090 spikes to 70% for the Final Fantasy VII Remake game (indicating a suboptimal rendering path?). This is the result for the videoonly folder in the below egltest.zip file.

When -e VKD3D_FRAME_RATE=60 -e DXVK_FRAME_RATE=60 were added to the above configuration, the GPU usage came back to 18-20%, still without any tearing, which is a good thing to see.

(4) However, there was substantial tearing happening when either display or graphics got included in NVIDIA_DRIVER_CAPABILITIES, when using --privileged with Docker with --runtime=nvidia /--gpus 1, and when using a virtual X11 server (Xvfb) with the virtual Vulkan X11 swapchain, but the GPU usage on RTX 4090 was stable at 18-20%. In contrast, glxgears -info framerates slightly decreased by around 20% compared to Number 3. The results for this scenario are all the other folders than the videoonly folder in the below egltest.zip file.

Results of running basic tests when using --privileged with Docker:

egltest.zip (28.9 KB)