itsmikethetech / Virtual-Display-Driver

Add virtual monitors to your windows 10/11 device! Works with VR, OBS, Sunshine, and/or any desktop sharing software.
1.97k stars 89 forks source link

Causes performance issues with Sunshine streaming #36

Open epsilon-a opened 5 months ago

epsilon-a commented 5 months ago

I installed this in order to do Sunshine streaming when my monitor is turned off. Unfortunately it causes performance issues on the receiving client side, my guess is there is some problem during the encoding/frame capture step. I get consistent stuttering, wild frame rate fluctuations (the host performs perfectly), often some audio distortion too. I already played around with all the Sunshine and Moonlight settings, it's down to this driver. When I test the streaming without this driver, while my monitor is on (it's only required to be on to initialize the capture), the stream performance is flawless and only limited by network stability.

Seems like I will have to go the hardware dummy plug route, so that I'm just directly interfacing with the Nvidia driver.

Jaxsown commented 5 months ago

Same issue, incoming frame from network drop to around 40 or 50 fps when host has 60 fps at the same moment. With a monitor on, both stick to 60 fps

epsilon-a commented 5 months ago

Same issue, incoming frame from network drop to around 40 or 50 fps when host has 60 fps at the same moment. With a monitor on, both stick to 60 fps

If you're fine with spending a few bucks, just go the HDMI dummy plug route. Get any random HDMI dummy plug, cheapest one, if you can make sure it has no flash write protection then get it, if it's write protected, you can do a simple hardware mod that takes 5 minutes, cutting the write protection pin. You flash that plug with the EDID of something like an LG OLED which supports 4K 120Hz (or higher) and HDR. Then you need to get a dp 1.4 to hdmi 2.1 adapter for it to work fully. I did that and it works perfectly. My guess is that virtual solutions like this one which have an additional driver layer will always have some performance issues.

Jaxsown commented 5 months ago

Thanks ! Did you try a displayport dummy plug directly instead of hdmi dummy + dp to hdmi ?

epsilon-a commented 5 months ago

Thanks ! Did you try a displayport dummy plug directly instead of hdmi dummy + dp to hdmi ?

You cannot flash DP dummy plugs so you are stuck with whatever their firmware allows in terms of HDR and resolution, refresh. They're also fewer.

HerringTheCoder commented 5 months ago

I can confirm the issue above. Sunshine + Moonlight is stuttering badly with this driver (RTX 3080). Ended up streaming from my main display (it has to be on though) and it works flawlessly.

dimitrij2k commented 5 months ago

I bought a cheap HDMI Switch with 2 Ports - just one HDMI connected... before i stream over sunshine, i switch hdmi to the empty port...

HerringTheCoder commented 5 months ago

@dimitrij2k Doesn't it make the stream freeze? Unless you are saying that you are still using virtual screen and that's your way of switching the main desktop. The issue of the topic is how to mitigate performance issues and the only sane option seems to be avoiding the virtual display for now.

DistractionRectangle commented 4 months ago

I was having some pretty jarring issues with sunshine + monitorswapautomation + this, but after a bit of fiddling, I found disabling 'Hardware Accelerated GPU scheduling' under Settings > System > Display > Graphics > Default Graphics Settings followed by restarting the PC fixed streaming from the Virtual Display Driver

kayti commented 4 months ago

I was having some pretty jarring issues with sunshine + monitorswapautomation + this, but after a bit of fiddling, I found disabling 'Hardware Accelerated GPU scheduling' under Settings > System > Display > Graphics > Default Graphics Settings followed by restarting the PC fixed streaming from the Virtual Display Driver

HAGS is causing stutter and low performance for sunshine when GPU is under heavy load or/and heavy vram load. So generally should be disabled for best performance of stream. Didn't check if VDD has additional problem with it.

HerringTheCoder commented 4 months ago

For me disabling HAGS has never improved anything related to the framerate stability while using this driver, though it can sometimes resolve Sunshine-related issues.

DistractionRectangle commented 4 months ago

HAGS is causing stutter and low performance for sunshine when GPU is under heavy load or/and heavy vram load. So generally should be disabled for best performance of stream. Didn't check if VDD has additional problem with it.

In my case, the out of the box sunshine stream was just fine (with HAGS on). I was testing with 1920x1080x60, doing lightweight tasks like playing 1080p 60fps youtube video fullscreen and couple of games on my 3080. All far from high utilization//vram usage and all performed fine streaming direct from my monitor. However, the stream was stuttery, blurry, and high latency when using VDD. Since there are varying reports - some good, some bad - about using VDD with sunshine, I figured it was perhaps a conflict//configuration problem and played around various ways to "optimize" sunshine, trying both from VDD and from direct from my monitor as a control.

The problem completely disappeared when I disabled HAGS and rebooted. So sample size of 1, but IMO there's probably perhaps an underlying conflict with HAGS and VDD, as it's both resolved and reproducible on my machine. Turning it back on makes the problem return.

Win 11 Pro, 22621.3085, 5700G + 3080 10G + 32GB 3200cl16 ram.

DistractionRectangle commented 4 months ago

So I had a little time to play with this + sunshine further, and I agree - HAGS isn't the core problem, it just compounded with the underlying problem. With a 60FPS stream frame paced by Rivatuner Statistics Server, and VDD set to 1920x1080x60FPS I was getting a consistent stutter, which I initially chalked up to a network issue. I took this morning to setup everything over ethernet, and that took care of an stuttering when streaming direct from my monitor, but the stutter remained when streaming from VDD.

