pub struct Scope {
pub depth: u8,
pub instructions: Vec<Instruction>,
pub locals: Vec<Variable>,
pub const_arrays: Vec<(Variable, Vec<Variable>)>,
pub allocator: Allocator,
pub debug: DebugInfo,
pub typemap: Rc<RefCell<HashMap<TypeId, Elem>>>,
/* private fields */
}
Expand description
The scope is the main operation and variable container that simplify the process of reading inputs, creating local variables and adding new operations.
Notes:
This type isn’t responsible for creating shader bindings and figuring out which variable can be written to.
Fields§
§depth: u8
§instructions: Vec<Instruction>
§locals: Vec<Variable>
§const_arrays: Vec<(Variable, Vec<Variable>)>
§allocator: Allocator
§debug: DebugInfo
§typemap: Rc<RefCell<HashMap<TypeId, Elem>>>
Implementations§
Source§impl Scope
impl Scope
Sourcepub fn root(debug_enabled: bool) -> Scope
pub fn root(debug_enabled: bool) -> Scope
Create a scope that is at the root of a kernel definition.
A local scope can be created with the child method.
Sourcepub fn create_matrix(&mut self, matrix: Matrix) -> ExpandElement
pub fn create_matrix(&mut self, matrix: Matrix) -> ExpandElement
Create a new matrix element.
pub fn add_matrix(&mut self, variable: Variable)
Sourcepub fn create_pipeline(&mut self, item: Item, num_stages: u8) -> ExpandElement
pub fn create_pipeline(&mut self, item: Item, num_stages: u8) -> ExpandElement
Create a new pipeline element.
Sourcepub fn create_barrier(
&mut self,
item: Item,
level: BarrierLevel,
) -> ExpandElement
pub fn create_barrier( &mut self, item: Item, level: BarrierLevel, ) -> ExpandElement
Create a new barrier element.
pub fn add_pipeline(&mut self, variable: Variable)
pub fn add_barrier(&mut self, variable: Variable)
Sourcepub fn create_slice(&mut self, item: Item) -> ExpandElement
pub fn create_slice(&mut self, item: Item) -> ExpandElement
Create a new slice element.
pub fn add_slice(&mut self, slice: Variable)
Sourcepub fn create_local_mut<I>(&mut self, item: I) -> ExpandElement
pub fn create_local_mut<I>(&mut self, item: I) -> ExpandElement
Create a mutable variable of the given item type.
Sourcepub fn add_local_mut(&mut self, var: Variable)
pub fn add_local_mut(&mut self, var: Variable)
Create a mutable variable of the given item type.
Sourcepub fn create_local_restricted(&mut self, item: Item) -> ExpandElement
pub fn create_local_restricted(&mut self, item: Item) -> ExpandElement
Create a new restricted variable. The variable is Useful for for loops and other algorithms that require the control over initialization.
Sourcepub fn create_local(&mut self, item: Item) -> ExpandElement
pub fn create_local(&mut self, item: Item) -> ExpandElement
Create a new immutable variable.
Sourcepub fn last_local_index(&self) -> Option<&Variable>
pub fn last_local_index(&self) -> Option<&Variable>
Retrieve the last local variable that was created.
Sourcepub fn register<T>(&mut self, instruction: T)where
T: Into<Instruction>,
pub fn register<T>(&mut self, instruction: T)where
T: Into<Instruction>,
Register an operation into the scope.
Sourcepub fn resolve_elem<T>(&self) -> Option<Elem>where
T: 'static,
pub fn resolve_elem<T>(&self) -> Option<Elem>where
T: 'static,
Resolve the element type of the given generic type.
Sourcepub fn register_elem<T>(&mut self, elem: Elem)where
T: 'static,
pub fn register_elem<T>(&mut self, elem: Elem)where
T: 'static,
Register the element type for the given generic type.
Sourcepub fn process(&mut self) -> ScopeProcessing
pub fn process(&mut self) -> ScopeProcessing
Returns the variables and operations to be declared and executed.
Notes:
New operations and variables can be created within the same scope without having name conflicts.
pub fn new_local_index(&self) -> u32
Create a shared variable of the given item type.
Sourcepub fn create_const_array<I>(
&mut self,
item: I,
data: Vec<Variable>,
) -> ExpandElement
pub fn create_const_array<I>( &mut self, item: I, data: Vec<Variable>, ) -> ExpandElement
Create a shared variable of the given item type.
Sourcepub fn input(&mut self, id: u32, item: Item) -> ExpandElement
pub fn input(&mut self, id: u32, item: Item) -> ExpandElement
Obtain the index-th input
Sourcepub fn output(&mut self, id: u32, item: Item) -> ExpandElement
pub fn output(&mut self, id: u32, item: Item) -> ExpandElement
Obtain the index-th output
Sourcepub fn scalar(&self, id: u32, elem: Elem) -> ExpandElement
pub fn scalar(&self, id: u32, elem: Elem) -> ExpandElement
Obtain the index-th scalar
Sourcepub fn create_local_array<I>(
&mut self,
item: I,
array_size: u32,
) -> ExpandElement
pub fn create_local_array<I>( &mut self, item: I, array_size: u32, ) -> ExpandElement
Create a local array of the given item type.