Skip to main content

Module offscreen

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§

AreaPpt8AttemptAccounting
Actual Area PPT8 passes recorded since an explicit measured-workload reset. Counters describe synchronous route attempts only, including retries, not completion or speed.
CanonicalSegmentOrderAttemptAccounting
Actual canonical-segment-order passes recorded since an explicit measured-workload reset. Counters describe synchronous route attempts only, including retries, not completion or speed.
ClipSingleGroupAttemptAccounting
Actual single-workgroup clip leaf passes recorded since an explicit measured-workload reset.
OffscreenMemoryStats
OffscreenRenderTiming
Host-side phases of one completed offscreen render, populated only by OffscreenRenderer::render_damage_regions_gpu_wait_profiled.
OffscreenRenderer
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).
SharedGpu
Handles to the process-wide shared wgpu device — the very same one every OffscreenRenderer draws through.
SparseSubmissionAccounting
Lightweight accounting for actual sparse submissions. Unlike OffscreenRenderTiming, this is updated for every sparse attempt, including one that later overflows into dense recovery.

Enums§

OffscreenError
Why an OffscreenRenderer could 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-scale itself 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 scale device 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 to 1..=MAX_CAPTURE_DEVICE_SCALE.
shared_gpu
Borrow the shared device/queue, initialising the process-wide context on first call. Fails with the same OffscreenErrors as OffscreenRenderer::try_new — a machine with no usable adapter gets a NoAdapter, never a panic.