Reduce GdiEngine input latency (#15608)

This commit reduces GdiEngine's average display latency by 8ms,
which caused it to miss a v-blank about half the time at 60Hz.

Closes #15607

## Validation Steps Performed
Input latency with `frarees/typometer` matches conhost from Win10 
This commit is contained in:
Leonard Hecker
2023-06-28 00:14:42 +02:00
committed by GitHub
parent 99c18ce57e
commit 72b44888b5

View File

@@ -169,6 +169,11 @@ DWORD WINAPI RenderThread::_ThreadProc()
{
while (_fKeepRunning)
{
// Between waiting on _hEvent and calling PaintFrame() there should be a minimal delay,
// so that a key press progresses to a drawing operation as quickly as possible.
// As such, we wait for the renderer to complete _before_ waiting on _hEvent.
_pRenderer->WaitUntilCanRender();
WaitForSingleObject(_hPaintEnabledEvent, INFINITE);
if (!_fNextFrameRequested.exchange(false, std::memory_order_acq_rel))
@@ -209,10 +214,7 @@ DWORD WINAPI RenderThread::_ThreadProc()
}
ResetEvent(_hPaintCompletedEvent);
_pRenderer->WaitUntilCanRender();
LOG_IF_FAILED(_pRenderer->PaintFrame());
SetEvent(_hPaintCompletedEvent);
}