Jump to content
  • Advertisement
mark_braga

DX12 Difference between Texture sharing across devices and adapters

Recommended Posts

I am working on a VR project where we have two devices. One for the renderer belonging to the game engine and the other used to present the textures to the VR screens.

We ported both the game engine renderer and the VR renderer to DirectX12 recently. I haven't seen any examples of sharing textures across devices in DirectX12. Microsoft has an example on cross adapter sharing but we are only dealing with one GPU.

Can we create a shared heap for two devices like we do for two adapters? Is there a way to do async copy between two devices? If async copy is possible, it would be ideal since we already have designed our engine along the lines of taking the most advantage of async copy and compute.

Any guidance on this will really help to reduce the texture transfer overhead.

Thank you

Share this post


Link to post
Share on other sites
Advertisement

Are your two devices in separate processes? If not, why do they need to be different devices? In D3D11 it would've made sense, since a device has an immediate context that goes with it, but in D3D12 the device is entirely stateless.

At the end of the day, all you need to do is create your heaps or committed resources with the HEAP_SHARED flag, create shared handles for them and open them on the other device, and then synchronize access to them using fences.

Share this post


Link to post
Share on other sites

I tried to create a resource on one device and use it on another and it works without specifying any flags or even opening any handles. Any reason why the validation won't complain?

This is the overview of what I did and it works just fine even if the render target texture was created on pDevice0 and the render target is cleared on a command list created on pDevice1

initDevice(pDevice0);
addRenderTarget(pDevice0, &pRenderTarget);

initDevice(pDevice1);
// This works without any problems
clearRTV(pDevice1->pCmdList, pRenderTarget, WHITE);
Edited by mark_braga

Share this post


Link to post
Share on other sites

D3D12 devices are singleton-per-adapter. That means that calling D3D12CreateDevice while a device already exists will just return the same device. You can compare the pointers and confirm.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • 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!