pub struct Reflector<'a> { /* private fields */ }Expand description
Reflects SPIR-V code through a module.
§Example
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 push_constant in reflector.resources_for_type(ResourceType::PushConstant).unwrap() {
let push_constant = push_constant.unwrap();
let size = reflector
.type_description(push_constant.base_type_id)
.unwrap().size_hint.declared();
println!("Push constant (size {size}): {}", push_constant.name.unwrap_or_default());
}Implementations§
Source§impl<'a> Reflector<'a>
impl<'a> Reflector<'a>
Sourcepub fn new(module: Module<'a>) -> ReflectResult<Reflector<'a>>
pub fn new(module: Module<'a>) -> ReflectResult<Reflector<'a>>
Creates a reflector from a module.
Automatically calls parse_full.
Sourcepub fn variables(&self) -> impl Iterator<Item = ReflectResult<Variable>>
pub fn variables(&self) -> impl Iterator<Item = ReflectResult<Variable>>
Returns an iterator over all variables.
Sourcepub fn set_entry_point(
&mut self,
name: &CStr,
execution_model: ExecutionModel,
) -> ReflectResult<()>
pub fn set_entry_point( &mut self, name: &CStr, execution_model: ExecutionModel, ) -> ReflectResult<()>
Sets the entry point to reflect.
This must be set before reflecting any resources.
Sourcepub fn spec_constants(
&self,
) -> impl Iterator<Item = ReflectResult<SpecConstant>>
pub fn spec_constants( &self, ) -> impl Iterator<Item = ReflectResult<SpecConstant>>
Returns an iterator over the statically known values and constant ids of all specialization constants.
Sourcepub fn constant(&self, id: Id) -> ReflectResult<Constant<'a>>
pub fn constant(&self, id: Id) -> ReflectResult<Constant<'a>>
Gets a specific constant with id.
Sourcepub fn name(
&self,
id: Id,
struct_member: Option<u32>,
) -> ReflectResult<Option<CompilerStr<'a>>>
pub fn name( &self, id: Id, struct_member: Option<u32>, ) -> ReflectResult<Option<CompilerStr<'a>>>
Returns a name assigned to an Id, or optionally to a struct member of a struct.
Sourcepub fn resources_for_type(
&self,
ty: ResourceType,
) -> ReflectResult<impl Iterator<Item = ReflectResult<Resource<'a>>>>
pub fn resources_for_type( &self, ty: ResourceType, ) -> ReflectResult<impl Iterator<Item = ReflectResult<Resource<'a>>>>
Sourcepub fn decorations(&self, target_id: Id) -> impl Iterator<Item = Decorate<'a>>
pub fn decorations(&self, target_id: Id) -> impl Iterator<Item = Decorate<'a>>
Returns all decorations added to a given Id.
Sourcepub fn type_description(&self, id: Id) -> ReflectResult<Type<'a>>
pub fn type_description(&self, id: Id) -> ReflectResult<Type<'a>>
Gets a type description of a given Id pointing to a type.
The description notably contains a hint of its size, which can be resolved to a
known size when needed.
Auto Trait Implementations§
impl<'a> Freeze for Reflector<'a>
impl<'a> RefUnwindSafe for Reflector<'a>
impl<'a> Send for Reflector<'a>
impl<'a> Sync for Reflector<'a>
impl<'a> Unpin for Reflector<'a>
impl<'a> UnsafeUnpin for Reflector<'a>
impl<'a> UnwindSafe for Reflector<'a>
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