Vsync stutter on Windows optimus laptop with external primary monitor

My setup is as follows: I have a laptop that I do everything on with a 1440p external monitor connected over HDMI as my primary monitor. The laptop in question is a Dell G5 5587 with i7-8750H (so Intel UHD 630 iGPU) and a GTX 1050 Ti. I believe the HDMI port is wired to the nvidia GPU directly. The monitor doesn’t support anything fancy like Gsync (it supports Freesync but I think that’s not over HDMI, that or nvidia doesn’t support it.)

It seems that when Vulkan vsyncs (both with FIFO and FIFO_RELAXED) there is significant visual stutter on the Vulkan app. OpenGL and D3D11 apps do not have this issue at all. I should also note that any Vulkan apps that selected the Intel GPU explicitly also render perfectly smoothly, even on the external monitor. It is specifically the nvidia GPU with specifically vulkan apps that stutters specifically when an external primary monitor is connected. Also using MAILBOX or IMMEDIATE also doesn’t stutter, given enough FPS. But that’s obviously not desirable.

I should note that FPS obviously stays stable at monitor refresh rate, but visual stutter is definitely visible to the naked eye. Especially when compared to non-stuttering windows.

I have also tried this with no external monitor connected. In this case everything runs totally smoothly with no stutter.

The easiest way to test this is to simply run vkcube on both GPUs (with --gpu_number) and put the two windows side by side. The window rendering with the Intel GPU is significantly smoother.

Is it possible this is a bug in the driver? Or is there something I can do to fix it.

I can provide NSight Systems traces or similar if necessary to help diagnose this.

Thank you for your report. Can you specify your OS and Nvidia driver version?
does it only reproduce when using fullscreen exclusive mode on the primary external display? or even with Windowed mode?

OS: Windows 10 Pro, 19042.1165
Driver version (just updated & rebooted): Game Ready Driver 471.68

does it only reproduce when using fullscreen exclusive mode on the primary external display? or even with Windowed mode?

No, fullscreen exclusive mode works fine on the external display, it stutters only on windowed mode. iGPU’s window is fine even when rendering side-by-side.

For reference, I was testing with Sascha Willems’s Vulkan examples, specifically with imgui (since imgui has some very smooth animating test widgets that are easy to see stutters in, specifically Widgets → Plot Widgets).

I was able to record this with OBS Display Capture (Shadowplay just seemed to produce a video that has both windows stutter despite this not being the case visually). I’d recommend you frame-step through the video (I’ve been using mpv to). About halfway through there’s two stutters when the top progress bar is at 84% and 82% going left.

I have a similar issue. I write an application for video playback in windowed Mode using Vulkan in a system with multiple monitors. VLC shows that issue too. I use GLFW for the creation of the window. I think this issue is caused by a mismatch of the VSYNC intervall of DWM.Exe and the Vulkan API. DWM that can’t be bypassed in windows 10 anymore. Is there ayn way to synchronize the VSYNC between the vulkan API with the DWM Exe?