gfx-rs/wgpu · error
Attempted to create a static DXC shader compiler, but the st
Error message
Attempted to create a static DXC shader compiler, but the static-dxc feature was not enabled
What it means
wgpu-hal can link DXC (the modern HLSL compiler) either statically (static-dxc feature, shipping dxc DLLs/objects) or dynamically at runtime. new_static_dxc is only compiled into a working path when the `static_dxc` cfg is active; otherwise it deliberately panics to signal a build-configuration mistake: the caller asked for static DXC but the crate was built without that feature.
Source
Thrown at wgpu-hal/src/dx12/shader_compilation.rs:91
{
unsafe {
let compiler = dxc_create_instance::<Dxc::IDxcCompiler3>(|clsid, iid, ppv| {
windows_core::HRESULT(mach_dxcompiler_rs::DxcCreateInstance(
clsid.cast(),
iid.cast(),
ppv,
))
})?;
Ok(CompilerContainer::StaticDxc(CompilerStaticDxc {
max_shader_model: wgt::DxcShaderModel::V6_7,
compiler,
}))
}
}
#[cfg(not(static_dxc))]
{
panic!("Attempted to create a static DXC shader compiler, but the static-dxc feature was not enabled")
}
}
pub(super) fn max_shader_model(&self) -> Option<wgt::DxcShaderModel> {
match *self {
CompilerContainer::Fxc(..) => None,
CompilerContainer::DynamicDxc(CompilerDynamicDxc {
max_shader_model, ..
})
| CompilerContainer::StaticDxc(CompilerStaticDxc {
max_shader_model, ..
}) => Some(max_shader_model),
}
}
pub(super) fn compile(
&self,
device: &super::Device,View on GitHub (pinned to 3e11ff59bf)
Solutions
- Enable the feature: wgpu-hal = { features = ["static-dxc"] } (or the corresponding wgpu feature) in Cargo.toml and rebuild.
- Switch the caller to the dynamic DXC compiler path (ensure dxcompiler.dll is present at runtime) or fall back to FXC.
- Make the compiler choice conditional on build features at runtime rather than hard-coding static DXC.
Example fix
// before (Cargo.toml)
wgpu-hal = { version = "25", features = ["dx12"] }
// after
wgpu-hal = { version = "25", features = ["dx12", "static-dxc"] } Defensive patterns
Strategy: validation
Validate before calling
#[cfg(not(feature = "wgpu-hal/static-dxc"))] // do not request static DXC at runtime; fall back to dynamic dxc or fxc let compiler_choice = CompilerChoice::DynamicDxc;
Prevention
- Keep runtime compiler choice consistent with cargo feature flags.
- Enable static-dxc only in builds that ship with the required DXC artifacts.
- Document the required features in deployment docs for Windows builds.
When it happens
Trigger: Instantiating a CompilerContainer::new_static_dxc (e.g. via adapter/device options choosing DxcCompiler with static linking) on a build compiled without the wgpu-hal `static-dxc` feature; toggling between dynamic-dxc and static-dxc builds without updating the calling configuration.
Common situations: Windows deployments where the app requests static DXC for shader-model 6.x features but the wgpu build used default features (dynamic dxc only); mismatch between a wrapper crate's feature flags and wgpu-hal's; CI builds stripping features.
Related errors
- Feature `MESH_SHADING` not enabled
- {:?} is not enabled for this backend
- wgpu error: {err}
- Mismatched pop_error_scope call: no error scope for this thr
- Mismatched pop_error_scope call: error scopes must be popped
AI-assisted analysis of gfx-rs/wgpu@3e11ff59bf (2026-09-03).
Data as JSON: /api/errors/bc0b23b649eeab61.
Report an issue: GitHub.