Jump to content
  • Advertisement
Sign in to follow this  
BlackJoker

Copy shared textures between D3D11 devices

This topic is 943 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to copy shared texture 2d between 2 different D3D11 devices, but this is not so easy as I thought.

 

I have 2 d3d devices + 2 device contexts( one per device) and 2 texture2d (one created with first device and second with second device correspondingly).

 

When i try do like that:

 

deviceContext2.CopyResource(textureOnDevice2 (source), textureOnDevice1 (destination))

 

I receive the following error: D3D11 CORRUPTION: ID3D11DeviceContext::CopyResource: Second parameter does not match device. [ MISCELLANEOUS CORRUPTION #14: CORRUPTED_PARAMETER2]

 

Both textures were created with ResourceOptionFlag = Shared, so it must be possible to copy textures between devices.

 

What I am missing here?

 

Share this post


Link to post
Share on other sites
Advertisement

The Shared resource flag alone isn't sufficient to achieve what you're trying to do.

 

Have you read the "Surface Sharing Between Windows Graphics APIs" MSDN page?

 

I would expect to see at least one call to GetSharedHandle and OpenSharedResource in the code before you can Copy between textures created on different devices.

Share this post


Link to post
Share on other sites

Thanks a lot. That helped. 

In case anyone will need it for SharpDX, here is how you can do this:

 

public T GetSharedResource<T>(Resource resource) where T: ComObject
      {
         using (var shared = resource.QueryInterface<SharpDX.DXGI.Resource>())
         {
            return Device.OpenSharedResource<T>(shared.SharedHandle);
         }
      }

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!