[PATCH] ui/spice: Destroy the temporary egl fb after the blit is submitted

Vivek Kasireddy posted 1 patch 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250718062607.2209900-1-vivek.kasireddy@intel.com
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>
There is a newer version of this series
ui/spice-display.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] ui/spice: Destroy the temporary egl fb after the blit is submitted
Posted by Vivek Kasireddy 4 months ago
The temporary egl fb scanout_tex_fb is only needed to facilitate the
blit to the display surface's texture (ssd->ds->texture). Therefore,
destroy it after the blit is submitted. And, also make sure that it
is empty initialized before it is actually used.

Fixes: f851cd65 ("ui/spice: Blit the scanout texture if its memory layout is not linear")
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
---
 ui/spice-display.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ui/spice-display.c b/ui/spice-display.c
index 9ce622cefc..401d6c4aba 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -1191,12 +1191,12 @@ static bool spice_gl_blit_scanout_texture(SimpleSpiceDisplay *ssd,
     uint64_t modifier;
     bool ret;
 
-    egl_fb_destroy(scanout_tex_fb);
     egl_fb_setup_for_tex(scanout_tex_fb,
                          surface_width(ssd->ds), surface_height(ssd->ds),
                          ssd->ds->texture, false);
     egl_fb_blit(scanout_tex_fb, &ssd->guest_fb, false);
     glFlush();
+    egl_fb_destroy(scanout_tex_fb);
 
     if (!ssd->new_scanout_texture) {
         return true;
@@ -1330,7 +1330,7 @@ static void qemu_spice_gl_update(DisplayChangeListener *dcl,
     }
 
     if (spice_remote_client && ssd->blit_scanout_texture) {
-        egl_fb scanout_tex_fb;
+        egl_fb scanout_tex_fb = {};
 
         ret = spice_gl_blit_scanout_texture(ssd, &scanout_tex_fb);
         if (!ret) {
-- 
2.49.0


Re: [PATCH] ui/spice: Destroy the temporary egl fb after the blit is submitted
Posted by Peter Maydell 4 months ago
On Fri, 18 Jul 2025 at 07:29, Vivek Kasireddy <vivek.kasireddy@intel.com> wrote:
>
> The temporary egl fb scanout_tex_fb is only needed to facilitate the
> blit to the display surface's texture (ssd->ds->texture). Therefore,
> destroy it after the blit is submitted. And, also make sure that it
> is empty initialized before it is actually used.
>
> Fixes: f851cd65 ("ui/spice: Blit the scanout texture if its memory layout is not linear")
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
> Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
> ---
>  ui/spice-display.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/ui/spice-display.c b/ui/spice-display.c
> index 9ce622cefc..401d6c4aba 100644
> --- a/ui/spice-display.c
> +++ b/ui/spice-display.c
> @@ -1191,12 +1191,12 @@ static bool spice_gl_blit_scanout_texture(SimpleSpiceDisplay *ssd,
>      uint64_t modifier;
>      bool ret;
>
> -    egl_fb_destroy(scanout_tex_fb);
>      egl_fb_setup_for_tex(scanout_tex_fb,
>                           surface_width(ssd->ds), surface_height(ssd->ds),
>                           ssd->ds->texture, false);
>      egl_fb_blit(scanout_tex_fb, &ssd->guest_fb, false);
>      glFlush();
> +    egl_fb_destroy(scanout_tex_fb);
>
>      if (!ssd->new_scanout_texture) {
>          return true;
> @@ -1330,7 +1330,7 @@ static void qemu_spice_gl_update(DisplayChangeListener *dcl,
>      }
>
>      if (spice_remote_client && ssd->blit_scanout_texture) {
> -        egl_fb scanout_tex_fb;
> +        egl_fb scanout_tex_fb = {};
>
>          ret = spice_gl_blit_scanout_texture(ssd, &scanout_tex_fb);
>          if (!ret) {

It looks like we only call spice_gl_blit_scanout_texture()
once -- would it make more sense to put the scanout_tx_fb
variable inside that function rather than making its only
callsite set it up? That way the function owns, sets up,
uses and destroys the egl_fb.

thanks
-- PMM