I have a laptop with an integrated Intel graphics card and an NVIDIA T1000 graphics card.
I set the NVIDIA card as the preferred graphic processor in the Managed 3D in NVIDIA Control Panel.
However, since doing that,
lDxgiOutput1->DuplicateOutput(mlDevice, &mComPtrlDeskDupl)
fails with the error hr 0x887a0004 (DXGI_ERROR_UNSUPPORTED): The specified device interface or feature level is not supported on this system.
EnumAdapters1 selects NVIDIA as the first lDxgiAdapter option when it's set to preferred and Intel lDxgiAdapter when NVIDIA is not set as preferred.
If I choose the Intel lDxgiAdapter using EnumAdapters1 (which is the second one), then the following fails:
iOutput = 0;
lDxgiAdapter->EnumOutputs(iOutput, &lDxgiOutput);
with hr = 0x887a0002 (DXGI_ERROR_NOT_FOUND) : The object was not found
However, if I choose the NVIDIA lDxgiAdapter using EnumAdapters1, this works:
lDxgiOutput->QueryInterface(IID_PPV_ARGS(&lDxgiOutput1));
lDxgiAdapter->EnumOutputs(iOutput, &lDxgiOutput);
But as said before, this fails:
lDxgiOutput1->DuplicateOutput(mlDevice, &mComPtrlDeskDupl);
with hr 0x887a0004: The specified device interface or feature level is not supported on this system.
I want to duplicate the desktop while NVIDIA is set as the preferred adapter (as is the case on some systems). However, as explained, it fails with DuplicateOutput.
I don't mind using the Intel lDxgiAdapter in that case, but when the chosen lDxgiAdapter is Intel (using EnumAdapters1), it fails on EnumOutputs.
When the preferred adapter is set to Intel, Intel is selected as the first lDxgiAdapter, and both EnumOutputs and DuplicateOutput work for the Intel lDxgiAdapter. But I want to make it work when NVIDIA is set as the preferred adapter as well.