diff options
author | Bas Nieuwenhuizen <[email protected]> | 2017-11-13 23:18:19 +0100 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2017-11-17 19:24:29 +0000 |
commit | 577af89bd13e69541329136138a19e043bc63a17 (patch) | |
tree | dbf48204ee86ce2c8601e815d3d4d2ccfee57089 | |
parent | 040c0df11dbc43017700a15f94439bd49c5d26b7 (diff) |
radv: Free syncobj with multiple imports.
Otherwise we can leak the old syncobj.
Fixes: eaa56eab6da "radv: initial support for shared semaphores (v2)"
Reviewed-by: Dave Airlie <[email protected]>
Reviewed-by: Samuel Pitoiset <[email protected]>
(cherry picked from commit 917d3b43f2b206ccf036542aa1c39f1dbdd84f62)
-rw-r--r-- | src/amd/vulkan/radv_device.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index abdbdeb6017..63129a1d1d9 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -3515,6 +3515,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); @@ -3522,10 +3523,15 @@ VkResult radv_ImportSemaphoreFdKHR(VkDevice _device, return 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; } |