bevyengine/bevy · error
Enable feature "shader_format_spirv" to use SPIR-V shaders
Error message
Enable feature "shader_format_spirv" to use SPIR-V shaders
What it means
load_module, the shader-module construction step of PipelineCache, hits unimplemented!() when a queued pipeline's shader source is ShaderCacheSource::SpirV(data) but the cargo feature 'shader_format_spirv' is not enabled on bevy_render. Bevy makes naga's SPIR-V frontend optional, so SPIR-V ingestion simply does not exist without the feature.
Solutions
- Enable the feature: bevy = { features = ["shader_format_spirv"] } (or add the feature to your bevy_render dependency)
- Prefer WGSL: convert the shader with naga-cli (naga --input shader.spv --output shader.wgsl) and use the WGSL source instead
- If the SPIR-V is generated at build time, switch the generator to emit WGSL
Example fix
# before
bevy = { version = "..." } # SPIR-V shaders panic at pipeline creation
# after
bevy = { version = "...", features = ["shader_format_spirv"] } Defensive patterns
Strategy: validation
Validate before calling
// Cargo.toml check before using SPIR-V shaders:
// [dependencies] bevy = { features = ["shader_format_spirv"] }
// At runtime, guard the shader source:
enum SafeShaderSource<'a> { Wgsl(&'a str), SpirvDisabled }
fn classify(bytes: &'a [u8]) -> SafeShaderSource<'a> {
if cfg!(feature = "shader_format_spirv") { /* ... */ }
SafeShaderSource::Wgsl("/* fallback */")
} Type guard
fn accepts_spirv() -> bool {
cfg!(feature = "shader_format_spirv")
} Prevention
- Add the shader_format_spirv feature to Cargo.toml the moment you introduce .spv assets
- Prefer WGSL for new shaders so no optional feature is required
- Document required cargo features next to SPIR-V asset paths in your project README
When it happens
Trigger: Creating a shader from SPIR-V bytes (e.g. Shader::from_spirv or a custom asset loader producing ShaderCacheSource::SpirV) and then queueing a render/compute pipeline with it, while the default (non-spirv) feature set is in use.
Common situations: Porting an old project that used .spv shaders; using a third-party crate that hands SPIR-V to Bevy; trimming Bevy's default features for compile time and forgetting SPIR-V is now opt-in.
Related errors
- spirv not yet implemented
- no safety checks are performed for spirv shaders. use…
- unhandled extension
- An elapsed time getter has not been provided to `Instant`…
- array layout should be valid
AI-assisted analysis of bevyengine/bevy@8d743eb7dc (2026-08-20).
Data as JSON: /api/errors/831aa099e69b7398.
Report an issue: GitHub.
Appendix: source
Thrown at crates/bevy_render/src/render_resource/pipeline_cache.rs:136
.map(BindGroupLayout::value)
.map(Some)
.collect::<SmallVec<[_; BIND_GROUP_LAYOUTS_INLINE_CAPACITY]>>();
Arc::new(WgpuPipelineLayout::new(
render_device.create_pipeline_layout(&PipelineLayoutDescriptor {
bind_group_layouts: &bind_group_layouts,
immediate_size: *immediate_size,
..default()
}),
))
})
.clone()
}
}
fn load_module(
render_device: &RenderDevice,
shader_source: ShaderCacheSource,
validate_shader: &ValidateShader,
) -> Result<WgpuShaderModule, ShaderCacheError> {
let shader_source = match shader_source {
#[cfg(feature = "shader_format_spirv")]
ShaderCacheSource::SpirV(data) => wgpu::util::make_spirv(data),
#[cfg(not(feature = "shader_format_spirv"))]
ShaderCacheSource::SpirV(_) => {
unimplemented!("Enable feature \"shader_format_spirv\" to use SPIR-V shaders")
}
ShaderCacheSource::Wgsl(src) => ShaderSource::Wgsl(Cow::Owned(src)),
};
let module_descriptor = ShaderModuleDescriptor {
label: None,
source: shader_source,
};
let scope = render_device
.wgpu_device()
.push_error_scope(wgpu::ErrorFilter::Validation);View on GitHub (pinned to 8d743eb7dc)