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

2023-06-02 Thread Simon Ser
On Friday, June 2nd, 2023 at 12:29, Michel Dänzer  wrote:

> > 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.

If you _really_ need a sync_file FD, you can extract it via
DMA_BUF_IOCTL_EXPORT_SYNC_FILE. This is a somewhat recent kernel uAPI.


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

2023-06-02 Thread Michel Dänzer
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



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

2023-06-01 Thread Hoosier, Matt
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?

-Matt

[1] 
https://www.collabora.com/news-and-blog/blog/2022/06/09/bridging-the-synchronization-gap-on-linux/
[2] https://lwn.net/Articles/814587/

Matt Hoosier
Staff Software Engineer
[auto_oem_sig_96dpi_solid]