Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve shader source documentation #2315

Merged
merged 1 commit into from
Dec 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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