v150 · WebGPU

Push Constants Basics

A shader that receives a time value every frame via setImmediateData(). The value drives a hue rotation — no uniform buffer, no bind group, no writeBuffer call. One 4-byte push per draw.

Feature detection: checking…
frame 0

method: —

// WGSL — declare `immediate` address space
var<immediate> time: f32;

@fragment fn fs(@builtin(position) pos: vec4f) -> @location(0) vec4f {
  let hue = time * 0.5 + pos.x / 400.0;
  return hsv_to_rgb(hue, 0.8, 0.9);
}

// JS — pass data every frame, no buffer objects needed
function frame(t) {
  const pass = encoder.beginRenderPass(descriptor);
  const timeF32 = new Float32Array([t / 1000]);

  // NEW in Chrome 150 — like Vulkan pushConstants
  pass.setImmediateData(0, timeF32);

  pass.draw(3);
  pass.end();
}

see also

implementation reference

Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