{"record":{"id":"bc0b23b649eeab61","repo":"gfx-rs/wgpu","slug":"attempted-to-create-a-static-dxc-shader-compiler","errorCode":null,"errorMessage":"Attempted to create a static DXC shader compiler, but the static-dxc feature was not enabled","messagePattern":"Attempted to create a static DXC shader compiler, but the static-dxc feature was not enabled","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wgpu-hal/src/dx12/shader_compilation.rs","lineNumber":91,"sourceCode":"        {\n            unsafe {\n                let compiler = dxc_create_instance::<Dxc::IDxcCompiler3>(|clsid, iid, ppv| {\n                    windows_core::HRESULT(mach_dxcompiler_rs::DxcCreateInstance(\n                        clsid.cast(),\n                        iid.cast(),\n                        ppv,\n                    ))\n                })?;\n\n                Ok(CompilerContainer::StaticDxc(CompilerStaticDxc {\n                    max_shader_model: wgt::DxcShaderModel::V6_7,\n                    compiler,\n                }))\n            }\n        }\n        #[cfg(not(static_dxc))]\n        {\n            panic!(\"Attempted to create a static DXC shader compiler, but the static-dxc feature was not enabled\")\n        }\n    }\n\n    pub(super) fn max_shader_model(&self) -> Option<wgt::DxcShaderModel> {\n        match *self {\n            CompilerContainer::Fxc(..) => None,\n            CompilerContainer::DynamicDxc(CompilerDynamicDxc {\n                max_shader_model, ..\n            })\n            | CompilerContainer::StaticDxc(CompilerStaticDxc {\n                max_shader_model, ..\n            }) => Some(max_shader_model),\n        }\n    }\n\n    pub(super) fn compile(\n        &self,\n        device: &super::Device,","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/gfx-rs/wgpu/blob/3e11ff59bf3f9795d285ecc045014089640d7248/wgpu-hal/src/dx12/shader_compilation.rs#L73-L109","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (Cargo.toml)\nwgpu-hal = { version = \"25\", features = [\"dx12\"] }\n// after\nwgpu-hal = { version = \"25\", features = [\"dx12\", \"static-dxc\"] }","handlingStrategy":"validation","validationCode":"#[cfg(not(feature = \"wgpu-hal/static-dxc\"))]\n// do not request static DXC at runtime; fall back to dynamic dxc or fxc\nlet compiler_choice = CompilerChoice::DynamicDxc;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["dx12","dxc","shader-compilation","compile-time-feature","panic"],"backgroundTag":"missing-cargo-feature","analyzedSha":"3e11ff59bf3f9795d285ecc045014089640d7248","analyzedAt":"2026-09-03T01:43:21.459Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}