Skip to main content

Module parallel_ctx

Module parallel_ctx 

Source
Expand description

Generic Send/Sync shim for parallel per-pass command recording, shared by all three backend executors ({metal,directx,vulkan}/graph_exec.rs). Each backend fans its non-composite render-graph passes onto worker threads; every worker records into its own command buffer/list and reaches the immutable subset of the backend context it needs through a ParallelCtxRef.

The backend context types are not Send/Sync in Rust’s type system: they hold COM smart pointers, objc2 protocol objects, RefCells, and the like. The graphics APIs nonetheless permit shared, read-only access to device-derived resources from many threads. A backend adopts that claim for its own context type with a single unsafe impl ParallelEncodeCtx, where it documents the audit of every interior-mutable field reachable during encode. The Send/Sync impls on ParallelCtxRef below are then keyed off that marker, so the unsafe reasoning lives in one auditable place per backend instead of being repeated on three structurally identical wrapper types.

Structs§

ParallelCtxRef
A handle to a &'a T borrow that is Send + Sync when T: ParallelEncodeCtx. Worker closures use it to reach the immutable subset of the backend context they need while recording commands into their own command buffer/list.

Traits§

ParallelEncodeCtx
Marker for a backend context that may be shared, read-only, across the parallel-encode worker fan-out.