title: Desktop Duplication API & switchable graphics
body: <p><strong>The problem</strong>: calling <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/hh404600(v=vs.85).aspx" rel="nofollow noreferrer">IDXGIOutput1::DuplicateOutput method</a> returns DXGI_ERROR_UNSUPPORTED when you run an application using discrete graphics controller on a machine with switchable graphics.</p>
  
  <p><a href="https://superuser.com/a/586811">This answer</a> 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.</p>
  
  <p>I wrote a sample that gets all outputs and their videoadapters using <strong>winapi</strong> (<a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd162609%28v=vs.85%29.aspx" rel="nofollow noreferrer">EnumDisplayDevices function</a>) &amp; <strong>directx</strong> (<a href="https://msdn.microsoft.com/en-us/library/windows/desktop/bb174538%28v=vs.85%29.aspx" rel="nofollow noreferrer">IDXGIFactory::EnumAdapters method</a> &amp; <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/bb174525%28v=vs.85%29.aspx" rel="nofollow noreferrer">IDXGIAdapter::EnumOutputs method</a>) to compare on a machine with switchable graphics (Intel HD 4600 &amp; NVIDIA 840M). This is the result:</p>
  
  <p><a href="https://i.stack.imgur.com/VWUVN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VWUVN.png" alt="enter image description here"></a></p>
  
  <p>Not sure how much correct is my may of comparison, but you can see that <strong>winapi</strong> says that DISPLAY1 belongs to Intel card and <strong>directx</strong> 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.</p>
  
  <p>Currently there is a <em>workaround</em>: always run an application that uses Duplication API using the integrated graphics controller.</p>
  
  <p><strong>The question</strong>: 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?</p>