Hi Marc-André, > Subject: Re: [PATCH] ui/egl: reset framebuffer state when creating new EGL > > Hi > > On Thu, May 21, 2026 at 4:48 AM <[email protected]> wrote: > > > > From: Dongwon Kim <[email protected]> > > > > When an old EGL context is destroyed, its associated OpenGL textures > > and framebuffer resource IDs are already implicitly freed by the > > driver. However, the cached IDs and geometry attributes stored within > > the egl_fb structures remain stale and invalid for the new context. > > > > Call egl_fb_destroy() on the guest, cursor, and window framebuffers in > > gd_egl_refresh() to safely clear these stale fields back to zero > > before they are re-initialized under the new current context. > > > > Cc: Marc-André Lureau <[email protected]> > > Cc: Philippe Mathieu-Daudé <[email protected]> > > Cc: Daniel P. Berrangé <[email protected]> > > Signed-off-by: Dongwon Kim <[email protected]> > > --- > > ui/gtk-egl.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 7c5c9b2428..fd14b391ed > > 100644 > > --- a/ui/gtk-egl.c > > +++ b/ui/gtk-egl.c > > @@ -163,6 +163,12 @@ void gd_egl_refresh(DisplayChangeListener *dcl) > > surface_gl_create_texture(vc->gfx.gls, vc->gfx.ds); > > } > > #ifdef CONFIG_GBM > > + > > + /* resetting old ids to 0 for new egl context */ > > + egl_fb_destroy(&vc->gfx.guest_fb); > > + egl_fb_destroy(&vc->gfx.cursor_fb); > > + egl_fb_destroy(&vc->gfx.win_fb); > > + > > Hmm.. It looks like the whole block is flawed.. All the destruction should be > done before the new context is created in gd_egl_init().
Yeah the best thing is to destroy and reset all egl/gl references before destroying EGL Context. Then we will introduce a new function that cleans up and call it from gtk.c where eglDestroyContext are called. We can go with this route. Or was gd_egl_init() > intended to be called only once? Tbh, this is X11 stuff I think we should get > rid > of.. gd_egl_init is designed to be called after whenever gtk window is closed or created (when context is destroyed..) > > > > > -- > Marc-André Lureau
