mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
ui/gtk: skip any extra draw of same guest scanout blob res
Any extra draw call for the same blob resource representing guest scanout before the previous drawing is not finished can break synchronous draw sequence. To prevent this, drawing is now done only once for each draw submission (when draw_submitted == true). v2: - removed mutex - updated commit msg Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Vivek Kasireddy <vivek.kasireddy@intel.com> Signed-off-by: Dongwon Kim <dongwon.kim@intel.com> Message-Id: <20210924225105.24930-1-dongwon.kim@intel.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
760deab30e
commit
55f4b767f6
4 changed files with 59 additions and 33 deletions
|
@ -38,6 +38,9 @@ static void gtk_gl_area_set_scanout_mode(VirtualConsole *vc, bool scanout)
|
|||
|
||||
void gd_gl_area_draw(VirtualConsole *vc)
|
||||
{
|
||||
#ifdef CONFIG_GBM
|
||||
QemuDmaBuf *dmabuf = vc->gfx.guest_fb.dmabuf;
|
||||
#endif
|
||||
int ww, wh, y1, y2;
|
||||
|
||||
if (!vc->gfx.gls) {
|
||||
|
@ -53,6 +56,16 @@ void gd_gl_area_draw(VirtualConsole *vc)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_GBM
|
||||
if (dmabuf) {
|
||||
if (!dmabuf->draw_submitted) {
|
||||
return;
|
||||
} else {
|
||||
dmabuf->draw_submitted = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, vc->gfx.guest_fb.framebuffer);
|
||||
/* GtkGLArea sets GL_DRAW_FRAMEBUFFER for us */
|
||||
|
||||
|
@ -62,6 +75,22 @@ void gd_gl_area_draw(VirtualConsole *vc)
|
|||
glBlitFramebuffer(0, y1, vc->gfx.w, y2,
|
||||
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) {
|
||||
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
|
||||
} else {
|
||||
if (!vc->gfx.ds) {
|
||||
return;
|
||||
|
@ -72,25 +101,6 @@ void gd_gl_area_draw(VirtualConsole *vc)
|
|||
surface_gl_render_texture(vc->gfx.gls, vc->gfx.ds);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_GBM
|
||||
if (vc->gfx.guest_fb.dmabuf) {
|
||||
egl_dmabuf_create_sync(vc->gfx.guest_fb.dmabuf);
|
||||
}
|
||||
#endif
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -237,6 +247,7 @@ void gd_gl_area_scanout_flush(DisplayChangeListener *dcl,
|
|||
|
||||
if (vc->gfx.guest_fb.dmabuf) {
|
||||
graphic_hw_gl_block(vc->gfx.dcl.con, true);
|
||||
vc->gfx.guest_fb.dmabuf->draw_submitted = true;
|
||||
}
|
||||
gtk_gl_area_queue_render(GTK_GL_AREA(vc->gfx.drawing_area));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue