How to fetch the implicit sync fence for a GPU buffer?

Michel Dänzer michel at daenzer.net
Fri Jun 2 10:29:56 UTC 2023


On 6/1/23 23:15, Hoosier, Matt wrote:
> Hi,
> 
>  
> 
> In the past there has been writing about Wayland’s model using implicit synchronization of GPU renderbuffers and KMS commits [1] [2].
> 
>  
> 
> It would sometimes be nice to do that waiting explicitly in a compositor before enqueueing a KMS pageflip that references a buffer who may go on rendering for some time still. This stalls the pipeline.
> 
>  
> 
> I’m wondering whether there’s an API -- maybe something analogous to drmPrimeHandleToFD() – that allows userspace to fetch a waitable fence fd for a dmabuf?

A dma-buf fd itself can serve this purpose; it polls as readable when the GPU has finished drawing to the buffer.

See https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1880 for how I used this to implement what you describe above in mutter. Note that this involves some Wayland state management challenges for correct operation in all cases though.


-- 
Earthling Michel Dänzer            |                  https://redhat.com
Libre software enthusiast          |         Mesa and Xwayland developer



More information about the dri-devel mailing list