Struct Scope

Source
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

Source

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.

Source

pub fn create_matrix(&mut self, matrix: Matrix) -> ExpandElement

Create a new matrix element.

Source

pub fn add_matrix(&mut self, variable: Variable)

Source

pub fn create_pipeline(&mut self, item: Item, num_stages: u8) -> ExpandElement

Create a new pipeline element.

Source

pub fn create_barrier( &mut self, item: Item, level: BarrierLevel, ) -> ExpandElement

Create a new barrier element.

Source

pub fn add_pipeline(&mut self, variable: Variable)

Source

pub fn add_barrier(&mut self, variable: Variable)

Source

pub fn create_slice(&mut self, item: Item) -> ExpandElement

Create a new slice element.

Source

pub fn add_slice(&mut self, slice: Variable)

Source

pub fn create_local_mut<I>(&mut self, item: I) -> ExpandElement
where I: Into<Item>,

Create a mutable variable of the given item type.

Source

pub fn add_local_mut(&mut self, var: Variable)

Create a mutable variable of the given item type.

Source

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.

Source

pub fn create_local(&mut self, item: Item) -> ExpandElement

Create a new immutable variable.

Source

pub fn last_local_index(&self) -> Option<&Variable>

Retrieve the last local variable that was created.

Source

pub fn register<T>(&mut self, instruction: T)
where T: Into<Instruction>,

Register an operation into the scope.

Source

pub fn resolve_elem<T>(&self) -> Option<Elem>
where T: 'static,

Resolve the element type of the given generic type.

Source

pub fn register_elem<T>(&mut self, elem: Elem)
where T: 'static,

Register the element type for the given generic type.

Source

pub fn child(&mut self) -> Scope

Create an empty child scope.

Source

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.

Source

pub fn new_local_index(&self) -> u32

Source

pub fn create_shared<I>( &mut self, item: I, shared_memory_size: u32, alignment: Option<u32>, ) -> ExpandElement
where I: Into<Item>,

Create a shared variable of the given item type.

Source

pub fn create_const_array<I>( &mut self, item: I, data: Vec<Variable>, ) -> ExpandElement
where I: Into<Item>,

Create a shared variable of the given item type.

Source

pub fn input(&mut self, id: u32, item: Item) -> ExpandElement

Obtain the index-th input

Source

pub fn output(&mut self, id: u32, item: Item) -> ExpandElement

Obtain the index-th output

Source

pub fn scalar(&self, id: u32, elem: Elem) -> ExpandElement

Obtain the index-th scalar

Source

pub fn create_local_array<I>( &mut self, item: I, array_size: u32, ) -> ExpandElement
where I: Into<Item>,

Create a local array of the given item type.

Source

pub fn add_local_array(&mut self, var: Variable)

Source

pub fn update_source(&mut self, source: CubeFnSource)

Source

pub fn update_span(&mut self, line: u32, col: u32)

Source

pub fn update_variable_name( &self, variable: Variable, name: impl Into<Cow<'static, str>>, )

Trait Implementations§

Source§

impl Clone for Scope

Source§

fn clone(&self) -> Scope

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Scope

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Scope

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Scope, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Hash for Scope

Source§

fn hash<H>(&self, ra_expand_state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Scope

Source§

fn eq(&self, other: &Scope) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Scope

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TypeHash for Scope

Source§

fn write_hash(hasher: &mut impl Hasher)

Write the structure of the type to the hasher
Source§

fn type_hash() -> u64

Generate a stable hash of the type structure. Read more
Source§

impl Eq for Scope

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> CacheKey for T

Source§

impl<T> CacheValue for T

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,