Skip to main content

CompositeEncoder

Trait CompositeEncoder 

Source
pub trait CompositeEncoder {
    type Rec;
    type Args;

    // Required methods
    fn begin_composite(&self, rec: &Self::Rec, args: &Self::Args);
    fn composite_draw(&self, rec: &Self::Rec, args: &Self::Args);
    fn begin_text(&self, rec: &Self::Rec, args: &Self::Args) -> bool;
    fn text_draw(
        &self,
        rec: &Self::Rec,
        args: &Self::Args,
        call: &TextDrawCall,
    ) -> Result<(), String>;
    fn end_composite(&self, rec: &Self::Rec, args: &Self::Args);
}
Expand description

The composite pass: tonemap (+ optional LUT grade) the post-stack scene onto the swapchain image, then layer the text overlay on top in the same pass. Its begin -> composite-draw -> text-loop -> end shape is identical on every backend; the swapchain target lifecycle, the descriptor binding, and the text-geometry uploads stay backend-specific behind the trait. Args carries the per-frame binding context each backend needs (DX: the swapchain back-buffer + its RTV, the scene SRV, the window size, the frame slot; VK: the acquired image index + the frame slot).

Every backend uploads a frame’s text geometry into one persistent buffer per frame-in-flight slot, reserved up front with text_upload_bytes and appended to per call, and binds sub-ranges of it: no GPU buffer is created per label per frame anywhere. DX and VK append inside text_draw; Metal (which drives its own composite loop rather than this trait) writes the whole frame’s geometry into its slot before the render graph runs.

Required Associated Types§

Source

type Rec

Per-backend command recorder (DX ID3D12GraphicsCommandList, VK vk::CommandBuffer).

Source

type Args

Per-invocation binding context (see the trait doc).

Required Methods§

Source

fn begin_composite(&self, rec: &Self::Rec, args: &Self::Args)

Begin the pass: target the swapchain image (DX transitions it to RENDER_TARGET + binds the RTV; VK begins the composite render pass) and set the full-window viewport / scissor.

Source

fn composite_draw(&self, rec: &Self::Rec, args: &Self::Args)

The fullscreen tonemap draw: bind the composite pipeline + its inputs (scene, bloom, LUT) + push constants, draw the fullscreen triangle.

Source

fn begin_text(&self, rec: &Self::Rec, args: &Self::Args) -> bool

Bind the text pipeline + any one-time text state. Returns false when text is inert (no pipeline or no atlases), so the driver skips the call loop.

Source

fn text_draw( &self, rec: &Self::Rec, args: &Self::Args, call: &TextDrawCall, ) -> Result<(), String>

Encode one text draw call: append its vertex/index geometry to this frame slot’s persistent upload buffer, bind the atlas plus the two sub-ranges, and draw.

Source

fn end_composite(&self, rec: &Self::Rec, args: &Self::Args)

End the pass: DX transitions the back-buffer back to PRESENT; VK ends the render pass.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§