Enum wgpu::ShaderSource

source ·
#[non_exhaustive]
pub enum ShaderSource<'a> {
    SpirV(Cow<'a, [u32]>),
    Glsl {
        shader: Cow<'a, str>,
        stage: ShaderStage,
        defines: FastHashMap<String, String>,
    },
    Wgsl(Cow<'a, str>),
    Naga(Cow<'static, Module>),
    // some variants omitted
}
Expand description

Source of a shader module.

The source will be parsed and validated.

Any necessary shader translation (e.g. from WGSL to SPIR-V or vice versa) will be done internally by wgpu.

This type is unique to the Rust API of wgpu. In the WebGPU specification, only WGSL source code strings are accepted.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

SpirV(Cow<'a, [u32]>)

Available on crate feature spirv only.

SPIR-V module represented as a slice of words.

See also: util::make_spirv, include_spirv

§

Glsl

Fields

§shader: Cow<'a, str>

The source code of the shader.

§stage: ShaderStage

The shader stage that the shader targets. For example, naga::ShaderStage::Vertex

§defines: FastHashMap<String, String>

Defines to unlock configured shader features.

Available on crate feature glsl only.

GLSL module as a string slice.

Note: GLSL is not yet fully supported and must be a specific ShaderStage.

§

Wgsl(Cow<'a, str>)

Available on crate feature wgsl only.

WGSL module as a string slice.

§

Naga(Cow<'static, Module>)

Available on crate feature naga only.

Naga module.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.