[Mesa-dev] [PATCH 1/2] radv: Free syncobj with multiple imports.

Dave Airlie airlied at gmail.com
Tue Nov 14 03:30:06 UTC 2017


Reviewed-by: Dave Airlie <airlied at redhat.com>

On 14 November 2017 at 09:45, Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl> wrote:
> Otherwise we can leak the old syncobj.
>
> Fixes: eaa56eab6da "radv: initial support for shared semaphores (v2)"
> ---
>  src/amd/vulkan/radv_device.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
> index 929082182c2..4e3ad111382 100644
> --- a/src/amd/vulkan/radv_device.c
> +++ b/src/amd/vulkan/radv_device.c
> @@ -3525,6 +3525,7 @@ VkResult radv_ImportSemaphoreFdKHR(VkDevice _device,
>         RADV_FROM_HANDLE(radv_device, device, _device);
>         RADV_FROM_HANDLE(radv_semaphore, sem, pImportSemaphoreFdInfo->semaphore);
>         uint32_t syncobj_handle = 0;
> +       uint32_t *syncobj_dst = NULL;
>         assert(pImportSemaphoreFdInfo->handleType == VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT_KHR);
>
>         int ret = device->ws->import_syncobj(device->ws, pImportSemaphoreFdInfo->fd, &syncobj_handle);
> @@ -3532,10 +3533,15 @@ VkResult radv_ImportSemaphoreFdKHR(VkDevice _device,
>                 return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR);
>
>         if (pImportSemaphoreFdInfo->flags & VK_SEMAPHORE_IMPORT_TEMPORARY_BIT_KHR) {
> -               sem->temp_syncobj = syncobj_handle;
> +               syncobj_dst = &sem->temp_syncobj;
>         } else {
> -               sem->syncobj = syncobj_handle;
> +               syncobj_dst = &sem->syncobj;
>         }
> +
> +       if (*syncobj_dst)
> +               device->ws->destroy_syncobj(device->ws, *syncobj_dst);
> +
> +       *syncobj_dst = syncobj_handle;
>         close(pImportSemaphoreFdInfo->fd);
>         return VK_SUCCESS;
>  }
> --
> 2.15.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list