Skip to main content

Module pump

Module pump 

Source
Expand description

Surface pump: owns the wgpu surface and every swapchain call, on a dedicated thread on Windows and inline elsewhere.

On Windows the editor frame loop runs on the host’s GUI thread, and any wgpu call that enters the graphics driver can park that thread for an unbounded time - a stalled AMD driver was measured blocking device creation, swapchain reconfigure (DestroyAllocation2), and acquire in kernel calls that never return, freezing the DAW. The threaded pump moves all of those off the GUI thread:

  • init: instance / surface / adapter / device creation runs on the pump thread; the GUI adopts the product when it lands.
  • configure: resizes are queued latest-wins and applied there.
  • acquire: the pump pre-acquires the next frame, so the GUI thread picks up an already-acquired texture or skips the paint.
  • present: painted frames are handed back and presented there.

The GUI thread’s only remaining GPU work is encoding + submitting into a pre-acquired texture - queue submission was never observed blocking in any captured hang.

On macOS / Linux the same PumpClient API runs everything synchronously on the calling thread (their drivers don’t exhibit the unbounded blocking, and macOS ties layer updates to the main thread), so editors share one code path across platforms.

Structs§

PumpClient
Cheap cloneable handle for per-frame pump operations: resize, frame acquire, present. The editor’s backend keeps one; the SurfacePump owner keeps the lifecycle.
SurfacePump
Owning handle for the pump. On Windows, dropping it shuts the thread down (bounded join, then detach - a thread wedged in a driver call is left behind rather than hanging the GUI thread).

Type Aliases§

PumpInit
What the per-backend init closure returns: the GUI-side product (device handles, pipelines, …) plus the device + configuration the pump needs for surface.configure.
PumpInitFn
Per-backend GPU init, run once the instance / adapter / surface exist (on the pump thread on Windows, inline elsewhere). Returns None on failure (editor stays blank, host survives). Must NOT configure the surface - the pump does that with the returned configuration.