[host] windows: directly link D3DKMTSetProcessSchedulingPriorityClass

This function is available since Windows Vista and can therefore be used
directly without going through GetProcAddress. Unfortunately, MinGW does
not have d3dkmthk.h, but we can declare the prototype ourselves and link
against gdi32.dll.
This commit is contained in:
Quantum 2021-07-19 19:42:20 -04:00 committed by Geoffrey McRae
parent 323d321a77
commit f5ad14b109

View File

@ -504,33 +504,25 @@ finish:
return result; return result;
} }
void boostPriority(void)
{
typedef enum _D3DKMT_SCHEDULINGPRIORITYCLASS typedef enum _D3DKMT_SCHEDULINGPRIORITYCLASS
{ {
D3DKMT_SCHEDULINGPRIORITYCLASS_IDLE, D3DKMT_SCHEDULINGPRIORITYCLASS_IDLE = 0,
D3DKMT_SCHEDULINGPRIORITYCLASS_BELOW_NORMAL, D3DKMT_SCHEDULINGPRIORITYCLASS_BELOW_NORMAL = 1,
D3DKMT_SCHEDULINGPRIORITYCLASS_NORMAL, D3DKMT_SCHEDULINGPRIORITYCLASS_NORMAL = 2,
D3DKMT_SCHEDULINGPRIORITYCLASS_ABOVE_NORMAL, D3DKMT_SCHEDULINGPRIORITYCLASS_ABOVE_NORMAL = 3,
D3DKMT_SCHEDULINGPRIORITYCLASS_HIGH, D3DKMT_SCHEDULINGPRIORITYCLASS_HIGH = 4,
D3DKMT_SCHEDULINGPRIORITYCLASS_REALTIME D3DKMT_SCHEDULINGPRIORITYCLASS_REALTIME = 5,
} }
D3DKMT_SCHEDULINGPRIORITYCLASS; D3DKMT_SCHEDULINGPRIORITYCLASS;
typedef NTSTATUS WINAPI (*PD3DKMTSetProcessSchedulingPriorityClass)
(HANDLE, D3DKMT_SCHEDULINGPRIORITYCLASS);
HMODULE gdi32 = GetModuleHandleA("GDI32"); NTSTATUS APIENTRY D3DKMTSetProcessSchedulingPriorityClass(
if (!gdi32) _In_ HANDLE, _In_ D3DKMT_SCHEDULINGPRIORITYCLASS
return; );
PD3DKMTSetProcessSchedulingPriorityClass fn = void boostPriority(void)
(PD3DKMTSetProcessSchedulingPriorityClass) {
GetProcAddress(gdi32, "D3DKMTSetProcessSchedulingPriorityClass"); if (FAILED(D3DKMTSetProcessSchedulingPriorityClass(GetCurrentProcess(),
D3DKMT_SCHEDULINGPRIORITYCLASS_REALTIME)))
if (!fn)
return;
if (FAILED(fn(GetCurrentProcess(), D3DKMT_SCHEDULINGPRIORITYCLASS_REALTIME)))
{ {
DEBUG_WARN("Failed to set realtime GPU priority."); DEBUG_WARN("Failed to set realtime GPU priority.");
DEBUG_INFO("This is not a failure, please do not report this as an issue."); DEBUG_INFO("This is not a failure, please do not report this as an issue.");