Composite grouped/nested video on the GPU path

Imported video is a Group[Video, Audio] that rendered as a Vello-baked
Vector layer, re-uploading the full frame to Vello's image atlas every
frame (~17ms/frame at 1080p, hitting playback and export alike). Extract
video frames out of the Group/clip scene recursion into
VideoRenderInstances so they composite via the GPU Video path; mixed
video+vector containers fall back to Vello (correct, unaccelerated).

Also route video through hardware sRGB decode: upload raw sRGB bytes to an
Rgba8UnormSrgb texture and blit with a non-unpremultiplying shader variant
(blit_straight), removing the per-frame per-pixel CPU sRGB->linear pass.
Add an F3 GPU-timestamp timer and a per-frame video texture cache.

Drops the live composite of a 1080p video from ~17ms to ~2-3ms.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Skyler Lehmkuhl
2026-06-22 17:38:30 -04:00
co-authored by Claude Opus 4.8
parent ce151ffd61
commit 5844a0f070
8 changed files with 637 additions and 86 deletions
@@ -75,3 +75,25 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
let tinted = base + tint - base * tint;
return vec4<f32>(tinted, masked_a);
}
// Variant for sources that are ALREADY straight-alpha linear — notably a video
// frame uploaded to an `Rgba8UnormSrgb` texture, where the hardware decodes
// sRGB→linear on sample and leaves alpha untouched. No unpremultiply (the source
// was never premultiplied), so we skip the divide entirely. The compositor wants
// straight-alpha linear, which is exactly what the sample already is.
@fragment
fn fs_main_straight(in: VertexOutput) -> @location(0) vec4<f32> {
let m = mat3x3<f32>(transform.col0.xyz, transform.col1.xyz, transform.col2.xyz);
let canvas_uv = (m * vec3<f32>(in.uv.x, in.uv.y, 1.0)).xy;
if canvas_uv.x < 0.0 || canvas_uv.x > 1.0
|| canvas_uv.y < 0.0 || canvas_uv.y > 1.0 {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
}
let c = textureSample(canvas_tex, canvas_sampler, canvas_uv);
let mask = textureSample(mask_tex, mask_sampler, canvas_uv).r;
let tint = vec3<f32>(transform.col0.w, transform.col1.w, transform.col2.w);
let tinted = c.rgb + tint - c.rgb * tint;
return vec4<f32>(tinted, c.a * mask);
}