Module gpu
Expand description
wgpu state, asked for in a size this machine can give.
This module exists for one line: RenderContext::new_device requests the
device with wgpu::MemoryHints::Manual instead of the default.
vello::util::RenderContext defaults to MemoryHints::Performance — right
for a game alone on a discrete card, wrong for a Tilo session where a dozen
clients share one integrated GPU whose memory is the machine’s memory.
Measured on an idle file manager: 488 MB across 459 buffers, of which
448 MB was three suballocator chunks (256 + 128 + 64 MB) and only 20 MB
was actual content. Thirteen clients paying that is the whole 16 GB GTT
window, and a GPU allocation that can neither be served nor fail takes
the box with it — no OOM, no panic, just a freeze.
Not a patched vello: RenderSurface’s fields are public and
Renderer::new takes a plain &Device, so only DeviceHandle needed
reimplementing, for its private adapter field. The one change to
vello::util is that RenderSurface::blitter is optional, so a surface
the target reaches by a texture copy compiles no blit pipeline
(vendor/PATCHES.md); this file stays close to vello::util’s own logic
so the two can be compared when vello moves.
It also decides which backends the instance is made with
(default_backends): without OpenGL whenever OpenGL could not be
chosen anyway, because wgpu initialises every backend it is asked for.
Structs§
- Device
Handle - An adapter and the device opened on it.
- Device
Loss Monitor - Shared observation of the context-owned device loss callback, and of a loss
declared for a GPU that stopped finishing work (
LossWatch). - Loss
Watch - Watches one device for loss, reported or not.
- Render
Context - wgpu state for one process, with a memory hint that fits a shared GPU.
- Submitted
Work - Everything submitted to a queue up to some moment, and whether it finished.
Enums§
- Create
Surface Error - Why a surface could not be made.
- Recovery
- What a renderer opens after its device was lost.
Constants§
- ADAPTER_
LINE_ PREFIX - Prefix of every line a window prints about the adapter it renders on. The compositor reads app stderr for it; session checks grep for it.
- NOT_
PROGRESSING_ AFTER - How long work found unfinished may stay unfinished before the GPU counts as no longer making progress. A frame takes a hardware GPU milliseconds; a kernel resets a GPU stuck on one job within seconds and fails its fence; a software rasteriser takes seconds for a large frame at worst. Work still pending this long after a renderer stopped waiting for it will not finish.
- SOFTWARE_
FALLBACK_ MESSAGE - What follows
ADAPTER_LINE_PREFIXwhen a window presents through a CPU adapter on a machine that has a GPU.
Functions§
- draw_
target_ to_ surface - Put
surface’s render target into the acquiredtextureof its swapchain: a texture copy when the surface was configured for one, else its blit. - rasterizes_
on_ cpu - Whether a host on this adapter rasterizes its frames on the CPU
(
crate::cpu_raster) and uploads the pixels, instead of running vello’s compute pipelines on an emulated GPU: a SwiftShader page draws its first frame this way before any pipeline compiles. Vello then draws only backdrop blurs. - recover
- Decide what follows the loss of a device on
adapter.finished_framessays whether that device finished at least one frame before it was lost. A loss before any is a GPU that cannot be brought back, and from then on this process opens only software adapters (software_fallback). - requested_
texture_ limit - The largest texture edge of every device this module opens: wgpu’s
default, which
required_limitskeeps. A window’s frame is fitted under it before it is drawn (crate::scale::fit_to_texture_limit), since a surface target past it fails validation and the window stops. - software_
fallback - Why this process renders in software although it has a GPU, once
recoverdecided it must. - submit_
target_ to_ surface draw_target_to_surface, submitted on its own. With nothing drawn into the target since, this shows the last frame again: a host that acquiredtexturefor a frame it then skipped presents that frame rather than a cleared texture.