You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
extensions: Use Rust IO-safety types for fd/handle arguments/returns
Use Rust's IO-safety types like `OwnedFd`/`BorrowedFd` (and their
Windows `*Handle` equivalent) to communicate ownership transfer (or lack
thereof) to the user and provide automatic cleanup when an owned handle
is transferred to the caller.
For Windows however the returned handle is only owned when it is a
"handle type defined as NT handle" [1], being unclear what classifies as
an NT handle (anything built/used after 1993??).
We already contemplated this before, and the change puts `cfg(windows)`
and `cfg(unix)` guards in place for the corresponding OS-specific
extension wrappers, as these safety types are likewise only available on
the aforementioned platforms.
Unfortunately the import APIs pass file descriptors and handles via
structs which have non-trivial ownership transfer into Vulkan functions:
we could switch them to move semantics but there's no guarantee that
these structs are only used with these functions. And it's even
more complicated for external memory import: there the handle / file
descriptor is passed in an `Info` struct chained in `pNext` for calls
to `vkAllocateMemory()`, making it even more complicated (if at all
possible) for us to intercept and "consume" the owned handle in a
wrapper layer to prevent Rust from closing it.
Furthermore note that all import APIs only transfer ownership _on Unix_;
on Windows the caller remains responsible for calling `CloseHandle()`
after (not sooner) the import is no longer used in Vulkan.
This bumps MSRV to 1.63, and we could switch from `std::os::unix::io` to
`std::os::fd` in MSRV 1.66.
[1]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetMemoryWin32HandleKHR.html#_description
0 commit comments