From 2d6560611fc2db7f434d8427746f3e389a0799fd Mon Sep 17 00:00:00 2001 From: David Rosca Date: Mon, 7 Jul 2025 14:02:57 +0200 Subject: [PATCH] frontends/va: Fix leaking fences in GetImage/PutImage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When we need to perform format conversion, we use temporary surface allocated with vlVaHandleSurfaceAllocate. If the driver requires clearing the surface on allocation, it will create a fence that must be destroyed later. Fixes: 0f20a3a4f1a ("frontends/va: Add surface pipe_fence for vl_compositor rendering") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13198 Reported-by: Mariusz Białończyk Tested-by: Mariusz Białończyk Reviewed-by: Ruijing Dong Part-of: --- src/gallium/frontends/va/image.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gallium/frontends/va/image.c b/src/gallium/frontends/va/image.c index 0a53c048af0..eac75e760fd 100644 --- a/src/gallium/frontends/va/image.c +++ b/src/gallium/frontends/va/image.c @@ -489,6 +489,8 @@ vlVaGetImage(VADriverContextP ctx, VASurfaceID surface, int x, int y, mtx_unlock(&drv->mutex); return VA_STATUS_ERROR_ALLOCATION_FAILED; } + if (tmp_surf.pipe_fence) + drv->pipe->screen->fence_reference(drv->pipe->screen, &tmp_surf.pipe_fence, NULL); VARectangle src_rect = { .x = x, .y = y, @@ -656,6 +658,8 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image, mtx_unlock(&drv->mutex); return VA_STATUS_ERROR_ALLOCATION_FAILED; } + if (tmp_surf.pipe_fence) + drv->pipe->screen->fence_reference(drv->pipe->screen, &tmp_surf.pipe_fence, NULL); vlVaUploadImage(drv, &tmp_surf, img_buf, vaimage); VARectangle src_rect = { .x = src_x,