Draft: Add infrastructure for Vulkan drivers written in Rust
We all know that C sucks. Many of us think C++ sucks worse. Rust doesn't suck. Wouldn't it be great if we could write Vulkan drivers in a competent language? If we can figure out how to avoid the mental overhead of the C <-> Rust interface leaking everywhere, Rust would probably be a great language for writing drivers.
This MR is going to stay a draft and be my personal scratch pad for this for a while. I don't expect to see any Rust Vulkan drivers in Mesa any time soon.
A few of the problems I want to solve:
-
Make working with Vulkan allocators reasonable -
Wrap our vk_log framework into something that looks like Rust write/print. -
Handle Vulkan errors using Result<T, VkResult>
or similar-
Automatic unwrapping Result<(), VkResult>
-
Automatic unwrapping Result<VkObjBox<T>, VkResult>
for constructor functions -
A Rust equivalent of vk_error()
andvk_errorf()
.
-
-
Make object construction with vk_foo
base objects reasonable.- This probably means some sort of
VkObjBox<T>
type which constructs an object which is avk_foo
followed by a driver type with some sort of magic to make initializing it using C initializers not a giant pain. Rust's lack of placement-new makes this a tad annoying.
- This probably means some sort of
-
Generate entrypoint wrappers using Vulkan explicit sync to determine mut
- This one is tricky because we can't just pull the weak function pointer trick for automatically NULLing out entrypoints. We probably need to somehow scan the rust project and generate only the wrappers we need or something like that.