How to give GPU priority to my process?

Recently we find out that it seems there some priorities in OS. So, for example, our application uses GPU for rendering (not so much). And then I run benchmark that also loads GPU (uses most of GPU power). When I switch to our application - I can get stable 60fps, but when I switch to benchmark app - I can not get this anymore (app stuck in IDXGISwapChain::Present even with disabled vsync). I was able to make some fixes and produce stable 60fps still while app in background. But when I start to render video in our app I can not get 60 fps anymore in background, app stuck (spend all thread time) in ID3D11DeviceContext::Flush. But everything fine when I make app in foreground. It seems GPU executes D3D instructions too slow when app is in background. Is there some way to give priority to our application in background so it will use GPU as much as it needs?

1 Like

It seems I find already API that I need. Will check.

It seems SetGPUThreadPriority did not help much. Our situation is following. We run some game that loads GPU and make game window in focus. At same time our app running in background.

  1. Our app renders 4K 60fps in background and can get stable 60fps without rendering to screen (using ID3D11DeviceContext::Flush). Rendering takes 5-10% of render thread time, all remaining time in waiting.

  2. When app renders to screen (using IDXGISwapChain::Present), render thread spends most time in Present call and FPS drops.

  3. No rendering to screen. When app renders HD video (VMR9, EVR, MediaFoundation Engine methods), video updates much slower than other content and render thread spends most time in ID3D11DeviceContext::Flush. It seems DXVA processing in renderers depends somehow from GPU load.

No issues when our app renders in FullHD.
Is there some way to give priority to our background app?

I have very similar issue, unfortunatelly I can’t find a solution for that :( If anyone ever comes up with something, please do share. Thanks!

For me the issue was Windows 10 GAME MODE which overprioritizes game threads when running in foreground. turning it off and rebooting fixed issue for me.