All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] ui/gtk-egl: fix for untab/tab problem
@ 2021-09-17  0:13 Dongwon Kim
  2021-09-17  0:13 ` [PATCH 1/4] ui/gtk-egl: un-tab and re-tab should destroy egl surface and context Dongwon Kim
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Dongwon Kim @ 2021-09-17  0:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dongwon Kim

This series fixes several problems happening while doing VC untab/tab.

Dongwon Kim (4):
  ui/gtk-egl: un-tab and re-tab should destroy egl surface and context
  ui/gtk-egl: make sure the right context is set as the current
  ui/gtk: gd_draw_event returns FALSE when no cairo surface is bound
  ui/gtk-egl: guest fb texture needs to be regenerated when
    reinitializing egl

 ui/gtk-egl.c | 10 ++++++++++
 ui/gtk.c     | 19 +++++++++++++++++++
 2 files changed, 29 insertions(+)

-- 
2.17.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/4] ui/gtk-egl: un-tab and re-tab should destroy egl surface and context
  2021-09-17  0:13 [PATCH 0/4] ui/gtk-egl: fix for untab/tab problem Dongwon Kim
@ 2021-09-17  0:13 ` Dongwon Kim
  2021-11-02 13:37   ` Gerd Hoffmann
  2021-09-17  0:13 ` [PATCH 2/4] ui/gtk-egl: make sure the right context is set as the current Dongwon Kim
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Dongwon Kim @ 2021-09-17  0:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Khairul Anuar Romli, Dongwon Kim, Gerd Hoffmann

An old esurface should be destroyed and set to be NULL when doing
un-tab and re-tab so that a new esurface an context can be created
for the window widget that those will be bound to.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
Signed-off-by: Khairul Anuar Romli <khairul.anuar.romli@intel.com>
---
 ui/gtk.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/ui/gtk.c b/ui/gtk.c
index b0564d80c1..92df3d4c5c 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1242,6 +1242,14 @@ static gboolean gd_tab_window_close(GtkWidget *widget, GdkEvent *event,
                                     vc->tab_item, vc->label);
     gtk_widget_destroy(vc->window);
     vc->window = NULL;
+    if (vc->gfx.esurface) {
+        eglDestroySurface(qemu_egl_display, vc->gfx.esurface);
+        vc->gfx.esurface = NULL;
+    }
+    if (vc->gfx.ectx) {
+        eglDestroyContext(qemu_egl_display, vc->gfx.ectx);
+        vc->gfx.ectx = NULL;
+    }
     return TRUE;
 }
 
@@ -1271,6 +1279,14 @@ static void gd_menu_untabify(GtkMenuItem *item, void *opaque)
     if (!vc->window) {
         gtk_widget_set_sensitive(vc->menu_item, false);
         vc->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+        if (vc->gfx.esurface) {
+            eglDestroySurface(qemu_egl_display, vc->gfx.esurface);
+            vc->gfx.esurface = NULL;
+        }
+        if (vc->gfx.esurface) {
+            eglDestroyContext(qemu_egl_display, vc->gfx.ectx);
+            vc->gfx.ectx = NULL;
+        }
         gd_widget_reparent(s->notebook, vc->window, vc->tab_item);
 
         g_signal_connect(vc->window, "delete-event",
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/4] ui/gtk-egl: make sure the right context is set as the current
  2021-09-17  0:13 [PATCH 0/4] ui/gtk-egl: fix for untab/tab problem Dongwon Kim
  2021-09-17  0:13 ` [PATCH 1/4] ui/gtk-egl: un-tab and re-tab should destroy egl surface and context Dongwon Kim
@ 2021-09-17  0:13 ` Dongwon Kim
  2021-09-17  0:13 ` [PATCH 3/4] ui/gtk: gd_draw_event returns FALSE when no cairo surface is bound Dongwon Kim
  2021-09-17  0:13 ` [PATCH 4/4] ui/gtk-egl: guest fb texture needs to be regenerated when reinitializing egl Dongwon Kim
  3 siblings, 0 replies; 10+ messages in thread
From: Dongwon Kim @ 2021-09-17  0:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dongwon Kim, Gerd Hoffmann

Making the vc->gfx.ectx current before handling texture
associated with it

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
---
 ui/gtk-egl.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index 72ce5e1f8f..7c9629d6cc 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -139,6 +139,7 @@ void gd_egl_refresh(DisplayChangeListener *dcl)
         }
         vc->gfx.gls = qemu_gl_init_shader();
         if (vc->gfx.ds) {
+            surface_gl_destroy_texture(vc->gfx.gls, vc->gfx.ds);
             surface_gl_create_texture(vc->gfx.gls, vc->gfx.ds);
         }
     }
