Skip to content

anyrender_vello: each window creates its own wgpu device and Vello renderer (~180 MB per window) #121

Open

Description

@Meirdrarel

Every VelloWindowRenderer owns its own WGPUContext (wgpu instance + device pool) and its own
vello::Renderer, so an app with several windows pays the whole GPU setup once per window.
VelloWindowRenderer has no way to share them: no constructor or option takes an existing context
or device.

Measurements

macOS (Apple M2 Max), Retina windows, a simple page with some text and a button, rendered with Blitz
(blitz-shell with several Views). macOS "physical footprint", ~6 s after launch:

Windows Stock VelloWindowRenderer Shared device + renderer (patch below)
1 223 MB 223 MB
2 424 MB 240 MB
4 802 MB 273 MB

Almost all of it is the "graphics" category (178 MB for one window, 714 MB for four). With the device
and the Vello renderer shared, an extra window costs ~16 MB (its surface and intermediate texture).

A gotcha even if contexts were shared

The new device is only added to device_pool in complete_resume, which runs later (when the
embedder handles the "ready" callback). Windows created at startup all call resume before any of
them completes, so none of them finds a device to reuse, even with a shared WGPUContext.

Proposal

An opt-in shared context, without changing the existing API:

let gpu = SharedVelloContext::new(&VelloRendererOptions::default());
let renderer_a = VelloWindowRenderer::with_shared_context(options.clone(), gpu.clone());
let renderer_b = VelloWindowRenderer::with_shared_context(options, gpu.clone());

SharedVelloContext holds the WGPUContext and one vello::Renderer per device (Rc<RefCell<…>>,
since windows live on the event-loop thread). new() / with_options() keep working as today with a
private context. The device is registered as soon as it is created, so startup windows reuse it.

I have a working implementation in #122.

anyrender_vello_hybrid seems to have the same one-device-per-window structure; happy to look at it
in a follow-up if this approach is OK. Related: #12 (memory usage of backends).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions