The problem: calling IDXGIOutput1::DuplicateOutput method returns DXGI_ERROR_UNSUPPORTED when you run an application using discrete graphics controller on a machine with switchable graphics.
This answer shed some light on the issue. In short, the discrete graphics renders only a part of the screen and sends the data to the framebuffer of the intergrated graphics controller -- in other words all output always goes through the integrated graphics controller. It seems that this is why DuplicateOutput returns DXGI_ERROR_UNSUPPORTED.
I wrote a sample that gets all outputs and their videoadapters using winapi (EnumDisplayDevices function) & directx (IDXGIFactory::EnumAdapters method & IDXGIAdapter::EnumOutputs method) to compare on a machine with switchable graphics (Intel HD 4600 & NVIDIA 840M). This is the result:
Not sure how much correct is my may of comparison, but you can see that winapi says that DISPLAY1 belongs to Intel card and directx says DISPLAY1 belongs to NVIDIA card. One solution would be to duplicate the output of Intel card (because everything goes through it) but EnumOutputs returns no outputs for it.
Currently there is a workaround: always run an application that uses Duplication API using the integrated graphics controller.
The question: how to make DuplicateOutput work with the discrete graphics controller on a laptop with switchable graphics? Or it is a limitation of the Desktop Duplication API?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…