I am trying to synchronize access to external memory across 2 processes on android vulkan, my system is telling me that it is only supporting
VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT
which can be exported as as copy, not as a reference.
What I am doing is this in process A ( exporting fd )
CALL_VK(vkQueueSubmit(queue, 1, &submit_info, fence));
int fd;
VkFenceGetFdInfoKHR getFdInfo{};
getFdInfo.sType = VK_STRUCTURE_TYPE_FENCE_GET_FD_INFO_KHR;
getFdInfo.handleType = VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT;
getFdInfo.fence = fence;
CALL_VK(vkGetFenceFdKHR(device.device_, &getFdInfo, &fd));
and then this in process B ( importing copy of a payload from a fd)
VkImportFenceFdInfoKHR importFenceFdInfo{};
importFenceFdInfo.sType = VK_STRUCTURE_TYPE_IMPORT_FENCE_FD_INFO_KHR;
importFenceFdInfo.handleType = VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT;
importFenceFdInfo.fd = fd;
importFenceFdInfo.fence = fence;
importFenceFdInfo.flags = VK_FENCE_IMPORT_TEMPORARY_BIT;
CALL_VK(vkImportFenceFdKHR(device.device_, &importFenceFdInfo));
The thing is if in the process B the fence I've got back is still unsignalled ( it was pending after vkQueueSubmit ) then since this is a copy and not a reference it will never be signalled and I will never know when my GPU runtime will have been finished. I am getting a freeze in the following call in my process B
VkResult result = vkWaitForFences(device, 1, &fence, VK_TRUE, -1);
Then what is the point in all this?
I am expecting that I shall be able to get the state of the fence updated in my process B once it is signalled by GPU.