Skip to contentSkip to conversation

ui/gtk-egl: Ensure EGL surface is available before drawing

PATCH In review [email protected] 2 participants 2 messages Mar 3

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ui/gtk-egl: Ensure EGL surface is available before drawing

From: Dongwon Kim <[email protected]>

The EGL surface and context are destroyed when a new GTK window is created. We must ensure these are recreated and initialized before any rendering happens in gd_egl_refresh.

Currently, the check for a pending draw is performed before the surface initialization block. This can result in an attempt to draw when the EGL surface (vc->gfx.esurface) is not yet available.

This patch moves the drawing check after the surface initialization to ensure a valid surface exists before rendering in gd_egl_refresh.

Cc Gerd Hoffmann <[email protected]>
Cc Marc-André Lureau <[email protected]>
---
 ui/gtk-egl.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
ui/gtk-egl.c +6 -6
index ae9239999c..52d187c482 100644
@@ -152,12 +152,6 @@ 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 &&
-        qemu_dmabuf_get_draw_submitted(vc->gfx.guest_fb.dmabuf)) {
-        gd_egl_draw(vc);
-        return;
-    }
-
     if (!vc->gfx.esurface) {
         gd_egl_init(vc);
         if (!vc->gfx.esurface) {
@@ -176,6 +170,12 @@ void gd_egl_refresh(DisplayChangeListener *dcl)
 #endif
     }
 
+    if (vc->gfx.guest_fb.dmabuf &&
+        qemu_dmabuf_get_draw_submitted(vc->gfx.guest_fb.dmabuf)) {
+        gd_egl_draw(vc);
+        return;
+    }
+
     graphic_hw_update(dcl->con);
 
     if (vc->gfx.glupdates) {
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · On Tue, Mar 3, 2026 at 2:17 AM <[email protected]> wrote:

From: Dongwon Kim <[email protected]>

The EGL surface and context are destroyed when a new GTK window is created. We must ensure these are recreated and initialized before any rendering happens in gd_egl_refresh.

Currently, the check for a pending draw is performed before the surface initialization block. This can result in an attempt to draw when the EGL surface (vc->gfx.esurface) is not yet available.

Quoted 7 lines

This patch moves the drawing check after the surface initialization to ensure a valid surface exists before rendering in gd_egl_refresh.

Cc Gerd Hoffmann <[email protected]>
Cc Marc-André Lureau <[email protected]>
Quoted 38 lines
---
 ui/gtk-egl.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
ui/gtk-egl.c +6 -7
index ae9239999c..52d187c482 100644
@@ -152,12 +152,6 @@ 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 &&
-        qemu_dmabuf_get_draw_submitted(vc->gfx.guest_fb.dmabuf)) {
-        gd_egl_draw(vc);
-        return;
-    }
-
     if (!vc->gfx.esurface) {
         gd_egl_init(vc);
         if (!vc->gfx.esurface) {
@@ -176,6 +170,12 @@ void gd_egl_refresh(DisplayChangeListener *dcl)
 #endif
     }
 
+    if (vc->gfx.guest_fb.dmabuf &&
+        qemu_dmabuf_get_draw_submitted(vc->gfx.guest_fb.dmabuf)) {
+        gd_egl_draw(vc);
+        return;
+    }
+
     graphic_hw_update(dcl->con);
 
     if (vc->gfx.glupdates) {
--

2.43.0

Signature · 1 line
Marc-André Lureau