<div dir="ltr"><div dir="ltr"><div dir="ltr"><div><br></div></div><div dir="ltr">Hi Pekka,<div><br></div><div>> I suppose that applies to the opaque EGL buffers only?</div><div>Sort of. As far as I understand it, the divide is between wl_surface managed by EGL/WSI vs. wl_surface managed directly by the client application. For EGL case the wl_surface managed by EGL would be set-up more or less like this:</div><div><font color="#000000" face="monospace, monospace"><span style="white-space:pre-wrap">struct wl_egl_window *window = wl_egl_window_create(surface, w, h);</span></font></div><div><font face="monospace, monospace">EGLDisplay dpy = eglGetPlatformDisplay(<span style="color:rgb(0,0,0);white-space:pre-wrap">EGL_PLATFORM_WAYLAND_EXT, ...);</span></font></div><div><font face="monospace, monospace">EGLSurface surface = eglCreatePlatformWindowSurface(dpy, config, window);</font></div><div>With this setup EGL becomes responsible for managing the swapchain buffers, keeping up with window resizes, sending wl_buffers to compositor when client app calls eglSwapBuffers() etc. This is how weston-simple-egl works.</div><div><br>> Otherwise, a client could use e.g. EGL in a different way to get dmabuf,<br>> send those manually to the compositor and set up fences manually as<br>> well. weston-simple-dmabuf-egl in the MR is one variant of that. Of<br>> course, it depends on the EGL stack supporting dmabuf to begin with, so<br>> if yours doesn't then it's not possible.</div><div>Yes, exactly. This is the example where the application manages the Wayland window directly and the EGL driver is not involved. EGL is only used to set up rendering into an off-screen buffer(s) of some description.</div><div><br></div><div>In both cases the compositor receives a wl_buffer and has to figure out how to render the contents of such buffer. In both cases the wl_buffer could encapsulate dma-buf and the compositor wouldn't be able to tell whether it came directly from application (weston-simple-dmabuf-egl) or from the EGL driver (weston-simple-egl). in fact the Waylad client could choose dma-buf, prime, flink, shm, something else, regardless of how the wl_surface is managed, whether it's done directly by the application, by the EGL or Vulkan driver. And some of those wl_buffer types will be known to the compositor, some to the 3D driver and perhaps some to both. At least that's my understanding. </div><div><br></div><div>Cheers,</div><div>Tomek</div><div><br></div><div><br></div><div><br></div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, 27 Nov 2018 at 08:53, Pekka Paalanen <<a href="mailto:ppaalanen@gmail.com">ppaalanen@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, 26 Nov 2018 15:14:45 +0000<br>
Tomek Bury <<a href="mailto:tomek.bury@gmail.com" target="_blank">tomek.bury@gmail.com</a>> wrote:<br>
<br>
> Hi Pekka,<br>
> <br>
> Yes, sorry, I was writing specifically about Weston implementation. In the<br>
> merge request from Alexandros the actual compatibility check is in the main<br>
> compositor, while compositor doesn't have enough information to decide<br>
> whether the selected renderer can handle buffer+fence combination or not.<br>
> <br>
> As for the opaque wl_buffer, that's an internal implementation detail of<br>
> Vulkan WSI or EGL so different drivers can choose to do different things<br>
> here. It's the 3D driver, and *NOT* the client application, that creates<br>
> those buffers and sends attach/damage/commit sequence to the compositor.<br>
> The 3D driver makes a decision what type of buffer to use, an EGL or Vulkan<br>
> client application doesn't have any means of accessing wl_buffer objects,<br>
> it's all hidden away.<br>
<br>
Hi Tomek,<br>
<br>
I suppose that applies to the opaque EGL buffers only?<br>
<br>
Otherwise, a client could use e.g. EGL in a different way to get dmabuf,<br>
send those manually to the compositor and set up fences manually as<br>
well. weston-simple-dmabuf-egl in the MR is one variant of that. Of<br>
course, it depends on the EGL stack supporting dmabuf to begin with, so<br>
if yours doesn't then it's not possible.<br>
<br>
However, in the fence protocol extension specification we must take all<br>
possible use cases into account. The client side of the fence extension<br>
is not exclusive to EGL implementations, and the server side is even<br>
less, because the server side implementation cannot be an EGL<br>
implementation detail.<br>
<br>
This is why I'm talking about protocol spec - the Weston implementation<br>
just reflects the spec, or at least attempts to.<br>
<br>
> On the compositor side buffers are received through one of the protocol<br>
> extensions you've mentioned. The compositor has a choice to make. It can<br>
> either probe the wl_buffer for known buffer types or leave that task to the<br>
> EGL implementation. Let's say a client-side driver uses dma-buf buffers for<br>
> its swapchain images. If the compositor knows how to handle dma-buf, it can<br>
> either directly access those buffers or it can hand them over to the<br>
> compositor-side 3D driver through<br>
> eglCreateImage(dpy, EGL_LINUX_DMA_BUF_EXT, ...). If the compositor doesn't<br>
> know the particular type of buffer, it can check if EGL can handle it<br>
> either through eglCreateImage(dpy, EGL_WAYLAND_BUFFER_WL, ...) or<br>
> eglQueryWaylandBufferWL(...).<br>
> If the client and compositor use the same 3D driver (that's the most likely<br>
> scenario) this is bound to work. In multiple-GPU configurations your<br>
> mileage may vary though.<br>
<br>
Right.<br>
<br>
A wl_buffer can be used with either EGL_WAYLAND_BUFFER_WL or as a<br>
dmabuf via EGL_LINUX_DMA_BUF, but there is no choice for a compositor<br>
to make as at most only one these can work for a given wl_buffer.<br>
<br>
> If the EGL implementation can use the type of the wl_buffer and can import<br>
> the fence fd, you're home. Having said that, I can't think of a way of<br>
> figuring out ahead of time what type of wl_buffer the client-side driver is<br>
> going to use for its swapchain and whether this particular type will be<br>
> accepted by the compositor-side driver.<br>
<br>
There is no need for the compositor to know in advance. Instead, the<br>
client must know what the compositor supports, since the client is<br>
making the decisions on buffer allocation etc. (or the decision to use<br>
EGL or Vulkan and not care about buffers explicitly, in which case the<br>
EGL/WSI implementation must know).<br>
<br>
The opaque EGL buffers already rely on using the same EGL<br>
implementation on both compositor and client, so if a compositor also<br>
exposes the fence extension, the client-side EGL implementation can be<br>
sure it can use the fence extension with the opaque EGL buffers (or if<br>
it cannot, the client-side EGL implementation already knows that<br>
because it knows the details of the compositor-side EGL implementation).<br>
<br>
That is, if we write that down in the fence extension spec. I think we<br>
should.<br>
<br>
> This is how I use it at the moment: I've written a custom Weston backend<br>
> because the code runs on top of an embedded middleware. My backend always<br>
> uses GL renderer. The GL renderer has to call eglBindWaylandDisplayWL() at<br>
> startup, and the implementation of that API in the 3D driver adds a custom<br>
> Wayland protocol extension for sharing buffers. Now the scene is set. When<br>
> a Wayland client application starts, the EGL or Vulkan WSI implementation<br>
> driver goes for that extension and bails out if unavailable. This way<br>
> swapchain buffers from EGL and Vulkan client can be used by Weston's GL<br>
> renderer without any knowledge of the embedded platform details.<br>
<br>
Yup, that is how the "opaque EGL buffer" type is supposed to work.<br>
<br>
> With regards to using fences directly by the client app, I guess it's the<br>
> same principle as drawing into the window. Either client app does<br>
> everything "by hand" or lets the Vulkan or EGL/GLES do it. If the app is in<br>
> charge, the app manages the window swap chain buffers and synchronization,<br>
> otherwise the 3D driver does it. You shouldn't allow more than one thing<br>
> managing the Wayland window at the same time. Perhaps you could use wording<br>
> similar to Vulkan WSI or EGL window surface when describing what is and<br>
> what isn't allowed when it comes to Wayland windows.<br>
<br>
Yes, we probably should have some wording that if a client is letting<br>
something like EGL to commit the buffers, it must not attempt to use<br>
the fence extension on that wl_surface itself because EGL will probably<br>
be using the extension already.<br>
<br>
Alf?<br>
<br>
<br>
Thanks,<br>
pq<br>
<br>
> On Mon, 26 Nov 2018 at 09:22, Pekka Paalanen <<a href="mailto:ppaalanen@gmail.com" target="_blank">ppaalanen@gmail.com</a>> wrote:<br>
> <br>
> > On Fri, 23 Nov 2018 16:26:19 +0000<br>
> > Tomek Bury <<a href="mailto:tomek.bury@gmail.com" target="_blank">tomek.bury@gmail.com</a>> wrote:<br>
> > <br>
> > > Hi Pekka,<br>
> > > <br>
> > > > I presume you have a driver stack that relies on the opaque EGL <br>
> > buffers <br>
> > > and not zwp_linux_dmabuf any time soon?<br>
> > > Yes, exactly. I've added a protocol extension for sharing those buffers <br>
> > and <br>
> > > our eglCreateImage() implementation can import such buffers into the <br>
> > driver <br>
> > > on the compositor end. The buffers are carried by an fd to the compositor<br>
> > > that's the only similarity. They're not dma-buf.<br>
> > > <br>
> > > > Yeah, support for opaque EGL buffers could be added, just need to <br>
> > think <br>
> > > of a good wording, since acquire fences do not make sense for all buffer<br>
> > > types. <br>
> > <br>
> > > Isn't that renderer's and/or backend's decision? The GL renderer can <br>
> > accept <br>
> > > fence with any buffer it can send to the 3D driver, so, effectively,<br>
> > > anything backed by available EGL image extensions. Someone may add a <br>
> > custom <br>
> > > backend and/or renderer using whatever hardware or API they have at <br>
> > hand. A <br>
> > > Vulkan renderer could potentially use fences with anything a Vulkan <br>
> > driver <br>
> > > is capable of importing. A renderer that does the CPU wait could be <br>
> > useful <br>
> > > at least for debugging. So I wouln't block the explicit sync at the<br>
> > > compositor level based on the white list. <br>
> ><br>
> > Hi Tomek,<br>
> ><br>
> > fences do not make sense to all buffer types to begin with, today. My<br>
> > objection is to allowing fencing buffer types that cannot be sent to<br>
> > the 3D driver, e.g. wl_shm which is usually copied through glTexImage2D<br>
> > and friends. We cannot ignore those in the spec language.<br>
> ><br>
> > A renderer (a compositor really, we're not talking about just Weston)<br>
> > decides what buffer types it accepts, yes. This is communicated to<br>
> > clients through which buffer factory interface globals are being<br>
> > advertised. Each type is a different protocol extension. The fence<br>
> > extension OTOH is just a single extension, and currently there is no<br>
> > protocol to negotiate which buffer types are usable with acquire<br>
> > fences. The first attempt is to define in the spec language what will<br>
> > always be supported, provided the buffer factory exists.<br>
> ><br>
> > The opaque EGL buffer type is really just one type in practise:<br>
> > compositors and clients use it through a well-known, single API: EGL.<br>
> > It does not matter that there are multiple incompatible EGL<br>
> > implementations, it all looks like just one opaque buffer type to<br>
> > compositors. I think this makes it easier to extend the fence spec<br>
> > wording to require opaque EGL buffers to be supported.<br>
> ><br>
> > Either the fence protocol spec needs to be clear on what works, or we<br>
> > need advertisement events to let clients know in advance what the<br>
> > compositor supports. A client sending a fence that the compositor<br>
> > cannot use must not be possible; compositor, client, EGL, driver, etc.<br>
> > bugs notwithstanding.<br>
> ><br>
> > Btw. I just realized that if client-side EGL uses the fence extension<br>
> > internally, that means the client app code must not attempt to add or<br>
> > request fences of its own, because the spec disallows multiple acquire<br>
> > fences and multiple release notification requests. I suppose that's<br>
> > fine?<br>
> ><br>
> > Alf, can you come up with changes to the spec wording and Weston to<br>
> > require opaque EGL buffers are supported?<br>
> ><br>
> > On one hand it is actually a little strange to couple opaque EGL<br>
> > buffers (a private, EGL implementation specific protocol interface)<br>
> > with a generic fencing extension, but maybe that is necessary because<br>
> > there is not enough compositor-side GBM and EGL API so that the EGL<br>
> > implementation could handle it all in an EGL implementation specific<br>
> > interface?<br>
> ><br>
> ><br>
> > Thanks,<br>
> > pq<br>
> > <br>
> > > On Fri, 23 Nov 2018 at 13:47, Pekka Paalanen <<a href="mailto:ppaalanen@gmail.com" target="_blank">ppaalanen@gmail.com</a>> <br>
> > wrote: <br>
> > > <br>
> > > > On Fri, 23 Nov 2018 13:07:37 +0000<br>
> > > > Tomek Bury <<a href="mailto:tomek.bury@gmail.com" target="_blank">tomek.bury@gmail.com</a>> wrote:<br>
> > > > <br>
> > > > > Hi Alexandros,<br>
> > > > ><br>
> > > > > Sorry for a delay. I've finally got an end-to-end system to test it <br>
> > out. <br>
> > > > It <br>
> > > > > took some time because Weston backend I wrote a while back needed <br>
> > serious <br>
> > > > > rework to catch up with latest changes.<br>
> > > > ><br>
> > > > > There's one thing that didn't work for me. In compositor you reject<br>
> > > > > anything that isn't a DMA buffer and then in glrenderer you put an <br>
> > extra <br>
> > > > > assertion. Why? All you do is use an EGL extension in order to import<br>
> > > > > external fence_fd. There's no dmabuf dependency there. As long as <br>
> > the EGL <br>
> > > > > implementation exposes EGL_SYNC_NATIVE_FENCE_ANDROID extension this <br>
> > > > should <br>
> > > > > "just work" (tm) for the GL renderer. It certainly did for me. <br>
> > CPU-based <br>
> > > > > renderers can poll() to wait. <br>
> > > ><br>
> > > > Hi Tomek,<br>
> > > ><br>
> > > > with Weston it was decided not to implement a poll() based wait at<br>
> > > > first as implementing that properly (not blocking the compositor) would<br>
> > > > be a big hassle and no-one could see the benefit of it given what<br>
> > > > clients could actually produce.<br>
> > > ><br>
> > > > Therefore the acquire fence can only apply to buffers which can be<br>
> > > > pipelined to a GPU. Mesa EGL is using zwp_linux_dmabuf, but the support<br>
> > > > could be extended to opaque EGL buffers very well. We just chose to<br>
> > > > start small and bring up the infrastructure around fences first.<br>
> > > ><br>
> > > > Restrictions on buffer types etc. can certainly be lifted in the future<br>
> > > > if there are good use cases. I presume you have a driver stack that<br>
> > > > relies on the opaque EGL buffers and not zwp_linux_dmabuf any time <br>
> > soon? <br>
> > > ><br>
> > > > Would anyone ever use an acquire fence with wl_shm buffers? That sounds<br>
> > > > fundamentally wrong to me as one cannot create fences to be signalled<br>
> > > > by userspace AFAIK. Therefore buffers whose wait cannot be pipelined to<br>
> > > > the GPU or the display device do not make much sense to me.<br>
> > > > <br>
> > > > > The type of buffer used is an orthogonal problem. The<br>
> > > > > EGL_WL_bind_wayland_display<br>
> > > > > extension takes care of GL clients' buffers in GL renderer, for <br>
> > anything <br>
> > > > > else the renderer needs to know how to get pixels and use whatever <br>
> > means <br>
> > > > to <br>
> > > > > put those pixels on screen. <br>
> > > ><br>
> > > > Yeah, support for opaque EGL buffers could be added, just need to think<br>
> > > > of a good wording, since acquire fences do not make sense for all<br>
> > > > buffer types. A compositor must be allowed to raise protocol errors for<br>
> > > > fence+buffer combinations it cannot use, which means that clients must<br>
> > > > know in advance what they cannot use.<br>
> > > ><br>
> > > ><br>
> > > > Thanks,<br>
> > > > pq<br>
> > > > <br>
> > > > > On Tue, 13 Nov 2018 at 09:33, Tomek Bury <<a href="mailto:tomek.bury@gmail.com" target="_blank">tomek.bury@gmail.com</a>> <br>
> > wrote: <br>
> > > > > <br>
> > > > > > Thanks!<br>
> > > > > ><br>
> > > > > > On Tue, Nov 13, 2018 at 9:08 AM Alexandros Frantzis < <br>
> > > > > > <a href="mailto:alexandros.frantzis@collabora.com" target="_blank">alexandros.frantzis@collabora.com</a>> wrote: <br>
> > > > > > <br>
> > > > > >> On Mon, Nov 12, 2018 at 12:39:58PM +0000, Tomek Bury wrote: <br>
> > > > > >> > On Mon, Nov 12, 2018 at 11:15 AM Daniel Stone < <br>
> > <a href="mailto:daniel@fooishbar.org" target="_blank">daniel@fooishbar.org</a>> <br>
> > > > <br>
> > > > > >> wrote: <br>
> > > > > >> > <br>
> > > > > >> > > On Fri, 9 Nov 2018 at 10:48, Pekka Paalanen < <br>
> > <a href="mailto:ppaalanen@gmail.com" target="_blank">ppaalanen@gmail.com</a>> <br>
> > > > <br>
> > > > > >> wrote: <br>
> > > > > >> > > > I can add that while pushing upstream, if there are no <br>
> > other <br>
> > > > changes <br>
> > > > > >> > > > coming.<br>
> > > > > >> > > ><br>
> > > > > >> > > > Reviewed-by: Pekka Paalanen <<a href="mailto:pekka.paalanen@collabora.co.uk" target="_blank">pekka.paalanen@collabora.co.uk</a> <br>
> > > <br>
> > > > > >> > > ><br>
> > > > > >> > > > You have ensured that the C files generated from this <br>
> > revision <br>
> > > > build <br>
> > > > > >> > > > fine in Weston, right?<br>
> > > > > >> > > ><br>
> > > > > >> > > > David, Daniel, since your name is in the maintainers, can <br>
> > I <br>
> > > > have <br>
> > > > > >> your <br>
> > > > > >> > > > R-b, please? <br>
> > > > > >> > ><br>
> > > > > >> > > The protocol is:<br>
> > > > > >> > > Reviewed-by: Daniel Stone <<a href="mailto:daniels@collabora.com" target="_blank">daniels@collabora.com</a>><br>
> > > > > >> > ><br>
> > > > > >> > > The Weston implementation looks pretty good so far, though <br>
> > > > there's no <br>
> > > > > >> > > full implementation of release yet.<br>
> > > > > >> > ><br>
> > > > > >> > > Cheers,<br>
> > > > > >> > > Daniel<br>
> > > > > >> > > _______________________________________________<br>
> > > > > >> > > wayland-devel mailing list<br>
> > > > > >> > > <a href="mailto:wayland-devel@lists.freedesktop.org" target="_blank">wayland-devel@lists.freedesktop.org</a><br>
> > > > > >> > > <a href="https://lists.freedesktop.org/mailman/listinfo/wayland-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
> > > > > >> > > <br>
> > > > > >> ><br>
> > > > > >> > HI Daniel,<br>
> > > > > >> ><br>
> > > > > >> > Where can I find the work-in-progress implementation? I'd like <br>
> > to <br>
> > > > try it <br>
> > > > > >> > out with Broadcom driver which doesn't have implicit <br>
> > cross-process <br>
> > > > > >> sync. I <br>
> > > > > >> > can add the explicit sync protocol implementation on the <br>
> > driver <br>
> > > > side but <br>
> > > > > >> > I'd need a reference to test it against.<br>
> > > > > >> ><br>
> > > > > >> > Cheers,<br>
> > > > > >> > Tomek <br>
> > > > > >><br>
> > > > > >> Hi Tomek,<br>
> > > > > >><br>
> > > > > >> the WIP implementation can be found here [1]. I hope to push an <br>
> > > > update, <br>
> > > > > >> including some zwp_buffer_release_v1 correctness fixes, in the <br>
> > > > following <br>
> > > > > >> days.<br>
> > > > > >><br>
> > > > > >> Thanks,<br>
> > > > > >> Alexandros<br>
> > > > > >><br>
> > > > > >> [1] <br>
> > <a href="https://gitlab.freedesktop.org/wayland/weston/merge_requests/32" rel="noreferrer" target="_blank">https://gitlab.freedesktop.org/wayland/weston/merge_requests/32</a> <br>
> > > > > >> <br>
> > > > > > <br>
> > > ><br>
> > > > <br>
> ><br>
> > <br>
<br>
</blockquote></div>