#[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.
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
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.
Fields
§
stage: ShaderStage
The shader stage that the shader targets. For example, naga::ShaderStage::Vertex
§
defines: FastHashMap<String, String>
Defines to unlock configured shader features.
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-ir
only.Naga module.
Trait Implementations§
Source§impl<'a> Clone for ShaderSource<'a>
impl<'a> Clone for ShaderSource<'a>
Source§fn clone(&self) -> ShaderSource<'a>
fn clone(&self) -> ShaderSource<'a>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<'a> Freeze for ShaderSource<'a>
impl<'a> RefUnwindSafe for ShaderSource<'a>
impl<'a> Send for ShaderSource<'a>
impl<'a> Sync for ShaderSource<'a>
impl<'a> Unpin for ShaderSource<'a>
impl<'a> UnwindSafe for ShaderSource<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more