maia

Crates.iomaia
lib.rsmaia
version0.1.1
sourcesrc
created_at2022-06-24 20:09:25.405713
updated_at2022-07-11 07:53:24.248332
descriptionSafe low-level Vulkan bindings
homepagehttps://github.com/danielkeller/maia
repositoryhttps://github.com/danielkeller/maia
max_upload_size
id612595
size465,047
Daniel Keller (danielkeller)

documentation

README

Maia

Crates.io docs.rs GitHub Workflow Status

Safe, low-level Vulkan bindings. The general properties of this library are

  1. Memory safe on the CPU. No safe operation can cause memory corruption or data races in host* memory.
  2. Lock-free. Thread safety is handled at compile time with &mut rather than with mutexes, to avoid performance surprises.
  3. Low-level. Close to 1-1 correspondance with Vulkan API calls. Calls which don't allocate in Vulkan also don't allocate in Maia.
  4. Selective. Maia intentionally omits Vulkan features that are not performant, not useful, or are rarely supported. However, APIs are provided to allow extension in downstream crates.
  5. As ergonomic as possible. In particular, nearly everything is Send and Sync.

Setup

Maia dynamically links to the system's Vulkan loader, so one must be installed. Instructions for specific systems follow.

To begin using the API, create an instance object with vk::Instance::new.

To enable validation layers for debugging, set the environment variable VK_INSTANCE_LAYERS="VK_LAYER_KHRONOS_validation" or use the Configurator GUI.

On Linux

To build, install your distro's Vulkan development libaries (eg for Debian, sudo apt install libvulkan-dev). You will also probably want to install the validation layers, either from the distro (eg sudo apt install vulkan-validationlayers) or by installing the Vulkan SDK.

To run, a Vulkan-compatible graphics driver should suffice.

On MacOS

To build, install the Vulkan SDK, and enable the "System Global Files" option during installation.

To run, you will probably want to include the Vulkan loader and MoltenVK into your .app bundle. Full instructions are available here, and an example can be found in the demo/ directory.

On Windows

A Vulkan-compatible graphics driver is sufficient to build and run. You will probably want to install the Vulkan SDK for validation layers, though.

To run the demos

To compile shaders in the demos, either CMake or the Vulkan SDK must be installed. (CMake appears to be the easier approach on Linux, and the Vulkan SDK on other systems.)

Using Vulkan

This documentation assumes that you already know how Vulkan works. If you're just getting started, I can recommend the Vulkan Guide, the Vulkan Tutorial, or the older, but more detailed API without Secrets. The code that they walk you through will look very similar to the demo and hello-triangle examples in this repo, so you can look at those alongside the walkthroughs to see what the corresponding Rust functions are called.

Safety

Maia does not try to protect the contents of your buffers, images, and shader variables, since these values don't have invalid bit patterns and in particular don't contain pointers. Instead, it prevents incorrect API usage where the consequences could "escape" into the rest of your program, for example use-after-free of Vulkan objects, or out of bounds accesses in RAM buffers. 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 implication of this is that Maia does not enforce every "the application must not" statement in the Vulkan spec, since the spec does not distinguish between these different kinds of misuse. The safety it provides is instead in regards to the behavior of actual Vulkan implementations.

Commit count: 176

cargo fmt