@@ -51,8 +51,7 @@ int egl_get_fd_for_texture(uint32_t tex_id, EGLint *stride, EGLint *fourcc,
void egl_dmabuf_import_texture(QemuDmaBuf *dmabuf);
void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf);
-void egl_dmabuf_create_sync(QemuDmaBuf *dmabuf);
-void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf);
+int egl_dmabuf_create_fence_fd(QemuDmaBuf *dmabuf);
#endif
@@ -371,9 +371,10 @@ void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf)
qemu_dmabuf_set_texture(dmabuf, 0);
}
-void egl_dmabuf_create_sync(QemuDmaBuf *dmabuf)
+int egl_dmabuf_create_fence_fd(QemuDmaBuf *dmabuf)
{
EGLSyncKHR sync;
+ int fence_fd = -1;
if (epoxy_has_egl_extension(qemu_egl_display,
"EGL_KHR_fence_sync") &&
@@ -382,23 +383,16 @@ void egl_dmabuf_create_sync(QemuDmaBuf *dmabuf)
sync = eglCreateSyncKHR(qemu_egl_display,
EGL_SYNC_NATIVE_FENCE_ANDROID, NULL);
if (sync != EGL_NO_SYNC_KHR) {
- qemu_dmabuf_set_sync(dmabuf, sync);
+ fence_fd = eglDupNativeFenceFDANDROID(qemu_egl_display,
+ sync);
+ if (fence_fd >= 0) {
+ qemu_dmabuf_set_fence_fd(dmabuf, fence_fd);
+ }
+ eglDestroySyncKHR(qemu_egl_display, sync);
}
}
-}
-
-void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf)
-{
- void *sync = qemu_dmabuf_get_sync(dmabuf);
- int fence_fd;
- if (sync) {
- fence_fd = eglDupNativeFenceFDANDROID(qemu_egl_display,
- sync);
- qemu_dmabuf_set_fence_fd(dmabuf, fence_fd);
- eglDestroySyncKHR(qemu_egl_display, sync);
- qemu_dmabuf_set_sync(dmabuf, NULL);
- }
+ return fence_fd;
}
#endif /* CONFIG_GBM */
@@ -68,7 +68,6 @@ void gd_egl_draw(VirtualConsole *vc)
GdkWindow *window;
#ifdef CONFIG_GBM
QemuDmaBuf *dmabuf = vc->gfx.guest_fb.dmabuf;
- int fence_fd;
#endif
int ww, wh, ws;
@@ -98,14 +97,13 @@ void gd_egl_draw(VirtualConsole *vc)
glFlush();
#ifdef CONFIG_GBM
- if (dmabuf) {
- egl_dmabuf_create_fence(dmabuf);
- fence_fd = qemu_dmabuf_get_fence_fd(dmabuf);
+ if (dmabuf && qemu_dmabuf_get_fence_fd(dmabuf) == -1) {
+ int fence_fd = egl_dmabuf_create_fence_fd(dmabuf);
if (fence_fd >= 0) {
qemu_set_fd_handler(fence_fd, gd_hw_gl_flushed, NULL, vc);
- return;
+ } else {
+ graphic_hw_gl_block(vc->gfx.dcl.con, false);
}
- graphic_hw_gl_block(vc->gfx.dcl.con, false);
}
#endif
} else {
@@ -364,12 +362,6 @@ 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);
}
@@ -387,7 +379,6 @@ void gd_egl_flush(DisplayChangeListener *dcl,
gtk_widget_queue_draw_area(area, x, y, w, h);
return;
}
-
gd_egl_scanout_flush(&vc->gfx.dcl, x, y, w, h);
}
@@ -78,16 +78,9 @@ void gd_gl_area_draw(VirtualConsole *vc)
0, 0, ww, wh,
GL_COLOR_BUFFER_BIT, GL_NEAREST);
#ifdef CONFIG_GBM
- if (dmabuf) {
- egl_dmabuf_create_sync(dmabuf);
- }
-#endif
- glFlush();
-#ifdef CONFIG_GBM
- if (dmabuf) {
+ if (dmabuf && qemu_dmabuf_get_fence_fd(dmabuf) == -1) {
int fence_fd;
- egl_dmabuf_create_fence(dmabuf);
- fence_fd = qemu_dmabuf_get_fence_fd(dmabuf);
+ fence_fd = egl_dmabuf_create_fence_fd(dmabuf);
if (fence_fd >= 0) {
qemu_set_fd_handler(fence_fd, gd_hw_gl_flushed, NULL, vc);
return;
@@ -95,6 +88,7 @@ void gd_gl_area_draw(VirtualConsole *vc)
graphic_hw_gl_block(vc->gfx.dcl.con, false);
}
#endif
+ glFlush();
} else {
if (!vc->gfx.ds) {
return;