Direct GPU copy of a Cuda Memory image into a 2D texture of UE4 in Linux

Hello,

I am integrating a camera driver that can copy the image directly into GPU memory. There, I processed the incoming streams using cuda functions (Debayering+whitebalancing). I would like to directly copy (GPUmem->GPUmem) the resulting image into a texture with the format “UTextureRenderTarget2D” in Linux.
I have achieved this in Windows by simply getting the D3D11 texture and registering it as a resource using the functions “GetD3D11TextureFromRHITexture” and “cudaGraphicsD3D11RegisterResource”.

Is there an equivalent way of doing the same procedure for linux environment? I would be happy if you share your experiences.

Best,

Linux opengl,cuda opengl interop.

Hi,

May be my question was not that clear. Of course there exist these cuda interop samples for OpenGL and Vulkan but I would like to implement it specifically working in UE4’s rendering loop.

OpenGL is deprecated and Vulkan RHI is going to be the only supported interface on Linux.

I tried with the following lines:

FVulkanTextureBase* VulkanTexture = GetVulkanTextureFromRHITexture(RenderTarget->Resource->TextureRHI);

uint8_t * destPtr = (uint8_t*)VulkanTexture->Surface.GetMappedPointer();

cudaMemcpy2D(destPtr,VideoWidth,dpFrame,nPitch, (size_t)VideoWidth*4, (size_t)VideoHeight,cudaMemcpyDeviceToDevice);

However, it fails. There must be a proper way of mapping and locking the GPU memory of the texture.

Hello everyone,

I have also generated a github repo to fix this problem:

If you switch to feature/windows branch, it illustrates how direct copy of textures into UE works on Windows.

Please write me if you want to work on the problem together.

Best,