Rendering with OpenGL ES 2.x/3.x to a DMA buffer / physical memory?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Rendering with OpenGL ES 2.x/3.x to a DMA buffer / physical memory?

3,591 Views
crg7475
Contributor III

When one wants to render from a DMA buffer (using its physical address) in OpenGL ES 2.x/3.x - that is, the GPU shall get the pixels from that DMA buffer instead of from a regular OpenGL texture object - the Vivante VIV direct texture extension can be used. I've done that in the past. Works well.

However, now I want to do the opposite: I render something in OpenGL, to a framebuffer object (FBO). A texture is attached to that FBO. The result is that I now render to that texture. If I want to get that rendered texture's pixels, I can use glReadPixels(), but that is slow, since it copies the pixels with the CPU. Ideally, there would be something like VIV direct textures, but for cases where I want to render into a DMA buffer.

Does such a functionality exist? Is this possible with Vivante GPUs and the current Linux Vivante drivers?

0 Kudos
4 Replies

3,433 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello Carlos,

You can use glReadPixels but this is not going to DMA. Will talk to developers I see if this going to be available in future releases.

Regards

0 Kudos

3,433 Views
crg7475
Contributor III

Thanks, found a solution - the EGL_EXT_image_dma_buf_import is what makes it possible. You allocate a DMA-BUF buffer, pass its FD to eglCreateImage in the attrib_list argument, and then use that EGLImage as the backing store of an OpenGL ES color renderbuffer. That color renderbuffer you then attach to an FBO, and use it as the color attachment. Result: through the FBO and the color renderbuffer, the GPU will render the pixels into the EGLImage, and ultimately, into the DMA-BUF buffer.

0 Kudos

3,189 Views
dnebrich
Contributor I

Hi crg7475,

I am having this same issue.  Could you provide any more detail on how you got eglCreateImage to work?

I have an example based on GLES3/Debayer from the gtec-demo-framework.  I've created an FBO/render buffer with help from here: https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044158

Are you calling eglCreateImage or eglCreateImageKHR?  I've tried both.  When looking at the extension spec (https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_image_dma_buf_import.txt), my first try was to use the default display with no context, and the dma buf fd in the attributes:

g_eglimage = eglCreateImageKHR(EGL_DEFAULT_DISPLAY, EGL_NO_CONTEXT, EGL_GL_RENDERBUFFER, (EGLClientBuffer)(&m_userData.renderbuf), g_attribs);

But that got me EGL_BAD_DISPLAY.  I'm using the fsl-imx-wayland distro on an IMX8QM dev board.  Searching in the forum turned up hits on setting displayinfo on kernel cmd line, exporting DISPLAY and WAYLAND_DISPLAY but it didn't help.

So next I tried to create a display.  Which I was eventually able to do using fbGetDisplayByIndex / fbCreateWindow.  But I'm not sure this is correct given I have a wayland build.  And while I was able to create the display and context, I now get different errors (bad param, bad match) from eglCreateImage.

Any help is appreciated.

Thanks,

Daryl

0 Kudos

2,450 Views
solson
Contributor I

I've run into the same issue. Did you find a solution, or a relevant example?

0 Kudos