video.rs' delivery (deliver, FrameSlot, Handoff, Buffers; video.rs:360-480) ported to GPUI: the decoder hands over its newest frame only, a converter thread turns it into an Arc<RenderImage> (BGRA, spike_common::bgra), the window takes the newest from a Latest in render and drops the one it replaces from every window's atlas (cx.drop_image). A RenderImage owns its pixels with no way back to them, so Buffers' reuse cannot be ported. Sources: --mode pipeline is LocalPreview with SourceId::Synthetic through the real VP8 encoder and decoder, as Video::demo; --mode raw hands I420 frames from memory to the converter; --mode static (added in this attempt) is the control: one picture, uploaded once, the window repainted every frame. --convert rgba measures voelin-media's conversion in place, --no-drop is the negative control for drop_image, --bench times RGBA against BGRA. measure.sh runs every case on the headless display, with damage-count beside it and the Slint app's demo stream for comparison. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3.8 KiB
Spike 1: the video path
spike-video shows the synthetic test pattern in a GPUI window the way
voelin-ui shows a watched stream:
- Source.
--mode pipelinerunsvoelin_core::media::LocalPreviewwithSourceId::Synthetic, asVideo::demo(crates/voelin-ui/src/video.rs) does: capture, the VP8 encoder (libvpx), the decoder, no server.--mode rawhands decoded-looking I420 frames from memory at--fpsstraight to the converter, so a frame rate below the source's belongs to the conversion and GPUI alone. - Delivery (
src/frames.rs): the port ofvideo.rs'deliver,FrameSlot,HandoffandBuffers. The decoder hands over its newest frame only; a converter thread (voelin-picture) turns it into anArc<RenderImage>(BGRA,spike_common::bgra::to_bgra, the BGRA twin ofvoelin_media::convert::to_rgba) and puts it into aLatest; the window is woken through a channel only when the slot was empty (GPUI'sAsyncAppis notSend). ARenderImageowns its pixels and gives no way back to them, so the buffer reuse ofBufferscannot be ported: every picture is a new buffer. - Window (
src/main.rs):img(ImageSource::Render(..)), the picture taken fromLatestinrender, the one it replaces dropped from every window's sprite atlas withcx.drop_image(--no-dropleaves it: the negative control).inactive_frame_interval: None: GPUI throttles animation frames of an unfocused window to 30 fps by default.
Once a second it prints a JSON line (CPU of the process and of each thread group in percent of one core, resident memory, and per second: frames captured, encoded, decoded, handed to the converter, converted, shown and rendered, conversion time); at the end a summary over the steady part.
Reproducing the measurements
Build, then run every case on the headless display (Xvfb :91, openbox,
lavapipe through wgpu's Vulkan backend; see ../README.md):
spikes/gpui/shell.sh sh -c 'cd spikes/gpui && cargo build --locked --release'
# the Slint app, for its demo stream (the root workspace, Rust 1.94):
TOOLCHAIN=1.94 spikes/gpui/shell.sh cargo build --locked --release -p voelin-ui
spikes/gpui/shell.sh spikes/gpui/headless.sh -- spikes/gpui/video/measure.sh
measure.sh runs, 70 s each with 10 s of warm-up not averaged
(SECONDS_RUN, WARMUP), and writes <case>.jsonl, <case>-damage.jsonl
(the X server's count of the window's content changes), <case>.load (load
average before and after) and a screenshot from the warm-up to $OUT
(default .scratch/gpui-spikes-results):
| Case | Command |
|---|---|
bench |
spike-video --bench --iterations 300 (RGBA against BGRA, 1080p and 1440p, into a reused and a new buffer, and as a RenderImage) |
raw-1080p60, raw-1440p60 |
spike-video --mode raw --size 1920x1080 (or 2560x1440) --fps 60 |
pipeline-1080p60, pipeline-1440p60 |
spike-video --mode pipeline --size … --fps 60 (bitrate automatic, as the share dialog's default) |
pipeline-1440p60-rgba |
the same with --convert rgba (voelin-media's conversion; red and blue show swapped) |
nodrop-1440p |
spike-video --mode pipeline --size 2560x1440 --fps 15 --no-drop --seconds 12 --warmup 2 (memory grows by a picture per frame) |
pipeline-720p30 |
spike-video --mode pipeline --size 1280x720 --fps 30 --bitrate 4608: Video::demo's own settings (StreamerConfig::default()) |
slint-720p30 |
voelin with VOELIN_DEMO_STREAM=1 SLINT_BACKEND=winit-software, measured from outside with proc-meter and damage-count |
One case: spikes/gpui/shell.sh spikes/gpui/headless.sh -- spikes/gpui/video/measure.sh raw-1440p60.
The figures and what they mean are in docs/design/gpui-spikes.md.