The synchronization issue between the DMA-BUF fd of the nvbuffer and the device pointer mapped out by EGL

Hi nvidia:

I obtained the device pointer from the nvbufsurface using the EGL method: NvBufSurfaceMapEglImage->cuGraphicsEGLRegisterImage->cuGraphicsResourceGetMappedEglFrame

After completing the CUDA kernel function and performing cudaStreamSynchronize, I immediately placed the nvbuffer into the encoder for H264 encoding. The last few lines of the encoded picture data were damaged and not synchronized.

If I apply remap process: cuGraphicsUnregisterResource-> cuGraphicsEGLRegisterImage ->cuGraphicsResourceGetMappedEglFrame to ensure synchronization and reusability, this process occasionally blocks for a relatively long time. Most of the time it’s 2 milliseconds, occasionally it exceeds 10 milliseconds.

My question is: Is there any efficient way to ensure that the memory Stably synchronized between the mapped device memory and the fd of the nvbuffer can be achieved? Or are there any other methods besides the EGL way to obtain the device memory from the nvbuffer?

My platform is Jetson Xavier AGX. R35.6.0

Thanks,

ernan

Hi,

Which SDK do you use? Deepstream or Multimedia API?

Thanks.

Multimedia API

Hi,

There is a migration guide for r36.5.0.
Please check if this can help your question first:

(nvbuf_utils to NvUtils Migration Guide)

Thanks

This document only describes one method of obtaining the device data pointer suitable for CUDA processing from the DMABUF FD using EGLImage, and it does not explain the synchronization issue between the device data pointer processed by CUDA and the DMABUF FD.

My application scenario is that after CUDA processing is completed, the DMABUF FD will be immediately used for H264 encoding by nvenc.

Hi,

Please also check below source:

/usr/src/jetson_multimedia_api/samples/common/algorithm/cuda/nvcudaproc.cpp

Thanks.