Transferring textures across adapters in DirectX 11

大兔子大兔子 提交于 2019-12-10 20:54:13

问题


I'm capturing the desktop with the Desktop Duplication API from one GPU and need to copy the texture (which is in GPU memory) to another GPU. To do this I have a capture thread that acquires the desktop image then copies it to a staging resource (created on the same device) using ID3D11DeviceContext::CopyResource. I then map that staging resource with Read, map the destination dynamic resource (which was created on the other device) with WriteDiscard and copy the data. On the rendering thread, I do a ID3D11DeviceContext::CopyResource from the dynamic texture onto the final render target.

This works but I will get a random crash in nvwgf2umx.dll (Exception code: 0xc0000005) after a while (usually within 30 seconds). Both devices are created without the SingleThreaded creation flag. I did a bit of research and using a dynamic texture seemed like the best way to do this.

Any ideas on what's causing the crash? Could it be a bug specific to the Nvidia driver?


回答1:


You have to QueryInterface for a shared resource with the other device you are using. This would look like this in C# (what I guess you are really using beside given snippets in C++)

var sharedResource = aquiredDesktopTexture11.QueryInterface<SharpDX.DXGI.Resource>();
var sharedSurfDesktop = device11.OpenSharedResource<SharpDX.Direct3D11.Texture2D>(sharedResource.SharedHandle);

..were aquiredDesktopTexture11 is the copyed resource from the original capture, and sharedSurfDesktop then can be used by the other device. Also make sure the usage is mutual exclusive.



来源:https://stackoverflow.com/questions/26321167/transferring-textures-across-adapters-in-directx-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!