Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDXGIOutputDuplication::AcquireNextFrame - DXGI_ERROR_ACCESS_LOST #45

Open
gnif opened this issue Jan 28, 2024 · 2 comments
Open

IDXGIOutputDuplication::AcquireNextFrame - DXGI_ERROR_ACCESS_LOST #45

gnif opened this issue Jan 28, 2024 · 2 comments

Comments

@gnif
Copy link

gnif commented Jan 28, 2024

When using D3D11on12, when using Desktop Duplication, calling IDXGIOutputDuplication::AcquireNextFrame results in DXGI_ERROR_ACCESS_LOST.

Tracing this as far as I can it seems to be caused by CGraphicsCommandQueue::AcquireKeyedMutex which calls D3DKMTAcquireKeyedMutex2 which returns 0x80 (WAIT_ABANDONED)

Note, this code is functioning perfectly on DX11 directly.

@yiyaowen
Copy link

yiyaowen commented Mar 2, 2025

I also encountered the same issue! The situation is exactly as you described, and I was wondering if I misunderstood the documentation. Did you find a solution later, or do we have to wait for d3d11on12 to fix this bug?

@yiyaowen
Copy link

yiyaowen commented Mar 2, 2025

Temporarily resolved, but I still hope that d3d11on12 interp can work as normally as d3d11. 😂

To obtain the correct screenshot, I had to create an additional d3d11Device, share the output d3d11Texture2D with the existing d3d11on12Device, and finally obtain the corresponding d2d1bitmap1 through CreateBitmapFromDxgiSurface:

outputDupl->AcquireNextFrame(timeout, &frameInfo, &src);

D3D11_TEXTURE2D_DESC desc = {};
// ... others
desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
desc.MiscFlags = D3D11_RESOURCE_MISC_SHARED | D3D11_RESOURCE_MISC_SHARED_NTHANDLE;
// ... others

d3d11Device->CreateTexture2D(&desc, NULL, &dst);
d3d11DeviceContext->CopyResource(dst.Get(), src.Get());

dst->CreateSharedHandle(nullptr, DXGI_SHARED_RESOURCE_READ, nullptr, &handle);
d3d11on12Device->OpenSharedResource1(handle, IID_PPV_ARGS(&surface));

d2d1DeviceContext->CreateBitmapFromDxgiSurface(surface.Get(), &props, &frame);

That final frame is the perfect screenshot. However, the additional d3d11device and resource sharing synchronization introduced some overhead (though it seems that the impact on overall performance is not significant). 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants