veldrid icon indicating copy to clipboard operation
veldrid copied to clipboard

[D3D11] Use FlipSequential instead of Discard on Win8+?

Open RaZeR-RBI opened this issue 2 years ago • 3 comments

Greetings! After a bit of testing of my project on Windows 10, I've noticed that I get increased frame latency while running in windowed mode on D3D11. I've measured it through PresentMon CLI, which told me that the swapchain uses GPU GDI copy for compositing with latency before displaying (msUntilDisplayed) hovering around 45 ms. After replacing SwapEffect.Discard with SwapEffect.FlipSequential for Win32SwapchainSource (so it's now just like the UWP one), latency dropped to 30 ms, so given my display refresh rate the net result is about one frame less latency.

I'm not much experienced with D3D (I've worked mostly with OpenGL), so I'm not aware of any shortcomings to this except that it's seem to be incompatible with Win7 according to docs (which is probably due to DWM changes between versions if I understand correctly).

The question is, can we add a Windows version check to D3D11Swapchain so it will use FlipSequential if running on Win8+ for better performance?

RaZeR-RBI avatar Aug 25 '23 09:08 RaZeR-RBI

I've just found out that there's a related pull request #484, though it doesn't contain a version check, so it'll break on Win7.

RaZeR-RBI avatar Aug 25 '23 09:08 RaZeR-RBI

Of note, we fixed the breakage and are using it in production on our fork (see: https://github.com/ppy/veldrid/pull/25)

@smoogipoo maybe push this to #484 if it's a quick cherry pick?

peppy avatar Aug 25 '23 09:08 peppy

It's a bit more than a cherry pick, but I've ported the fix to #484 .

smoogipoo avatar Aug 25 '23 12:08 smoogipoo