Skip to main content

Module render_thread

Module render_thread 

Expand description

UI render worker thread.

Moves scene encode, swapchain acquire, blit, submit, present, and poll off the main winit thread onto a dedicated ui-render worker. Main keeps the widget tree + scene encoding; the worker owns the wgpu RenderContext, RenderSurface<'static>, and vello::Renderer.

Three channels: render_tx/rx (capacity 1 — blocks main until the worker drains the previous frame) moves an encoded Scene + dims + base colour; pool_tx/buffers (worker → main, capacity 2, pre-seeded) recycles each Scene and damage vector as one atomic pair; outcome_tx/frame_complete (capacity 8) reports per-frame outcomes so main can re-request a redraw on Outdated/Suboptimal/Occluded/Timeout.

The worker resizes the surface itself — main never touches it after handing it off at spawn — so wgpu state never crosses threads.

On exiting, the App sends RenderRequest::Shutdown and join()s the worker, which drops its RenderSurface<'static> before the Window is dropped — required or wgpu panics on a surface outliving its window. On suspended the worker drops only the surface and hands its context and renderer back (RenderThreadHandle::shutdown_keeping_renderer), so the next surface does not open a device and compile pipelines again.

Modules§

remote
The remote renderer: a window’s frames drawn by the workspace’s render service instead of a GPU in this process.

Structs§

FrameContent
One frame’s scene, surface size and damage, as the worker received it.
RenderThreadHandle
RetainedRaster
What a host keeps between frames to rasterize them into one retained target: the damage scratch, the backdrop blur and, on a software adapter, the CPU canvas. The app’s own render worker draws with it, and so does the workspace’s render service for each surface it draws for an app, so both produce the same pixels from the same frame.
RetainedTarget
The retained frame the native host rasterizes into and presents from. Pixels outside a frame’s damage are whatever the previous frame left, so it must only ever be written through RetainedRaster::rasterize. Rgba8Unorm with storage, copy-source and copy-destination usage.

Enums§

FrameOutcome
RenderRequest

Type Aliases§

PresentHook
Runs on the render thread once a frame is presented.