Module offscreen
Expand description
Headless offscreen render harness: renders a Vello Scene into a GPU
texture with no window, reads the bytes back, optionally writes a PNG.
copy_texture_to_buffer needs the buffer’s row pitch aligned to
COPY_BYTES_PER_ROW_ALIGNMENT (256 today), so a non-aligned width is
padded and the padding stripped on readback.
Two renders of the same Scene are not guaranteed bit-identical:
vello assigns path-segment order via atomicAdd (GPU scheduling), and
float addition isn’t associative, so coverage on a quantisation
boundary can land ±1 in a channel. Measured here: ≤4/57 600 pixels,
always ±1, ink-count unchanged — a race between concurrent renders in
one process, not a single-frame artifact. Compare with
OffscreenRenderer::pixels_differing_beyond_aa, not byte equality. The
stored pixels use straight alpha: RGB in fully transparent pixels is
invisible, while if either pixel has nonzero alpha, every channel keeps the
±1 comparison tolerance. Exact untouched-pixel assertions remain separate
checks for byte preservation.
Never cache one in a thread_local!: dropping wgpu resources touches
wgpu’s own thread-local, and TLS destructors run in reverse
registration order, so a cache registered before the first wgpu call is
torn down after wgpu’s — SIGABRT, killing the process. Use a
process-wide static instead (never drops); this type is Send to
allow that.
Structs§
- Area
Ppt8 Attempt Accounting - Actual Area PPT8 passes recorded since an explicit measured-workload reset. Counters describe synchronous route attempts only, including retries, not completion or speed.
- Canonical
Segment Order Attempt Accounting - Actual canonical-segment-order passes recorded since an explicit measured-workload reset. Counters describe synchronous route attempts only, including retries, not completion or speed.
- Clip
Single Group Attempt Accounting - Actual single-workgroup clip leaf passes recorded since an explicit measured-workload reset.
- Offscreen
Memory Stats - Offscreen
Render Timing - Host-side phases of one completed offscreen render, populated only by
OffscreenRenderer::render_damage_regions_gpu_wait_profiled. - Offscreen
Renderer - An offscreen wgpu + vello pipeline sized at
width × height. Reuse a single instance for multiple renders to amortise adapter / device creation (which is the expensive part). - Shared
Gpu - Handles to the process-wide shared wgpu device — the very same one
every
OffscreenRendererdraws through. - Sparse
Submission Accounting - Lightweight accounting for actual sparse submissions. Unlike
OffscreenRenderTiming, this is updated for every sparse attempt, including one that later overflows into dense recovery.
Enums§
- Offscreen
Error - Why an
OffscreenRenderercould not be built.
Constants§
- MAX_
CAPTURE_ DEVICE_ SCALE - The largest device scale a capture draws at: a glyph sheet enlarged
from the outlines (16x);
--device-scaleitself stops at 4.
Functions§
- capture_
device_ scale - The device scale captures draw at (
set_capture_device_scale). - set_
capture_ device_ scale - Draw every following capture frame at
scaledevice pixels per logical pixel, as a HiDPI display draws it: the frame is laid out at its logical size and drawn with the window scale transform the live host uses, so text is rasterised from the glyph outlines at that size rather than enlarged afterwards (crate::headless::FrameHarness). Clamped to1..=MAX_CAPTURE_DEVICE_SCALE. - shared_
gpu - Borrow the shared device/queue, initialising the process-wide context
on first call. Fails with the same
OffscreenErrors asOffscreenRenderer::try_new— a machine with no usable adapter gets aNoAdapter, never a panic.