This went away once I bumped the refresh rate of VDD to be larger than the desired FPS - with RTSS frame pacing at 60FPS, moonlight set to 60 FPS, and VDD set to higher refresh rate - the stuttering disappears. I just leave VDD set to 165Hz now and just adjust the resolution based on the client now.

This leads me to believe there is a timing issue which causes one or more frames to get dropped.

ScraggyMcRaggy commented 4 months ago

So I had a little time to play with this + sunshine further, and I agree - HAGS isn't the core problem, it just compounded with the underlying problem. With a 60FPS stream frame paced by Rivatuner Statistics Server, and VDD set to 1920x1080x60FPS I was getting a consistent stutter, which I initially chalked up to a network issue. I took this morning to setup everything over ethernet, and that took care of an stuttering when streaming direct from my monitor, but the stutter remained when streaming from VDD.

This went away once I bumped the refresh rate of VDD to be larger than the desired FPS - with RTSS frame pacing at 60FPS, moonlight set to 60 FPS, and VDD set to higher refresh rate - the stuttering disappears. I just leave VDD set to 165Hz now and just adjust the resolution based on the client now.

This leads me to believe there is a timing issue which causes one or more frames to get dropped.

Great suggestion. This has helped me too. No matter what FPS I set on my client, the game would always run worse. For example I would set moonlight to 90FPS and get 70-80. Then I'd set it to 60 and get 50-60. Even turning down graphics settings way below my PC's capabilities (4090/13900k) didn't help.

Setting my VD to 120hz and keeping everything else capped at 90 has fixed this.

Nonary commented 4 months ago

Thanks ! Did you try a displayport dummy plug directly instead of hdmi dummy + dp to hdmi ?

You cannot flash DP dummy plugs so you are stuck with whatever their firmware allows in terms of HDR and resolution, refresh. They're also fewer.

I’m sorry but where did you get this idea? I’ve flashed display port dummy plugs, in fact I have guided dozens of users. This whole flashing process became popular due to my guides on moonlight discord…

Jaxsown commented 4 months ago

So I had a little time to play with this + sunshine further, and I agree - HAGS isn't the core problem, it just compounded with the underlying problem. With a 60FPS stream frame paced by Rivatuner Statistics Server, and VDD set to 1920x1080x60FPS I was getting a consistent stutter, which I initially chalked up to a network issue. I took this morning to setup everything over ethernet, and that took care of an stuttering when streaming direct from my monitor, but the stutter remained when streaming from VDD.

This went away once I bumped the refresh rate of VDD to be larger than the desired FPS - with RTSS frame pacing at 60FPS, moonlight set to 60 FPS, and VDD set to higher refresh rate - the stuttering disappears. I just leave VDD set to 165Hz now and just adjust the resolution based on the client now.

This leads me to believe there is a timing issue which causes one or more frames to get dropped.

I'll try that thanks, do you have a good framepacing with vsync on ? Wouldn't it be better to have an even multiple of your framerate ? 120hz for 60 fps 240hz for 120fps...

DistractionRectangle commented 4 months ago

I'll try that thanks, do you have a good framepacing with vsync on ? Wouldn't it be better to have an even multiple of your framerate ? 120hz for 60 fps 240hz for 120fps...

I don't run vsync on the host, just the client, frame pacing is handled purely with RTSS. Probably setting it to 240 would be best; I settled on 165hz because I first tried to emulate the same settings as my physical monitor and once that worked only tried to change the resolution to match the client. I didn't really experiment after that aside from toggling between 60hz and 165hz to confirm the stuttering was indeed related to emulated refresh rate in VDD.

Jaxsown commented 4 months ago

I tested 90 and 120hz in vdd host rtss at 60 vsync off and client at 60 moonlight vsync on and it's a perfect framepacing without frame drop ! Thanks again it solve my performances issues.

harun911 commented 3 months ago

Same issue, incoming frame from network drop to around 40 or 50 fps when host has 60 fps at the same moment. With a monitor on, both stick to 60 fps

If you're fine with spending a few bucks, just go the HDMI dummy plug route. Get any random HDMI dummy plug, cheapest one, if you can make sure it has no flash write protection then get it, if it's write protected, you can do a simple hardware mod that takes 5 minutes, cutting the write protection pin. You flash that plug with the EDID of something like an LG OLED which supports 4K 120Hz (or higher) and HDR. Then you need to get a dp 1.4 to hdmi 2.1 adapter for it to work fully. I did that and it works perfectly. My guess is that virtual solutions like this one which have an additional driver layer will always have some performance issues.

Can you link me to a source where I could perform such a hardware mod, I've got three dummy plugs, but they're all writeprotected. What write protection pin would I need to cut?

epsilon-a commented 2 months ago

Same issue, incoming frame from network drop to around 40 or 50 fps when host has 60 fps at the same moment. With a monitor on, both stick to 60 fps

If you're fine with spending a few bucks, just go the HDMI dummy plug route. Get any random HDMI dummy plug, cheapest one, if you can make sure it has no flash write protection then get it, if it's write protected, you can do a simple hardware mod that takes 5 minutes, cutting the write protection pin. You flash that plug with the EDID of something like an LG OLED which supports 4K 120Hz (or higher) and HDR. Then you need to get a dp 1.4 to hdmi 2.1 adapter for it to work fully. I did that and it works perfectly. My guess is that virtual solutions like this one which have an additional driver layer will always have some performance issues.

Can you link me to a source where I could perform such a hardware mod, I've got three dummy plugs, but they're all writeprotected. What write protection pin would I need to cut?

image

The one inside the dummy plugs is SOT-23