naga::proc

Struct GlobalCtx

Source
pub struct GlobalCtx<'a> {
    pub types: &'a UniqueArena<Type>,
    pub constants: &'a Arena<Constant>,
    pub overrides: &'a Arena<Override>,
    pub global_expressions: &'a Arena<Expression>,
}

Fields§

§types: &'a UniqueArena<Type>§constants: &'a Arena<Constant>§overrides: &'a Arena<Override>§global_expressions: &'a Arena<Expression>

Implementations§

Source§

impl GlobalCtx<'_>

Source

pub(crate) fn eval_expr_to_u32( &self, handle: Handle<Expression>, ) -> Result<u32, U32EvalError>

Try to evaluate the expression in self.global_expressions using its handle and return it as a u32.

Source

pub(crate) fn eval_expr_to_u32_from( &self, handle: Handle<Expression>, arena: &Arena<Expression>, ) -> Result<u32, U32EvalError>

Try to evaluate the expression in the arena using its handle and return it as a u32.

Source

pub(crate) fn eval_expr_to_bool_from( &self, handle: Handle<Expression>, arena: &Arena<Expression>, ) -> Option<bool>

Try to evaluate the expression in the arena using its handle and return it as a bool.

Source

pub(crate) fn eval_expr_to_literal( &self, handle: Handle<Expression>, ) -> Option<Literal>

Source

pub(crate) fn eval_expr_to_literal_from( &self, handle: Handle<Expression>, arena: &Arena<Expression>, ) -> Option<Literal>

Trait Implementations§

Source§

impl<'a> Clone for GlobalCtx<'a>

Source§

fn clone(&self) -> GlobalCtx<'a>

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 TypeContext for GlobalCtx<'_>

Format types as WGSL based on a GlobalCtx.

This is probably good enough for diagnostic output, but it has some limitations:

  • It does not apply Namer renamings, to avoid collisions.

  • It generates invalid WGSL for anonymous struct types.

  • It doesn’t write the lengths of override-expression-sized arrays correctly, unless the expression is just the override identifier.

Source§

fn lookup_type(&self, handle: Handle<Type>) -> &Type

Return the Type referred to by handle.
Source§

fn type_name(&self, handle: Handle<Type>) -> &str

Return the name to be used for the type referred to by handle.
Source§

fn write_override<W: Write>( &self, handle: Handle<Override>, out: &mut W, ) -> Result

Write the WGSL form of override to out.
Source§

fn write_non_wgsl_inner<W: Write>( &self, inner: &TypeInner, out: &mut W, ) -> Result

Write a TypeInner that has no representation as WGSL source, even including Naga extensions. Read more
Source§

fn write_non_wgsl_scalar<W: Write>(&self, scalar: Scalar, out: &mut W) -> Result

Write a Scalar that has no representation as WGSL source, even including Naga extensions. Read more
Source§

fn write_type<W: Write>(&self, handle: Handle<Type>, out: &mut W) -> Result

Write the type ty as it would appear in a value’s declaration. Read more
Source§

fn write_type_inner<W: Write>(&self, inner: &TypeInner, out: &mut W) -> Result

Write the TypeInner inner as it would appear in a value’s declaration. Read more
Source§

fn write_scalar<W: Write>(&self, scalar: Scalar, out: &mut W) -> Result

Write the Scalar scalar as a WGSL type.
Source§

fn write_type_resolution<W: Write>( &self, resolution: &TypeResolution, out: &mut W, ) -> Result

Write the TypeResolution resolution as a WGSL type.
Source§

fn write_type_conclusion<W: Write>( &self, conclusion: &Conclusion, out: &mut W, ) -> Result

Source§

fn write_type_rule<W: Write>( &self, name: &str, rule: &Rule, out: &mut W, ) -> Result

Source§

fn type_to_string(&self, handle: Handle<Type>) -> String

Source§

fn type_inner_to_string(&self, inner: &TypeInner) -> String

Source§

fn type_resolution_to_string(&self, resolution: &TypeResolution) -> String

Source§

fn type_rule_to_string(&self, name: &str, rule: &Rule) -> String

Source§

impl<'a> Copy for GlobalCtx<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for GlobalCtx<'a>

§

impl<'a> RefUnwindSafe for GlobalCtx<'a>

§

impl<'a> Send for GlobalCtx<'a>

§

impl<'a> Sync for GlobalCtx<'a>

§

impl<'a> Unpin for GlobalCtx<'a>

§

impl<'a> UnwindSafe for GlobalCtx<'a>

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.