diff options
author | Bas Nieuwenhuizen <[email protected]> | 2017-11-28 00:21:12 +0100 |
---|---|---|
committer | Bas Nieuwenhuizen <[email protected]> | 2017-12-18 09:31:17 +0100 |
commit | 6abfa378796131317c5b983e2273047bf28a69b0 (patch) | |
tree | 2563dc8737ba6a7f92c6939604b053b219a4e624 | |
parent | 969421b7dab414313c2ec9ba6f2d193b4c117cec (diff) |
radv: Implement VK_KHR_external_fence_fd.
Reviewed-by: Dave Airlie <[email protected]>
-rw-r--r-- | src/amd/vulkan/radv_device.c | 47 | ||||
-rw-r--r-- | src/amd/vulkan/radv_extensions.py | 1 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index fc9fb59f991..94562fda875 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -3746,3 +3746,50 @@ void radv_GetPhysicalDeviceExternalSemaphorePropertiesKHR( pExternalSemaphoreProperties->externalSemaphoreFeatures = 0; } } + +VkResult radv_ImportFenceFdKHR(VkDevice _device, + const VkImportFenceFdInfoKHR *pImportFenceFdInfo) +{ + RADV_FROM_HANDLE(radv_device, device, _device); + RADV_FROM_HANDLE(radv_fence, fence, pImportFenceFdInfo->fence); + uint32_t syncobj_handle = 0; + uint32_t *syncobj_dst = NULL; + assert(pImportFenceFdInfo->handleType == VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT_KHR); + + int ret = device->ws->import_syncobj(device->ws, pImportFenceFdInfo->fd, &syncobj_handle); + if (ret != 0) + return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR); + + if (pImportFenceFdInfo->flags & VK_FENCE_IMPORT_TEMPORARY_BIT_KHR) { + syncobj_dst = &fence->temp_syncobj; + } else { + syncobj_dst = &fence->syncobj; + } + + if (*syncobj_dst) + device->ws->destroy_syncobj(device->ws, *syncobj_dst); + + *syncobj_dst = syncobj_handle; + close(pImportFenceFdInfo->fd); + return VK_SUCCESS; +} + +VkResult radv_GetFenceFdKHR(VkDevice _device, + const VkFenceGetFdInfoKHR *pGetFdInfo, + int *pFd) +{ + RADV_FROM_HANDLE(radv_device, device, _device); + RADV_FROM_HANDLE(radv_fence, fence, pGetFdInfo->fence); + int ret; + uint32_t syncobj_handle; + + assert(pGetFdInfo->handleType == VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT_KHR); + if (fence->temp_syncobj) + syncobj_handle = fence->temp_syncobj; + else + syncobj_handle = fence->syncobj; + ret = device->ws->export_syncobj(device->ws, syncobj_handle, pFd); + if (ret) + return vk_error(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR); + return VK_SUCCESS; +} diff --git a/src/amd/vulkan/radv_extensions.py b/src/amd/vulkan/radv_extensions.py index 2c1c71ecdc7..3188735ea78 100644 --- a/src/amd/vulkan/radv_extensions.py +++ b/src/amd/vulkan/radv_extensions.py @@ -53,6 +53,7 @@ EXTENSIONS = [ Extension('VK_KHR_bind_memory2', 1, True), Extension('VK_KHR_dedicated_allocation', 1, True), Extension('VK_KHR_descriptor_update_template', 1, True), + Extension('VK_KHR_external_fence_fd', 1, 'device->rad_info.has_syncobj_wait'), Extension('VK_KHR_external_memory', 1, True), Extension('VK_KHR_external_memory_capabilities', 1, True), Extension('VK_KHR_external_memory_fd', 1, True), |