demo · v137

Effect Chain

The specific shape the feature was requested for: a video-effects pipeline where pass 0 samples a live camera (texture_external) and pass 1 samples pass-0's output (texture_2d). Pre-v137 those required different shaders. Post-v137, you can write one shader that uses a regular texture binding for both — which is what the chain below does.

probing…

source video

chained output

chain: (not started)
click start camera

the code

// pre-v137: two shaders needed, because pass 0 used texture_external
//           and pass 1 used texture_2d.
// post-v137: one shader, same texture binding type works for both.

@group(0) @binding(0) var s : sampler;
@group(0) @binding(1) var t : texture_2d<f32>;   // same binding type
@fragment fn fmain(in: VOut) -> @location(0) vec4f { ... }

// Pass 0: external texture, view-able now.
const view = device.importExternalTexture({ source: video });
// Pass N: intermediate render target.
const view = intermediateTexture.createView();
// Both are bound at the same slot, no shader specialisation.

see also