1

I have some code to get the current screens contents which works smoothly on at least one computer (code simplified, only the relevant parts are shown and error handling is removed):

hr = D3D11CreateDevice(nullptr,gDriverTypes[DriverTypeIndex],nullptr,0,gFeatureLevels,
                       NumFeatureLevels,D3D11_SDK_VERSION,&lDevice,&lFeatureLevel,
                       &lImmediateContext);

ComPtr<IDXGIDevice> lDxgiDevice;
hr = lDevice.As(&lDxgiDevice);

// Get DXGI adapter
ComPtr<IDXGIAdapter> lDxgiAdapter;
hr = lDxgiDevice->GetParent(__uuidof(IDXGIAdapter), &lDxgiAdapter);
lDxgiDevice.Reset();

// Get output
ComPtr<IDXGIOutput> lDxgiOutput;
hr = lDxgiAdapter->EnumOutputs(output, &lDxgiOutput);
lDxgiAdapter.Reset();

hr = lDxgiOutput->GetDesc(&lOutputDesc);

// QI for Output 1
ComPtr<IDXGIOutput1> lDxgiOutput1;
hr = lDxgiOutput.As(&lDxgiOutput1);
lDxgiOutput.Reset();

// Create desktop duplication
hr = lDxgiOutput1->DuplicateOutput(lDevice.Get(), &lDeskDupl);

On an other computer that last call to DuplicateOutput() fails, here "hr" returns E_UNEXPECTED.

DxDiag of this second, not working computer shows DirectX12, right as the first, working one.

Any idea how to get additional information about the reason for this error or any idea what could be wrong?

Thanks!

Elmi
  • 5,899
  • 15
  • 72
  • 143
  • 1
    Use the Debug Layer https://learn.microsoft.com/en-us/windows/win32/direct3d11/using-the-debug-layer-to-test-apps https://walbourn.github.io/dxgi-debug-device/ – Simon Mourier Feb 16 '21 at 07:42
  • @SimonMourier this sounds very good but ends up with a message "Flags (0x2) were specified which require the D3D11 SDK Layers for Windows 10, but they are not present on the system". Any idea hwere to get this D3D11 SDK from? Neither Google nor MS provides something, seems to be very hidden... – Elmi Feb 16 '21 at 08:00
  • @Elmi See here: https://stackoverflow.com/questions/32809169/use-d3d11-debug-layer-with-vs2013-on-windows-10/32828880 for that particular message – mateeeeeee Feb 16 '21 at 08:26

0 Answers0