<div dir="ltr"><div dir="ltr">Hi Pekka,<div><br></div><div>I'm just trying to figure out how to use this extension in a driver. Without this extension the only option I have is to take a copy if each wl_buffer on the compositor-side. I can't really do implicit sync so I'm really happy with anything that allows for explicit sync.</div><div><br></div><div>> Is it possible to have some variant of glTexImage2D wait for an EGLSync<br></div><div>> before it actually reads from the source?<br></div><div>I don't think so. The glTexImage2D mustn't hold onto any client pointers. GLES3 buffers require mmap and CPU copy. Pixmaps are unsupported so EGL images are the only remaining thing I can think of.</div><div><br></div><div>>  It would be enough for the fence spec to<br>> define what "opaque EGL buffer" is and then say that they also work in<br>> addition to zwp_linux_dmabuf buffers.<br></div><div>Yup, that works for me.</div><div><br></div><div><div>> If a client wants to, it could start with wl_shm and CPU-rendered<br>> content, then switch to EGL managed surface, then shut down EGL and<br>> switch back to wl_shm all on the very same wl_surface, for example.<br></div><div>Hmmm, perhaps the set_acquire_fence() should be a buffer operation, not a surface operation then? What you wrote means to me that the compositor knows of every buffer the client created but doesn't know which buffer the client is going to attach next. The earliest moment the compositor learns about the buffer for the next frame is when the attach request reaches the compositor. And that would be most likely after the attach/damage/commit gets flushed at the end of frame by the client. But that's a battle for another day.</div><div><br></div></div><div>Cheers,</div><div>Tomek</div><div><br></div><div><br></div><div><br></div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, 27 Nov 2018 at 13:10, Pekka Paalanen <<a href="mailto:ppaalanen@gmail.com" target="_blank">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 Tue, 27 Nov 2018 10:56:39 +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 suppose that applies to the opaque EGL buffers only?  <br>
> Sort of. As far as I understand it, the divide is between wl_surface<br>
> managed by EGL/WSI vs. wl_surface managed directly by the client<br>
> application. For EGL case the wl_surface managed by EGL would be set-up<br>
> more or less like this:<br>
> struct wl_egl_window *window = wl_egl_window_create(surface, w, h);<br>
> EGLDisplay dpy = eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, ...);<br>
> EGLSurface surface = eglCreatePlatformWindowSurface(dpy, config, window);<br>
> With this setup EGL becomes responsible for managing the swapchain buffers,<br>
> keeping up with window resizes, sending wl_buffers to compositor when<br>
> client app calls eglSwapBuffers() etc. This is how weston-simple-egl works.<br>
<br>
Hi Tomek,<br>
<br>
that is how most apps work, but nothing is forbidding a client from<br>
switching.<br>
<br>
If a client wants to, it could start with wl_shm and CPU-rendered<br>
content, then switch to EGL managed surface, then shut down EGL and<br>
switch back to wl_shm all on the very same wl_surface, for example.<br>
<br>
I cannot point to any example of such client, but it is not forbidden<br>
anywhere. If apps start supporting GPU hotplug, then I imagine such<br>
switching would become useful.<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>
> Yes, exactly. This is the example where the application manages the Wayland<br>
> window directly and the EGL driver is not involved. EGL is only used to set<br>
> up rendering into an off-screen buffer(s) of some description.<br>
> <br>
> In both cases the compositor receives a wl_buffer and has to figure out how<br>
> to render the contents of such buffer. In both cases the wl_buffer could<br>
> encapsulate dma-buf and the compositor wouldn't be able to tell whether it<br>
> came directly from application (weston-simple-dmabuf-egl) or from the EGL<br>
> driver (weston-simple-egl). in fact the Waylad client could choose dma-buf,<br>
> prime, flink, shm, something else, regardless of how the wl_surface is<br>
> managed, whether it's done directly by the application, by the EGL or<br>
> Vulkan driver. And some of those wl_buffer types will be known to the<br>
> compositor, some to the 3D driver and perhaps some to both. At least that's<br>
> my understanding.<br>
<br>
Sure. I'm not sure how that is relevant though, or what we are debating<br>
about.<br>
<br>
A compositor cares about how it will access a buffer: is the access<br>
off-loaded somewhere which can or cannot import acquire fences, or does it<br>
need to read the buffer with CPU directly. I would like to avoid<br>
requiring fence support from compositors when they do not have a way to<br>
off-load the fence wait.<br>
<br>
Is it possible to have some variant of glTexImage2D wait for an EGLSync<br>
before it actually reads from the source? If there is, then I'll<br>
reconsider about the buffer type requirements.<br>
<br>
It is a happy coincidence, that in the cases where a compositor does<br>
not have a way to off-load a fence wait, it would also be very hard for<br>
a client to arrange a fence to be waited on in the first place. But,<br>
the protocol specification cannot rely on such practicalities, instead<br>
it needs to set clear expectations on what should work.<br>
<br>
Saying, that if a compositor supports the fence extension and opaque EGL<br>
buffers then it needs to support opaque EGL buffers with acquire<br>
fences, seems like a good idea. Neither condition needs to be written<br>
out explicitly: it is the fence extension spec and a compositor either<br>
supports all of it or none of it; whether it is possible to have opaque<br>
EGL buffers depends on the compositor initializing the support which is<br>
well discoverable to clients. It would be enough for the fence spec to<br>
define what "opaque EGL buffer" is and then say that they also work in<br>
addition to zwp_linux_dmabuf buffers.<br>
<br>
<br>
Thanks,<br>
pq<br>
</blockquote></div>