display/ui: add a callback to indicate GL state is flushed

Displaying rendered resources requires blocking qemu GPU to avoid extra
framebuffer copies. For an external display, via Spice currently, there
is a callback to block/unblock the rendering in the same thread.

But with the vhost-user-gpu backend, the qemu process doesn't handle
the rendering itself, and the blocking callback isn't effective.
Instead, the backend must be notified when the display code is done.

Fix this by adding a new GraphicHwOps callback to indicate the GL state
is flushed, and we are done manipulating the shared GL resources. Call
it from gtk and spice display.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20210204105232.834642-19-marcandre.lureau@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Marc-André Lureau 2021-02-04 14:52:30 +04:00 committed by Gerd Hoffmann
parent f8f3c2719e
commit 3cddb8b9e0
11 changed files with 48 additions and 10 deletions

View file

@ -294,6 +294,15 @@ void graphic_hw_gl_block(QemuConsole *con, bool block)
}
}
void graphic_hw_gl_flushed(QemuConsole *con)
{
assert(con != NULL);
if (con->hw_ops->gl_flushed) {
con->hw_ops->gl_flushed(con->hw);
}
}
int qemu_console_get_window_id(QemuConsole *con)
{
return con->window_id;

View file

@ -92,6 +92,9 @@ void gd_egl_draw(VirtualConsole *vc)
vc->gfx.scale_x = (double)ww / surface_width(vc->gfx.ds);
vc->gfx.scale_y = (double)wh / surface_height(vc->gfx.ds);
}
glFlush();
graphic_hw_gl_flushed(vc->gfx.dcl.con);
}
void gd_egl_update(DisplayChangeListener *dcl,

View file

@ -70,6 +70,9 @@ void gd_gl_area_draw(VirtualConsole *vc)
surface_gl_setup_viewport(vc->gfx.gls, vc->gfx.ds, ww, wh);
surface_gl_render_texture(vc->gfx.gls, vc->gfx.ds);
}
glFlush();
graphic_hw_gl_flushed(vc->gfx.dcl.con);
}
void gd_gl_area_update(DisplayChangeListener *dcl,

View file

@ -58,6 +58,7 @@ static void sdl2_gl_render_surface(struct sdl2_console *scon)
surface_gl_render_texture(scon->gls, scon->surface);
SDL_GL_SwapWindow(scon->real_window);
graphic_hw_gl_flushed(scon->dcl.con);
}
void sdl2_gl_update(DisplayChangeListener *dcl,
@ -240,4 +241,5 @@ void sdl2_gl_scanout_flush(DisplayChangeListener *dcl,
egl_fb_blit(&scon->win_fb, &scon->guest_fb, !scon->y0_top);
SDL_GL_SwapWindow(scon->real_window);
graphic_hw_gl_flushed(dcl->con);
}

View file

@ -826,6 +826,7 @@ static void qemu_spice_gl_unblock_bh(void *opaque)
SimpleSpiceDisplay *ssd = opaque;
qemu_spice_gl_block(ssd, false);
graphic_hw_gl_flushed(ssd->dcl.con);
}
static void qemu_spice_gl_block_timer(void *opaque)