{"record":{"id":"dfa9197c0f8b6f80","repo":"gfx-rs/wgpu","slug":"web-backend-does-not-support-arrays-of-samplers","errorCode":null,"errorMessage":"Web backend does not support arrays of samplers","messagePattern":"Web backend does not support arrays of samplers","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wgpu/src/backend/webgpu.rs","lineNumber":2319,"sourceCode":"                    mapped_buffer_binding.set_offset_f64(offset as f64);\n                    if let Some(s) = size {\n                        mapped_buffer_binding.set_size_f64(s.get() as f64);\n                    }\n\n                    webgpu_sys::GpuBindGroupEntry::new_with_gpu_buffer_binding(\n                        binding.binding,\n                        &mapped_buffer_binding,\n                    )\n                }\n                crate::BindingResource::BufferArray(..) => {\n                    panic!(\"Web backend does not support arrays of buffers\")\n                }\n                crate::BindingResource::Sampler(sampler) => {\n                    let sampler = &sampler.inner.as_webgpu().inner;\n                    webgpu_sys::GpuBindGroupEntry::new(binding.binding, sampler)\n                }\n                crate::BindingResource::SamplerArray(..) => {\n                    panic!(\"Web backend does not support arrays of samplers\")\n                }\n                crate::BindingResource::TextureView(texture_view) => {\n                    let texture_view = &texture_view.inner.as_webgpu().inner;\n                    webgpu_sys::GpuBindGroupEntry::new_with_gpu_texture_view(\n                        binding.binding,\n                        texture_view,\n                    )\n                }\n                crate::BindingResource::TextureViewArray(..) => {\n                    panic!(\"Web backend does not support BINDING_INDEXING extension\")\n                }\n                crate::BindingResource::AccelerationStructure(_) => {\n                    unimplemented!(\"Raytracing not implemented for web\")\n                }\n                crate::BindingResource::AccelerationStructureArray(_) => {\n                    unimplemented!(\"Raytracing not implemented for web\")\n                }\n                crate::BindingResource::ExternalTexture(external_texture) => {","sourceCodeStart":2301,"sourceCodeEnd":2337,"githubUrl":"https://github.com/gfx-rs/wgpu/blob/3e11ff59bf3f9795d285ecc045014089640d7248/wgpu/src/backend/webgpu.rs#L2301-L2337","documentation":"Raised when creating a bind group whose entry is a BindingResource::SamplerArray. The browser WebGPU API has no sampler-array binding representation this backend can use, so the mapping path panics instead of creating the bind group.","triggerScenarios":"Calling device.create_bind_group with a BindGroupEntry whose resource is BindingResource::SamplerArray(&[...]) on the web backend, for a layout entry declaring an array of samplers.","commonSituations":"Bindless sampler arrays written for native backends; shared material/texture systems that index samplers dynamically; porting engines that use per-draw sampler selection to wasm.","solutions":["Bind each sampler as its own separate BindGroupEntry with distinct binding indices.","Restructure shaders to select filtering behavior procedurally (e.g. one combined sampler plus shader branching).","Gate sampler-array usage behind a backend check and supply an alternate bind group layout for web."],"exampleFix":"// before\nentries.push(wgpu::BindGroupEntry { binding: 3, resource: wgpu::BindingResource::SamplerArray(&samplers) });\n// after\nfor (i, s) in samplers.iter().enumerate() {\n    entries.push(wgpu::BindGroupEntry { binding: 3 + i as u32, resource: wgpu::BindingResource::Sampler(s) });\n}","handlingStrategy":"validation","validationCode":"for e in &entries {\n    assert!(!matches!(e.resource, wgpu::BindingResource::SamplerArray(_)), \"SamplerArray unsupported on web backend\");\n}","typeGuard":"fn has_no_sampler_array(entries: &[wgpu::BindGroupEntry]) -> bool {\n    entries.iter().all(|e| !matches!(e.resource, wgpu::BindingResource::SamplerArray(_)))\n}","tryCatchPattern":null,"preventionTips":["Bind each sampler to a distinct binding slot on web.","Replace dynamic sampler selection with shader-side branching over a few fixed samplers.","Add a debug assertion that no arrayed resources appear in web bind groups."],"tags":["webgpu","wasm","bind-group","sampler","unsupported-feature"],"backgroundTag":"sampler-array-unsupported-on-web","analyzedSha":"3e11ff59bf3f9795d285ecc045014089640d7248","analyzedAt":"2026-09-03T01:43:21.459Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}