{"record":{"id":"7770b840571fc37d","repo":"gfx-rs/wgpu","slug":"no-binary-data-provided-to-shadermoduledescriptor","errorCode":null,"errorMessage":"No binary data provided to `ShaderModuleDescriptorGeneric`","messagePattern":"No binary data provided to `ShaderModuleDescriptorGeneric`","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wgpu-types/src/shader.rs","lineNumber":201,"sourceCode":"    #[cfg(feature = \"trace\")]\n    /// Returns the source data for tracing purpose.\n    pub fn trace_data(&self) -> &[u8] {\n        if let Some(spirv) = &self.spirv {\n            bytemuck::cast_slice(spirv)\n        } else if let Some(metallib) = &self.metallib {\n            metallib\n        } else if let Some(msl) = &self.msl {\n            msl.as_bytes()\n        } else if let Some(dxil) = &self.dxil {\n            dxil\n        } else if let Some(hlsl) = &self.hlsl {\n            hlsl.as_bytes()\n        } else if let Some(glsl) = &self.glsl {\n            glsl.as_bytes()\n        } else if let Some(wgsl) = &self.wgsl {\n            wgsl.as_bytes()\n        } else {\n            panic!(\"No binary data provided to `ShaderModuleDescriptorGeneric`\")\n        }\n    }\n\n    #[cfg(feature = \"trace\")]\n    /// Returns the binary file extension for tracing purpose.\n    pub fn trace_binary_ext(&self) -> &'static str {\n        if self.spirv.is_some() {\n            \"spv\"\n        } else if self.metallib.is_some() {\n            \"metallib\"\n        } else if self.msl.is_some() {\n            \"metal\"\n        } else if self.dxil.is_some() {\n            \"dxil\"\n        } else if self.hlsl.is_some() {\n            \"hlsl\"\n        } else if self.glsl.is_some() {\n            \"glsl\"","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/gfx-rs/wgpu/blob/3e11ff59bf3f9795d285ecc045014089640d7248/wgpu-types/src/shader.rs#L183-L219","documentation":"`ShaderModuleDescriptorGeneric::trace_data` returns the binary shader source (HLSL, GLSL, or WGSL) for tracing purposes and panics if none of the source fields is populated. A shader module descriptor must carry exactly one binary/source representation; when all are `None` there is nothing to write. This is reachable when shader tracing is enabled and a descriptor is constructed empty or via a path that never sets a source.","triggerScenarios":"Calling `trace_data()` (with the `trace` feature enabled) on a `ShaderModuleDescriptorGeneric` where `dxil`, `hlsl`, `glsl`, and `wgsl` are all None.","commonSituations":"Constructing the descriptor programmatically and forgetting to set the WGSL source; Naga-related paths where the source field is filled later; tracing infrastructure writing a shader capture before source assignment.","solutions":["Ensure the descriptor has a source set before use: assign `wgsl`, `glsl`, `hlsl`, or `dxil` in `ShaderModuleDescriptorGeneric`.","If building descriptors from Naga, serialize the module to WGSL and store it in the `wgsl` field.","Guard trace calls behind a check that at least one source field is Some."],"exampleFix":"// before\nlet desc = ShaderModuleDescriptorGeneric::default();\ncreate_shader_module(&device, &desc);\n// after\nlet desc = ShaderModuleDescriptorGeneric {\n    wgsl: Some(wgsl_source.into()),\n    ..Default::default()\n};","handlingStrategy":"validation","validationCode":"// Before creating/tracing a shader module:\nif desc.wgsl.is_none() && desc.glsl.is_none() && desc.hlsl.is_none() && desc.dxil.is_none() {\n    return Err(\"ShaderModuleDescriptorGeneric needs a source: set wgsl, glsl, hlsl, or dxil\");\n}","typeGuard":"fn has_shader_source(desc: &ShaderModuleDescriptorGeneric) -> bool {\n    desc.wgsl.is_some() || desc.glsl.is_some() || desc.hlsl.is_some() || desc.dxil.is_some()\n}","tryCatchPattern":null,"preventionTips":["Always construct descriptors with exactly one source field set (prefer wgsl).","When only Naga IR is available, serialize to WGSL before building the descriptor.","assert!(has_shader_source(&desc)) in debug builds around shader creation helpers."],"tags":["shader","tracing","missing-data","panic"],"backgroundTag":"missing-shader-source","analyzedSha":"3e11ff59bf3f9795d285ecc045014089640d7248","analyzedAt":"2026-09-03T01:43:21.459Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}