pub struct Scope {
pub depth: u8,
pub operations: Vec<Operation>,
pub locals: Vec<Variable>,
pub const_arrays: Vec<(Variable, Vec<Variable>)>,
pub layout_ref: Option<Variable>,
pub undeclared: u16,
/* 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
§operations: Vec<Operation>
§locals: Vec<Variable>
§const_arrays: Vec<(Variable, Vec<Variable>)>
§layout_ref: Option<Variable>
§undeclared: u16
Implementations§
Source§impl Scope
impl Scope
Sourcepub fn root() -> Self
pub fn root() -> Self
Create a scope that is at the root of a kernel definition.
A local scope can be created with the child method.
Sourcepub fn zero<I: Into<Item>>(&mut self, item: I) -> Variable
pub fn zero<I: Into<Item>>(&mut self, item: I) -> Variable
Create a variable initialized at zero.
Sourcepub fn create_with_value<E, I>(&mut self, value: E, item: I) -> Variable
pub fn create_with_value<E, I>(&mut self, value: E, item: I) -> Variable
Create a variable initialized at some value.
Sourcepub fn create_matrix(&mut self, matrix: Matrix) -> Variable
pub fn create_matrix(&mut self, matrix: Matrix) -> Variable
Create a matrix variable
Sourcepub fn create_slice(&mut self, item: Item) -> Variable
pub fn create_slice(&mut self, item: Item) -> Variable
Create a slice variable
Sourcepub fn create_local<I: Into<Item>>(&mut self, item: I) -> Variable
pub fn create_local<I: Into<Item>>(&mut self, item: I) -> Variable
Create a local variable of the given item type.
Sourcepub fn create_local_undeclared(&mut self, item: Item) -> Variable
pub fn create_local_undeclared(&mut self, item: Item) -> Variable
Create a new undeclared local, but doesn’t perform the declaration.
Useful for for loops and other algorithms that require the control over initialization.
Sourcepub fn create_local_binding(&mut self, item: Item) -> Variable
pub fn create_local_binding(&mut self, item: Item) -> Variable
Create a new undeclared local binding, but doesn’t perform the declaration.
Useful for temporaries and other algorithms that require the control over initialization.
Sourcepub fn read_array<I: Into<Item>>(
&mut self,
index: u16,
item: I,
position: Variable,
) -> Variable
pub fn read_array<I: Into<Item>>( &mut self, index: u16, item: I, position: Variable, ) -> Variable
Reads an input array to a local variable.
The index refers to the argument position of the array in the compute shader.
Sourcepub fn read_scalar(&mut self, index: u16, elem: Elem) -> Variable
pub fn read_scalar(&mut self, index: u16, elem: Elem) -> Variable
Reads an input scalar to a local variable.
The index refers to the scalar position for the same element type.
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 write_global(
&mut self,
input: Variable,
output: Variable,
position: Variable,
)
pub fn write_global( &mut self, input: Variable, output: Variable, position: Variable, )
Writes a variable to given output.
Notes:
This should only be used when doing compilation.
Sourcepub fn write_global_custom(&mut self, output: Variable)
pub fn write_global_custom(&mut self, output: Variable)
Writes a variable to given output.
Notes:
This should only be used when doing compilation.
pub fn read_globals(&self) -> Vec<(u16, ReadingStrategy)>
Sourcepub fn register<T: Into<Operation>>(&mut self, operation: T)
pub fn register<T: Into<Operation>>(&mut self, operation: T)
Register an operation into the scope.
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) -> u16
Create a shared variable of the given item type.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Scope
impl<'de> Deserialize<'de> for Scope
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)