Specifying buffer usage at creation time
This applies to both shm buffers and dma-bufs but dma-bufs are more interesting.
When creating a buffer via linux-dmabuf, the compositor cannot know how the client intends to use the buffer. The client could want to use the buffer
- as a framebuffer and/or
- for sampling.
Therefore, when the client calls
- create or
- create_immed,
the compositor cannot actually fully import the buffer. Even if those requests signal success, using the buffers might later fail if the compositor has to create additional data structures.
Therefore, I believe that it would be useful to add a new request to linux-dmabuf:
<interface name="zwp_linux_buffer_params_v1" version="5">
<enum name="error">
<entry name="no_usage" value="8"
summary="tried to create a buffer without a usage"/>
</enum>
<enum name="usage" bitfield="true">
<entry name="rendering" value="1" summary="the buffer will be rendered-to"/>
<entry name="sampling" value="2" summary="the buffer will be sampled-from"/>
</enum>
<request name="add_usage" since="5">
<description summary="add a usage to this buffer">
This request specifies in which ways the created buffer will be used. It is a
protocol error to attempt to use the buffer in a way not specified via this
request.
The client must request at least one usage before attempting to create the buffer.
Otherwise, the no_usage error is raised.
This request allows the compositor to determine at create time if the dma-buf
can be used for the intended purpose.
</description>
<arg name="usage" type="uint" enum="usage" summary="see enum usage"/>
</request>
</interface>
Edited by Julian Orth