Struct naga::front::wgsl::lower::Lowerer

source ·
pub struct Lowerer<'source, 'temp> {
    index: &'temp Index<'source>,
    layouter: Layouter,
}

Fields§

§index: &'temp Index<'source>§layouter: Layouter

Implementations§

source§

impl<'source> Lowerer<'source, '_>

source

pub fn construct( &mut self, span: Span, constructor: &ConstructorType<'source>, ty_span: Span, components: &[Handle<Expression<'source>>], ctx: &mut ExpressionContext<'source, '_, '_>, ) -> Result<Handle<Expression>, Error<'source>>

Generate Naga IR for a type constructor expression.

The constructor value represents the head of the constructor expression, which is at least a hint of which type is being built; if it’s one of the Partial variants, we need to consider the argument types as well.

This is used for Construct expressions, but also for Call expressions, once we’ve determined that the “callable” (in WGSL spec terms) is actually a type.

source

fn constructor<'out>( &mut self, constructor: &ConstructorType<'source>, ctx: &mut ExpressionContext<'source, '_, 'out>, ) -> Result<Constructor<Handle<Type>>, Error<'source>>

Build a Constructor for a WGSL construction expression.

If constructor conveys enough information to determine which Naga Type we’re actually building (i.e., it’s not a partial constructor), then ensure the Type exists in ctx.module, and return Constructor::Type.

Otherwise, return the Constructor partial variant corresponding to constructor.

source§

impl<'source, 'temp> Lowerer<'source, 'temp>

source

pub fn new(index: &'temp Index<'source>) -> Self

source

pub fn lower( &mut self, tu: &'temp TranslationUnit<'source>, ) -> Result<Module, Error<'source>>

source

fn function( &mut self, f: &Function<'source>, span: Span, ctx: &mut GlobalContext<'source, '_, '_>, ) -> Result<LoweredGlobalDecl, Error<'source>>

source

fn workgroup_size_override( &mut self, size_expr: Handle<Expression<'source>>, ctx: &mut ExpressionContext<'source, '_, '_>, ) -> Result<Handle<Expression>, Error<'source>>

source

fn block( &mut self, b: &Block<'source>, is_inside_loop: bool, ctx: &mut StatementContext<'source, '_, '_>, ) -> Result<Block, Error<'source>>

source

fn statement( &mut self, stmt: &Statement<'source>, block: &mut Block, is_inside_loop: bool, ctx: &mut StatementContext<'source, '_, '_>, ) -> Result<(), Error<'source>>

source

fn expression( &mut self, expr: Handle<Expression<'source>>, ctx: &mut ExpressionContext<'source, '_, '_>, ) -> Result<Handle<Expression>, Error<'source>>

Lower expr and apply the Load Rule if possible.

For the time being, this concretizes abstract values, to support consumers that haven’t been adapted to consume them yet. Consumers prepared for abstract values can call expression_for_abstract.

source

fn expression_for_abstract( &mut self, expr: Handle<Expression<'source>>, ctx: &mut ExpressionContext<'source, '_, '_>, ) -> Result<Handle<Expression>, Error<'source>>

source

fn expression_for_reference( &mut self, expr: Handle<Expression<'source>>, ctx: &mut ExpressionContext<'source, '_, '_>, ) -> Result<Typed<Handle<Expression>>, Error<'source>>

source

