Recently I managed to connect Unreal Engine 4 and CUDA via DirectX 11 without custom engine build. “Connect” here means using some result on GPU memory by CUDA as a resource of Unreal Engine 4 directly, without passing CPU memory.
Now I’d like to do the same thing via DirectX 12, instead of DirectX 11.
In order to do so, ID3D12Resource such as vertex buffers or index buffers seem to have to be initialized with
and the fence, ID3D12Fence with
according to NVIDIA’s official sample code.
However, RHI on DirectX 12 always uses either
D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS | D3D12RHI_HEAP_FLAG_ALLOW_INDIRECT_BUFFERS
and the D3D12_FENCE_FLAGS is always
We cannot change or add the flags without custom engine build (if I’m correct).
So it would be great if we can choose the flags freely like we can choose D3D12_RESOURCE_FLAGS (and D3D11_RESOURCE_FLAGS) through the argument
(EBufferUsageFlags such as BUF_Static, BUF_UnorderedAccess) whenever we call RHICreateVertexBuffer.
Maybe we have to change all the RHICreateVertexBuffer, RHIAsyncCreateVertexBuffer, RHICreateAndLockVertexBuffer, or some other CreateBuffer-related functions by adding an extra argument such as InFlags, and change the default fence flag to D3D12_FENCE_FLAG_SHARED, but this kind of improved freedom will make it possible to connect CUDA and Unreal Engine 4 via DirectX 12.
It would be appreciated if I get some comments on this.