summaryrefslogtreecommitdiffstats
path: root/ui/gtk-egl.c
diff options
context:
space:
mode:
authorVivek Kasireddy2021-09-14 23:18:35 +0200
committerGerd Hoffmann2021-09-15 08:41:59 +0200
commit65b847d284c1ab8a1dbd44d2b046e87e83ebb6e0 (patch)
tree63b0281591813862f2802aa44cf4e5fda2aecc8e /ui/gtk-egl.c
parentui/egl: Add egl helpers to help with synchronization (diff)
downloadqemu-65b847d284c1ab8a1dbd44d2b046e87e83ebb6e0.tar.gz
qemu-65b847d284c1ab8a1dbd44d2b046e87e83ebb6e0.tar.xz
qemu-65b847d284c1ab8a1dbd44d2b046e87e83ebb6e0.zip
ui: Create sync objects and fences only for blobs
Create sync objects and fences only for dmabufs that are blobs. Once a fence is created (after glFlush) and is signalled, graphic_hw_gl_flushed() will be called and virtio-gpu cmd processing will be resumed. Cc: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com> Message-Id: <20210914211837.3229977-4-vivek.kasireddy@intel.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui/gtk-egl.c')
-rw-r--r--ui/gtk-egl.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index b671181272..3a90aeb2b9 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -12,6 +12,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/main-loop.h"
#include "trace.h"
@@ -94,6 +95,18 @@ void gd_egl_draw(VirtualConsole *vc)
}
glFlush();
+#ifdef CONFIG_GBM
+ if (vc->gfx.guest_fb.dmabuf) {
+ QemuDmaBuf *dmabuf = vc->gfx.guest_fb.dmabuf;
+
+ egl_dmabuf_create_fence(dmabuf);
+ if (dmabuf->fence_fd > 0) {
+ qemu_set_fd_handler(dmabuf->fence_fd, gd_hw_gl_flushed, NULL, vc);
+ return;
+ }
+ graphic_hw_gl_block(vc->gfx.dcl.con, false);
+ }
+#endif
graphic_hw_gl_flushed(vc->gfx.dcl.con);
}
@@ -209,6 +222,8 @@ void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
QemuDmaBuf *dmabuf)
{
#ifdef CONFIG_GBM
+ VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
+
egl_dmabuf_import_texture(dmabuf);
if (!dmabuf->texture) {
return;
@@ -217,6 +232,10 @@ void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
gd_egl_scanout_texture(dcl, dmabuf->texture,
false, dmabuf->width, dmabuf->height,
0, 0, dmabuf->width, dmabuf->height);
+
+ if (dmabuf->allow_fences) {
+ vc->gfx.guest_fb.dmabuf = dmabuf;
+ }
#endif
}
@@ -281,6 +300,12 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl,
egl_fb_blit(&vc->gfx.win_fb, &vc->gfx.guest_fb, !vc->gfx.y0_top);
}
+#ifdef CONFIG_GBM
+ if (vc->gfx.guest_fb.dmabuf) {
+ egl_dmabuf_create_sync(vc->gfx.guest_fb.dmabuf);
+ }
+#endif
+
eglSwapBuffers(qemu_egl_display, vc->gfx.esurface);
}