logo
#[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>),
}
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.

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

WGSL module as a string slice.

Naga(Cow<'static, Module>)

Available on crate feature naga only.

Naga module.

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