Advertisement

Difference between Texture sharing across devices and adapters

Started by October 23, 2017 12:55 PM
3 comments, last by SoldierOfLight 7 years, 2 months ago

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

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.

Advertisement

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);

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.

This topic is closed to new replies.

Advertisement