Users complained my app (uses Direct3D 11 to render some heavy 3D content for a CAD-like functionality) runs on Intel GPU on a dual-GPU systems.
Found that NvOptimusEnablement
/ AmdPowerXpressRequestHighPerformance
exported variables. However, the application has .NET frontend, can’t export things from there. While there’s some workaround, that recompilation step breaks debugger (can't set breakpoints anymore) and invalidates debug symbols, and I need them both to work reliably.
Any other ideas?
Is it possible to create nVidia application profile while installing?
Or, how do I use NVApi to select the high-performance GPU?
I’ve made a C++ DLL with custom WIX action, that creates/updates the profile for the app when installing, and removes it when uninstalled.
While almost undocumented, the official nVidia API has the required NvAPI_DRS_* functions for that.
Here’s a workflow: NvAPI_Initialize
(if failed it means the user doesn’t have nVidia GPU, that’s not an error), NvAPI_DRS_CreateSession
, NvAPI_DRS_LoadSettings
, NvAPI_DRS_FindProfileByName
.
If was not found, NvAPI_DRS_CreateProfile
, and three calls to NvAPI_DRS_SetSetting
, setting three DWORD properties:
Then, call NvAPI_DRS_GetProfileInfo
to get number of applications, followed by NvAPI_DRS_EnumApplications
, and search for the EXE path.
When uninstalling, I delete the complete profile, by calling NvAPI_DRS_FindProfileByName
and then NvAPI_DRS_DeleteProfile
.
On reinstall and upgrade I do both, first remove then add.
Don't forget NvAPI_DRS_SaveSettings
at the end.
P.S. Most unexpected thing is, nVidia “normalizes” paths stored in NVDRS_APPLICATION::appName field, they convert them to lowercase, and also replace '\'
with '/'
. Because of this “normalization”, no standard string comparison function will work for them.