win32 app create 2 devices, device1 and device2(the same adapter). device1 creates a texture as "ComPtr<::ID3D12Resource> texture", then if device2 can use the texture created by device1? because the device1 and device2 are in the same process, so device2 has the way to access the "ComPtr<::ID3D12Resource> texture". ("ComPtr<::ID3D12Resource> texture" is not a shared texture) Thanks
I coded as above, i find it works. But i donot know if it works by using any other GPU.
You must create the resource using the flag
D3D12_HEAP_FLAG_SHARED, otherwise, you cannot share the resource between different devices.You should not use the
ID3D12Resourceinstance created by device 1 directly on device 2. Instead, use CreateSharedHandle on the resource created by device 1, and then call OpenSharedHandle on device 2 (using that handle) to create a secondID3D12Resourceinstance dedicated to device 2. After that, these twoID3D12Resourceinstances will point to the same resource on the GPU (this resource is now shared).If your devices are created on different adapters (different GPUs), you must use
D3D12_HEAP_FLAG_SHARED_CROSS_ADAPTERinstead ofD3D12_HEAP_FLAG_SHARED.