naga

Struct Module

Source
pub struct Module {
    pub types: UniqueArena<Type>,
    pub special_types: SpecialTypes,
    pub constants: Arena<Constant>,
    pub overrides: Arena<Override>,
    pub global_variables: Arena<GlobalVariable>,
    pub global_expressions: Arena<Expression>,
    pub functions: Arena<Function>,
    pub entry_points: Vec<EntryPoint>,
}
Expand description

Shader module.

A module is a set of constants, global variables and functions, as well as the types required to define them.

Some functions are marked as entry points, to be used in a certain shader stage.

To create a new module, use the Default implementation. Alternatively, you can load an existing shader using one of the available front ends.

When finished, you can export modules using one of the available backends.

Fields§

§types: UniqueArena<Type>

Arena for the types defined in this module.

§special_types: SpecialTypes

Dictionary of special type handles.

§constants: Arena<Constant>

Arena for the constants defined in this module.

§overrides: Arena<Override>

Arena for the pipeline-overridable constants defined in this module.

§global_variables: Arena<GlobalVariable>

Arena for the global variables defined in this module.

§global_expressions: Arena<Expression>

Constant expressions and override expressions used by this module.

Each Expression must occur in the arena before any Expression that uses its value.

§functions: Arena<Function>

Arena for the functions defined in this module.

Each function must appear in this arena strictly before all its callers. Recursion is not supported.

§entry_points: Vec<EntryPoint>

Entry points.

Implementations§

Source§

impl Module

Source

pub fn generate_ray_desc_type(&mut self) -> Handle<Type>

Populate this module’s SpecialTypes::ray_desc type.

SpecialTypes::ray_desc is the type of the descriptor operand of an Initialize RayQuery statement. In WGSL, it is a struct type referred to as RayDesc.

Backends consume values of this type to drive platform APIs, so if you change any its fields, you must update the backends to match. Look for backend code dealing with RayQueryFunction::Initialize.

Source

pub fn generate_ray_intersection_type(&mut self) -> Handle<Type>

Populate this module’s SpecialTypes::ray_intersection type.

SpecialTypes::ray_intersection is the type of a RayQueryGetIntersection expression. In WGSL, it is a struct type referred to as RayIntersection.

Backends construct values of this type based on platform APIs, so if you change any its fields, you must update the backends to match. Look for the backend’s handling for Expression::RayQueryGetIntersection.

Source

pub fn generate_predeclared_type( &mut self, special_type: PredeclaredType, ) -> Handle<Type>

Populate this module’s SpecialTypes::predeclared_types type and return the handle.

Source§

impl Module

Source

pub const fn to_ctx(&self) -> GlobalCtx<'_>

Trait Implementations§

Source§

impl Clone for Module

Source§

fn clone(&self) -> Module

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 Module

Source§

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

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

impl Default for Module

Source§

fn default() -> Module

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Module

§

impl RefUnwindSafe for Module

§

impl Send for Module

§

impl Sync for Module

§

impl Unpin for Module

§

impl UnwindSafe for Module

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 T)

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