Skip to main content

ExternalPass

Trait ExternalPass 

Source
pub trait ExternalPass: Send + Sync {
    // Required method
    fn record(&self, frame: &mut ExternalFrame<'_>);
}
Expand description

Caller-supplied GPU work recorded into the frame ahead of the scene.

Registered with register_external_pass under a SceneTextureId the caller minted (SceneTextureId::mint, or Texture::as_scene_texture when it has a frust_gpu::Texture to mint from), and called once per frame with that frame’s live ExternalFrame until unregister_external_pass takes it back.

Send + Sync because the registry is process-wide and the call happens on the render thread, which is not the thread that registered the pass on any shell that splits the two — and, with two engine-tier surfaces live in one process at once (each presenting through its own render thread), the same pass can be called by both at the same time: record genuinely may run concurrently on two threads, not merely sequentially from a changing one. record takes &self, so a pass mutating state across frames owns its own interior mutability, and that interior mutability has to tolerate the concurrent case, not just the sequential one.

Required Methods§

Source

fn record(&self, frame: &mut ExternalFrame<'_>)

Records this pass’s work for one frame.

Record passes and staged uploads only — never a submit, and never a wgpu::RenderPass left open across the return (see frust_gpu::encoder’s borrowing contract, which the frame’s encoder is under for exactly the same reason). The shared encoder must be left finishable on every exit path: no open render pass AND balanced push_debug_group/pop_debug_group calls (an unbalanced group makes encoder.finish() fail with wgpu’s MissingPop and loses the frame; the pass is retired so it self-heals next frame). Bind whatever this frame should composite through ExternalFrame::bind_texture; the engine draws it wherever the frame’s display list names the id.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§