ui/gtk: skip refresh if new dmabuf is submitted
PATCH 1/1 ui/gtk: skip refresh if new dmabuf is submitted
Skip refresh if a new dmabuf (guest scanout frame) is submitted and ready to be drawn because the scanout will be refreshed with new frame anyway.
Also, setting scanout mode is better to be done right before a draw event is scheduled because the mode can be reset anytime after it is set in dpy_gl_scanout_texture by any asynchronouse dpy_refresh call, which eventually cancels the drawing of the guest scanout texture.
--- ui/gtk-egl.c | 6 +++++- ui/gtk-gl-area.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-)
ui/gtk-egl.c +5 -1
@@ -143,6 +143,10 @@ void gd_egl_refresh(DisplayChangeListener *dcl)gd_update_monitor_refresh_rate ( vc, vc->window ? vc->window : vc->gfx.drawing_area); +if (vc->gfx.guest_fb.dmabuf && vc->gfx.guest_fb.dmabuf->draw_submitted) { +return ; + } +if (!vc->gfx.esurface) {gd_egl_init (vc);if (!vc->gfx.esurface) {
@@ -236,7 +240,6 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,eglMakeCurrent (qemu_egl_display, vc->gfx.esurface, vc->gfx.esurface, vc->gfx.ectx); -gtk_egl_set_scanout_mode (vc, true);egl_fb_setup_for_tex (&vc->gfx.guest_fb, backing_width, backing_height, backing_id, false); }
@@ -344,6 +347,7 @@ void gd_egl_flush(DisplayChangeListener *dcl,if (vc->gfx.guest_fb.dmabuf && !vc->gfx.guest_fb.dmabuf->draw_submitted) {graphic_hw_gl_block (vc->gfx.dcl.con, true); vc->gfx.guest_fb.dmabuf->draw_submitted = true; +gtk_egl_set_scanout_mode (vc, true);gtk_widget_queue_draw_area (area, x, y, w, h);return ; }
ui/gtk-gl-area.c +5 -1
@@ -123,6 +123,10 @@ void gd_gl_area_refresh(DisplayChangeListener *dcl)gd_update_monitor_refresh_rate (vc, vc->window ? vc->window : vc->gfx.drawing_area); +if (vc->gfx.guest_fb.dmabuf && vc->gfx.guest_fb.dmabuf->draw_submitted) { +return ; + } +if (!vc->gfx.gls) {if (!gtk_widget_get_realized (vc->gfx.drawing_area)) {return ;
@@ -261,7 +265,6 @@ void gd_gl_area_scanout_texture(DisplayChangeListener *dcl,return ; } -gtk_gl_area_set_scanout_mode (vc, true);egl_fb_setup_for_tex (&vc->gfx.guest_fb, backing_width, backing_height, backing_id, false); }
@@ -281,6 +284,7 @@ void gd_gl_area_scanout_flush(DisplayChangeListener *dcl,if (vc->gfx.guest_fb.dmabuf && !vc->gfx.guest_fb.dmabuf->draw_submitted) {graphic_hw_gl_block (vc->gfx.dcl.con, true); vc->gfx.guest_fb.dmabuf->draw_submitted = true; +gtk_gl_area_set_scanout_mode (vc, true); }gtk_gl_area_queue_render (GTK_GL_AREA (vc->gfx.drawing_area)); }
Signature · 1 line
2.34.1
Hi
Quoted 10 lines · Dongwon Kim
Skip refresh if a new dmabuf (guest scanout frame) is submitted and ready to be drawn because the scanout will be refreshed with new frame anyway.
Also, setting scanout mode is better to be done right before a draw event is scheduled because the mode can be reset anytime after it is set in
dpy_gl_scanout_textureby any asynchronousedpy_refreshcall, which eventually cancels the drawing of the guest scanout texture.
This is actually quite difficult to analyze. Can you be more explicit? Can you split the patch and add comments, because the state conditions & behavours aren't obvious.
Gerd, any chance you look at it too?
Quoted 83 lines
Cc Gerd Hoffmann <[email protected]>Cc Marc-André Lureau <[email protected]>Cc Vivek Kasireddy <[email protected]>Signed-off-by Dongwon Kim <[email protected]>--- ui/gtk-egl.c | 6 +++++- ui/gtk-gl-area.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-)ui/gtk-egl.c +4
-0@@ -143,6 +143,10 @@ void gd_egl_refresh(DisplayChangeListener *dcl)gd_update_monitor_refresh_rate ( vc, vc->window ? vc->window : vc->gfx.drawing_area); +if (vc->gfx.guest_fb.dmabuf && vc->gfx.guest_fb.dmabuf->draw_submitted) { +return ; + } +if (!vc->gfx.esurface) {gd_egl_init (vc);if (!vc->gfx.esurface) {ui/gtk-egl.c +1
-1@@ -236,7 +240,6 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,eglMakeCurrent (qemu_egl_display, vc->gfx.esurface, vc->gfx.esurface, vc->gfx.ectx); -gtk_egl_set_scanout_mode (vc, true);egl_fb_setup_for_tex (&vc->gfx.guest_fb, backing_width, backing_height, backing_id, false); }@@ -344,6 +347,7 @@ void gd_egl_flush(DisplayChangeListener *dcl,if (vc->gfx.guest_fb.dmabuf && !vc->gfx.guest_fb.dmabuf->draw_submitted) {graphic_hw_gl_block (vc->gfx.dcl.con, true); vc->gfx.guest_fb.dmabuf->draw_submitted = true; +gtk_egl_set_scanout_mode (vc, true);gtk_widget_queue_draw_area (area, x, y, w, h);return ;}ui/gtk-gl-area.c +4
-0@@ -123,6 +123,10 @@ void gd_gl_area_refresh(DisplayChangeListener *dcl)gd_update_monitor_refresh_rate (vc, vc->window ? vc->window : vc->gfx.drawing_area); +if (vc->gfx.guest_fb.dmabuf && vc->gfx.guest_fb.dmabuf->draw_submitted) { +return ; + } +if (!vc->gfx.gls) {if (!gtk_widget_get_realized(vc->gfx.drawing_area)) { return;ui/gtk-gl-area.c +0
-1@@ -261,7 +265,6 @@ void gd_gl_area_scanout_texture(DisplayChangeListener *dcl, return; } -gtk_gl_area_set_scanout_mode (vc, true);egl_fb_setup_for_tex (&vc->gfx.guest_fb, backing_width, backing_height, backing_id, false);}
ui/gtk-gl-area.c +1
-0@@ -281,6 +284,7 @@ void gd_gl_area_scanout_flush(DisplayChangeListener *dcl, if (vc->gfx.guest_fb.dmabuf && !vc->gfx.guest_fb.dmabuf->draw_submitted) {graphic_hw_gl_block (vc->gfx.dcl.con, true); vc->gfx.guest_fb.dmabuf->draw_submitted = true; +gtk_gl_area_set_scanout_mode (vc, true); }gtk_gl_area_queue_render(GTK_GL_AREA(vc->gfx.drawing_area));}
--
2.34.1
Signature · 1 line
Marc-André Lureau
PATCH 1/1 ui/gtk: set scanout-mode right before scheduling draw
Setting scanout mode is better to be done very last minute right because the mode can be reset anytime after it is set in dpy_gl_scanout_texture by any asynchronouse dpy_refresh call, which eventually cancels drawing of the guest scanout texture.
--- ui/gtk-egl.c | 2 +- ui/gtk-gl-area.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
ui/gtk-egl.c +1 -1
@@ -238,7 +238,6 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,eglMakeCurrent (qemu_egl_display, vc->gfx.esurface, vc->gfx.esurface, vc->gfx.ectx); -gtk_egl_set_scanout_mode (vc, true);egl_fb_setup_for_tex (&vc->gfx.guest_fb, backing_width, backing_height, backing_id, false); }
@@ -347,6 +346,7 @@ void gd_egl_flush(DisplayChangeListener *dcl,if (vc->gfx.guest_fb.dmabuf && !vc->gfx.guest_fb.dmabuf->draw_submitted) {graphic_hw_gl_block (vc->gfx.dcl.con, true); vc->gfx.guest_fb.dmabuf->draw_submitted = true; +gtk_egl_set_scanout_mode (vc, true);gtk_widget_queue_draw_area (area, x, y, w, h);return ; }
ui/gtk-gl-area.c +1 -1
@@ -262,7 +262,6 @@ void gd_gl_area_scanout_texture(DisplayChangeListener *dcl,return ; } -gtk_gl_area_set_scanout_mode (vc, true);egl_fb_setup_for_tex (&vc->gfx.guest_fb, backing_width, backing_height, backing_id, false); }
@@ -282,6 +281,7 @@ void gd_gl_area_scanout_flush(DisplayChangeListener *dcl,if (vc->gfx.guest_fb.dmabuf && !vc->gfx.guest_fb.dmabuf->draw_submitted) {graphic_hw_gl_block (vc->gfx.dcl.con, true); vc->gfx.guest_fb.dmabuf->draw_submitted = true; +gtk_gl_area_set_scanout_mode (vc, true); }gtk_gl_area_queue_render (GTK_GL_AREA (vc->gfx.drawing_area)); }
Signature · 1 line
2.34.1
PATCH 1/1 ui/gtk: skip refresh if new dmabuf has been submitted
Skip refresh if a new dmabuf (guest scanout frame) has already been submitted and ready to be drawn because the scanout will be updated with new frame anyway.
--- ui/gtk-egl.c | 4 ++++ ui/gtk-gl-area.c | 4 ++++ 2 files changed, 8 insertions(+)
ui/gtk-egl.c +4 -0
@@ -144,6 +144,10 @@ void gd_egl_refresh(DisplayChangeListener *dcl)gd_update_monitor_refresh_rate ( vc, vc->window ? vc->window : vc->gfx.drawing_area); +if (vc->gfx.guest_fb.dmabuf && vc->gfx.guest_fb.dmabuf->draw_submitted) { +return ; + } +if (!vc->gfx.esurface) {gd_egl_init (vc);if (!vc->gfx.esurface) {
ui/gtk-gl-area.c +4 -0
@@ -123,6 +123,10 @@ void gd_gl_area_refresh(DisplayChangeListener *dcl)gd_update_monitor_refresh_rate (vc, vc->window ? vc->window : vc->gfx.drawing_area); +if (vc->gfx.guest_fb.dmabuf && vc->gfx.guest_fb.dmabuf->draw_submitted) { +return ; + } +if (!vc->gfx.gls) {if (!gtk_widget_get_realized (vc->gfx.drawing_area)) {return ;
Signature · 1 line
2.34.1
Re: [PATCH] ui/gtk: skip refresh if new dmabuf has been submitted
Quoted 9 lines · Dongwon Kim
Skip refresh if a new dmabuf (guest scanout frame) has already been submitted and ready to be drawn because the scanout will be updated with new frame anyway.
Cc Gerd Hoffmann <[email protected]>Cc Marc-André Lureau <[email protected]>Cc Vivek Kasireddy <[email protected]>Signed-off-by Dongwon Kim <[email protected]>
Quoted 43 lines
--- ui/gtk-egl.c | 4 ++++ ui/gtk-gl-area.c | 4 ++++ 2 files changed, 8 insertions(+)ui/gtk-egl.c +4
-0@@ -144,6 +144,10 @@ void gd_egl_refresh(DisplayChangeListener *dcl)gd_update_monitor_refresh_rate ( vc, vc->window ? vc->window : vc->gfx.drawing_area); +if (vc->gfx.guest_fb.dmabuf && vc->gfx.guest_fb.dmabuf->draw_submitted) { +return ; + } +if (!vc->gfx.esurface) {gd_egl_init (vc);if (!vc->gfx.esurface) {ui/gtk-gl-area.c +4
-0@@ -123,6 +123,10 @@ void gd_gl_area_refresh(DisplayChangeListener *dcl)gd_update_monitor_refresh_rate (vc, vc->window ? vc->window : vc->gfx.drawing_area); +if (vc->gfx.guest_fb.dmabuf && vc->gfx.guest_fb.dmabuf->draw_submitted) { +return ; + } +if (!vc->gfx.gls) {if (!gtk_widget_get_realized(vc->gfx.drawing_area)) { return;--
2.34.1
Signature · 1 line
Marc-André Lureau
Re: [PATCH] ui/gtk: set scanout-mode right before scheduling draw
In reply to Dongwon KimQuoted 10 lines · Dongwon Kim
Setting scanout mode is better to be done very last minute right because the mode can be reset anytime after it is set in
dpy_gl_scanout_textureby any asynchronousedpy_refreshcall, which eventually cancels drawing of the guest scanout texture.Cc Gerd Hoffmann <[email protected]>Cc Marc-André Lureau <[email protected]>Cc Vivek Kasireddy <[email protected]>Signed-off-by Dongwon Kim <[email protected]>
Quoted 54 lines
--- ui/gtk-egl.c | 2 +- ui/gtk-gl-area.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)ui/gtk-egl.c +1
-1@@ -238,7 +238,6 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,eglMakeCurrent (qemu_egl_display, vc->gfx.esurface, vc->gfx.esurface, vc->gfx.ectx); -gtk_egl_set_scanout_mode (vc, true);egl_fb_setup_for_tex (&vc->gfx.guest_fb, backing_width, backing_height, backing_id, false); }@@ -347,6 +346,7 @@ void gd_egl_flush(DisplayChangeListener *dcl,if (vc->gfx.guest_fb.dmabuf && !vc->gfx.guest_fb.dmabuf->draw_submitted) {graphic_hw_gl_block (vc->gfx.dcl.con, true); vc->gfx.guest_fb.dmabuf->draw_submitted = true; +gtk_egl_set_scanout_mode (vc, true);gtk_widget_queue_draw_area (area, x, y, w, h);return ;}ui/gtk-gl-area.c +0
-1@@ -262,7 +262,6 @@ void gd_gl_area_scanout_texture(DisplayChangeListener *dcl, return; } -gtk_gl_area_set_scanout_mode (vc, true);egl_fb_setup_for_tex (&vc->gfx.guest_fb, backing_width, backing_height, backing_id, false);}
ui/gtk-gl-area.c +1
-0@@ -282,6 +281,7 @@ void gd_gl_area_scanout_flush(DisplayChangeListener *dcl, if (vc->gfx.guest_fb.dmabuf && !vc->gfx.guest_fb.dmabuf->draw_submitted) {graphic_hw_gl_block (vc->gfx.dcl.con, true); vc->gfx.guest_fb.dmabuf->draw_submitted = true; +gtk_gl_area_set_scanout_mode (vc, true); }gtk_gl_area_queue_render(GTK_GL_AREA(vc->gfx.drawing_area));}
--
2.34.1
Signature · 1 line
Marc-André Lureau