This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Memory Management for video display



I wrote a demo to display 3D model and image mosaicking.

=================================================

I got a question when copying memory from the data collected by camera to graphic buffer.

That takes 12ms and 30% cpu load on crotex-a15.

So I am thinking about sharing the buffer between camera and gpu.

===========Here is  the data flow======================

I find "memcpy" is to blame which consumes 12ms and 30% cpu load after testing.

So what I want to konw is "Is it possiable to share the buffer between camera and gpu"?

Because the camera data buffer must be continuous physical buffer!

But the graphic buffer is made by the api omap_bo_map!

==================Here is the code for memory allocate====================

******************************DRM PART****************************************

int fd = drmOpen("omapdrm", NULL);

omap_device* dev = omap_device_new(fd);

********************************OMAP PART*************************************

struct omap_bo *bo;

bo = omap_bo_new(dev,   width * height * bpp / 8,  bo_flags);

******************************OPENGL PART************************************

int dfd = omap_bo_dmabuf(bo);

                EGLint __attr[] = {
                    EGL_WIDTH,   nWid,
                    EGL_HEIGHT,   nHgt,
                    EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_YUYV,
                    EGL_DMA_BUF_PLANE0_FD_EXT, dfd,
                    EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
                    EGL_DMA_BUF_PLANE0_PITCH_EXT, nPitch,
                    EGL_NONE
                };

 

               m_pKHRImage = eglCreateImageKHR(
                    m_pGraphic->GetDisplay(),
                    EGL_NO_CONTEXT,
                    EGL_LINUX_DMA_BUF_EXT,
                    NULL,
                    __attr);

                glGenTextures(1, &m_nTexture);
                glBindTexture(GL_TEXTURE_EXTERNAL_OES, m_nTexture);
                glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
                glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
                glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, (GLeglImageOES)m_pKHRImage);

**********************Get Virtual Adress***************************************

m_pAddress       = omap_bo_map(bo); //Get graphic buffer

m_pVideoBuffer  = getVideoBuffer();     //abstract api----> camera buffer which is continuous physical buffer, using "mmap" api

memcpy(m_pAddress, m_pVideoBuffer, nPitch * nHgt);  // the api consumes lots of efficiency