Crates.io | spirv-layout |
lib.rs | spirv-layout |
version | 0.4.0 |
source | src |
created_at | 2021-12-21 14:34:55.57317 |
updated_at | 2022-01-28 09:44:53.123716 |
description | SPIRV reflection utility for deriving Vulkan DescriptorSetLayouts |
homepage | |
repository | https://github.com/Rob2309/spirv-layout |
max_upload_size | |
id | 501202 |
size | 53,115 |
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.
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