{"record":{"id":"67139dbda6d833ec","repo":"bevyengine/bevy","slug":"owneddata-has-no-binding-resource","errorCode":null,"errorMessage":"`OwnedData` has no binding resource","messagePattern":"`OwnedData` has no binding resource","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/bevy_render/src/render_resource/bind_group.rs","lineNumber":832,"sourceCode":"    /// Creates a [`BindingResource`] reference to this\n    /// [`OwnedBindingResource`].\n    ///\n    /// Note that this operation panics if passed a\n    /// [`OwnedBindingResource::Data`], because [`OwnedData`] doesn't itself\n    /// correspond to any binding and instead requires the\n    /// `MaterialBindGroupAllocator` to pack it into a buffer.\n    pub fn get_binding(&self) -> BindingResource<'_> {\n        match self {\n            OwnedBindingResource::Buffer(buffer) => buffer.as_entire_binding(),\n            OwnedBindingResource::ShaderBuffer(_) => {\n                panic!(\n                    \"You can't use `get_binding` with a `ShaderBuffer`; fetch the buffer from \\\n                     the `RenderAssets<GpuShaderBuffer>` instead\"\n                )\n            }\n            OwnedBindingResource::TextureView(_, view) => BindingResource::TextureView(view),\n            OwnedBindingResource::Sampler(_, sampler) => BindingResource::Sampler(sampler),\n            OwnedBindingResource::Data(_) => panic!(\"`OwnedData` has no binding resource\"),\n        }\n    }\n}\n\nimpl UnpreparedBindingResource {\n    /// Creates a [`BindingResource`] reference to this\n    /// [`UnpreparedBindingResource`].\n    ///\n    /// Note that this operation panics if passed a\n    /// [`UnpreparedBindingResource::Data`], because the range doesn't itself\n    /// correspond to any binding and instead requires the\n    /// `MaterialBindGroupAllocator` to pack it into a buffer.\n    pub fn get_binding<'a>(\n        &'a self,\n        fallback_buffer: &'a FallbackBuffer,\n        shader_buffer_assets: &'a RenderAssets<GpuShaderBuffer>,\n    ) -> BindingResource<'a> {\n        match self {","sourceCodeStart":814,"sourceCodeEnd":850,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_render/src/render_resource/bind_group.rs#L814-L850","documentation":"OwnedBindingResource::get_binding() (bind_group.rs:832) panics on the Data variant because OwnedData does not itself correspond to any binding: it is an unstructured value that must be packed into a buffer by the MaterialBindGroupAllocator before anything can be bound. Calling get_binding() on it bypasses that required packing step.","triggerScenarios":"Calling get_binding() on OwnedBindingResource::Data - e.g. custom code building a bind group from a material's owned binding resources without going through the MaterialBindGroupAllocator.","commonSituations":"Hand-rolled bind group construction for materials that use data slots; custom AsBindGroup implementations iterating owned resources; porting code from buffer-based bindings to packed data.","solutions":["Let the MaterialBindGroupAllocator pack OwnedData into its slotted buffer and bind at the allocated offset instead of calling get_binding().","If you need a directly bindable resource, store the data in a real wgpu buffer and produce OwnedBindingResource::Buffer rather than Data.","Route custom materials through the standard preparation pipeline."],"exampleFix":"// before\nlet binding = owned_resource.get_binding(); // panics on Data variant\n\n// after: only bind variants that map to a real binding resource\nif matches!(owned_resource, OwnedBindingResource::Data(_)) {\n    // let the MaterialBindGroupAllocator pack it into its buffer\n} else {\n    let binding = owned_resource.get_binding();\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"fn is_directly_bindable(res: &OwnedBindingResource) -> bool {\n    !matches!(res, OwnedBindingResource::Data(_))\n}","tryCatchPattern":null,"preventionTips":["Route OwnedData through the MaterialBindGroupAllocator instead of converting it to a binding.","Use OwnedBindingResource::Buffer when you need a directly bindable GPU resource.","Match on variants in generic binding code rather than assuming uniformity."],"tags":["bevy","owned-data","binding","panic","bind-group"],"backgroundTag":"unsupported-variant-access","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}