Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Errors

SourceError

Raised by wgsl_rs::Source methods.

VariantWhen
TemplateWgslwgsl_source() is called on a Source that is still a template (has unresolved TypeParam nodes). Call instantiate(...) first to produce concrete WGSL.

Recovery

#![allow(unused)]
fn main() {
match source.wgsl_source() {
    Ok(wgsl) => { /* write or compile */ }
    Err(SourceError::TemplateWgsl) => {
        let concrete = source.instantiate(&[concrete_type])?;
        let wgsl = concrete.wgsl_source()?;
    }
}
}

linkage::wgpu::Error

Raised by the linkage-wgpu feature when reflecting bind groups and pipeline layouts.

VariantWhen
TemplateResolutionA linkage query was made against a template that has not been instantiated with concrete types.
NoSuchBindGroupThe queried bind group index does not exist in the module.
NoSuchBindingThe queried binding within a bind group does not exist.
TypeMismatchA binding's type does not match the expected wgpu binding type.

Recovery

#![allow(unused)]
fn main() {
match source.linkage().bind_group(0) {
    Ok(group) => { /* build BindGroupLayout */ }
    Err(linkage::wgpu::Error::NoSuchBindGroup) => {
        // bind group 0 not declared in this shader
    }
    Err(linkage::wgpu::Error::TemplateResolution) => {
        let concrete = source.instantiate(&[concrete_type])?;
        let group = concrete.linkage().bind_group(0)?;
    }
}
}

General Pattern

Template errors are recoverable by instantiating with concrete types (see Template Modules & Instantiation and Template Linkage). Bind group / binding errors indicate a mismatch between the host-side layout code and the shader declaration — inspect ir::Module items (Uniform, Storage, Sampler, Texture) to reconcile.