6

There is an option in Windows control panel that allows to set a app to "high performance". Control Panel -> System -> Display -> Graphics Settings.

On adding my application there, I noticed that, when encoding with Media Foundation and H.265 it uses the NVIDIA gfx adapter for encoding. Before that, it used to use the embedded Intel graphics which would only do H.264 encoding, so H.265 encoding was slowly done in CPU.

How can I add my application there programmatically? It's crucial for my sequencer's performance.

Thanks a lot.

Graphics Settings

Roman R.
  • 68,205
  • 6
  • 94
  • 158
Michael Chourdakis
  • 10,345
  • 3
  • 42
  • 78
  • 1
    I can't confirm right now, but I think Windows also honors those NVIDIA and AMD tricks: https://gist.github.com/statico/6809850727c708f08458 as dxgi.dll, d3d9.dll and opengl32.dll contain those magic strings. – Simon Mourier Jan 14 '20 at 11:42
  • 2
    @SimonMourier: sadly, these tricks are one way only, these can only enforce discrete GPU preference. – Roman R. Jan 14 '20 at 13:27

1 Answers1

12

To my best knowledge there is no API or documentation for this. The preference is, however, kept in registry under

HKEY_CURRENT_USER\Software\Microsoft\DirectX\UserGpuPreferences

String value with GpuPreference part and integer value corresponding DXGI_GPU_PREFERENCE enumeration.

If you set the value there programmatically, it is picked up with next app restart. The parent UserGpuPreferences and DirectX keys might not exist, so you need to make sure they are present too.

Also, to my best knowledge, this preference takes precedence over possibly existing similar preference setting in vendor (AMD, NVIDIA) specific settings.

See also:

Example

If your application is C:\testapp.exe, you want to create the following registry entry:

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\DirectX\UserGpuPreferences]
"C:\\testapp.exe"="GpuPreference=1;"

Or another way is to add the override interactively using settings and then review the created registry value.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • 1
    NOTE: It looks like this key may or may not already be there on any given machine. That threw me at first, but the usual Direct3D stuff is under HKLM (not HKCU). So, you may need to create the key under HKCU in addition to adding a value under it. – Scott Smith Sep 16 '20 at 16:55
  • I have tried this solution... and it doesn't work correctly. –  Jul 12 '22 at 19:21
  • for example in my application I have added a code; which on startup is supposed to add both the executable and another executable of the thread to the hig performance profile –  Jul 12 '22 at 19:23
  • i have restarte the app –  Jul 12 '22 at 19:24
  • The problem is that it does not recognize it as such. I have looked at the windows 11 task manager that shows what graph it is using... and it always marks #0... –  Jul 12 '22 at 19:24
  • Out of curiosity, enter the application preference manager in the graphic section and I have managed to verify that they do appear. –  Jul 12 '22 at 19:25
  • then try to open the application for the third time and then it came to use dedicated GPU #1 according to the task manager ... –  Jul 12 '22 at 19:25
  • any idea why this peculiarity? –  Jul 12 '22 at 19:26
  • I'd expect this method to be in good standing for Windows 11, even though it's not really clear what exactly does not work for you. I have a small tool here https://alax.info/blog/1987 which adds itself into registry the way suggested in this asnwer. Maybe you can try it out and see if it works (and than the method is assumed to be applicable to your system). – Roman R. Jul 12 '22 at 19:30