Ideas on portable APIs to cheaply copy a GBM bo?

Matt Hoosier matt.hoosier at
Tue Oct 10 16:12:57 UTC 2017

Hi all,

My organization maintains a small patch against the DRM compositor
that causes it to register another output. This output accepts the
usual compositor scenegraph, does the rendering down to a primary
plane, and then funnels the resulting GBM buffer through a codepath
that does video compression and network transmission. (Why hack this
into the DRM compositor? Mostly because it has all the infrastructure
for setting up GBM, which as far as I can tell ends up being pretty
much a requirement to get access to the composited scene as a dmabuf.)

There's a small bit of trouble involved in handing off the dmabuf of
the FB completed, composited scene to the compress/transmit code. That
stuff runs asynchronously from the Weston event loop by virtue of
living in GStreamer. The means that it's technically prone to tearing
if the compositor gets around to flipping the back/front buffer sooner
than the GStreamer compress/transmit stuff finishes accessing the GBM
bo's dmabuf.

One possible way to remove this race would be to use GL to take a
private copy of the rendered primary plane. That's fairly expensive
though, so it would be nice to avoid if at all possible.

Another option is to enforce a synchronous handshake between the
Weston foreground loop and the compressor/transmit asynchronous code.
The idea would be to (1) suck out the primary plane GBM bo's dmabuf,
(2) wait for the async stuff to work and then signal the completion of
its usage on the BO, and then (3) release the BO locked in the first
step. This has some pretty bad stalling implications though -- the
async code can at times take nearly a full frame to run. The spillover
into the next vblank period would basically force this scheme to run
at half the normal framerate even though better interleaved use of the
hardware can do much better.

Does the readership here on wayland-devel know of any DRM-centric API
(I looked and nothing came to mind) for leveraging a basic cheap blit
from one DRM fb into another?


More information about the wayland-devel mailing list