[Bug 743345] New: glimagesink: Add support for dmabuf

GStreamer (bugzilla.gnome.org) bugzilla at gnome.org
Thu Jan 22 04:54:29 PST 2015

  GStreamer | gst-plugins-bad | unspecified

           Summary: glimagesink: Add support for dmabuf
    Classification: Platform
           Product: GStreamer
           Version: unspecified
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: Normal
         Component: gst-plugins-bad
        AssignedTo: gstreamer-bugs at lists.freedesktop.org
        ReportedBy: lubosz at gmail.com
         QAContact: gstreamer-bugs at lists.freedesktop.org
     GNOME version: ---

A summary of the work George Kiagiadakis and I have been doing on dmabuf
support in the GL plugins.
Hopefully the remaining problems can be resolved and dmabuf support can land
upstream soon.

The current branch can be found here

I am not uploading the patches to bugzilla yet, since I want to wait for the

== Platform Support ==

Since dmabuf is a Linux feature, it won't be available on other platforms. 
Currently my tests were limited to the Intel driver, but I will soon test on
Mali and NVIDIA / nouveau.

dmabuf support in the GL plugins can be achieved conveniently with an EGL

An EGL context is a requirement for the extension, but
EGL_EXT_image_dma_buf_import is not necessarily an OpenGL ES only feature.
But currently the Intel i965 driver does not implement it for Desktop GL.

To achieve the dma_buf_import on ES, a GL_OES_EGL_image_external texture target
is needed.

== Patch 1 # glupload: make texture target parameterizable ==

To use a different texture target during upload, I extended the glmemory calls 

The best solution for this problem is being discussed in another issue

== Patch 2 # glupload: implement dmabuf upload

This patch was originally authored by George Kiagiadakis. I ported it onto the
current glupload.

The dma_buf_upload_accept method checks for gst_is_dmabuf_memory and does not
require dmabuf caps features.
This is needed, since v4l2 elements do not expose this caps feature, but the
allocated memory type.


== Patch 3 # glimagesink: implement dmabuf display

This patch was originally authored by George Kiagiadakis.
The glsink needs to use the different texture target for displaying the dmabuf.
The target needs also to be specified in the shader. To recognize a dmabuf,
gst_is_dmabuf_memory is used.


== Patch 4 # dmabuf: add drm format support without conversion

Using a dmabuf without conversion requires to know when a drm format is
supported by the driver.
According to the spec this can not be queried, but only recognized by trial and

    6. How can an application query which formats the EGL implementation

    PROPOSAL: Don't provide a query mechanism but instead add an error
    that EGL_BAD_MATCH is raised if the EGL implementation doesn't support that
    particular format.

Several fourcc formats are specified in the drm header:

To avoid inclusion of this header I am currently redefining these in a switch
to convert from GStreamer to drm format.
The "known working formats" problem could be solved by testing all drm formats
and checking for EGL errors.
The question is if this should be done every time during negotiation of the

This supported drm format detection is also needed in the glimagesink, since it
is not communicated in another way.
This could be solved however with caps feature and formats (as seen in the
later described dma caps features patch).

I am also omitting gst_video_frame_map for dmabufs, since it seems to be an
unneeded copy.
Additionally gst_video_frame_map needs to have a RGBA formatted source buffer
from glcolorconvert.


== Patch 5 # glupload: add GST_GL_DRM_FOURCC_OVERRIDE option

I used this patch to test supported drm formats and correct conversion.

For example:

This was the script I was using for the test


== Patch 6 # glimagesink: use memory:dmabuf caps features

These caps features are currently only negotiated from the inteldmabufupload
Making the uplaod rely on these features would require the v4l2 elements to use


== Patch 7 # WIP: glconvert: enable conversion for dmabuf

This shows how glconvert would needed to be modified to support conversion for
formats drm does not support.
All the shaders would require to be modified. In multiplane cases, more than
the sampler type would needed to be changed.

After a new texture is created during conversion, the sink needs to display a
GL_TEXTURE_2D target.
The question is if this should be done at all, and how this could be solved in
a proper way.


== Multiplane format support ==

I was not able yet to run multiplane support, since the Intel driver does not
support it.

Following EGL error is reported when using I420:
libEGL debug: EGL user error 0x3004 (EGL_BAD_ATTRIBUTE) in too many plane

I hopefully will be able to test this on the Mali driver.

== inteldmabufupload ==

For testing reasons George Kiagiadakis implemented an element to create dmabufs
in a GStreamer pipeline.
It uses memory:dmabuf caps features and was not accepted upstream


I rebased it on current master for convenience and testing


Example pipelines for displaying the dmabuf in glimagesink is 

 $ GST_GL_PLATFORM=egl GST_GL_API=gles2 gst-launch-1.0 videotestsrc !
inteldmabufupload ! glimagesink
 $ GST_GL_PLATFORM=egl GST_GL_API=gles2 gst-launch-1.0 videotestsrc !
inteldmabufupload ! video/x-raw\(memory:dmabuf\),format=RGBx ! glimagesink

== vivid module ==

Since I do not own dmabuf supported video hardware, I relied on the vivid
kernel module to emulate one.
This module allows generation of a virtual video device with dmabuf
capabilities suitable for v4l2src.


The module can be found on the Linux media branch and has not yet been merged
into upstream kernel 3.18.


The module can easily be loaded with modprobe and creates a /dev/videoX device.

 $ sudo modprobe vivid n_devs=1 node_types=0x1

An example pipeline for displaying the vivid dmabuf in glimagesink is 

 $ GST_GL_PLATFORM=egl GST_GL_API=gles2 gst-launch-1.0 v4l2src
device=/dev/video1 io-mode=4 ! video/x-raw,format=BGRA ! glimagesink

Configure bugmail: https://bugzilla.gnome.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the gstreamer-bugs mailing list