NVENC performance drops when direct x game becomes active window

So. whenever a directx game becomes an active window, encoder performance greatly drops. going from 6ms to 70~ ms. if ther is some form of “windows” overlay on top (ex: alt+tab overlay) the still runs without droping frames in the background and the encoder also works flawlessly.

I’m using desktop duplication api and copying the frame to different texture before sending it to encoder.
Encoder running in synchronous mode.

looks like when a game is the active window, the driver is applying some sort of limiters on other functions of gpu. Can someone please help me debug this issue.

Hi, I’m a little new to video encoding and some direction towards debugging this issue is greatly appreciated.

I’m using

RTX 2070 super
VideoCodec SDK 11
Mode: Async / Sync (tried both)

Encode time while on desktop / video playback etc is 4-6 ms
Encode time while a “game” application is the active window - 16- 78 ms

I’m encoding one frame at a time without buffering. I’m not looking for maximum performance but least latency and Possibly variable framerate based on client and / or network performance degradation. hence this approach.

If this is done by drivers as a way to increase game performance, is there a way i can override this functionality? if not, can you suggest a different approach.

In case someone is looking at this later, The culprit was Windows 10 GAME MODE. It prioritizes game threads over every other GPU related threads.

turning it off, restarting, and setting gpu thread priority fixed my issue. the avg encode time was still higher but it’s now at 8-12ms instead of ~40ms