Skip to contentSkip to conversation

ui/gtk: Launching GTK UI with OpenGL on causes the refreshrate update to not run

PATCH Superseded Nikola Pavlica 3 participants 4 messages Dec 6, 2020 – May 15, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ui/gtk: Launching GTK UI with OpenGL on causes the refreshrate update to not run

I've discussed this issue back January and September. But it still occurs on my machine, despite the two patches. This time, the issue is that the UI refresh rate doesn't get updated when I launch QEMU with gl=on. My fix for this issue is to move the code for updating the refresh rate above the code that checks for OpenGL.

Or because OpenGL is meant to be called back with the "render" callback, should we instead add the refresh rate checking code there?

Anyway, regardless of method, I'm happy with any solution that just fixes the issue.

---

ui/gtk.c +0 -12
index a752aa22be..74287edde8 100644
@@ -776,18 +776,6 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque)
    int fbw, fbh;
    int refresh_rate_millihz;
 
-#if defined(CONFIG_OPENGL)
-    if (vc->gfx.gls) {
-        if (gtk_use_gl_area) {
-            /* invoke render callback please */
-            return FALSE;
-        } else {
-            gd_egl_draw(vc);
-            return TRUE;
-        }
-    }
-#endif
-
    if (!gtk_widget_get_realized(widget)) {
        return FALSE;
    }
@@ -801,6 +789,18 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque)
        vc->gfx.dcl.update_interval = MILLISEC_PER_SEC / 
refresh_rate_millihz;
    }

+#if defined(CONFIG_OPENGL)
+ if (vc->gfx.gls) {
+ if (gtk_use_gl_area) {
+ /* invoke render callback please */
+ return FALSE;
+ } else {
+ gd_egl_draw(vc);
+ return TRUE;
+ }
+ }
+#endif
+

    fbw = surface_width(vc->gfx.ds);
    fbh = surface_height(vc->gfx.ds);
Signature · 1 line
2.21.1
#1 lore raw

Hi Nikola,

Quoted 9 lines · Nikola Pavlica

I've discussed this issue back January and September. But it still occurs on my machine, despite the two patches. This time, the issue is that the UI refresh rate doesn't get updated when I launch QEMU with gl=on. My fix for this issue is to move the code for updating the refresh rate above the code that checks for OpenGL.

Or because OpenGL is meant to be called back with the "render" callback, should we instead add the refreshÂ
rate checking code there?

This is not my area, but I think you are right, the the refresh rate should be updated in the "render" callback.

To speed things you can send another patch, and Gerd will pick the correct/best one :)

Quoted 49 lines

Anyway, regardless of method, I'm happy with any solution that just fixes the issue.

ui/gtk.c +0 -0
index a752aa22be..74287edde8 100644
@@ -776,18 +776,6 @@ static gboolean gd_draw_event(GtkWidget *widget,
 cairo_t *cr, void *opaque)
      int fbw, fbh;
      int refresh_rate_millihz;

Â

ui/gtk.c +0 -12
-#if defined(CONFIG_OPENGL)
-    if (vc->gfx.gls) {
-        if (gtk_use_gl_area) {
-            /* invoke render callback please */
-            return FALSE;
-        } else {
-            gd_egl_draw(vc);
-            return TRUE;
-        }
-    }
-#endif
-

     if (!gtk_widget_get_realized(widget)) {
         return FALSE;
     }

ui/gtk.c +0 -0
@@ -801,6 +789,18 @@ static gboolean gd_draw_event(GtkWidget *widget,
 cairo_t *cr, void *opaque)

         vc->gfx.dcl.update_interval = MILLISEC_PER_SEC / refresh_rate_millihz;
     }
Â

ui/gtk.c +12 -0
+#if defined(CONFIG_OPENGL)
+    if (vc->gfx.gls) {
+        if (gtk_use_gl_area) {
+            /* invoke render callback please */
+            return FALSE;
+        } else {
+            gd_egl_draw(vc);
+            return TRUE;
+        }
+    }
+#endif
+

     fbw = surface_width(vc->gfx.ds);
     fbh = surface_height(vc->gfx.ds);

Signature · 1 line
2.21.1
#2 lore raw
Quoted 5 lines · Philippe Mathieu-Daudé

Hi Nikola,

Quoted 2 lines · Nikola Pavlica

I've discussed this issue back January and September. But it still occurs on my machine, despite the two patches.

Oh, also, instead of "my machine", please provide more information about your setup (installed versions), so we might eventually reproduce.

Quoted 18 lines

This time, the issue is

Quoted 7 lines

that the UI refresh rate doesn't get updated when I launch QEMU with gl=on. My fix for this issue is to move the code for updating the refresh rate above the code that checks for OpenGL.

Or because OpenGL is meant to be called back with the "render" callback, should we instead add the refreshÂ
rate checking code there?

This is not my area, but I think you are right, the the refresh rate should be updated in the "render" callback.

To speed things you can send another patch, and Gerd will pick the correct/best one :)

Quoted 3 lines

Anyway, regardless of method, I'm happy with any solution that just fixes the issue.

#3 lore raw
In reply to Nikola Pavlica
Quoted 6 lines · Nikola Pavlica

I've discussed this issue back January and September. But it still occurs on my machine, despite the two patches. This time, the issue is that the UI refresh rate doesn't get updated when I launch QEMU with gl=on. My fix for this issue is to move the code for updating the refresh rate above the code that checks for OpenGL.

Or because OpenGL is meant to be called back with the "render" callback, should we instead add the refresh rate checking code there?

Anyway, regardless of method, I'm happy with any solution that just fixes the issue.

Is this change not needed anymore?

Nikola, your patch email is html-garbled, at the very least you have to send it as plain text.

Thanks,

/mjt

Quoted 42 lines
ui/gtk.c +12 -12
index a752aa22be..74287edde8 100644
@@ -776,18 +776,6 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque)
      int fbw, fbh;
      int refresh_rate_millihz;
-#if defined(CONFIG_OPENGL)
-    if (vc->gfx.gls) {
-        if (gtk_use_gl_area) {
-            /* invoke render callback please */
-            return FALSE;
-        } else {
-            gd_egl_draw(vc);
-            return TRUE;
-        }
-    }
-#endif
-
      if (!gtk_widget_get_realized(widget)) {
          return FALSE;
      }
@@ -801,6 +789,18 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque)
          vc->gfx.dcl.update_interval = MILLISEC_PER_SEC / refresh_rate_millihz;
      }
+#if defined(CONFIG_OPENGL)
+    if (vc->gfx.gls) {
+        if (gtk_use_gl_area) {
+            /* invoke render callback please */
+            return FALSE;
+        } else {
+            gd_egl_draw(vc);
+            return TRUE;
+        }
+    }
+#endif
+
      fbw = surface_width(vc->gfx.ds);
      fbh = surface_height(vc->gfx.ds);
Signature · 1 line
2.21.1