Skip to main content

create_offscreen_renderer

Function create_offscreen_renderer 

Source
pub async fn create_offscreen_renderer(
    label: &'static str,
) -> Option<(Renderer, Device, Queue)>
Expand description

Build an offscreen renderer on the shared device, or None if this host can open no usable GPU device at all.

The Renderer is fresh per call; the device and queue behind it are shared process-wide, which is load-bearing rather than an optimisation: two D3D12 WARP devices rasterizing at once fault inside Microsoft’s software rasterizer — exactly what a GPU-less Windows host and the CI runners use — so a device per caller turns any two concurrent offscreen renders into a crash. Atlases still live on the per-call Renderer, so no caller can see another’s cached glyphs.

label names the device, so it only takes effect on the call that actually opens it; later callers join a device someone else already named.

This is the entry shipped code uses (the headless automation server’s screenshots, the previewer’s PNG export). It never panics: a host without a GPU gets None, whatever the environment says. Tests call require_test_renderer, which can insist on an adapter.