@@ -165,6 +166,8 @@ void gd_egl_switch(DisplayChangeListener *dcl,
         surface_height(vc->gfx.ds) == surface_height(surface)) {
         resized = false;
     }
+    eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
+                   vc->gfx.esurface, vc->gfx.ectx);
 
     surface_gl_destroy_texture(vc->gfx.gls, vc->gfx.ds);
     vc->gfx.ds = surface;
@@ -224,6 +227,9 @@ void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
 #ifdef CONFIG_GBM
     VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
 
+    eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
+                   vc->gfx.esurface, vc->gfx.ectx);
+
     egl_dmabuf_import_texture(dmabuf);
     if (!dmabuf->texture) {
         return;
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/4] ui/gtk: gd_draw_event returns FALSE when no cairo surface is bound
  2021-09-17  0:13 [PATCH 0/4] ui/gtk-egl: fix for untab/tab problem Dongwon Kim
  2021-09-17  0:13 ` [PATCH 1/4] ui/gtk-egl: un-tab and re-tab should destroy egl surface and context Dongwon Kim
  2021-09-17  0:13 ` [PATCH 2/4] ui/gtk-egl: make sure the right context is set as the current Dongwon Kim
@ 2021-09-17  0:13 ` Dongwon Kim
  2021-09-17  0:13 ` [PATCH 4/4] ui/gtk-egl: guest fb texture needs to be regenerated when reinitializing egl Dongwon Kim
  3 siblings, 0 replies; 10+ messages in thread
From: Dongwon Kim @ 2021-09-17  0:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dongwon Kim, Gerd Hoffmann

gd_draw_event shouldn't try to repaint if surface does not exist
for the VC.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
---
 ui/gtk.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ui/gtk.c b/ui/gtk.c
index 92df3d4c5c..5346c331f4 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -778,6 +778,9 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque)
     if (!vc->gfx.ds) {
         return FALSE;
     }
+    if (!vc->gfx.surface) {
+        return FALSE;
+    }
 
     vc->gfx.dcl.update_interval =
         gd_monitor_update_interval(vc->window ? vc->window : s->window);
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/4] ui/gtk-egl: guest fb texture needs to be regenerated when reinitializing egl
  2021-09-17  0:13 [PATCH 0/4] ui/gtk-egl: fix for untab/tab problem Dongwon Kim
                   ` (2 preceding siblings ...)
  2021-09-17  0:13 ` [PATCH 3/4] ui/gtk: gd_draw_event returns FALSE when no cairo surface is bound Dongwon Kim
@ 2021-09-17  0:13 ` Dongwon Kim
  3 siblings, 0 replies; 10+ messages in thread
From: Dongwon Kim @ 2021-09-17  0:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dongwon Kim, Gerd Hoffmann

If guest fb is backed by dmabuf (blob-resource), the texture bound to the
old context needs to be recreated in case the egl is re-initialized (e.g.
new window for vc is created in case of detaching/reattaching of the tab)

v2: call egl_dmabuf_release_texutre instead of putting 0 to dmabuf->texture
    (Vivek Kasireddy)

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
---
 ui/gtk-egl.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index 7c9629d6cc..8c55ed18fb 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -142,6 +142,10 @@ void gd_egl_refresh(DisplayChangeListener *dcl)
             surface_gl_destroy_texture(vc->gfx.gls, vc->gfx.ds);
             surface_gl_create_texture(vc->gfx.gls, vc->gfx.ds);
         }
+        if (vc->gfx.guest_fb.dmabuf) {
+            egl_dmabuf_release_texture(vc->gfx.guest_fb.dmabuf);
+            gd_egl_scanout_dmabuf(dcl, vc->gfx.guest_fb.dmabuf);
+        }
     }
 
     graphic_hw_update(dcl->con);
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/4] ui/gtk-egl: un-tab and re-tab should destroy egl surface and context
  2021-09-17  0:13 ` [PATCH 1/4] ui/gtk-egl: un-tab and re-tab should destroy egl surface and context Dongwon Kim
