From 9de6b18d5c5281cfa05ff64f2285ba53b4f5d688 Mon Sep 17 00:00:00 2001 From: derrod Date: Thu, 18 May 2023 16:40:02 +0200 Subject: [PATCH] libobs-d3d11: Set priority to high instead of realtime if HAGS enabled --- libobs-d3d11/d3d11-subsystem.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libobs-d3d11/d3d11-subsystem.cpp b/libobs-d3d11/d3d11-subsystem.cpp index 1ccd0b48a..105aa3668 100644 --- a/libobs-d3d11/d3d11-subsystem.cpp +++ b/libobs-d3d11/d3d11-subsystem.cpp @@ -473,7 +473,7 @@ static bool increase_maximum_frame_latency(ID3D11Device *device) } #if USE_GPU_PRIORITY -static bool set_priority(ID3D11Device *device) +static bool set_priority(ID3D11Device *device, bool hags_enabled) { ComQIPtr dxgiDevice(device); if (!dxgiDevice) { @@ -482,7 +482,9 @@ static bool set_priority(ID3D11Device *device) } NTSTATUS status = D3DKMTSetProcessSchedulingPriorityClass( - GetCurrentProcess(), D3DKMT_SCHEDULINGPRIORITYCLASS_REALTIME); + GetCurrentProcess(), + hags_enabled ? D3DKMT_SCHEDULINGPRIORITYCLASS_HIGH + : D3DKMT_SCHEDULINGPRIORITYCLASS_REALTIME); if (status != 0) { blog(LOG_DEBUG, "%s: Failed to set process priority class: %d", __FUNCTION__, (int)status); @@ -596,7 +598,7 @@ void gs_device::InitDevice(uint32_t adapterIdx) /* adjust gpu thread priority on non-intel GPUs */ #if USE_GPU_PRIORITY - if (desc.VendorId != 0x8086 && !set_priority(device)) { + if (desc.VendorId != 0x8086 && !set_priority(device, hags_enabled)) { blog(LOG_INFO, "D3D11 GPU priority setup " "failed (not admin?)"); }