gfx-rs/wgpu · error

Web backend does not support arrays of buffers

Error message

Web backend does not support arrays of buffers

What it means

Raised when creating a bind group whose entry is a BindingResource::BufferArray. Browser WebGPU bind group entries bind one buffer per entry, so an array-of-buffers binding (native-only feature used with non-uniform binding arrays) cannot be expressed and the backend panics.

Source

Thrown at wgpu/src/backend/webgpu.rs:2312

                crate::BindingResource::Buffer(crate::BufferBinding {
                    buffer,
                    offset,
                    size,
                }) => {
                    let buffer = buffer.inner.as_webgpu();
                    let mapped_buffer_binding = webgpu_sys::GpuBufferBinding::new(&buffer.inner);
                    mapped_buffer_binding.set_offset_f64(offset as f64);
                    if let Some(s) = size {
                        mapped_buffer_binding.set_size_f64(s.get() as f64);
                    }

                    webgpu_sys::GpuBindGroupEntry::new_with_gpu_buffer_binding(
                        binding.binding,
                        &mapped_buffer_binding,
                    )
                }
                crate::BindingResource::BufferArray(..) => {
                    panic!("Web backend does not support arrays of buffers")
                }
                crate::BindingResource::Sampler(sampler) => {
                    let sampler = &sampler.inner.as_webgpu().inner;
                    webgpu_sys::GpuBindGroupEntry::new(binding.binding, sampler)
                }
                crate::BindingResource::SamplerArray(..) => {
                    panic!("Web backend does not support arrays of samplers")
                }
                crate::BindingResource::TextureView(texture_view) => {
                    let texture_view = &texture_view.inner.as_webgpu().inner;
                    webgpu_sys::GpuBindGroupEntry::new_with_gpu_texture_view(
                        binding.binding,
                        texture_view,
                    )
                }
                crate::BindingResource::TextureViewArray(..) => {
                    panic!("Web backend does not support BINDING_INDEXING extension")
                }

View on GitHub (pinned to 3e11ff59bf)

Solutions

  1. Bind each buffer as a separate BindGroupEntry with its own binding index.
  2. Pack per-object data into a single larger uniform/storage buffer with dynamic offsets, and use set_bind_group dynamic offsets per draw.
  3. Restrict buffer-array bindings to native backends and provide a web-specific bind group layout.

Example fix

// before
entries.push(wgpu::BindGroupEntry { binding: 0, resource: wgpu::BindingResource::BufferArray(&buffers) });
// after
for (i, buf) in buffers.iter().enumerate() {
    entries.push(wgpu::BindGroupEntry { binding: i as u32, resource: wgpu::BindingResource::Buffer(buf.slice(..)) });
}
Defensive patterns

Strategy: validation

Validate before calling

for e in &entries {
    assert!(!matches!(e.resource, wgpu::BindingResource::BufferArray(_)), "BufferArray unsupported on web backend");
}

Type guard

fn is_web_safe_resource(r: &wgpu::BindingResource) -> bool {
    !matches!(r, wgpu::BindingResource::BufferArray(_) | wgpu::BindingResource::SamplerArray(_) | wgpu::BindingResource::TextureViewArray(_))
}

Prevention

When it happens

Trigger: Calling device.create_bind_group with a BindGroupEntry whose resource is BindingResource::BufferArray(&[...]) on the web backend, typically for bindings declared as arrays of storage/uniform buffers.

Common situations: Using the bindless-style buffer-array patterns on wasm32-web; shared bind group layout code written for native backends; batching many uniform buffers into one array binding.

Related errors


AI-assisted analysis of gfx-rs/wgpu@3e11ff59bf (2026-09-03). Data as JSON: /api/errors/9badb6657b10a145. Report an issue: GitHub.