[PATCH 1/7] protocol: add linux_dmabuf extension RFCv1

Bill Spitzak spitzak at gmail.com
Tue Dec 16 13:19:53 PST 2014

It looks like the purpose of "dmabuf_batch" is to send a more complex 
set of arguments to the dmabuf::create_buffer request. This is a 
variable-sized list of fd's, each containing a variable-sized list of 
planes. The Wayland protocol does not have a method of passing this as a 
request argument, so this object is used to build it with multiple 
requests. Is this correct? And is this considered the correct way to do 
this sort of thing in Wayland?

It is not clear but I assume you must add at least one fd to the 
dmabuf_batch for this to work, right?

Assuming this is correct, I think some consolidation of the objects 
would help. A few ideas:

- Make create_buffer a method on dmabuf_batch, not on dmabuf.

- Get rid of dmabuf_create_feedback object, and just reuse the 
already-existing dmabuf_batch object to deliver the success/failure event.

- I am a bit suspicious of the exactly 3 planes, there are 4:2:2 formats 
with alpha channels. I think it would be better if there was a request 

- Isn't there a problem with having an event deliver a new object (ie 
the wl_buffer in the create_successful event)? Can the dmabuf_batch 
object just "be" a wl_buffer, but you cannot use it as a wl_buffer until 
you get the success event?

So in the most-cleaned-up version I can come up with the api is more 
like this:

dmabuf - singleton factory used to create dmabuf_buffer.

dmabuf::create_buffer - create a new dmabuf_buffer. You must then do 
some requests on it before it can be used as a wl_buffer.

dmabuf::format event - same as you describe it

dmabuf_buffer - A subclass of wl_buffer representing a (potential) dma 

dmabuf_buffer::add_fd - Add a new fd describing a dmabuf

dmabuf_buffer::add_plane - Add a plane (offset + stride) to map from the 
most recent fd.

dmabuf_buffer::create - try to create the dma buffer. After this you 
cannot do the add_fd/plane requests.

dmabuf_buffer::create_successful event - you can now use the 
dmabuf_buffer as a wl_buffer (for instance to attach it to a wl_surface).

dmabuf_buffer::create_failed event - It did not work. The only thing you 
are allowed to do is destroy the dmabuf_buffer.

More information about the wayland-devel mailing list