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.
Structs§
Enums§
Type Aliases§
- Present
Hook - Runs on the render thread once a frame is presented.