KhronosGroup / KhronosGroup/Vulkan-Docs

New extension for linking fences with OS events/file handles

Open
#310 27 comments 18 reactions 0 assignees View on GitHub
Feature Request Resolving Inside Khronos
Dominant language
JavaScript
Stars
3.3k
Forks
549
Avg merge
5d 5h
Merged PRs (30d)
2

Description

Currently the only way to wait on the device for a Fence is vkWaitForFences.

However all of this will block the current thread and prevent other OS events (like IO a disk read finishing up, a key press from the user, ...) being handled.

To let other OS events get through to the thread you would need to associate the fence with a Kernel object that can be waited on in bulk (like WairForMultipleObjects or select/epoll).

This would for example be with a `vkLinkFenceToWin32EventHandleEXT(vkDevice, vkFence, HANDLE);` where if the fence gets signaled the associated event also gets signaled. (only 1 event per fence and vice versa)

Or instead the notification could be done with a IO completion queue:

``` C
struct vkLinkFenceToWin32CompletionQueueInfoEXT{
VkStructureType sType;
void* pNext;
HANDLE completionQueue;
ULONG_PTR completionKey;
OVERLAPPED *overlapped;
}

vkLinkFenceToWin32CompletionQueueEXT(vkDevice, vkFence, vkLinkFenceToWin32CompletionQueueInfoEXT*);
//or as part of the pNext in fence create info
```

The completionKey and OVERLAPPED pointer are passed back to [GetQueuedCompletionStatus](https://msdn.microsoft.com/en-us/library/windows/desktop/aa364986%28v=vs.85%29.aspx) after the fence is signaled. The OVERLAPPED struct is not copied (to mimic the rest of the win32 api concerning the struct which allows the user to put data after the struct).

I'm not familiar enough with linux programming to judge what the best method for linking fences to file handles is; eventfd(2) per fence or a pipe(7) acting as a queue? I'll leave that up to others to judge.

Contributor guide

Open the contributing guide

Research direction

Start with the existing vkWaitForFences entry point and review the proposed vkLinkFenceToWin32EventHandleEXT and vkLinkFenceToWin32CompletionQueueEXT designs, including GetQueuedCompletionStatus, eventfd, and pipe behavior. Done means reaching agreement on a cross-platform fence-to-OS-event extension and documenting its synchronization and lifetime semantics.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, linux
Domain
api, operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.