Skip to content

Commit

Permalink
Improve shader source documentation (#2315)
Browse files Browse the repository at this point in the history
- remove outdated note about WGSL web support
- try to combine the note about parsing/validation/translation
  • Loading branch information
grovesNL authored Dec 24, 2021
1 parent 890f326 commit 97e6ea7
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,35 +753,29 @@ impl Drop for ShaderModule {
}

/// 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.
#[non_exhaustive]
pub enum ShaderSource<'a> {
/// SPIR-V module represented as a slice of words.
///
/// wgpu will attempt to parse and validate it, but the original binary
/// is passed to `gfx-rs` and `spirv_cross` for translation.
#[cfg(feature = "spirv")]
SpirV(Cow<'a, [u32]>),
/// GLSL module as a string slice.
///
/// wgpu will attempt to parse and validate it. The module will get
/// passed to wgpu-core where it will translate it to the required languages.
///
/// Note: GLSL is not yet fully supported and must be a direct ShaderStage.
/// Note: GLSL is not yet fully supported and must be a specific ShaderStage.
#[cfg(feature = "glsl")]
Glsl {
/// The shaders code
/// The source code of the shader.
shader: Cow<'a, str>,
/// Stage in which the GLSL shader is for example: naga::ShaderStage::Vertex
/// The shader stage that the shader targets. For example, `naga::ShaderStage::Vertex`
stage: naga::ShaderStage,
/// Defines to unlock configured shader features
/// Defines to unlock configured shader features.
defines: naga::FastHashMap<String, String>,
},
/// WGSL module as a string slice.
///
/// wgpu-rs will parse it and use for validation. It will attempt
/// to build a SPIR-V module internally and panic otherwise.
///
/// Note: WGSL is not yet supported on the Web.
Wgsl(Cow<'a, str>),
}

Expand Down

0 comments on commit 97e6ea7

Please sign in to comment.