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 with_allocator(self, allocator: Allocator) -> Scope
pub fn with_allocator(self, allocator: Allocator) -> Scope
Shift variable ids.
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_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,
processors: impl IntoIterator<Item = Box<dyn Processor>>,
) -> ScopeProcessing
pub fn process( &mut self, processors: impl IntoIterator<Item = Box<dyn Processor>>, ) -> 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.
pub fn add_local_array(&mut self, var: Variable)
pub fn update_source(&mut self, source: CubeFnSource)
pub fn update_span(&mut self, line: u32, col: u32)
pub fn update_variable_name( &self, variable: Variable, name: impl Into<Cow<'static, str>>, )
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Scope
impl<'de> Deserialize<'de> for Scope
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Scope, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Scope, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Scope
impl Serialize for Scope
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for Scope
impl StructuralPartialEq for Scope
Auto Trait Implementations§
impl Freeze for Scope
impl !RefUnwindSafe for Scope
impl !Send for Scope
impl !Sync for Scope
impl Unpin for Scope
impl !UnwindSafe for Scope
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.