{"record":{"id":"ed37eccb0c8135fe","repo":"bevyengine/bevy","slug":"renderpipelinedescriptor-has-no-fragmentstate-conf","errorCode":null,"errorMessage":"RenderPipelineDescriptor has no FragmentState configured","messagePattern":"RenderPipelineDescriptor has no FragmentState configured","errorType":"exception","errorClass":"NoFragmentStateError","httpStatus":null,"severity":"error","filePath":"crates/bevy_material/src/descriptor.rs","lineNumber":54,"sourceCode":"    /// Supply 0 if the pipeline doesn't use push constants/immediates.\n    pub immediate_size: u32,\n    /// The compiled vertex stage, its entry point, and the input buffers layout.\n    pub vertex: VertexState,\n    /// The properties of the pipeline at the primitive assembly and rasterization level.\n    pub primitive: PrimitiveState,\n    /// The effect of draw calls on the depth and stencil aspects of the output target, if any.\n    pub depth_stencil: Option<DepthStencilState>,\n    /// The multi-sampling properties of the pipeline.\n    pub multisample: MultisampleState,\n    /// The compiled fragment stage, its entry point, and the color targets.\n    pub fragment: Option<FragmentState>,\n    /// Whether to zero-initialize workgroup memory by default. If you're not sure, set this to true.\n    /// If this is false, reading from workgroup variables before writing to them will result in garbage values.\n    pub zero_initialize_workgroup_memory: bool,\n}\n\n#[derive(Copy, Clone, Debug, Error)]\n#[error(\"RenderPipelineDescriptor has no FragmentState configured\")]\npub struct NoFragmentStateError;\n\nimpl RenderPipelineDescriptor {\n    pub fn fragment_mut(&mut self) -> Result<&mut FragmentState, NoFragmentStateError> {\n        self.fragment.as_mut().ok_or(NoFragmentStateError)\n    }\n\n    pub fn set_layout(&mut self, index: usize, layout: BindGroupLayoutDescriptor) {\n        filling_set_at(&mut self.layout, index, bevy_utils::default(), layout);\n    }\n}\n\n#[derive(Clone, Debug, PartialEq, Default)]\npub struct VertexState {\n    /// The compiled shader module for this stage.\n    pub shader: Handle<Shader>,\n    pub shader_defs: Vec<ShaderDefVal>,\n    /// The name of the entry point in the compiled shader, or `None` if the default entry point","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_material/src/descriptor.rs#L36-L72","documentation":"RenderPipelineDescriptor::fragment_mut() returns NoFragmentStateError when the descriptor's fragment field is None (crates/bevy_material/src/descriptor.rs:58). Descriptors legitimately lack a fragment state for depth-only-style pipelines, but any code that tries to mutate the fragment stage will get this error — Bevy's own gizmo, fullscreen-material, CAS and TAA specializers all call fragment_mut() with ? propagation.","triggerScenarios":"Calling fragment_mut() (directly or via ? in a pipeline specialization) on a descriptor built with fragment: None — typically a prepass/depth-derived or otherwise color-less descriptor being specialized as if it rendered color.","commonSituations":"Custom Material specializations that assume every pipeline has a fragment; base descriptors cloned from depth-only passes; writing a new post-process material and copying a depth-only template.","solutions":["Only mutate the fragment for passes that output color: guard with if let Some(fragment) = &mut descriptor.fragment.","Populate fragment: Some(FragmentState { .. }) when constructing descriptors that will be specialized.","Propagate the Result with ? from your specialization function so the failure surfaces as a pipeline error."],"exampleFix":"// before\nlet fragment = descriptor.fragment_mut()?; // Err when fragment is None (depth-only)\nfragment.shader_defs.push(\"MY_DEF\".into());\n\n// after\nif let Some(fragment) = &mut descriptor.fragment {\n    fragment.shader_defs.push(\"MY_DEF\".into());\n}","handlingStrategy":"validation","validationCode":"fn configure_fragment(descriptor: &mut RenderPipelineDescriptor) {\n    if descriptor.fragment.is_some() {\n        let fragment = descriptor.fragment_mut().expect(\"checked above\");\n        fragment.shader_defs.push(\"MY_DEF\".into());\n    }\n}","typeGuard":null,"tryCatchPattern":"match descriptor.fragment_mut() {\n    Ok(fragment) => fragment.shader_defs.push(\"MY_DEF\".into()),\n    Err(NoFragmentStateError) => { /* depth-only pipeline: nothing to specialize */ }\n}","preventionTips":["Never assume a descriptor has a fragment; depth-only pipelines are common.","Set fragment: Some(..) at construction for pipelines you will specialize for color output.","Propagate ? in specializers so the error surfaces with pipeline context."],"tags":["bevy","rendering","material","pipeline","wgpu","shader"],"backgroundTag":"missing-pipeline-fragment-state","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"}