I use Microsoft Desktop Duplication API and if my code runs on the Integrated (Intel) graphic card then everything works fine. But if I run on the dedicated card, I get an error.
I found that Microsoft does not support this usage on a dedicated card on Microsoft Hybrid system
DXGI_ERROR_UNSUPPORTED
Similar questions without solution for my needs:
The workaround is to launch the program on the Integrated card.
I would like to solve this from code.
I found that NVIDIA / AMD card can be forced from my code
extern "C" { // Hint to Hybrid laptop drivers that our app would really rather use the NVidia/AMD GPU that you've got sitting over there rather than Intel Graphics...
_declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
_declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
Although you can use NVAPI to create an application profile and set a specific flag to make your application run on the integrated chip, newer versions of Windows may override your preference. Thus, the most reliable/easy way to do it is to set a registry value that was introduced in Windows 10 build 17093.
Or is it possible to change the NVIDIA / AMD card settings from my code to run next time on Integrated GPU? I mean: start my app, which check the NVIDIA / AMD settings, and if it's not forced to use Integrated graphic (when available), then modify this setting and restart my application.
You can do this with the registry value, yes. I'm using this approach in practice and wrote an overview of how I chose to do the GPU check. I believe Roman Ryltsov did something similar in his DxgiTakeSnapshot application (he has a bunch of posts on the subject worth reading).