Trait CustomPipe

Source
pub trait CustomPipe: 'static {
    type Window: CustomWindow;

    // Required method
    fn new_window(&self, device: &Device) -> Self::Window;

    // Provided methods
    fn resize(
        &self,
        window: &mut Self::Window,
        device: &Device,
        queue: &Queue,
        size: Size,
    ) { ... }
    fn prepare(
        &self,
        window: &mut Self::Window,
        device: &Device,
        staging_belt: &mut StagingBelt,
        encoder: &mut CommandEncoder,
    ) { ... }
    fn render_pass<'a>(
        &'a self,
        window: &'a mut Self::Window,
        device: &Device,
        pass: usize,
        rpass: &mut RenderPass<'a>,
        bg_common: &'a BindGroup,
    ) { ... }
    fn render_final<'a>(
        &'a self,
        window: &'a mut Self::Window,
        device: &Device,
        encoder: &mut CommandEncoder,
        frame_view: &TextureView,
        size: Size,
    ) { ... }
}
Expand description

A custom draw pipe

A “draw pipe” consists of draw primitives (usually triangles), resources (textures), shaders, and pipe configuration (e.g. blending mode). A custom pipe allows direct use of the wgpu graphics stack.

To use this, pass the corresponding CustomPipeBuilder to Runner::new_custom.

Note that kas-wgpu accepts only a single custom pipe. To use more than one custom graphics pipeline, you must implement your own multiplexer.

Required Associated Types§

Source

type Window: CustomWindow

Associated per-window state for the custom pipe

Required Methods§

Source

fn new_window(&self, device: &Device) -> Self::Window

Construct a window associated with this pipeline

Note: Self::resize will be called before usage.

Provided Methods§

Source

fn resize( &self, window: &mut Self::Window, device: &Device, queue: &Queue, size: Size, )

Called whenever the window is resized

Source

fn prepare( &self, window: &mut Self::Window, device: &Device, staging_belt: &mut StagingBelt, encoder: &mut CommandEncoder, )

Per-frame updates

This is called once per frame before rendering operations, and may for example be used to prepare uniform and buffers.

This method is optional; by default it does nothing.

Source

fn render_pass<'a>( &'a self, window: &'a mut Self::Window, device: &Device, pass: usize, rpass: &mut RenderPass<'a>, bg_common: &'a BindGroup, )

Render (pass)

Each item drawn is associated with a clip region, and each of these with a pass. This method will be called once for each clip region in use (possibly also for other clip regions). Drawing uses an existing texture and occurs after most other draw operations, but before text.

The “common” bind group supplies window scaling and theme lighting information may optionally be set (see CustomPipeBuilder::build).

This method is optional; by default it does nothing.

Source

fn render_final<'a>( &'a self, window: &'a mut Self::Window, device: &Device, encoder: &mut CommandEncoder, frame_view: &TextureView, size: Size, )

Render (final)

This method is the last step in drawing a frame. Usually (including in the default implementation) it does nothing.

Implementations on Foreign Types§

Source§

impl CustomPipe for ()

A dummy implementation (does nothing)

Source§

type Window = ()

Source§

fn new_window(&self, _: &Device) -> Self::Window

Source§

fn resize(&self, _: &mut Self::Window, _: &Device, _: &Queue, _: Size)

Implementors§