@ 2021-11-02 13:37   ` Gerd Hoffmann
  2021-11-02 22:36     ` [PATCH v2 " Dongwon Kim
  0 siblings, 1 reply; 10+ messages in thread
From: Gerd Hoffmann @ 2021-11-02 13:37 UTC (permalink / raw)
  To: Dongwon Kim; +Cc: Khairul Anuar Romli, qemu-devel

On Thu, Sep 16, 2021 at 05:13:17PM -0700, Dongwon Kim wrote:
> An old esurface should be destroyed and set to be NULL when doing
> un-tab and re-tab so that a new esurface an context can be created
> for the window widget that those will be bound to.

Fails to build on windows (probably also on --disable-opengl builds).

take care,
  Gerd



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/4] ui/gtk-egl: un-tab and re-tab should destroy egl surface and context
  2021-11-02 13:37   ` Gerd Hoffmann
@ 2021-11-02 22:36     ` Dongwon Kim
  2021-11-02 22:36       ` [PATCH 2/4] ui/gtk-egl: make sure the right context is set as the current Dongwon Kim
                         ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Dongwon Kim @ 2021-11-02 22:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: Khairul Anuar Romli, Dongwon Kim, Gerd Hoffmann

An old esurface should be destroyed and set to be NULL when doing
un-tab and re-tab so that a new esurface an context can be created
for the window widget that those will be bound to.

v2: enabling opengl specific routines only when CONFIG_OPENGL is set

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
Signed-off-by: Khairul Anuar Romli <khairul.anuar.romli@intel.com>
---
 ui/gtk.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/ui/gtk.c b/ui/gtk.c
index b0564d80c1..8da673c18c 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1242,6 +1242,16 @@ static gboolean gd_tab_window_close(GtkWidget *widget, GdkEvent *event,
                                     vc->tab_item, vc->label);
     gtk_widget_destroy(vc->window);
     vc->window = NULL;
+#if defined(CONFIG_OPENGL)
+    if (vc->gfx.esurface) {
+        eglDestroySurface(qemu_egl_display, vc->gfx.esurface);
+        vc->gfx.esurface = NULL;
+    }
+    if (vc->gfx.ectx) {
+        eglDestroyContext(qemu_egl_display, vc->gfx.ectx);
+        vc->gfx.ectx = NULL;
+    }
+#endif
     return TRUE;
 }
 
@@ -1271,6 +1281,16 @@ static void gd_menu_untabify(GtkMenuItem *item, void *opaque)
     if (!vc->window) {
         gtk_widget_set_sensitive(vc->menu_item, false);
         vc->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+#if defined(CONFIG_OPENGL)
+        if (vc->gfx.esurface) {
+            eglDestroySurface(qemu_egl_display, vc->gfx.esurface);
+            vc->gfx.esurface = NULL;
+        }
+        if (vc->gfx.esurface) {
+            eglDestroyContext(qemu_egl_display, vc->gfx.ectx);
+            vc->gfx.ectx = NULL;
+        }
+#endif
         gd_widget_reparent(s->notebook, vc->window, vc->tab_item);
 
         g_signal_connect(vc->window, "delete-event",
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/4] ui/gtk-egl: make sure the right context is set as the current
  2021-11-02 22:36     ` [PATCH v2 " Dongwon Kim
@ 2021-11-02 22:36       ` Dongwon Kim
  2021-11-02 22:36       ` [PATCH 3/4] ui/gtk-egl: guest fb texture needs to be regenerated when reinitializing egl Dongwon Kim
  2021-11-02 22:36       ` [PATCH 4/4] ui/gtk: gd_draw_event returns FALSE when no cairo surface is bound Dongwon Kim
  2 siblings, 0 replies; 10+ messages in thread
From: Dongwon Kim @ 2021-11-02 22:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dongwon Kim, Gerd Hoffmann

Making the vc->gfx.ectx current before handling texture
associated with it

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
---
 ui/gtk-egl.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index 72ce5e1f8f..7c9629d6cc 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -139,6 +139,7 @@ void gd_egl_refresh(DisplayChangeListener *dcl)
         }
         vc->gfx.gls = qemu_gl_init_shader();
         if (vc->gfx.ds) {
+            surface_gl_destroy_texture(vc->gfx.gls, vc->gfx.ds);
             surface_gl_create_texture(vc->gfx.gls, vc->gfx.ds);
         }
     }
@@ -165,6 +166,8 @@ void gd_egl_switch(DisplayChangeListener *dcl,
         surface_height(vc->gfx.ds) == surface_height(surface)) {
         resized = false;
     }
+    eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
+                   vc->gfx.esurface, vc->gfx.ectx);
 
     surface_gl_destroy_texture(vc->gfx.gls, vc->gfx.ds);
     vc->gfx.ds = surface;
@@ -224,6 +227,9 @@ void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
 #ifdef CONFIG_GBM
     VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
 
+    eglMakeCurrent(qemu_egl_display, vc->gfx.esurface,
+                   vc->gfx.esurface, vc->gfx.ectx);
+
     egl_dmabuf_import_texture(dmabuf);
     if (!dmabuf->texture) {
         return;
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/4] ui/gtk-egl: guest fb texture needs to be regenerated when reinitializing egl
  2021-11-02 22:36     ` [PATCH v2 " Dongwon Kim
  2021-11-02 22:36       ` [PATCH 2/4] ui/gtk-egl: make sure the right context is set as the current Dongwon Kim
@ 2021-11-02 22:36       ` Dongwon Kim
  2021-11-02 22:36       ` [PATCH 4/4] ui/gtk: gd_draw_event returns FALSE when no cairo surface is bound Dongwon Kim
  2 siblings, 0 replies; 10+ messages in thread
From: Dongwon Kim @ 2021-11-02 22:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dongwon Kim, Gerd Hoffmann

If guest fb is backed by dmabuf (blob-resource), the texture bound to the
old context needs to be recreated in case the egl is re-initialized (e.g.
new window for vc is created in case of detaching/reattaching of the tab)

v2: call egl_dmabuf_release_texutre instead of putting 0 to dmabuf->texture
    (Vivek Kasireddy)

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
---
 ui/gtk-egl.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index 7c9629d6cc..8c55ed18fb 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -142,6 +142,10 @@ void gd_egl_refresh(DisplayChangeListener *dcl)
             surface_gl_destroy_texture(vc->gfx.gls, vc->gfx.ds);
             surface_gl_create_texture(vc->gfx.gls, vc->gfx.ds);
         }
+        if (vc->gfx.guest_fb.dmabuf) {
+            egl_dmabuf_release_texture(vc->gfx.guest_fb.dmabuf);
+            gd_egl_scanout_dmabuf(dcl, vc->gfx.guest_fb.dmabuf);
+        }
     }
 
     graphic_hw_update(dcl->con);
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/4] ui/gtk: gd_draw_event returns FALSE when no cairo surface is bound
  2021-11-02 22:36     ` [PATCH v2 " Dongwon Kim
  2021-11-02 22:36       ` [PATCH 2/4] ui/gtk-egl: make sure the right context is set as the current Dongwon Kim
  2021-11-02 22:36       ` [PATCH 3/4] ui/gtk-egl: guest fb texture needs to be regenerated when reinitializing egl Dongwon Kim
@ 2021-11-02 22:36       ` Dongwon Kim
  2 siblings, 0 replies; 10+ messages in thread
From: Dongwon Kim @ 2021-11-02 22:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dongwon Kim, Gerd Hoffmann

gd_draw_event shouldn't try to repaint if surface does not exist
for the VC.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
---
 ui/gtk.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ui/gtk.c b/ui/gtk.c
index 8da673c18c..d2892ea6b4 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -778,6 +778,9 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque)
     if (!vc->gfx.ds) {
         return FALSE;
     }
+    if (!vc->gfx.surface) {
+        return FALSE;
+    }
 
     vc->gfx.dcl.update_interval =
         gd_monitor_update_interval(vc->window ? vc->window : s->window);
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-11-02 23:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-17  0:13 [PATCH 0/4] ui/gtk-egl: fix for untab/tab problem Dongwon Kim
2021-09-17  0:13 ` [PATCH 1/4] ui/gtk-egl: un-tab and re-tab should destroy egl surface and context Dongwon Kim
2021-11-02 13:37   ` Gerd Hoffmann
2021-11-02 22:36     ` [PATCH v2 " Dongwon Kim
2021-11-02 22:36       ` [PATCH 2/4] ui/gtk-egl: make sure the right context is set as the current Dongwon Kim
2021-11-02 22:36       ` [PATCH 3/4] ui/gtk-egl: guest fb texture needs to be regenerated when reinitializing egl Dongwon Kim
2021-11-02 22:36       ` [PATCH 4/4] ui/gtk: gd_draw_event returns FALSE when no cairo surface is bound Dongwon Kim
2021-09-17  0:13 ` [PATCH 2/4] ui/gtk-egl: make sure the right context is set as the current Dongwon Kim
2021-09-17  0:13 ` [PATCH 3/4] ui/gtk: gd_draw_event returns FALSE when no cairo surface is bound Dongwon Kim
2021-09-17  0:13 ` [PATCH 4/4] ui/gtk-egl: guest fb texture needs to be regenerated when reinitializing egl Dongwon Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.