Announcing Maia - Safe, low-level Vulkan bindings
Hi everyone! I've just released the initial version of Maia, a new safe Vulkan wrapper I've been working on. I would be really interested to hear everyone's thoughts on the API and the design! Here's a brief summary:
Maia's goal is to be as close as possible in flexibility and performance as raw unsafe API calls, while still being safe. To do this, it takes a slightly different approach from existing Rust Vulkan libraries in several areas.
First of all, it avoids adding any abstraction that isn't absolutely necessary for safety, and the abstractions it does use limit the user's flexibility as little as possible. Code written with Maia will usually look quite similar to the corresponding C, except with Rust idioms (eg, create_ is spelled ::new).
Second, it uses no locks at all. When possible, synchronization is taken care of at compile time with &mut, and the rest is done with reference counting. Any function that is called at the wrong time (like resetting a command pool while its buffers are pending) will return an error instead of blocking. This prevents certain hard-to-debug performance issues.
The tradeoff that makes this work is that it does not try to prevent every kind of API misuse, like missing memory barriers, or data races in glsl. Instead, it only prevents problems like use-after-free that have a "cascading" effect on CPU memory safety. In this way, Maia's memory safety experience is akin to talking to a C program on the other end of a network connection: The GPU might give you back nonsense values, but it won't infect your program with UB. My hope is that this is a useful tradeoff to avoid Vulkan's many safety pitfalls while keeping reasonable performance and flexibility.