This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Web Workers.
The createBindGroup() method of the GPUDevice interface creates a GPUBindGroup based on a GPUBindGroupLayout that defines a set of resources to be bound together in a group and how those resources are used in shader stages.
createBindGroup(descriptor)
descriptorAn object containing the following properties:
entriesAn array of entry objects describing the resources to expose to the shader. There will be one for each corresponding entry described by the GPUBindGroupLayout referenced in layout. Each entry object has the following properties:
bindingA number representing a unique identifier for this resource binding, which matches the binding value of a corresponding GPUBindGroupLayout entry. In addition, it matches the n index value of the corresponding @binding(n) attribute in the shader (GPUShaderModule) used in the related pipeline.
resourceThe resource to bind. This can be one of the following:
GPUBufferBinding (which wraps a GPUBuffer; see GPUBufferBinding objects for a definition)GPUExternalTextureGPUSamplerGPUTextureView; can be used in place of a GPUExternalTexture provided it is compatible (a 2D format with a single subresource, that is, dimension: "2d").label OptionalA string providing a label that can be used to identify the object, for example in GPUError messages or console warnings.
layoutThe GPUBindGroupLayout that the entries of this bind group will conform to.
A GPUBufferBinding object can contain the following properties:
bufferThe GPUBuffer object you want to bind.
offset OptionalThe offset, in bytes, from the beginning of the buffer to the beginning of the range exposed to the shader by the buffer binding. If omitted, offset defaults to 0.
size OptionalThe size, in bytes, of the buffer binding. If omitted, size will be the range starting at offset and ending at the end of the buffer. If both offset and size are omitted, the entire buffer is exposed to the shader.
A GPUBindGroup object instance.
The following criteria must be met when calling createBindGroup(), otherwise a GPUValidationError is generated and an invalid GPUBindGroup object is returned:
layout GPUBindGroupLayout equals the number of entry objects in entries.layout GPUBindGroupLayout, the corresponding entry object in entries binds the correct resource type. For example, a buffer resource layout object has a GPUBufferBinding object specified in the corresponding binding.buffer: GPUBuffer: offset and size) contained inside it completely, with a non-zero size.buffer resource layout's minBindingSize.type is "uniform": GPUBuffer has a usage that includes GPUBufferUsage.UNIFORM.GPUDevice's maxUniformBufferBindingSize limit.GPUBufferBinding offset is a multiple of the GPUDevice's minUniformBufferOffsetAlignment limit.type is "storage" or "read-only-storage": GPUBuffer has a usage that includes GPUBufferUsage.STORAGE.GPUDevice's maxStorageBufferBindingSize limit.GPUBufferBinding offset is a multiple of the GPUDevice's minStorageBufferOffsetAlignment limit.storageTexture, the corresponding bound GPUTextureView: dimension equal to the resource layout object's viewDimension (see GPUTexture.createView() for more details of a texture view's settings).format equal to the resource layout object's sampleType.mipLevelCount equal to 1.GPUTexture with a usage that includes GPUTextureUsage.STORAGE_BINDING.texture, the corresponding bound GPUTextureView: dimension equal to the resource layout object's viewDimension (see GPUTexture.createView() for more details of a texture view's settings).format compatible with the resource layout object's sampleType.GPUTexture with a usage that includes GPUTextureUsage.TEXTURE_BINDING.GPUTexture with a sampleCount greater than 1 if the resource layout object's multisampled property is true, or equal to 1 if it is false.Note: The WebGPU samples feature many more examples.
Our basic compute demo shows an example of creating a bind group layout and then using that as a template when creating a bind group.
// …
const bindGroupLayout = device.createBindGroupLayout({
entries: [
{
binding: 0,
visibility: GPUShaderStage.COMPUTE,
buffer: {
type: "storage",
},
},
],
});
const bindGroup = device.createBindGroup({
layout: bindGroupLayout,
entries: [
{
binding: 0,
resource: {
buffer: output,
},
},
],
});
// …
| Specification |
|---|
| WebGPU> # dom-gpudevice-createbindgroup> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
createBindGroup |
113Currently supported on ChromeOS, macOS, and Windows only. |
113Currently supported on ChromeOS, macOS, and Windows only. |
141Currently supported on Windows only, in all contexts except for service workers. |
99Currently supported on ChromeOS, macOS, and Windows only. |
26 | 121 | No | 81 | 26 | 25.0 | 121 | 26 |
descriptor_entries_option_accepts_GPUTextureView_resource |
137Currently supported on ChromeOS, macOS, and Windows only. |
137Currently supported on ChromeOS, macOS, and Windows only. |
No | 121Currently supported on ChromeOS, macOS, and Windows only. |
No | 137 | No | 90 | No | No | 137 | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/GPUDevice/createBindGroup