#spirv #reflection #vulkan #glsl #hlsl

spirv-layout

SPIRV reflection utility for deriving Vulkan DescriptorSetLayouts

5 releases (3 breaking)

1.0.0 Jan 26, 2022
0.4.0 Jan 28, 2022
0.3.0 Jan 26, 2022
0.2.1 Jan 25, 2022
0.1.2 Dec 22, 2021

#562 in Game dev

Download history 2/week @ 2022-11-25 2/week @ 2022-12-02 7/week @ 2022-12-09 2/week @ 2022-12-16 10/week @ 2022-12-23 3/week @ 2022-12-30 4/week @ 2023-01-06 2/week @ 2023-01-13 6/week @ 2023-01-20 13/week @ 2023-01-27 46/week @ 2023-02-03 30/week @ 2023-02-10 24/week @ 2023-02-17 1/week @ 2023-02-24 6/week @ 2023-03-03 19/week @ 2023-03-10

60 downloads per month

MIT license

37KB
858 lines

SPIRV-Layout

MIT License Continuous integration Crates.io docs.rs

This library parses SPIRV binaries and retrieves reflection info. It is most useful for deriving a Vulkan DescriptorSetLayout from a shader module, as well as finding offsets and names of individual fields in the Uniform Buffers of a shader.

This crate is used by the vulkan-engine project.

Usage

let bytes = std::fs::read(PATH).unwrap();
let words = unsafe { slice::from_raw_parts(bytes.as_ptr() as *const u32, bytes.len() / 4) };
let module = Module::from_words(words).unwrap();

println!("=== UNIFORMS ===");
for var in module.get_uniforms() {
    print_var(&module, var);
}

println!("=== PUSH CONSTANTS ===");
for var in module.get_push_constants() {
    print_var(&module, var);
}

For an actual usage example, see examples/reflect-shader

Dependencies

~0.7–1MB
~27K SLoC