Skip to contentSkip to conversation

ui/gtk: adds status bar for expressing ups and fps

PATCH In review Dongwon Kim 3 participants 6 messages Jul 26, 2021 – Jul 29, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ui/gtk: adds status bar for expressing ups and fps

With a display option, "show-fps=on", qemu adds a status bar and print following performance numbers on the bar,

ups = update per seconds - the rate the guest scanout is updated. fps = frame per seconds - the frame rate of VC's GL drawing area

One function, gd_gl_count_frame is added to count # frames and calculate ups and fps every 100 frames or guest scanout updates.

---
 include/ui/console.h |  4 +++-
 include/ui/gtk.h     |  2 ++
 qapi/ui.json         |  6 +++++-
 ui/console.c         |  6 ++++++
 ui/gtk.c             | 51 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 67 insertions(+), 2 deletions(-)
include/ui/console.h +3 -1
index b30b63976a..3ca8d07220 100644
@@ -243,7 +243,8 @@ typedef struct DisplayChangeListenerOps {
     /* required if GL */
     void (*dpy_gl_update)(DisplayChangeListener *dcl,
                           uint32_t x, uint32_t y, uint32_t w, uint32_t h);
-
+    /* optional */
+    void (*dpy_gl_count_frame)(DisplayChangeListener *dcl, bool ups);
 } DisplayChangeListenerOps;
 
 struct DisplayChangeListener {
@@ -314,6 +315,7 @@ void dpy_gl_release_dmabuf(QemuConsole *con,
                            QemuDmaBuf *dmabuf);
 void dpy_gl_update(QemuConsole *con,
                    uint32_t x, uint32_t y, uint32_t w, uint32_t h);
+void dpy_gl_count_frame(QemuConsole *con, bool ups);
 
 QEMUGLContext dpy_gl_ctx_create(QemuConsole *con,
                                 QEMUGLParams *params);
include/ui/gtk.h +2 -0
index 9516670ebc..8d1a6c2cef 100644
@@ -118,6 +118,7 @@ struct GtkDisplayState {
     GtkWidget *show_tabs_item;
     GtkWidget *untabify_item;
     GtkWidget *show_menubar_item;
+    GtkWidget *status_bar;
 
     GtkWidget *vbox;
     GtkWidget *notebook;
@@ -152,6 +153,7 @@ extern bool gtk_use_gl_area;
 /* ui/gtk.c */
 void gd_update_windowsize(VirtualConsole *vc);
 int gd_monitor_update_interval(GtkWidget *widget);
+void gd_gl_count_frame(DisplayChangeListener *dcl, bool ups);
 
 /* ui/gtk-egl.c */
 void gd_egl_init(VirtualConsole *vc);
qapi/ui.json +5 -1
index 1052ca9c38..a0882d6428 100644
@@ -1035,13 +1035,17 @@
 #               assuming the guest will resize the display to match
 #               the window size then.  Otherwise it defaults to "off".
 #               Since 3.1
+# @show-fps:    Enable showing Guest Scanout's update rate (UPS) and
+#               Surface render swap rate (FPS) on a status bar (default: off).
+#               Since 6.0
 #
 # Since: 2.12
 #
 ##
 { 'struct'  : 'DisplayGTK',
   'data'    : { '*grab-on-hover' : 'bool',
-                '*zoom-to-fit'   : 'bool'  } }
+                '*zoom-to-fit'   : 'bool',
+                '*show-fps'      : 'bool'  } }
 
 ##
 # @DisplayEGLHeadless:
ui/console.c +6 -0
index 2de5f4105b..31efdb0512 100644
@@ -1924,6 +1924,12 @@ void dpy_gl_update(QemuConsole *con,
     con->gl->ops->dpy_gl_update(con->gl, x, y, w, h);
 }
 
+void dpy_gl_count_frame(QemuConsole *con, bool ups)
+{
+    assert(con->gl);
+    con->gl->ops->dpy_gl_count_frame(con->gl, ups);
+}
+
 /***********************************************************/
 /* register display */
 
ui/gtk.c +51 -0

81 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/3 ui/gtk: calling gd_gl_frame_counter at every draw/swap

For FPS calculation, gd_gl_frame_counter is called at every draw(gtk-gl-area) or swap(gtk-egl) activity.

---
 ui/gtk-egl.c     | 2 ++
 ui/gtk-gl-area.c | 1 +
 2 files changed, 3 insertions(+)
ui/gtk-egl.c +2 -0
index 2a2e6d3a17..ac56f5b9f4 100644
@@ -89,6 +89,7 @@ void gd_egl_draw(VirtualConsole *vc)
 
         eglSwapBuffers(qemu_egl_display, vc->gfx.esurface);
 
