Hi Gerd, Sorry for the delayed response. I wanted to wait until I finished my proof-of-concept -- that included adding synchronization -- to ask follow up questions.
> > > > Does your work above not count for anything? > > It is quite old, and I think not up-to-date with the final revision of the > blob resource > specification. I wouldn't be able to update this in near future due to being > busy with other > projects. Feel free to grab & update & submit these patches though. [Kasireddy, Vivek] Sure, we'll take a look at your work and use that as a starting point. Roughly, how much of your work can be reused? Also, given my limited understanding of how discrete GPUs work, I was wondering how many copies would there need to be with blob resources/dmabufs and whether a zero-copy goal would be feasible or not? > > Beside the code duplication this is also a maintainance issue. This adds one > more > configuration to virtio-gpu. Right now you can build virtio-gpu with virgl > (depends on > opengl), or you can build without virgl (doesn't use opengl then). I don't > think it is a good > idea to add a third mode, without virgl support but using opengl for blob > dma-bufs. [Kasireddy, Vivek] We'll have to re-visit this part but for our use-case with virtio-gpu, we are disabling virglrenderer in Qemu and virgl DRI driver in the Guest. However, we still need to use Opengl/EGL to convert the dmabuf (guest fb) to texture and render as part of the UI/GTK updates. > > > > On a different note, any particular reason why Qemu UI EGL > > implementation is limited to Xorg and not extended to Wayland/Weston > > for which there is GTK glarea? > > Well, ideally I'd love to just use glarea. Which happens on wayland. > > The problem with Xorg is that the gtk x11 backend uses glx not egl to create > an opengl > context for glarea. At least that used to be the case in the past, maybe > that has changed > with newer versions. qemu needs egl contexts though, otherwise dma-bufs > don't work. So > we are stuck with our own egl widget implementation for now. Probably we > will be able > to drop it at some point in the future. [Kasireddy, Vivek] GTK X11 backend still uses GLX and it seems like that is not going to change anytime soon. Having said that, I was wondering if it makes sense to add a new purely Wayland backend besides GtkGlArea so that Qemu UI can more quickly adopt new features such as explicit sync. I was thinking about the new backend being similar to this: https://cgit.freedesktop.org/wayland/weston/tree/clients/simple-dmabuf-egl.c The reason why I am proposing this idea is because even if we manage to add explicit sync support to GTK and it gets merged, upgrading Qemu GTK support from 3.22 to > 4.x may prove to be daunting. Currently, the way I am doing explicit sync is by adding these new APIs to GTK and calling them from Qemu: static int create_egl_fence_fd(EGLDisplay dpy) { EGLSyncKHR sync = eglCreateSyncKHR(dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL); int fd; g_assert(sync != EGL_NO_SYNC_KHR); fd = eglDupNativeFenceFDANDROID(dpy, sync); g_assert(fd >= 0); eglDestroySyncKHR(dpy, sync); return fd; } static void wait_for_buffer_release_fence(EGLDisplay dpy) { int ret; EGLint attrib_list[] = { EGL_SYNC_NATIVE_FENCE_FD_ANDROID, release_fence_fd, EGL_NONE, }; if (release_fence_fd < 0) return; EGLSyncKHR sync = eglCreateSyncKHR(dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, attrib_list); g_assert(sync); release_fence_fd = -1; eglClientWaitSyncKHR(dpy, sync, 0, EGL_FOREVER_KHR); eglDestroySyncKHR(dpy, sync); } And, of-course, I am tying the wait above to a dma_fence associated with the previous guest FB that is signalled to ensure that the Host is done using the FB thereby providing explicit synchronization between Guest and Host. It seems to work OK but I was wondering if you had any alternative ideas or suggestions for doing explicit or implicit sync that are more easier. Lastly, on a different note, I noticed that there is a virtio-gpu Windows driver here: https://github.com/virtio-win/kvm-guest-drivers-windows/tree/master/viogpu We are going to try it out but do you know how up to date it is kept? Thanks, Vivek