Skip to main content

Crate xgpui_gpu_interop

Crate xgpui_gpu_interop 

Source
Expand description

Experimental zero-copy GPU interop for xgpui: show frames from a GPU engine you own in xgpui windows, the way an engine presents to a swapchain. See the GPU interop guide.

The engine keeps its own device, queue and thread. An [EngineSurface] owns a fixed ring of shareable slots:

  1. acquire() a writable slot, or get AcquireError::WouldBlock when every slot is still in use (bounded backpressure).
  2. Render into the slot on the engine’s GPU and submit a signal of a sync point after that work.
  3. present(slot, sync) publishes the slot. It is never written again until every retained scene that sampled it is gone and the compositor’s GPU sampling has completed; then it returns to the ring.

The host composites the latest presented slot as ordinary custom content, after a GPU-side wait on the sync point. Nothing is copied through the CPU.

Contract: call present only after the engine has submitted the work that signals the sync point. A sync point whose signal is never submitted can stall composition.

Implemented: macOS (IOSurface slots, MTLSharedEvent sync); with feature wgpu, Linux (opaque-fd Vulkan memory, timeline semaphore) and Windows (shared NT-handle D3D12 textures and fence, opened by the D3D11 compositor). The compositor waits for each frame on the GPU.

The engine must run on the compositor’s GPU; otherwise the surface reports Unsupported. On a machine with two GPUs, nothing yet helps an engine pick the right one (issue #253).

Structs§

HeavyEngine
Configuration for heavy-engine mode.
HeavyStatus
Snapshot of a target’s heavy-engine state.
SurfaceDesc
Fixed properties of a surface’s slots.
SurfaceStats
Counters for diagnostics and pressure tests.
Unsupported
Returned when the platform or configuration cannot support a surface.

Enums§

AcquireError
Why acquire returned no slot.
SurfaceFormat
Pixel storage and color interpretation of every slot in a surface.
Transport
How engine output reaches the compositor.