v150 · web api · shipped
WebGPU: Immediates
A new mechanism for passing small amounts of frequently-updated data directly to GPU shaders — without creating GPU buffer objects or bind groups — by introducing an immediate address space in WGSL and a setImmediateData() method on render passes, compute passes, and render bundle encoders. Ships in Chrome 150.
at a glance
| Shipped in | Chrome 150 (desktop, Android, WebView where WebGPU hardware is available) |
|---|---|
| Status | Enabled by default |
| Spec | WebGPU specification (gpuweb/gpuweb) |
| ChromeStatus | 5199437611794432 — WebGPU: Immediates |
why it exists
In a typical WebGPU draw loop, per-draw parameters — object index, material index, transform matrix — are updated every call. The standard pattern is to write these into a GPU buffer and set a bind group pointing to it. For data that changes every draw, this creates significant overhead: buffer writes, bind group updates, and descriptor validation on the critical path.
GPU hardware has long supported a concept sometimes called "push constants" (Vulkan) or "root constants" (D3D12): a small block of bytes that travel directly with a pipeline draw command, bypassing buffer and bind group machinery. WebGPU Immediates exposes this mechanism to web applications, enabling a common high-performance GPU programming pattern without workarounds.
Source: gpuweb/gpuweb — Immediates proposal (#5118).the API
pipeline layout: declare immediate data range
When creating a pipeline layout, declare the size (in bytes) of the immediate data block the pipeline will use:
const layout = device.createPipelineLayout({
bindGroupLayouts: [ /* ... */ ],
immediateDataRangeByteSize: 16, // 16 bytes = 4 × float32
});
WGSL shader: read from immediate address space
In the shader, declare a variable in the new immediate address space. The type must be a host-shareable struct:
struct DrawParams {
object_index: u32,
material_index: u32,
time: f32,
_padding: f32,
}
var<immediate> params: DrawParams;
@vertex fn vs_main(@builtin(vertex_index) vi: u32) -> @builtin(position) vec4f {
let obj = objects[params.object_index];
/* ... */
}
JavaScript: set data per draw
setImmediateData(offset, data) is available on GPURenderPassEncoder, GPUComputePassEncoder, and GPURenderBundleEncoder:
const passEncoder = commandEncoder.beginRenderPass(/* ... */);
passEncoder.setPipeline(pipeline);
// Per-object loop: update immediates before each draw, no bind group change
for (const [i, obj] of objects.entries()) {
const data = new Uint32Array([i, obj.materialIndex, 0, 0]);
passEncoder.setImmediateData(0, data);
passEncoder.draw(obj.vertexCount);
}
passEncoder.end();
Source: chromestatus.com — WebGPU: Immediates and gpuweb spec PR #5423.
constraints
| Maximum size | Defined by the device limit maxImmediateDataRangeByteSize (at least 128 bytes guaranteed) |
|---|---|
| Alignment | Offset must be aligned to 4 bytes |
| Scope | Immediate data is per-pass — it does not persist across passes or render bundles re-executed in a different pass |
| Types | Host-shareable structs only; cannot reference textures or samplers |
browser support
| Chrome / Edge | 150 (where WebGPU hardware is available) |
|---|---|
| Firefox | Not yet; following the WebGPU spec |
| Safari | Not yet; following the WebGPU spec |