VkFence _fence)
{
ANV_FROM_HANDLE(anv_fence, fence, _fence);
+ UNUSED struct anv_physical_device *pdevice = &device->instance->physicalDevice;
struct anv_execbuf execbuf;
anv_execbuf_init(&execbuf);
switch (impl->type) {
case ANV_SEMAPHORE_TYPE_BO:
+ assert(!pdevice->has_syncobj);
result = anv_execbuf_add_bo(&execbuf, impl->bo, NULL,
0, &device->alloc);
if (result != VK_SUCCESS)
break;
case ANV_SEMAPHORE_TYPE_SYNC_FILE:
+ assert(!pdevice->has_syncobj);
if (in_fence == -1) {
in_fence = impl->fd;
} else {
switch (impl->type) {
case ANV_SEMAPHORE_TYPE_BO:
+ assert(!pdevice->has_syncobj);
result = anv_execbuf_add_bo(&execbuf, impl->bo, NULL,
EXEC_OBJECT_WRITE, &device->alloc);
if (result != VK_SUCCESS)
break;
case ANV_SEMAPHORE_TYPE_SYNC_FILE:
+ assert(!pdevice->has_syncobj);
need_out_fence = true;
break;
switch (impl->type) {
case ANV_FENCE_TYPE_BO:
+ assert(!pdevice->has_syncobj_wait);
result = anv_execbuf_add_bo(&execbuf, &impl->bo.bo, NULL,
EXEC_OBJECT_WRITE, &device->alloc);
if (result != VK_SUCCESS)
}
if (fence && fence->permanent.type == ANV_FENCE_TYPE_BO) {
+ assert(!pdevice->has_syncobj_wait);
/* BO fences can't be shared, so they can't be temporary. */
assert(fence->temporary.type == ANV_FENCE_TYPE_NONE);
}
if (result == VK_SUCCESS && need_out_fence) {
+ assert(!pdevice->has_syncobj_wait);
int out_fence = execbuf.execbuf.rsvd2 >> 32;
for (uint32_t i = 0; i < num_out_semaphores; i++) {
ANV_FROM_HANDLE(anv_semaphore, semaphore, out_semaphores[i]);
}
} else if (handleTypes & VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT) {
assert(handleTypes == VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT);
-
- semaphore->permanent.type = ANV_SEMAPHORE_TYPE_SYNC_FILE;
- semaphore->permanent.fd = -1;
+ if (device->instance->physicalDevice.has_syncobj) {
+ semaphore->permanent.type = ANV_SEMAPHORE_TYPE_DRM_SYNCOBJ;
+ semaphore->permanent.syncobj = anv_gem_syncobj_create(device, 0);
+ } else {
+ semaphore->permanent.type = ANV_SEMAPHORE_TYPE_SYNC_FILE;
+ semaphore->permanent.fd = -1;
+ }
} else {
assert(!"Unknown handle type");
vk_free2(&device->alloc, pAllocator, semaphore);
break;
case VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT:
- new_impl = (struct anv_semaphore_impl) {
- .type = ANV_SEMAPHORE_TYPE_SYNC_FILE,
- .fd = fd,
- };
+ if (device->instance->physicalDevice.has_syncobj) {
+ new_impl = (struct anv_semaphore_impl) {
+ .type = ANV_SEMAPHORE_TYPE_DRM_SYNCOBJ,
+ .syncobj = anv_gem_syncobj_create(device, 0),
+ };
+ if (!new_impl.syncobj)
+ return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+ if (anv_gem_syncobj_import_sync_file(device, new_impl.syncobj, fd)) {
+ anv_gem_syncobj_destroy(device, new_impl.syncobj);
+ return vk_errorf(device->instance, NULL,
+ VK_ERROR_INVALID_EXTERNAL_HANDLE,
+ "syncobj sync file import failed: %m");
+ }
+ /* Ownership of the FD is transfered to Anv. Since we don't need it
+ * anymore because the associated fence has been put into a syncobj,
+ * we must close the FD.
+ */
+ close(fd);
+ } else {
+ new_impl = (struct anv_semaphore_impl) {
+ .type = ANV_SEMAPHORE_TYPE_SYNC_FILE,
+ .fd = fd,
+ };
+ }
break;
default:
return VK_SUCCESS;
case ANV_SEMAPHORE_TYPE_DRM_SYNCOBJ:
- fd = anv_gem_syncobj_handle_to_fd(device, impl->syncobj);
+ if (pGetFdInfo->handleType == VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT)
+ fd = anv_gem_syncobj_export_sync_file(device, impl->syncobj);
+ else {
+ assert(pGetFdInfo->handleType == VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT);
+ fd = anv_gem_syncobj_handle_to_fd(device, impl->syncobj);
+ }
if (fd < 0)
return vk_error(VK_ERROR_TOO_MANY_OBJECTS);
*pFd = fd;