How to get a gpu address from a pre-alloced Nvbuffer?

  1. I create a nvbuffer by NvBufferCreate(&fd, …); (it used for video converter)
  2. I want to get an gpu address from the nvbuffer, so that I can write the image data to the address directly in cuda kernel without any memcpy.

From NvBufferCreate(&fd, …), I can only get a mmaped cpu end address and the fd used for video converter. How to get the corresponding gpu end address?

Please refer to nvbuf_utils.h

/**
* This method must be used for getting `EGLImage` from `dmabuf-fd`.
*
* @param[in] display `EGLDisplay` object used during the creation of `EGLImage`.
* @param[in] dmabuf_fd `DMABUF FD` of buffer from which `EGLImage` to be created.
*
* @returns `EGLImageKHR` for success, `NULL` for failure
*/
EGLImageKHR NvEGLImageFromFd (EGLDisplay display, int dmabuf_fd);

/**
* This method must be used for destroying `EGLImage` object.

* @param[in] display `EGLDisplay` object used for destroying `EGLImage`.
* @param[in] eglImage `EGLImageKHR` object to be destroyed.
*
* @returns 0 for success, -1 for failure
*/
int NvDestroyEGLImage (EGLDisplay display, EGLImageKHR eglImage);

and tegra_multimedia_api\samples\common\algorithm\cuda\NvCudaProc.cpp

Please refer to this code snippet.
https://devtalk.nvidia.com/default/topic/1027288/jetson-tx1/libargus-crashing-with-cuda-opengl-interop/post/5228961/#5228961

@DaneLLL

I tried with the sample in NvCudaProc.cpp , in this sample , It was used to copy data from fd to a gpu address, the eglImage will be destroyed after that, I want to get a fixed and long time hold gpu address like mapEGLImage2Float does. I have four cameras, the eglImage was create with EGLDisplay, if I hold one of them, other cameras will be blocked.

@WayneWWW

I will try this on my board, will be feedback soon.