DirectX11 Desktop duplication not working with NVI

2020-07-18 04:52发布

I'm trying too use DirectX desktop duplication API.

I tried running exmaples from

http://www.codeproject.com/Tips/1116253/Desktop-Screen-Capture-on-Windows-via-Windows-Desk

And from

https://code.msdn.microsoft.com/windowsdesktop/Desktop-Duplication-Sample-da4c696a

Both of these are examples of screen capture using DXGI.

I have NVIDIA GeForce GTX 1060 with Windows 10 Pro on the machine. It has Intel™ Core i7-6700HQ processor.

These examples work perfectly fine when NVIDIA Control Panel > 3D Settings is selected to Auto select processor.

However if I set the setting manually to NVIDIA Graphics Card the samples stop working.

Error occurs at the following line.

//IDXGIOutput1* DxgiOutput1
hr = DxgiOutput1->DuplicateOutput(m_Device, &m_DeskDupl);

Error in hr(HRESULT) is DXGI_ERROR_UNSUPPORTED 0x887A0004

I'm new to DirectX and I don't know the issue here, is DirectX desktop duplication not supported on NVIDIA ?

If that's the case then is there a way to select a particular processor at the start of program so that program can run with any settings ?

#Edit

After looking around I asked the developer (Evgeny Pereguda) of the second sample project on codeproject.com

Here's a link to the discussion https://www.codeproject.com/Tips/1116253/Desktop-Screen-Capture-on-Windows-via-Windows-Desk?msg=5319978#xx5319978xx

Posting the screenshot of the discussion on codeproject.com in case original link goes down

discussion with Evgeny Pereguda

I also found an answer on stackoverflow which unequivocally suggested that it could not be done with the desktop duplication API referring to support ticket at microsoft's support site https://support.microsoft.com/en-us/help/3019314/error-generated-when-desktop-duplication-api-capable-application-is-ru

Quote from the ticket

This issue occurs because the DDA does not support being run against the discrete GPU on a Microsoft Hybrid system. By design, the call fails together with error code DXGI_ERROR_UNSUPPORTED in such a scenario.

However there are some applications which are efficiently duplicating desktop on windows in both modes (integrated graphics and discrete) on my machine. (https://www.youtube.com/watch?v=bjE6qXd6Itw)

I have looked into the installation folder of the Virtual Desktop on my machine and can see following DLLs of interest

SharpDX.D3DCompiler.dll
SharpDX.Direct2D1.dll
SharpDX.Direct3D10.dll
SharpDX.Direct3D11.dll
SharpDX.Direct3D9.dll
SharpDX.dll
SharpDX.DXGI.dll
SharpDX.Mathematics.dll

Its probably an indication that this application is using DXGI to duplicate desktop, or may be the application is capable of selecting a specific processor before it starts.

Anyway the question remains, is there any other efficient method of duplicating desktop in both modes?

1条回答
Viruses.
2楼-- · 2020-07-18 05:27

The likely cause is certain internal limitation for Desktop Duplication API, described in Error generated when Desktop Duplication API-capable application is run against discrete GPU:

... when the application tries to duplicate the desktop image against the discrete GPU on a Microsoft Hybrid system, the application may not run correctly, or it may generate one of the following errors:

  • Failed to create windows swapchain with 0x80070005
  • CDesktopCaptureDWM: IDXGIOutput1::DuplicateOutput failed: 0x887a0004

The article does not suggest any other workaround except use of a different GPU (without more specific detail as for whether it is at all achievable programmatically):

To work around this issue, run the application on the integrated GPU instead of on the discrete GPU on a Microsoft Hybrid system.

查看更多
登录 后发表回答