+        gd_gl_count_frame(&vc->gfx.dcl, false);
         vc->gfx.scale_x = (double)ww / surface_width(vc->gfx.ds);
         vc->gfx.scale_y = (double)wh / surface_height(vc->gfx.ds);
     }
@@ -290,6 +291,7 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl,
     }
 
     eglSwapBuffers(qemu_egl_display, vc->gfx.esurface);
+    gd_gl_count_frame(&vc->gfx.dcl, false);
 }
 
 void gtk_egl_init(DisplayGLMode mode)
ui/gtk-gl-area.c +1 -0
index dd5783fec7..a18b6ff425 100644
@@ -72,6 +72,7 @@ void gd_gl_area_draw(VirtualConsole *vc)
     }
 
     glFlush();
+    gd_gl_count_frame(&vc->gfx.dcl, false);
     graphic_hw_gl_flushed(vc->gfx.dcl.con);
 }
 
Signature · 1 line
2.17.1
#2 lore raw

PATCH 3/3 virtio-gpu: call dpy_gl_frame_counter at every guest scanout flush

In reply to Dongwon Kim

dpy_gl_frame_counter needs to be called for guest scanout frame count to calculate and display the performance figure - ups, the guest FB update per seconds.

---
 hw/display/virtio-gpu.c | 2 ++
 1 file changed, 2 insertions(+)
hw/display/virtio-gpu.c +2 -0
index e183f4ecda..722869864a 100644
@@ -523,6 +523,7 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,
                 console_has_gl(scanout->con)) {
                 dpy_gl_update(scanout->con, 0, 0, scanout->width,
                               scanout->height);
+                dpy_gl_count_frame(scanout->con, true);
                 return;
             }
         }
@@ -566,6 +567,7 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,
                        extents->x1, extents->y1,
                        extents->x2 - extents->x1,
                        extents->y2 - extents->y1);
+        dpy_gl_count_frame(scanout->con, true);
 
         pixman_region_fini(&region);
         pixman_region_fini(&finalregion);
Signature · 1 line
2.17.1
#3 lore raw
In reply to Dongwon Kim
Quoted 8 lines · Dongwon Kim

With a display option, "show-fps=on", qemu adds a status bar and print following performance numbers on the bar,

ups = update per seconds - the rate the guest scanout is updated. fps = frame per seconds - the frame rate of VC's GL drawing area

One function, gd_gl_count_frame is added to count # frames and calculate ups and fps every 100 frames or guest scanout updates.

This feels like a pretty niche/novelty feature. Is this really something we can justify adding to the UI, considering that it means we will be maintaining this UI and supporting code long term.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#4 lore raw

I found there are no such performance indicators available in Qemu/GTK. I thought this was the gap as in many fields, users want to check fps or ups to evaluate graphic or display performance in their use-cases.

Thanks for your feedback!.

Quoted 23 lines · Daniel P. Berrangé
Quoted 8 lines · Dongwon Kim

With a display option, "show-fps=on", qemu adds a status bar and print following performance numbers on the bar,

ups = update per seconds - the rate the guest scanout is updated. fps = frame per seconds - the frame rate of VC's GL drawing area

One function, gd_gl_count_frame is added to count # frames and calculate ups and fps every 100 frames or guest scanout updates.

This feels like a pretty niche/novelty feature. Is this really something we can justify adding to the UI, considering that it means we will be maintaining this UI and supporting code long term.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#5 lore raw
In reply to Dongwon Kim

On Mon, Jul 26, 2021 at 03:25:49PM -0700, Dongwon Kim wrote:

[meta-comment] When sending a patch series, remember to include a 0/3 cover letter, as it makes it easier to distinguish replies about the series as a whole from review of the first patch.

Quoted 20 lines

With a display option, "show-fps=on", qemu adds a status bar and print following performance numbers on the bar,

ups = update per seconds - the rate the guest scanout is updated. fps = frame per seconds - the frame rate of VC's GL drawing area

One function, gd_gl_count_frame is added to count # frames and calculate ups and fps every 100 frames or guest scanout updates.

---
 include/ui/console.h |  4 +++-
 include/ui/gtk.h     |  2 ++
 qapi/ui.json         |  6 +++++-
 ui/console.c         |  6 ++++++
 ui/gtk.c             | 51 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 67 insertions(+), 2 deletions(-)

+++ b/qapi/ui.json

qapi/ui.json line 1040

Quoted 6 lines
qapi/ui.json +3 -0
@@ -1035,13 +1035,17 @@
 #               assuming the guest will resize the display to match
 #               the window size then.  Otherwise it defaults to "off".
 #               Since 3.1
+# @show-fps:    Enable showing Guest Scanout's update rate (UPS) and
+#               Surface render swap rate (FPS) on a status bar (default: off).
+#               Since 6.0

This is too late to make the 6.1 release; at best, it should read 'since 6.2'

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org