WebGPU immediates, external textures and MediaStreamTrack speech

I wanted to test three newer Chrome APIs against HTML-in-canvas: binding a GPUTextureView from a drawn DOM card straight to a WGSL texture_external slot alongside a video, pushing per-card uniforms with pass.setImmediateData(), and feeding a video's audio track into SpeechRecognition.start(track) to drive a drawn DOM caption banner. Each section reports the path your browser took and falls back when a feature isn't there.

1. GPUTextureView bound to texture_external

One WGSL shader with a single texture_external binding samples either a playing video (importExternalTexture()) or the live DOM card's GPUTextureView (drawElementImageToTexture()), or both in split screen inside the same render pass.

Starting external texture check…
GPUTextureView -> texture_external

Live DOM card

Bound as GPUTextureView
50%
Show the code single texture_external shader, GPUTextureView bind group and hit geometry
  1. The drawable DOM card inside the canvas. Its texture view is handed to the same externalTexture binding as the video.
  2. One WGSL shader with one texture_external binding. Both sources are sampled through textureSampleBaseClampToEdge() with optional chroma shift and scanlines.
  3. Probing GPUTextureView in externalTexture and updating hit boxes. If validation rejects the view or WebGPU isn't usable, the stage switches to a 2D canvas.

2. Per-element uniforms with pass.setImmediateData()

Four interactive drawable DOM cards are drawn in one render pass on a subdivided mesh. Each card's offset, tilt, wave phase and highlight (48 bytes) are pushed straight onto the render pass with setImmediateData() (or setImmediates() where Chrome exposes the earlier name) and zero uniform buffers.

Checking WebGPU immediates support…
Offset#0
48 B immediate
Tilt#1
tilt boost: on
Wave#2
10x6 wave mesh
Highlight#3
glow 75%
Show the code 48-byte var<immediate> block, mesh warp shader and uniform buffer fallback
  1. Four interactive drawable cards in one canvas. Each has its own control and keeps its hit box synced as it moves.
  2. Subdivided wave mesh with var<immediate>. Packing the canvas size into the 48-byte immediate block removes every uniform buffer from the pass.
  3. One render pass for all four cards. Calls pass.setImmediateData() (or setImmediates()) before each draw, or binds a 256-byte dynamic offset in the fallback buffer.

3. SpeechRecognition.start(track) into drawn DOM captions

Plays /media/talk.webm, captures its audio track with video.captureStream().getAudioTracks()[0], and passes that track to recognition.start(audioTrack). The recognised text (or /media/talk.vtt cues when track recognition isn't available or returns nothing) writes straight into a selectable, editable DOM banner drawn over the video in one 2D canvas.

Press Play to start the clip and try SpeechRecognition.start(audioTrack).
Ready Clip: talk.webm
Press Play to transcribe the audio track into this editable DOM banner. You can select or edit this text while it's drawn over the video.
Show the code captureStream() audio track, SpeechRecognition.start(track) and 2D caption draw
  1. Video and editable DOM banner inside one 2D canvas. Drawing the banner after the video puts it on top for taps, text selection and editing.
  2. Capturing the audio track and falling back to talk.vtt. Reports whether start(audioTrack) was accepted, errored or timed out without results.
  3. Painting both elements at their layout size. Every drawElementImage() call passes width and height so HiDPI phone screens scale correctly.

How it works

All three demos share the page's single WebGPU device from webgpu() in /shared/backend.js (no extra device is opened, and nothing calls adapter.requestDevice() directly). When WebGPU isn't available or rejects a newer binding, Demos 1 and 2 switch to a 2D canvas with drawElementImage() so every control stays usable.

CapabilityIn this browserHow the page uses it
navigator.gpu + drawElementImageToTexture()Checking…Uploads drawable HTML cards straight into rgba8unorm WebGPU textures.
GPUTextureView in externalTextureChecking…Lets one WGSL texture_external pipeline sample both a <video> and a drawn DOM element.
pass.setImmediateData() / setImmediates()Checking…Pushes 48 bytes of offset, tilt, wave phase and highlight per card with zero uniform buffers.
SpeechRecognition + captureStream()Checking…Sends the playing video's audio MediaStreamTrack to recognition.start(audioTrack), falling back to /media/talk.vtt.

Live checks

Each check builds its own isolated fixture on a bench panel at the bottom of the screen and retires its canvas afterwards. The visible demos above aren't touched while the checks run.

ResultExperimentDetail

Findings

This page hasn't been measured in a browser yet; press "Run these checks" above to measure your browser, and see findings/webgpu-immediates.md for the verification checklist.