#vulkan #graphics

mira

Pure and simple Vulkan bindings generated from Vulkan-Headers!

22 releases

0.1.21 Jan 23, 2023
0.1.20 Aug 9, 2022
0.1.18 Jul 15, 2022
0.1.17 May 1, 2022
0.1.10 Oct 22, 2021

#73 in Graphics APIs

Download history 22/week @ 2022-10-13 7/week @ 2022-10-20 11/week @ 2022-10-27 21/week @ 2022-11-03 10/week @ 2022-11-10 20/week @ 2022-11-17 2/week @ 2022-11-24 4/week @ 2022-12-01 18/week @ 2022-12-08 26/week @ 2022-12-15 8/week @ 2022-12-22 8/week @ 2022-12-29 6/week @ 2023-01-05 5/week @ 2023-01-12 37/week @ 2023-01-19 24/week @ 2023-01-26

72 downloads per month
Used in runa

Apache-2.0

2MB
41K SLoC

Rust 29K SLoC // 0.0% comments C++ 9K SLoC // 0.1% comments JavaScript 1.5K SLoC // 0.1% comments Python 253 SLoC // 0.2% comments GLSL 46 SLoC // 0.6% comments Batch 4 SLoC

mira

crates.io docs.rs license

Pure and simple Vulkan bindings generated from Vulkan-Headers!

Mira provides a simple and straightforward way to interact with Vulkan. Everything was generated by bindgen and uses the original API names.

This crate provides:

  • 👀 Function pointers!
  • 💯 Dynamic loader of instance and device commands!
  • ✍️ Original names of commands, structures and macros!
  • 💪 Extra useful features to help with development!
  • 😀 Simple examples!

Code

Enumerate all instance extensions.

use mira::error::MiraError;
use mira::loader;
use mira::mem::{zeroed_vec, from_cstring};
use mira::vulkan::*;
use const_cstr::*;

fn main() -> Result<(), MiraError> {
    let enumerate_instance_extensions:PFN_vkEnumerateInstanceExtensionProperties;
    enumerate_instance_extensions = unsafe {
        loader::instance(std::ptr::null_mut(), const_cstr!("vkEnumerateInstanceExtensionProperties"))?
    };

    let mut count:u32 = 0;
    unsafe { enumerate_instance_extensions(std::ptr::null_mut(), &mut count, std::ptr::null_mut()) };
    let mut extensions = unsafe { zeroed_vec::<VkExtensionProperties>(count as usize) };

    unsafe { enumerate_instance_extensions(std::ptr::null_mut(), &mut count, extensions.as_mut_ptr()) };

    println!("Instance extensions");
    for extension in extensions.iter().enumerate() {
        let str = match unsafe { from_cstring(extension.1.extensionName.as_ptr()) } {
            Ok(str) => str,
            Err(_) => continue,
        };

        println!("extension #{} - {}", extension.0, str);
    }

    Ok(())
}

Examples

Successfully tested on Linux(Lubuntu 20.04) with Intel(R) HD Graphics 620 (KBL GT2).

Color

Displays a window with a purple background.

cargo run --example color

screenshot

Android build

Android NDK: 22.1.7171670

  1. Add ${HOME}/Android/Sdk/ndk/${NDK_VERSION}toolchains/llvm/prebuilt/linux-x86_64/bin to PATH.

export PATH=$PATH:/home/xxxx/Android/Sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin

  1. Add Android target of your choice(aarch64-linux-android, armv7-linux-androideabi, x86_64-linux-android ...)

rustup target add aarch64-linux-android

  1. Run cargo build --target ${TARGET}

cargo build --target aarch64-linux-android

Vulkan version

1.3.239

Vulkan Changelog

License

Apache 2.0

Dependencies

~0.3–2.4MB
~49K SLoC