pub struct RawModule { /* private fields */ }
Expand description
Minimal representation of a SPIR-V module.
Implementations§
Source§impl RawModule
impl RawModule
Sourcepub fn load_module<P: AsRef<Path>>(path: P) -> Result<RawModule>
pub fn load_module<P: AsRef<Path>>(path: P) -> Result<RawModule>
Load a module from a file
Examples found in repository?
examples/dump_variables.rs (line 14)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
fn main() {
let mut args = env::args_os();
args.next();
let filename = args.next();
let module = if let Some(filename) = filename {
spirv_utils::RawModule::load_module(filename).unwrap()
} else {
spirv_utils::RawModule::load_module("examples/vert.spv").unwrap()
};
for inst in module.instructions() {
if let instruction::Instruction::Variable { result_id, storage_class, .. } = *inst {
if let Some(name) = get_name(&module, result_id.into()) {
println!("Variable {: <15} {:?}", name, storage_class);
}
}
}
}
Sourcepub fn read_module<R: Read>(reader: R) -> Result<RawModule>
pub fn read_module<R: Read>(reader: R) -> Result<RawModule>
Read a module
Sourcepub fn instructions<'a>(&'a self) -> &'a [Instruction]
pub fn instructions<'a>(&'a self) -> &'a [Instruction]
Gets the instructions in the module
Examples found in repository?
examples/dump_variables.rs (line 19)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
fn main() {
let mut args = env::args_os();
args.next();
let filename = args.next();
let module = if let Some(filename) = filename {
spirv_utils::RawModule::load_module(filename).unwrap()
} else {
spirv_utils::RawModule::load_module("examples/vert.spv").unwrap()
};
for inst in module.instructions() {
if let instruction::Instruction::Variable { result_id, storage_class, .. } = *inst {
if let Some(name) = get_name(&module, result_id.into()) {
println!("Variable {: <15} {:?}", name, storage_class);
}
}
}
}
Sourcepub fn def_index<I: Into<Id>>(&self, id: I) -> Option<usize>
pub fn def_index<I: Into<Id>>(&self, id: I) -> Option<usize>
Gets the index of the instruction that defines the given id, if any
Sourcepub fn use_indices<'a, I: Into<Id>>(&'a self, id: I) -> Option<&'a [usize]>
pub fn use_indices<'a, I: Into<Id>>(&'a self, id: I) -> Option<&'a [usize]>
Gets the indices of the instructions that use the given id
Auto Trait Implementations§
impl Freeze for RawModule
impl RefUnwindSafe for RawModule
impl Send for RawModule
impl Sync for RawModule
impl Unpin for RawModule
impl UnwindSafe for RawModule
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more