-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix unexpected format switching in display_vram #667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit as-is doesn't seem to cause any noticeable problems with my AMD card & SDR only setup, but it has a bad interaction when tested together with #660 (so feel free to disregard in case you are aware) using the When connecting to the host with no significant movement on-screen, the first frame received will look OK, but moving the mouse will trigger a full black frame to display and then the desktop image again, which repeats with each successive mouse movement for perhaps 3-5 seconds, and then the video will appear to stabilize with no further black frames being inserted. There is no log activity when this happens. Edit: I also attempted to enable debugging via the |
Ok, thanks for testing. I think I'm going to take a different approach with #660 and try using 2 separate ID3D11Device objects (one for capture and one for encode) then pass textures between them using
Yeah, I think certain fatal errors (like synchronization issues) will cause the debug runtime to raise an exception that will kill the process without a debugger attached. If you attach to sunshine.exe with WinDbg, it will show you debug messages from the debug runtime. |
189d441
to
9c419ff
Compare
While I was redoing #660, I figured out what the problem was and it was indeed a bug in this PR, though one that's only likely to show up with |
9c419ff
to
d822a22
Compare
I pushed an additional fix for an issue in #654 that I discovered when testing my parallel encoding work. We don't actually want to fall back to There are temporary reasons that desktop duplication fails (such as being in the middle of a modeset operation or the secure desktop being displayed when not running as service). If we happen to fail our 2 tries of |
This can lead to suboptimal capture performance.
ffc131f
to
fb75eb9
Compare
Description
I think I finally figured out what's going on with the unexpected capture format changes. It looks like DWM will cheat by using a surface that is in the desktop format until a frame is returned that that has
LastPresentTime != 0
(which requires the DWM to convert the surface into the format we asked for).Due to this behavior, #654 introduced a bug that would cause the surface format to constantly flip-flop between the requested capture format (when the desktop is updated) and the desktop format (when returning a cursor-only update). This format-switching happened constantly when requesting
DXGI_FORMAT_R10G10B10A2_UNORM
which led to very poor performance due to constantly reinitializing the capture session. This issue wasn't visible when we tested #654 becausedisplay_vram
reported support for both R8G8B8A8 and B8G8R8A8 desktop formats, so the desktop format always matched the capture format.To address this, I've added an intermediate texture (similar to the staging texture
display_ram
uses) to store a copy of the last captured desktop frame. IfLastPresentTime == 0
, we copy from that frame instead ofsrc
.Screenshot
Issues Fixed or Closed
Type of Change
.github/...
)Checklist
Branch Updates
LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.