56 points · by HugoDaniel · 5y ago · 23 comments
AFAIK you can avoid it by using DXGI flip model.
random page:
>(DXGI) Flip Model is a new mode introduced in Windows 8 that makes the SwapChain work efficiently with the Windows DWM (Desktop Window Manager). Flip Model eliminates performance penalties normally associated with windowed mode rendering and introduces new methods to measure and regulate render latency.
There is a flag DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING which can completely eliminate DWM's latency even for normal composited windows, but it only functions on systems with hardware overlays, which are not supported on Nvidia or AMD.
If the flip triggered composite finishes before vsync, you could also let a second flip trigger a new composite, etc. If your windows do a lot of flipping between vsyncs, you could burn a lot of cpu/gpu time compositing, but latency improvement would be worth it, at least for some applications.
Edit: I have seen a lot of negative opinions on tripple buffering, but they seem to be related to increased latency as a result of implementations that wouldn't drop rendered frames, even when two frames were rendered between vsyncs. That's a silly thing to do, so I assume a triple buffered DWM wouldn't do that.
What about Intel and Matrox?
What about desktop compositors for Linux? And the macOS compositor? (Not that macOS is pleasant to use with a mouse...)
If we can just teach audiences to clap one sixteenth-note later than usual then all live music could go completely digital!
Exclusive fullscreen applications shouldn't need any compositing, surely they must be exempt from that.
There is also a feature designed to let applications bypass this delay in windowed mode using GPU hardware overlays, however it needs GPU driver support and it is not supported on Nvidia or AMD drivers AFAIK. Basically nobody uses it.
While investigating cursor lag issues on my computer (which were caused by an errant Intel Optane card, of all things...) I read through Windows’ video driver documentation and I learned that while Windows does direct the mouse pointer completely independently of the DWM, there is no requirement that the cursor be rendered during scanout (like a hardware sprite) and it is permissible for a GPU to render the pointer to the framebuffer. In fact, there’s a lot that’s undefined by the specs - for example, I used to believe there was a hard limit of 127x127 on cursor sizes (based on the ICO file format) but it turns out there is no upper-limit on cursor sizes at all. If you set a huge cursor image (say, 1500x1500px) some GPUs do render it to the framebuffer but others do not (in my testing, newer Radeon cards behaved differently if the image was above ~600px, whereas with my Nvidia cards anything over 255x255 had a different mouse-acceleration curve, that was weird)
Other tests, including on the same site, are able to get the real-time hardware cursor position which the test code knows is ahead of the last-drawn cursor position and whatever position it’s drawing right now.