Skip to main content

Module shader

Module shader 

Source
Expand description

The WGSL shader module registry: ShaderLibrary and ShaderId.

Every shader the engine ever draws with is compiled into a wgpu::ShaderModule once, at library-build time, and referred to afterwards by an opaque ShaderId. That indirection is what lets crate::pipeline::RenderPipelineDesc stay a cheap, hashable value: a pipeline variant names its program by id instead of carrying a module handle or a source string around.

The library is append-only and keyed by name, so building it is a start-up-time act (insert_wgsl per shader) and everything after it is a lookup. Once built it is wrapped in an Arc and shared — a wgpu::ShaderModule is Send + Sync, so the pipeline warm-up worker compiles against exactly the same modules the render thread does, with no second compile of the source.

Every module is created with a label (frust-gpu shader: <name>) so a capture in RenderDoc/Xcode names the shader rather than showing an anonymous module.

Structs§

ShaderId
An opaque handle to a WGSL module held by one ShaderLibrary.
ShaderLibrary
A name-keyed, append-only set of compiled WGSL modules.