Skip to content

Comments

Introduce KHR_external_semaphore_fd only for FD==-1#2670

Merged
billhollings merged 1 commit intoKhronosGroup:mainfrom
utmapp:submit/semaphore-fd
Dec 12, 2025
Merged

Introduce KHR_external_semaphore_fd only for FD==-1#2670
billhollings merged 1 commit intoKhronosGroup:mainfrom
utmapp:submit/semaphore-fd

Conversation

@osy
Copy link
Contributor

@osy osy commented Dec 1, 2025

There is a special use case for when importing/exporting a semaphore of handle type VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT and FD == -1. According to the Vulkan specs, calling vkImportSemaphoreFdKHR has the effect of signaling the binary semaphore and calling vkGetSemaphoreFdKHR has the effect of waiting on the binary semaphore.

Outside of KHR_external_semaphore_fd extension, there is no other way to achieve this behaviour. For example, vkWaitSemaphores does not operate on a binary semaphore and there is no other defined way for a CPU to send a signal operation.

In theory, we can use EXT_metal_objects and export the VkSemaphore to a MTLSharedEvent but we do not have access to the MVKSemaphoreMTLEvent in order to determine the _mtlEventValue (last encoded wait value).

This functionality is required to implement Venus on macOS which uses these functions to synchronize the guest semaphore state to the host.

There is a special use case for when importing/exporting a semaphore of
handle type `VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT` and FD == -1.
According to the Vulkan specs, calling `vkImportSemaphoreFdKHR` has the
effect of signaling the binary semaphore and calling `vkGetSemaphoreFdKHR`
has the effect of waiting on the binary semaphore.

Outside of KHR_external_semaphore_fd extension, there is no other way to
achieve this behaviour. For example, `vkWaitSemaphores` does not operate
on a binary semaphore and there is no other defined way for a CPU to send
a signal operation.

In theory, we can use EXT_metal_objects and export the VkSemaphore to a
`MTLSharedEvent` but we do not have access to the `MVKSemaphoreMTLEvent` in
order to determine the `_mtlEventValue` (last encoded wait value).

This functionality is required to implement Venus on macOS which uses these
functions to synchronize the guest semaphore state to the host.
@osy osy force-pushed the submit/semaphore-fd branch from d8db746 to 2f1358e Compare December 1, 2025 16:36
Copy link
Contributor

@billhollings billhollings left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting! LGTM.

@billhollings billhollings merged commit 2c3f25d into KhronosGroup:main Dec 12, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants