6 releases

0.1.5 Mar 7, 2022
0.1.4 Jan 5, 2022
0.1.3 Nov 7, 2021
0.1.2 Sep 24, 2021

#730 in Graphics APIs

GPL-3.0 license

37KB
703 lines

rivi-loader

Latest version Docs LICENSE

[dependencies]
rivi-loader = "0.1.5"

rivi-loader is a Vulkan-based program loader for GPGPU applications. Roughly speaking, if you have input(s) and an output it will run a SPIR-V kernel on those values. This way, the long days of wondering how Vulkan works can be forgotten / skipped. That being said, the library does not help you in writing SPIR-V or any other shading language. It neither helps you in scheduling. What it does do is help you to setup the Vulkan instance, attach debug layers on it, query compute capable logical devices, expose fences and compute-capable queue families and queues, manage memory and command buffers, and deal with shader creation with specialization constant support. There is also a keen interest in making sure that the command buffers can be queued and polled in parallel on the CPU side.

Example

fn main() {
    let a = vec![1.0f32; 64];
    let input = &vec![vec![a]];
    let mut output = vec![0.0f32; 1];

    let vk = rivi_loader::new(DebugOption::None).unwrap();

    let mut cursor = std::io::Cursor::new(&include_bytes!("./reduce/reduce.spv")[..]);
    let shader = vk.load_shader(&mut cursor, Some(vec![vec![2]])).unwrap();

    vk.compute(input, &mut output, &shader).unwrap();

    println!("Result: {:?}", output);
}

Features

  • lifetime management of Vulkan resources
  • multi-gpu support
  • allows scheduling on multiple queue families
  • allows scheduling on multiple queues of a single queue family
  • allows shader specialization constants to be set
  • supports per device querying of "advanced" compute capabilities, e.g., subgroup sizes
  • allows Rust generics to be used on input and output buffers

Limitations (i.e., what this repository assumes)

  • there should always exist an input vector and an output vector in your SPIR-V code
  • the length of the output vector has to be always statically known

Installation

  1. Make sure Rust is installed, if not, consider rustup
  2. Make sure Vulkan is installed, if not, consider LunarG and the installation instructions found on ash
  3. Run an example, e.g. cargo run --example reduce.

The library

To understand what is happening in the lib.rs, consider a blog post series about graphics applications.

Periferia Labs

Periferia Labs is an ad-hoc group of friends tinkering with GPGPU. See our other projects:

  • laskin.live - An online calculator, but you can only use it on your remote friend’s GPU

Dependencies

~14MB
~324K SLoC