From 6dfe56518cb8295e74e3e4aef0bc771a3c333c1e Mon Sep 17 00:00:00 2001 From: ns6089 <61738816+ns6089@users.noreply.github.com> Date: Tue, 4 Jul 2023 23:47:01 +0300 Subject: [PATCH] Decrease gpu scheduling priority for NVIDIA Fixes #1031 --- src/platform/windows/display_base.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/platform/windows/display_base.cpp b/src/platform/windows/display_base.cpp index e4483ae7..4fdf61b2 100644 --- a/src/platform/windows/display_base.cpp +++ b/src/platform/windows/display_base.cpp @@ -510,7 +510,11 @@ namespace platf::dxgi { PD3DKMTSetProcessSchedulingPriorityClass fn = (PD3DKMTSetProcessSchedulingPriorityClass) GetProcAddress(gdi32, "D3DKMTSetProcessSchedulingPriorityClass"); if (fn) { - status = fn(GetCurrentProcess(), D3DKMT_SCHEDULINGPRIORITYCLASS_REALTIME); + // Set scheduling priority to "high" for NVIDIA, or to "realtime" for other gpu vendors + // As of 2023.07, NVIDIA driver has unfixed bug(s) where "realtime" can cause unrecoverable encoding freeze or outright driver crash + // This issue happens more frequently with HAGS, in DX12 games or when VRAM is filled close to max capacity + // Track OBS to see if they find better workaround or NVIDIA fixes it on their end, they seem to be in communication + status = fn(GetCurrentProcess(), adapter_desc.VendorId == 0x10DE ? D3DKMT_SCHEDULINGPRIORITYCLASS_HIGH : D3DKMT_SCHEDULINGPRIORITYCLASS_REALTIME); if (FAILED(status)) { BOOST_LOG(warning) << "Failed to set realtime GPU priority. Please run application as administrator for optimal performance."; }