{"record":{"id":"478b988b32952bd6","repo":"bevyengine/bevy","slug":"spirv-not-yet-implemented","errorCode":null,"errorMessage":"spirv not yet implemented","messagePattern":"spirv not yet implemented","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/bevy_shader/src/shader.rs","lineNumber":237,"sourceCode":"\n/// Raw shader source code.\n#[expect(missing_docs, reason = \"The variants are self-explanatory.\")]\n#[derive(Debug, Clone)]\npub enum Source {\n    Wgsl(Cow<'static, str>),\n    Wesl(Cow<'static, str>),\n    SpirV(Cow<'static, [u8]>),\n    // TODO: consider the following\n    // PrecompiledSpirVMacros(HashMap<HashSet<String>, Vec<u32>>)\n    // NagaModule(Module) ... Module impls Serialize/Deserialize\n}\n\nimpl Source {\n    /// The underlying source code string, unless it is SPIR-V.\n    pub fn as_str(&self) -> &str {\n        match self {\n            Source::Wgsl(s) | Source::Wesl(s) => s,\n            Source::SpirV(_) => panic!(\"spirv not yet implemented\"),\n        }\n    }\n}\n\n/// The [`AssetLoader`] responsible for loading unprocessed shader assets.\n#[derive(Default, TypePath)]\npub struct ShaderLoader;\n\n/// An error encountered while loading a shader's source.\n#[non_exhaustive]\n#[derive(Debug, Error)]\n#[expect(missing_docs, reason = \"The variants are self-explanatory.\")]\npub enum ShaderLoaderError {\n    #[error(\"Could not load shader: {0}\")]\n    Io(#[from] std::io::Error),\n    #[error(\"Could not parse shader: {0}\")]\n    Parse(#[from] alloc::string::FromUtf8Error),\n}","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_shader/src/shader.rs#L219-L255","documentation":"Panic in Shader::Source::as_str(). A Shader's source can be Wgsl, Wesl, or SpirV bytes; as_str() only has meaning for the textual variants and explicitly panics with 'spirv not yet implemented' for SpirV because there is no way to return the binary payload as a string.","triggerScenarios":"Calling shader.get_source().as_str() (or any code path that assumes text) on a shader created via Shader::from_spirv / loaded from a .spv file. The match arm for Source::SpirV panics.","commonSituations":"Shader processing pipelines (reflection, preprocessing, import resolution) written against textual shaders and then fed a SPIR-V asset; tools that log or inspect shader source without checking the variant.","solutions":["Match on the Source variant before treating it as text instead of calling as_str()","Provide the shader as .wgsl/.wesl text if your pipeline needs source access","Gate SPIR-V shaders out of text-based preprocessing paths"],"exampleFix":"// before\nlet src = shader.get_source().as_str(); // panics for SpirV\n\n// after\nmatch shader.get_source() {\n    Source::Wgsl(s) | Source::Wesl(s) => process_text(s),\n    Source::SpirV(bytes) => process_binary(bytes),\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"fn is_text_shader(shader: &Shader) -> bool {\n    matches!(\n        shader.get_source(),\n        Source::Wgsl(_) | Source::Wesl(_)\n    )\n}","tryCatchPattern":null,"preventionTips":["Never call as_str() on an un-inspected Source — match the variant first","Keep SPIR-V shaders out of text-based preprocessing/reflection pipelines"],"tags":["bevy","shader","spirv","panic","wgsl"],"backgroundTag":"unimplemented-feature","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}