Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rob2309/spirv-layout
SPIRV reflection utility for deriving Vulkan DescriptorSetLayouts
https://github.com/rob2309/spirv-layout
game-development glsl graphics hlsl reflection rust spirv vulkan
Last synced: 3 months ago
JSON representation
SPIRV reflection utility for deriving Vulkan DescriptorSetLayouts
- Host: GitHub
- URL: https://github.com/rob2309/spirv-layout
- Owner: Rob2309
- License: mit
- Created: 2021-12-21T14:31:57.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T09:25:34.000Z (about 2 years ago)
- Last Synced: 2024-09-16T08:52:20.652Z (4 months ago)
- Topics: game-development, glsl, graphics, hlsl, reflection, rust, spirv, vulkan
- Language: Rust
- Homepage: https://crates.io/crates/spirv-layout
- Size: 28.3 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SPIRV-Layout
[![MIT License](https://img.shields.io/badge/License-MIT-blue?style=for-the-badge)](https://choosealicense.com/licenses/mit/)
[![Continuous integration](https://img.shields.io/github/actions/workflow/status/rob2309/spirv-layout/ci.yaml?style=for-the-badge)](https://github.com/rob2309/spirv-layout/actions)
[![Crates.io](https://img.shields.io/crates/v/spirv-layout?style=for-the-badge)](https://crates.io/crates/spirv-layout)
[![docs.rs](https://img.shields.io/docsrs/spirv-layout?style=for-the-badge)](https://docs.rs/spirv-layout)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](https://github.com/michidk/vulkan-engine) project.
## Usage
```rust
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`](examples/reflect-shader/main.rs)