frontends/va: Fix leaking fences in GetImage/PutImage

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: 0f20a3a4f1 ("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 <manio@skyboo.net>
Tested-by: Mariusz Białończyk <manio@skyboo.net>
Reviewed-by: Ruijing Dong <ruijing.dong@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36040>
This commit is contained in:
David Rosca 2025-07-07 14:02:57 +02:00 committed by Marge Bot
parent 94f42bb201
commit 2d6560611f

View file

@ -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,