The Desktop Duplication API allows applications to access frame-by-frame updates to the desktop image associated with a particular DXGI output as a DXGI surface. For hybrid graphics systems, there is a well-known issue that occurs when an application is run on one GPU but attempts to duplicate output from another GPU that is merely acting as a shim for the first. In the case of hybrid graphics laptops, this corresponds to the application being run on the discrete GPU and duplicating the laptop display which is generally connected to an integrated GPU. IDXGIOutput1::DuplicateOutput will fail with DXGI_ERROR_UNSUPPORTED.
Microsoft’s recommended fix for this error is to run the application on the appropriate GPU; in the case of hybrid laptops, this will usually correspond to the integrated (low-power) GPU. Fortunately for application developers, there are programmatic ways of forcing an executable to run on a certain GPU. For NVIDIA Optimus systems, you can use NVAPI to create an application profile and set the relevant flag. For AMD PowerXpress systems, the situation is murkier. Finally, in Windows 10 Build 17093, Microsoft introduced an abstraction that overrides any vendor-specific GPU preference. This abstraction is configurable by programmatically setting a registry value.
One strategy that applications can employ, then, is to determine at startup which GPU will allow them to duplicate the outputs that they want to duplicate, and – if they aren’t already running on that GPU – set the registry preference for themselves to that GPU, then restart themselves, possibly with some argument to skip the GPU check. If an application wants to duplicate any output visible to the user, then it should consider a wide variety of situations, such as an external monitor connected to a hybrid laptop, set as the primary display.
One solution for the GPU duplication check is to attempt to duplicate all outputs, reporting the number of successful attempts, doing this for each GPU preference (System default, Power saving, and High performance). The GPU preference that gives the highest number of duplicated outputs is chosen for the actual run of the application. Note that applications may want to register for display reconfiguration messages and redo the GPU duplication check, restarting if necessary.
Roman Ryltsov has written extensively about this problem and has some of the best information about this on his blog and on StackOverflow. Be sure to read through his articles for more information.