fn binary( &mut self, op: BinaryOperator, left: Handle<Expression<'source>>, right: Handle<Expression<'source>>, span: Span, ctx: &mut ExpressionContext<'source, '_, '_>, ) -> Result<Typed<Expression>, Error<'source>>

source

fn call( &mut self, span: Span, function: &Ident<'source>, arguments: &[Handle<Expression<'source>>], ctx: &mut ExpressionContext<'source, '_, '_>, is_statement: bool, ) -> Result<Option<Handle<Expression>>, Error<'source>>

Generate Naga IR for call expressions and statements, and type constructor expressions.

The “function” being called is simply an Ident that we know refers to some module-scope definition.

  • If it is the name of a type, then the expression is a type constructor expression: either constructing a value from components, a conversion expression, or a zero value expression.

  • If it is the name of a function, then we’re generating a Call statement. We may be in the midst of generating code for an expression, in which case we must generate an Emit statement to force evaluation of the IR expressions we’ve generated so far, add the Call statement to the current block, and then resume generating expressions.

source

fn atomic_pointer( &mut self, expr: Handle<Expression<'source>>, ctx: &mut ExpressionContext<'source, '_, '_>, ) -> Result<Handle<Expression>, Error<'source>>

source

fn atomic_helper( &mut self, span: Span, fun: AtomicFunction, args: &[Handle<Expression<'source>>], is_statement: bool, ctx: &mut ExpressionContext<'source, '_, '_>, ) -> Result<Option<Handle<Expression>>, Error<'source>>

source

fn texture_sample_helper( &mut self, fun: Texture, args: &[Handle<Expression<'source>>], span: Span, ctx: &mut ExpressionContext<'source, '_, '_>, ) -> Result<Expression, Error<'source>>

source

fn subgroup_operation_helper( &mut self, span: Span, op: SubgroupOperation, collective_op: CollectiveOperation, arguments: &[Handle<Expression<'source>>], ctx: &mut ExpressionContext<'source, '_, '_>, ) -> Result<Handle<Expression>, Error<'source>>

source

fn subgroup_gather_helper( &mut self, span: Span, mode: SubgroupGather, arguments: &[Handle<Expression<'source>>], ctx: &mut ExpressionContext<'source, '_, '_>, ) -> Result<Handle<Expression>, Error<'source>>

source

fn struct( &mut self, s: &Struct<'source>, span: Span, ctx: &mut GlobalContext<'source, '_, '_>, ) -> Result<Handle<Type>, Error<'source>>

source

fn const_u32( &mut self, expr: Handle<Expression<'source>>, ctx: &mut ExpressionContext<'source, '_, '_>, ) -> Result<(u32, Span), Error<'source>>

source

fn array_size( &mut self, size: ArraySize<'source>, ctx: &mut GlobalContext<'source, '_, '_>, ) -> Result<ArraySize, Error<'source>>

source

fn array_size_override( &mut self, size_expr: Handle<Expression<'source>>, ctx: &mut ExpressionContext<'source, '_, '_>, span: Span, ) -> Result<PendingArraySize, Error<'source>>

source

fn resolve_named_ast_type( &mut self, handle: Handle<Type<'source>>, name: Option<String>, ctx: &mut GlobalContext<'source, '_, '_>, ) -> Result<Handle<Type>, Error<'source>>

Build the Naga equivalent of a named AST type.

Return a Naga Handle<Type> representing the front-end type handle, which should be named name, if given.

If handle refers to a type cached in SpecialTypes, name may be ignored.

source

fn resolve_ast_type( &mut self, handle: Handle<Type<'source>>, ctx: &mut GlobalContext<'source, '_, '_>, ) -> Result<Handle<Type>, Error<'source>>

Return a Naga Handle<Type> representing the front-end type handle.

source

fn binding( &mut self, binding: &Option<Binding<'source>>, ty: Handle<Type>, ctx: &mut GlobalContext<'source, '_, '_>, ) -> Result<Option<Binding>, Error<'source>>

source

fn ray_query_pointer( &mut self, expr: Handle<Expression<'source>>, ctx: &mut ExpressionContext<'source, '_, '_>, ) -> Result<Handle<Expression>, Error<'source>>

Auto Trait Implementations§

§

impl<'source, 'temp> Freeze for Lowerer<'source, 'temp>

§

impl<'source, 'temp> RefUnwindSafe for Lowerer<'source, 'temp>

§

impl<'source, 'temp> Send for Lowerer<'source, 'temp>

§

impl<'source, 'temp> Sync for Lowerer<'source, 'temp>

§

impl<'source, 'temp> Unpin for Lowerer<'source, 'temp>

§

impl<'source, 'temp> UnwindSafe for Lowerer<'source, 'temp>

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> 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, 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.