1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! Compact SPIR-V reflection library written in pure-Rust with zero dependencies and minimal
//! allocations.
//!
//! # Allocation policy
//! - Strings and arrays are just slices to the SPIR-V passed to [`Module`].
//! - Only [`decorations`][1] and [`instructions streams`][2] with a [`result id`][3] are cached using
//! an extra allocation.
//! - Parsing is mostly done on-demand.
//!
//! [1]: op::Decoration
//! [2]: stream::InstructionStream
//! [3]: op::IdResult
//! # Usage
//! ``` rust
//! use nox_spirv::op;
//! use nox_spirv::Module;
//! use nox_spirv::reflect::{Reflector, ResourceType};
//!
//! let spirv: &[u32] = ...;
//! let module = Module::new(spirv).unwrap();
//! let mut reflector = Reflector::new(module).unwrap();
//! reflector.set_entry_point(c"main", op::ExecutionModel::FRAGMENT).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 offset = pc.offset.unwrap();
//! let size = reflector
//! .type_description(pc.base_type_id)
//! .unwrap().size_hint.declared();
//! println!("Push constant (offset {offset}, size {size}): {}", pc.name.unwrap_or_default());
//! },
//! Err(err) => eprintln!("parse error: {err}"),
//! }
//! }
//! ```
pub use ;