Hello,
I have been trying to use DMABUF With egl on a Mali 450 (on an odroid C2).
I was able to successfully use it with the following setup for a 1920x1080 image :
const EGLint img_attrs[] = { EGL_WIDTH, 1920, EGL_HEIGHT, 1080, EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_RGBA8888, EGL_DMA_BUF_PLANE0_FD_EXT, pbuffer->fd_handle, EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0, EGL_DMA_BUF_PLANE0_PITCH_EXT, 1920, EGL_NONE };eglCreateImageKHR(eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, 0, img_attrs);
const EGLint img_attrs[] = {
EGL_WIDTH, 1920,
EGL_HEIGHT, 1080,
EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_RGBA8888,
EGL_DMA_BUF_PLANE0_FD_EXT, pbuffer->fd_handle,
EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
EGL_DMA_BUF_PLANE0_PITCH_EXT, 1920,
EGL_NONE
};
eglCreateImageKHR(eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, 0, img_attrs);
Though RGBA format is not optimal when working with 1080p or 4K images, especially in terms of memory bandwidth.
So I wanted to use either DRM_FORMAT_NV12 or DRM_FORMAT_YUV420.
As far as i have seen DRM_FORMAT_NV12 is described as a two planes format in drm_fourcc.h so i tried the following :
const EGLint img_attrs[] = { EGL_WIDTH, 1920, EGL_HEIGHT, 1080, EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_NV12, EGL_DMA_BUF_PLANE0_FD_EXT, pbuffer->fd_handle, EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0, EGL_DMA_BUF_PLANE0_PITCH_EXT, 1920, EGL_DMA_BUF_PLANE1_FD_EXT, pbuffer->fd_handle, EGL_DMA_BUF_PLANE1_OFFSET_EXT, 1920*1080, EGL_DMA_BUF_PLANE1_PITCH_EXT, 1920 / 2 EGL_NONE };eglCreateImageKHR(eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, 0, img_attrs);
EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_NV12,
EGL_DMA_BUF_PLANE1_FD_EXT, pbuffer->fd_handle,
EGL_DMA_BUF_PLANE1_OFFSET_EXT, 1920*1080,
EGL_DMA_BUF_PLANE1_PITCH_EXT, 1920 / 2
This will results in EGL_BAD_PARAMETER error code when using eglCreateImageKHR
I have tried many combinations both for the NV12 DRM format and the YUV420, but i have always ended up with an EGL_BAD_PARAM error when using anything else than RGBA.
Could anyone shed some light on the proper way to configure the attributes, both for YUV420 and NV12 please ?.
DMABUF generally supports YUV to support non-GPU media masters - e.g. camera, video, ISP, etc - it would be unusual for the GPU to process YUV because OpenGL ES is specified in terms of RGB. Certainly YUV isn't guaranteed to be free - it comes with a lot of additional overheads in the GPU (color conversion to/from RGB, writing out to multi-plane surfaces, for example).
Writing out YUV is possible in some of the Mali hardware, depending on platform and use of driver extensions, but even if you managed to get it working on Mali-400 I would expect it to be slower than writing simple RGB.
Also note that the size of the render target is irrelevant to bandwidth per clock; larger render targets will take longer to process but for a consistent workload per pixel the bandwidth per clock will be identical at 640x480 and at 4K. Assuming that larger render targets are more likely to benefit from compression for a performance optimization is therefore incorrect.
Thanks for you input !
I can understand that this is not a native format for the GPU and that it might also have some incidence on the GPU perfomance eventually.
Although memory considerations systemwise are also a point. 4k frame in RGBA is about 33 Megs where it would be 12 megs on YUV / NV12.
therefore 4k@30fps is close to 1Gb /s for memory transfer, just to read the source image.
Also and as most player try to keep a few decoded frames in avance, it makes a lot of reserved memory to keep available.
I can still figure out what's the best between NV12, YUv420 vs RGBA in the end, but the issue I am currently facing is that I can't get the r6p1 Mali driver to create the EGL Image properly with dmabuf and YUV.
So the former issue is that trying to create those NV12/YUV420 EGLImage will fail with EGL_BAD_PARAM, whatever i do, So either there is something i'm handling wrong in the code above, or the r6p1 opengl Mali libraries expect something that is not in the specs.
If someone can point out someting wrong in my experiment above / confirm that YUV420 & NV12 should work, that would be great
Try setting EGL_YUV_COLOR_SPACE_HINT_EXT and EGL_SAMPLE_RANGE_HINT_EXT
That indeed allowed me to create an NV12 pixmap thanks !
Btw regarding the pixmaps formats when creating them from a dmabuf.
Could we have a list of the supported DRM formats in Mali 450 r6p1 please ?