3

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?

Community
  • 1
  • 1
Guy Godin
  • 448
  • 5
  • 16
  • 2
    I read from your latest release, you resolved the Error. Was it just magic via nVidia Driver update, or did you handle it a different way in code? An update on how this was resolved would be great! – thewhiteambit Feb 23 '15 at 10:45

1 Answers1

0

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.

thewhiteambit
  • 1,365
  • 16
  • 31
  • 1
    I already do this. I just think there's a bug with dynamic textures in the current Nvidia drivers. I'll be submitting them a sample project that replicates the issue. – Guy Godin Nov 17 '14 at 02:09
  • I had the same casual error between threads (but on the same gpu) when accessing desktop duplication texture while not handling resouces it in completely mutually exclusive way of access. @guygodin: to resolve the old AquireNextFrame(-1)/Synchronize problem we talked about https://github.com/sharpdx/SharpDX/issues/515 – thewhiteambit Jan 20 '15 at 16:35