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.
  • 66,586
  • 6
  • 89
  • 146
Michael Chourdakis
  • 9,693
  • 2
  • 38
  • 66
  • 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

11

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.
  • 66,586
  • 6
  • 89
  • 146
  • 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