nox-spirv 0.1.1

Compact SPIR-V reflection library written in pure-Rust
Documentation
  • Coverage
  • 4.2%
    171 out of 4067 items documented2 out of 44 items with examples
  • Size
  • Source code size: 1.03 MB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 223.9 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 1m 12s Average build duration of successful builds.
  • all releases: 1m 4s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • eikkukek/leimu
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • eikkukek

nox-spirv

A compact SPIR-V reflection library written in pure-Rust with zero dependencies, minimal allocations and fast compile-times.

Usage

An example of doing some reflection on SPIR-V words.

use nox_spirv::op;
use nox_spirv::Module;
use nox_spirv::reflect::{Reflector, ResourceType};

let spirv: &[u32] = ...;
let module = Module::new(spirv);
let mut reflector = Reflector::new(module).unwrap();
for ubo in reflector.resources_for_type(ResourceType::UniformBuffer).unwrap() {
    match ubo {
        Ok(ubo) => {
            let mut set = None;
            let mut binding = None;
            for dec in reflector.decorations(ubo.variable_id) {
                if let op::Decoration::DescriptorSet { descriptor_set } = dec.decoration {
                    set = Some(descriptor_set);
                } else if let op::Decoration::Binding { binding_point } = dec.decoration {
                    binding = Some(binding_point);
                }
            }
            println!("Uniform buffer (set {}, binding {}): {}",
                set.unwrap(), binding.unwrap(), ubo.name.unwrap_or_default(),
            );
        },
        Err(err) => eprintln!("parse error: {err}")
    }
}
for pc in reflector.resources_for_type(ResourceType::PushConstant).unwrap() {
    match pc {
        Ok(pc) => {
            let size = reflector
                .type_description(pc.base_type_id)
                .unwrap().size_hint.declared();
            println!("Push constant (size {size}): {}", pc.name.unwrap_or_default());
        },
        Err(err) => eprintln!("parse error: {err}"),
    }
}