ImguiSystem: fix input latency caused by mutex

There were reports of high input latency even though we implemented NVIDIA Reflex and AMD Anti-Lag 2.
The reason for this increased latency was because CThreadFastMutex was being used in the window procedure instead of a CThread mutex.

The contention for CImguiSystem::m_systemInitState in CImguiSystem::MessageHandler() is high, and therefore we should not use CThreadFastMutex as its only effective  in its fastness when the contention isn't high. Using CThreadMutex instead resulted in an extreme reduction of input latency.
This commit is contained in:
Kawe Mazidjatari 2024-11-14 23:28:47 +01:00
parent b88ed6d5cb
commit a331d43488

View File

@ -56,13 +56,13 @@ private:
// Mutex used during swapping and rendering, we draw the windows in the
// main thread, and render it in the render thread. The only place this
// mutex is used is during snapshot swapping and during rendering
mutable CThreadFastMutex m_snapshotBufferMutex;
mutable CThreadMutex m_snapshotBufferMutex;
// Mutex used between ImGui window procedure handling and drawing, see
// https://github.com/ocornut/imgui/issues/6895. In this engine the window
// is ran in thread separate from the main thread, therefore it needs a
// lock to control access as main calls SampleFrame().
mutable CThreadFastMutex m_inputEventQueueMutex;
mutable CThreadMutex m_inputEventQueueMutex;
};
CImguiSystem* ImguiSystem();